umsee commited on
Commit
7e1807d
·
1 Parent(s): af999d1

app.py and requirements.txt added

Browse files
Files changed (2) hide show
  1. app.py +22 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ from langchain_cohere import ChatCohere
3
+ from langchain_core.messages import HumanMessage, SystemMessage
4
+ from langchain_core.output_parsers import StrOutputParser
5
+ import gradio as gr
6
+
7
+ llm = ChatCohere(model='command-r')
8
+ pipe = pipeline("automatic-speech-recognition", model="openai/whisper-base")
9
+ parser = StrOutputParser()
10
+
11
+ def getting_prompt(txtmsg,spkmsg):
12
+ recog_text = pipe(spkmsg)
13
+ messages = [
14
+ SystemMessage(content=txtmsg),
15
+ HumanMessage(content=recog_text['text']),
16
+ ]
17
+ chain = llm | parser
18
+ response = chain.invoke(messages)
19
+ return response
20
+
21
+ demo = gr.Interface(getting_prompt,['text','audio'],'text')
22
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ transformers
2
+ langchain-chroma
3
+ langchain
4
+