hwberry2 commited on
Commit
a35346c
·
1 Parent(s): fe3149a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -10
app.py CHANGED
@@ -13,14 +13,7 @@ def transcribe(audio):
13
 
14
  return transcript["text"]
15
 
16
- def giveVoice(bot_message):
17
- myobj = gTTS(text=bot_message)
18
- myobj.save("temp.mp3")
19
-
20
- dir = os.getcwd()
21
- new_path = os.path.join(dir, "temp.mp3")
22
-
23
- return new_path
24
 
25
 
26
  with gr.Blocks() as demo:
@@ -43,6 +36,18 @@ with gr.Blocks() as demo:
43
 
44
  return chat_transcript
45
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  with gr.Row():
47
  with gr.Column():
48
  user_audio = gr.Audio(source="microphone", type="filepath", label="Input Phrase")
@@ -51,9 +56,9 @@ with gr.Blocks() as demo:
51
  user_transcript = gr.Text(label="User Transcript")
52
  gpt_transcript = gr.Text(label="Chat Transcript")
53
  gpt_voice = gr.Audio(label="Voice Response")
54
- submit_btn.click(transcribe, inputs=user_audio, outputs=user_transcript)
55
  user_transcript.change(botResponse, [user_transcript, messages], gpt_transcript)
56
- gpt_transcript.change(giveVoice, inputs=gpt_transcript, outputs=gpt_voice)
57
 
58
 
59
 
 
13
 
14
  return transcript["text"]
15
 
16
+
 
 
 
 
 
 
 
17
 
18
 
19
  with gr.Blocks() as demo:
 
36
 
37
  return chat_transcript
38
 
39
+ def giveVoice(message, messages):
40
+ response = messages[-1]
41
+ print(response)
42
+
43
+ myobj = gTTS(text=bot_message)
44
+ myobj.save("temp.mp3")
45
+
46
+ dir = os.getcwd()
47
+ new_path = os.path.join(dir, "temp.mp3")
48
+
49
+ return new_path
50
+
51
  with gr.Row():
52
  with gr.Column():
53
  user_audio = gr.Audio(source="microphone", type="filepath", label="Input Phrase")
 
56
  user_transcript = gr.Text(label="User Transcript")
57
  gpt_transcript = gr.Text(label="Chat Transcript")
58
  gpt_voice = gr.Audio(label="Voice Response")
59
+ submit_btn.click(transcribe, user_audio, user_transcript)
60
  user_transcript.change(botResponse, [user_transcript, messages], gpt_transcript)
61
+ gpt_transcript.change(giveVoice, [gpt_transcript, messages], gpt_voice)
62
 
63
 
64