alessandro trinca tornidor commited on
Commit
1470bc9
·
1 Parent(s): 8838421

feat: refactor app.py to add a clear button for the audio TTS component; now a new random phrase clear the tts and stt audio components

Browse files
Files changed (1) hide show
  1. app.py +25 -14
app.py CHANGED
@@ -29,9 +29,12 @@ function updateCssText(text, letters) {
29
  """
30
 
31
 
32
- def change_interactivity_components(components, is_active: bool):
33
- for component in components:
34
- component.interactive = is_active
 
 
 
35
 
36
 
37
  with gr.Blocks() as gradio_app:
@@ -72,14 +75,17 @@ with gr.Blocks() as gradio_app:
72
  )
73
  with gr.Row():
74
  with gr.Column(scale=7, min_width=240):
75
- tts = gr.Audio(label="Audio TTS")
76
  with gr.Column(scale=1, min_width=50):
77
- btn_tts = gr.Button(value="Run TTS")
 
 
78
  with gr.Row():
79
- learner_recording = gr.Audio(
80
  label="Learner Recording",
81
  sources=["microphone", "upload"],
82
  type="filepath",
 
83
  )
84
  with gr.Column(scale=4, min_width=320):
85
  examples_text = gr.Examples(
@@ -124,14 +130,9 @@ with gr.Blocks() as gradio_app:
124
  )
125
  with gr.Row():
126
  btn = gr.Button(value="Recognize speech accuracy")
127
- btn_random_phrase.click(
128
- lambdaGetSample.get_random_selection,
129
- inputs=[language, difficulty],
130
- outputs=[learner_transcription],
131
- )
132
  btn.click(
133
  lambdaSpeechToScore.get_speech_to_score_tuple,
134
- inputs=[learner_transcription, learner_recording, language],
135
  outputs=[
136
  transcripted_text,
137
  letter_correctness,
@@ -141,10 +142,20 @@ with gr.Blocks() as gradio_app:
141
  res,
142
  ],
143
  )
144
- btn_tts.click(
145
  fn=lambdaTTS.get_tts,
146
  inputs=[learner_transcription, language],
147
- outputs=tts,
 
 
 
 
 
 
 
 
 
 
148
  )
149
  html_output.change(
150
  None,
 
29
  """
30
 
31
 
32
+ def clear():
33
+ return None
34
+
35
+
36
+ def clear2():
37
+ return None, None
38
 
39
 
40
  with gr.Blocks() as gradio_app:
 
75
  )
76
  with gr.Row():
77
  with gr.Column(scale=7, min_width=240):
78
+ audio_tts = gr.Audio(label="Audio TTS")
79
  with gr.Column(scale=1, min_width=50):
80
+ btn_run_tts = gr.Button(value="Run TTS")
81
+ btn_clear_tts = gr.Button(value="Clear TTS")
82
+ btn_clear_tts.click(clear, inputs=[], outputs=[audio_tts])
83
  with gr.Row():
84
+ audio_learner_recording_stt = gr.Audio(
85
  label="Learner Recording",
86
  sources=["microphone", "upload"],
87
  type="filepath",
88
+ show_download_button=True,
89
  )
90
  with gr.Column(scale=4, min_width=320):
91
  examples_text = gr.Examples(
 
130
  )
131
  with gr.Row():
132
  btn = gr.Button(value="Recognize speech accuracy")
 
 
 
 
 
133
  btn.click(
134
  lambdaSpeechToScore.get_speech_to_score_tuple,
135
+ inputs=[learner_transcription, audio_learner_recording_stt, language],
136
  outputs=[
137
  transcripted_text,
138
  letter_correctness,
 
142
  res,
143
  ],
144
  )
145
+ btn_run_tts.click(
146
  fn=lambdaTTS.get_tts,
147
  inputs=[learner_transcription, language],
148
+ outputs=audio_tts,
149
+ )
150
+ btn_random_phrase.click(
151
+ lambdaGetSample.get_random_selection,
152
+ inputs=[language, difficulty],
153
+ outputs=[learner_transcription],
154
+ )
155
+ btn_random_phrase.click(
156
+ clear2,
157
+ inputs=[],
158
+ outputs=[audio_learner_recording_stt, audio_tts]
159
  )
160
  html_output.change(
161
  None,