alessandro trinca tornidor commited on
Commit
ce5c4e6
1 Parent(s): 918182d

feat: remove the button for splitting the recorded student audio, refactored interface

Browse files
Files changed (1) hide show
  1. app.py +16 -27
app.py CHANGED
@@ -119,42 +119,28 @@ with gr.Blocks(css=css, head=js.head_driver_tour) as gradio_app:
119
  value=" - ",
120
  elem_classes="speech-output-html background-white",
121
  )
122
- with gr.Row():
123
- gr.Markdown("### Speech accuracy score (%)", elem_classes="speech-accuracy-score-container row1", elem_id="speech-accuracy-score-container-id-element")
124
  with gr.Row():
125
  with gr.Column(min_width=100, elem_classes="speech-accuracy-score-container row2 col1"):
126
- num_pronunciation_accuracy = gr.Number(label="Current score", elem_id="number-pronunciation-accuracy-id-element")
127
  with gr.Column(min_width=100, elem_classes="speech-accuracy-score-container row2 col2"):
128
- num_score_de = gr.Number(label="Global score DE", value=0, interactive=False, elem_id="number-score-de-id-element")
129
  with gr.Column(min_width=100, elem_classes="speech-accuracy-score-container row2 col3"):
130
- num_score_en = gr.Number(label="Global score EN", value=0, interactive=False, elem_id="number-score-en-id-element")
131
- with gr.Row():
132
- btn_recognize_speech_accuracy = gr.Button(value="Recognize speech accuracy", elem_id="btn-recognize-speech-accuracy-id-element")
133
  with gr.Row():
134
- with gr.Column(scale=1, min_width=50):
135
- num_tot_recognized_words = gr.Number(label="Total recognized words", visible=True, minimum=0, interactive=False)
136
- with gr.Column(scale=1, min_width=50):
137
- num_selected_recognized_words = gr.Number(label=word_idx_text, visible=True, minimum=0, value=0)
138
- with gr.Column(scale=2, min_width=100):
139
  # todo: use https://www.gradio.app/docs/gradio/multimodaltextbox
140
  audio_splitted_student_recording_stt = gr.Audio(
141
- label="Splitted Speech-toText audio output",
142
  type="filepath",
143
  show_download_button=True,
144
  elem_id="audio-splitted-student-recording-stt-id-element",
145
  )
146
  with gr.Row():
147
- btn_select_recognized_word = gr.Button(value="Select recognized word", elem_id="btn-select-recognized-word-id-element")
148
- # slider_select_student_recorded_stt = gr.Slider(
149
- # label="Splitted Speech-toText audio output",
150
- # elem_id="slider-split-audio-student-recording-stt-id-element"
151
- # )
152
- # slider_select_student_recorded_stt.change(
153
- # lambdaSpeechToScore.get_selected_word,
154
- # inputs=[slider_select_student_recorded_stt, text_raw_json_output_hidden],
155
- # outputs=[audio_splitted_student_recording_stt]
156
- # )
157
- btn_select_recognized_word.click(
158
  lambdaSpeechToScore.get_selected_word,
159
  inputs=[num_selected_recognized_words, text_raw_json_output_hidden],
160
  outputs=[audio_splitted_student_recording_stt],
@@ -208,9 +194,12 @@ with gr.Blocks(css=css, head=js.head_driver_tour) as gradio_app:
208
 
209
  def change_max_selected_words(n):
210
  app_logger.info(f"change_max_selected_words: {n} ...")
 
211
  app_logger.info(f"num_selected_recognized_words.maximum, pre: {num_selected_recognized_words.maximum} ...")
212
- label = word_idx_text if n == 0 else f"{word_idx_text}, max {n}!"
213
- new_num_selected_recognized_words = gr.Number(label=label, visible=True, value=0, minimum=0, maximum=n)
 
 
214
  app_logger.info(f"num_selected_recognized_words.maximum, post: {num_selected_recognized_words.maximum} ...")
215
  return new_num_selected_recognized_words
216
 
@@ -235,7 +224,7 @@ with gr.Blocks(css=css, head=js.head_driver_tour) as gradio_app:
235
  def reset_max_total_recognized_words(content_text_recording_ipa, content_num_tot_recognized_words):
236
  if content_text_recording_ipa is None or content_text_recording_ipa == "":
237
  app_logger.info("reset_max_total_recognized_words...")
238
- new_num_tot_recognized_words = gr.Number(label="Total recognized words", visible=True, value=0, minimum=0, interactive=False)
239
  return new_num_tot_recognized_words
240
  return content_num_tot_recognized_words
241
 
 
119
  value=" - ",
120
  elem_classes="speech-output-html background-white",
121
  )
 
 
