Alesmikes commited on
Commit
c0a316a
1 Parent(s): 6beeacc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -68,6 +68,10 @@ def text2speech(text):
68
  define voice -> gpt -> text -> voice workflow
69
  """
70
  def transcribe(audio):
 
 
 
 
71
  #global messages
72
 
73
  """
@@ -124,11 +128,12 @@ def transcribe(audio):
124
 
125
  output_text = gr.outputs.Textbox(label="Chat Messages")
126
 
127
- output_audio = gr.outputs.Audio(type = "filepath", label="AI Assistant")
128
-
129
- gr.Interface(fn=transcribe, \
130
- inputs=gr.Audio(source="microphone", type="filepath",label="Speak here..."), \
131
- outputs=[output_audio, output_text], \
132
- live=True,\
133
- allow_flagging='never')\
134
- .launch()
 
 
68
  define voice -> gpt -> text -> voice workflow
69
  """
70
  def transcribe(audio):
71
+ messages = chat.generate_dialogue(audio)
72
+ voice_path = chat.synthesize_voice(messages)
73
+ chat_text = "\n".join([f"{msg['role']}: {msg['content']}" for msg in messages])
74
+ return voice_path, chat_text
75
  #global messages
76
 
77
  """
 
128
 
129
  output_text = gr.outputs.Textbox(label="Chat Messages")
130
 
131
+ output_audio = gr.outputs.Audio(label="Synthesized Voice")
132
+ output_text = gr.outputs.Textbox(label="Chat Messages")
133
+ gr.Interface(
134
+ fn=transcribe,
135
+ inputs=gr.inputs.Audio(source="microphone", label="Speak here..."),
136
+ outputs=[output_audio, output_text],
137
+ live=True,
138
+ allow_flagging='never'
139
+ ).launch()