ar08 commited on
Commit
1789395
·
verified ·
1 Parent(s): e255e64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -129,15 +129,15 @@ def create_demo():
129
  def process_audio(audio, volume):
130
  logging.info(f"Received audio: {audio}")
131
  if audio is None:
132
- return "No audio detected. Please try recording again.", None, None
133
  response, audio_path = transcribe_and_chat(audio)
134
  # Adjust volume for the response audio
135
  adjusted_audio_path = asyncio.run(text_to_speech_stream(response, volume))
136
  logging.info(f"Response: {response}, Audio path: {adjusted_audio_path}")
137
- return response, adjusted_audio_path, None # Return None to clear the audio input
138
 
139
- audio_input.change(process_audio, inputs=[audio_input, voice_volume], outputs=[chat_output, audio_output, audio_input])
140
- clear_button.click(lambda: (None, None, None), None, [chat_output, audio_output, audio_input])
141
 
142
  # JavaScript to handle autoplay and automatic submission
143
  demo.load(None, js="""
 
129
  def process_audio(audio, volume):
130
  logging.info(f"Received audio: {audio}")
131
  if audio is None:
132
+ return "No audio detected. Please try recording again.", None
133
  response, audio_path = transcribe_and_chat(audio)
134
  # Adjust volume for the response audio
135
  adjusted_audio_path = asyncio.run(text_to_speech_stream(response, volume))
136
  logging.info(f"Response: {response}, Audio path: {adjusted_audio_path}")
137
+ return response, adjusted_audio_path
138
 
139
+ audio_input.change(process_audio, inputs=[audio_input, voice_volume], outputs=[chat_output, audio_output])
140
+ clear_button.click(lambda: (None, None), None, [chat_output, audio_output])
141
 
142
  # JavaScript to handle autoplay and automatic submission
143
  demo.load(None, js="""