gradioapp commited on
Commit
4a2eb2b
1 Parent(s): a9d1942

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -11,6 +11,10 @@ openai.api_key = os.getenv("OPENAI_API_KEY")
11
  from transformers import pipeline
12
  p = pipeline("automatic-speech-recognition",model="openai/whisper-tiny")
13
 
 
 
 
 
14
 
15
 
16
 
@@ -72,7 +76,8 @@ def chatbot(input1,input2):
72
  reply = chat.choices[0].message.content
73
 
74
  messages.append({"role": "assistant", "content": reply})
75
- return reply
 
76
 
77
 
78
  ##inputs = gr.inputs.Textbox(lines=7, label="Chat with PepsiCo AI assitant")
@@ -83,11 +88,11 @@ inputs= [ gr.Audio(source="microphone", type="filepath"),
83
  gr.inputs.Textbox(lines=7)]
84
 
85
 
86
- outputs = gr.outputs.Textbox(label="Reply")
87
 
88
  gr.Interface(fn= chatbot,
89
  inputs= inputs,
90
- outputs= outputs,
91
  title="PepsiCo-chatbot",
92
  description="Give your order",
93
  theme="compact").launch()
 
11
  from transformers import pipeline
12
  p = pipeline("automatic-speech-recognition",model="openai/whisper-tiny")
13
 
14
+ def text_to_speech(text):
15
+ myobj = gTTS(text=text, lang='en', slow=False)
16
+ myobj.save("test.wav")
17
+ return 'test.wav'
18
 
19
 
20
 
 
76
  reply = chat.choices[0].message.content
77
 
78
  messages.append({"role": "assistant", "content": reply})
79
+ return text_to_speech(reply)
80
+
81
 
82
 
83
  ##inputs = gr.inputs.Textbox(lines=7, label="Chat with PepsiCo AI assitant")
 
88
  gr.inputs.Textbox(lines=7)]
89
 
90
 
91
+ #outputs = gr.outputs.Textbox(label="Reply")
92
 
93
  gr.Interface(fn= chatbot,
94
  inputs= inputs,
95
+ outputs= 'audio',
96
  title="PepsiCo-chatbot",
97
  description="Give your order",
98
  theme="compact").launch()