122
  with gr.Row():
123
  with gr.Column(min_width=100, elem_classes="speech-accuracy-score-container row2 col1"):
124
+ num_pronunciation_accuracy = gr.Number(label="Current score %", elem_id="number-pronunciation-accuracy-id-element")
125
  with gr.Column(min_width=100, elem_classes="speech-accuracy-score-container row2 col2"):
126
+ num_score_de = gr.Number(label="Global score DE %", value=0, interactive=False, elem_id="number-score-de-id-element")
127
  with gr.Column(min_width=100, elem_classes="speech-accuracy-score-container row2 col3"):
128
+ num_score_en = gr.Number(label="Global score EN %", value=0, interactive=False, elem_id="number-score-en-id-element")
129
+ btn_recognize_speech_accuracy = gr.Button(value="Get speech accuracy score (%)", elem_id="btn-recognize-speech-accuracy-id-element")
 
130
  with gr.Row():
131
+ num_tot_recognized_words = gr.Number(label="Total recognized words", visible=False, minimum=0, interactive=False)
132
+ with gr.Column(scale=2, min_width=50):
133
+ num_selected_recognized_words = gr.Number(label=word_idx_text, visible=True, minimum=0, value=0, interactive=False)
134
+ with gr.Column(scale=9, min_width=100):
 
135
  # todo: use https://www.gradio.app/docs/gradio/multimodaltextbox
136
  audio_splitted_student_recording_stt = gr.Audio(
137
+ label="Splitted student audio output",
138
  type="filepath",
139
  show_download_button=True,
140
  elem_id="audio-splitted-student-recording-stt-id-element",
141
  )
142
  with gr.Row():
143
+ num_selected_recognized_words.input(
 
 
 
 
 
 
 
 
 
 
144
  lambdaSpeechToScore.get_selected_word,
145
  inputs=[num_selected_recognized_words, text_raw_json_output_hidden],
146
  outputs=[audio_splitted_student_recording_stt],
 
194
 
195
  def change_max_selected_words(n):
196
  app_logger.info(f"change_max_selected_words: {n} ...")
197
+ num_max_selected_words = n -1
198
  app_logger.info(f"num_selected_recognized_words.maximum, pre: {num_selected_recognized_words.maximum} ...")
199
+ label = word_idx_text if n == 0 else f"{word_idx_text} ({num_max_selected_words} max)"
200
+ interactive = n > 0
201
+ app_logger.info(f"change_max_selected_words: {n}, is interactive? {interactive} ...")
202
+ new_num_selected_recognized_words = gr.Number(label=label, visible=True, value=0, minimum=0, maximum=num_max_selected_words, interactive=interactive)
203
  app_logger.info(f"num_selected_recognized_words.maximum, post: {num_selected_recognized_words.maximum} ...")
204
  return new_num_selected_recognized_words
205
 
 
224
  def reset_max_total_recognized_words(content_text_recording_ipa, content_num_tot_recognized_words):
225
  if content_text_recording_ipa is None or content_text_recording_ipa == "":
226
  app_logger.info("reset_max_total_recognized_words...")
227
+ new_num_tot_recognized_words = gr.Number(label="Total recognized words", visible=False, value=0, minimum=0, interactive=False)
228
  return new_num_tot_recognized_words
229
  return content_num_tot_recognized_words
230