Pijush2023 commited on
Commit
d8e6689
·
verified ·
1 Parent(s): d5b9901

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -247,10 +247,15 @@ def handle_voice_to_voice(audio):
247
  logging.error(f"Error in handle_voice_to_voice: {e}")
248
  return "Error processing the audio, please try again.", ""
249
 
 
 
 
 
250
  # Define the Gradio interface
251
  with gr.Blocks(theme="rawrsor1/Everforest") as demo:
252
  audio_input = gr.Audio(sources=["microphone"], type='numpy', streaming=True, label="Speak to Ask")
253
  submit_voice_btn = gr.Button("Submit Voice")
 
254
  transcription_textbox = gr.Textbox(label="Transcription", interactive=False)
255
  audio_output = gr.Audio(label="Response Audio", type="filepath", autoplay=True, interactive=False)
256
 
@@ -259,10 +264,13 @@ with gr.Blocks(theme="rawrsor1/Everforest") as demo:
259
  fn=handle_voice_to_voice,
260
  inputs=audio_input,
261
  outputs=[audio_output, transcription_textbox]
262
- ).then(
263
- fn=lambda: "",
264
- outputs=[transcription_textbox]
 
 
 
265
  )
266
 
267
  # Launch the Gradio interface
268
- demo.launch(show_error=True, share=True)
 
247
  logging.error(f"Error in handle_voice_to_voice: {e}")
248
  return "Error processing the audio, please try again.", ""
249
 
250
+ # Function to clear the transcription state
251
+ def clear_state():
252
+ return ""
253
+
254
  # Define the Gradio interface
255
  with gr.Blocks(theme="rawrsor1/Everforest") as demo:
256
  audio_input = gr.Audio(sources=["microphone"], type='numpy', streaming=True, label="Speak to Ask")
257
  submit_voice_btn = gr.Button("Submit Voice")
258
+ clear_state_btn = gr.Button("Clear State")
259
  transcription_textbox = gr.Textbox(label="Transcription", interactive=False)
260
  audio_output = gr.Audio(label="Response Audio", type="filepath", autoplay=True, interactive=False)
261
 
 
264
  fn=handle_voice_to_voice,
265
  inputs=audio_input,
266
  outputs=[audio_output, transcription_textbox]
267
+ )
268
+
269
+ # Interaction for Clear State Button
270
+ clear_state_btn.click(
271
+ fn=clear_state,
272
+ outputs=transcription_textbox
273
  )
274
 
275
  # Launch the Gradio interface
276
+ demo.launch(show_error=True, share=True)