gradioapp commited on
Commit
d03045f
1 Parent(s): 4112c5a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -14
app.py CHANGED
@@ -2,21 +2,13 @@
2
  import openai
3
  import gradio as gr
4
  import os
5
- from gtts import gTTS
6
- from pdfminer.high_level import extract_text
7
-
8
-
9
  openai.api_key = os.getenv("OPENAI_API_KEY")
10
 
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
- audio = test.wav
20
 
21
  def transcribe(audio):
22
  text = p(audio)["text"]
@@ -76,8 +68,7 @@ def chatbot(input1,input2):
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,12 +79,11 @@ inputs= [ gr.Audio(source="microphone", type="filepath"),
88
  gr.inputs.Textbox(lines=7)]
89
 
90
 
91
- #outputs = gr.outputs.Textbox(label="Reply")
92
-
93
 
94
  gr.Interface(fn= chatbot,
95
  inputs= inputs,
96
- outputs= audio,
97
  title="PepsiCo-chatbot",
98
  description="Give your order",
99
  theme="compact").launch()
 
2
  import openai
3
  import gradio as gr
4
  import os
 
 
 
 
5
  openai.api_key = os.getenv("OPENAI_API_KEY")
6
 
7
  from transformers import pipeline
8
  p = pipeline("automatic-speech-recognition",model="openai/whisper-tiny")
9
 
 
 
 
 
10
 
11
+
12
 
13
  def transcribe(audio):
14
  text = p(audio)["text"]
 
68
  reply = chat.choices[0].message.content
69
 
70
  messages.append({"role": "assistant", "content": reply})
71
+ return reply
 
72
 
73
 
74
  ##inputs = gr.inputs.Textbox(lines=7, label="Chat with PepsiCo AI assitant")
 
79
  gr.inputs.Textbox(lines=7)]
80
 
81
 
82
+ outputs = gr.outputs.Textbox(label="Reply")
 
83
 
84
  gr.Interface(fn= chatbot,
85
  inputs= inputs,
86
+ outputs= outputs,
87
  title="PepsiCo-chatbot",
88
  description="Give your order",
89
  theme="compact").launch()