unijoh commited on
Commit
94780f8
1 Parent(s): a4f1c3b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -41,27 +41,34 @@ def identify_language(audio):
41
  language = lid_processor.batch_decode(predicted_ids)
42
  return language[0]
43
 
 
 
 
 
 
 
 
44
  # Define the Gradio interfaces
45
  with gr.Blocks() as demo:
46
  with gr.Tab("ASR"):
47
  gr.Markdown("## Automatic Speech Recognition (ASR)")
48
  audio_input = gr.Audio(source="microphone", type="numpy")
49
  text_output = gr.Textbox(label="Transcription")
50
- gr.Button("Clear", clear_audio_input)
51
  gr.Button("Submit", fn=asr_transcribe, inputs=audio_input, outputs=text_output)
52
 
53
  with gr.Tab("TTS"):
54
  gr.Markdown("## Text-to-Speech (TTS)")
55
  text_input = gr.Textbox(label="Text")
56
  audio_output = gr.Audio(label="Audio Output")
57
- gr.Button("Clear", clear_text_input)
58
  gr.Button("Submit", fn=tts_synthesize, inputs=text_input, outputs=audio_output)
59
 
60
  with gr.Tab("Language ID"):
61
  gr.Markdown("## Language Identification (LangID)")
62
  audio_input = gr.Audio(source="microphone", type="numpy")
63
  language_output = gr.Textbox(label="Identified Language")
64
- gr.Button("Clear", clear_audio_input)
65
  gr.Button("Submit", fn=identify_language, inputs=audio_input, outputs=language_output)
66
 
67
  demo.launch()
 
41
  language = lid_processor.batch_decode(predicted_ids)
42
  return language[0]
43
 
44
+ # Clear Functions
45
+ def clear_audio_input():
46
+ return None
47
+
48
+ def clear_text_input():
49
+ return ""
50
+
51
  # Define the Gradio interfaces
52
  with gr.Blocks() as demo:
53
  with gr.Tab("ASR"):
54
  gr.Markdown("## Automatic Speech Recognition (ASR)")
55
  audio_input = gr.Audio(source="microphone", type="numpy")
56
  text_output = gr.Textbox(label="Transcription")
57
+ gr.Button("Clear", fn=clear_audio_input, inputs=[], outputs=audio_input)
58
  gr.Button("Submit", fn=asr_transcribe, inputs=audio_input, outputs=text_output)
59
 
60
  with gr.Tab("TTS"):
61
  gr.Markdown("## Text-to-Speech (TTS)")
62
  text_input = gr.Textbox(label="Text")
63
  audio_output = gr.Audio(label="Audio Output")
64
+ gr.Button("Clear", fn=clear_text_input, inputs=[], outputs=text_input)
65
  gr.Button("Submit", fn=tts_synthesize, inputs=text_input, outputs=audio_output)
66
 
67
  with gr.Tab("Language ID"):
68
  gr.Markdown("## Language Identification (LangID)")
69
  audio_input = gr.Audio(source="microphone", type="numpy")
70
  language_output = gr.Textbox(label="Identified Language")
71
+ gr.Button("Clear", fn=clear_audio_input, inputs=[], outputs=audio_input)
72
  gr.Button("Submit", fn=identify_language, inputs=audio_input, outputs=language_output)
73
 
74
  demo.launch()