from transformers import pipeline from langchain_cohere import ChatCohere from langchain_core.messages import HumanMessage, SystemMessage from langchain_core.output_parsers import StrOutputParser import gradio as gr llm = ChatCohere(model='command-r') pipe = pipeline("automatic-speech-recognition", model="openai/whisper-base") parser = StrOutputParser() def getting_prompt(txtmsg,spkmsg): recog_text = pipe(spkmsg) messages = [ SystemMessage(content=txtmsg), HumanMessage(content=recog_text['text']), ] chain = llm | parser response = chain.invoke(messages) return response demo = gr.Interface(getting_prompt,['text','audio'],'text') demo.launch()