alessandro trinca tornidor commited on
Commit
3a8b45a
1 Parent(s): 8b62994

style: improve speech-output style using a custom css

Browse files
Files changed (1) hide show
  1. app.py +31 -24
app.py CHANGED
@@ -5,6 +5,12 @@ from aip_trainer import PROJECT_ROOT_FOLDER, app_logger, sample_rate_start
5
  from aip_trainer.lambdas import js, lambdaGetSample, lambdaSpeechToScore, lambdaTTS
6
 
7
 
 
 
 
 
 
 
8
  def clear():
9
  return None
10
 
@@ -13,7 +19,7 @@ def clear2():
13
  return None, None
14
 
15
 
16
- with gr.Blocks() as gradio_app:
17
  local_storage = gr.BrowserState([0.0, 0.0])
18
  app_logger.info("start gradio app building...")
19
 
@@ -62,39 +68,40 @@ with gr.Blocks() as gradio_app:
62
  )
63
  with gr.Column(scale=4, min_width=320):
64
  text_transcribed_hidden = gr.Textbox(
65
- lines=2, placeholder=None, label="Transcribed text", visible=False
66
  )
67
  text_letter_correctness = gr.Textbox(
68
- lines=1,
69
  placeholder=None,
70
  label="Letters correctness",
71
  visible=False,
72
  )
73
- with gr.Row():
74
- gr.Markdown("Speech accuracy score (%)")
75
- with gr.Row():
76
- with gr.Column(min_width=100):
77
- number_pronunciation_accuracy = gr.Number(label="Current score")
78
- with gr.Column(min_width=100):
79
- number_score_de = gr.Number(label="Global score DE", value=0, interactive=False)
80
- with gr.Column(min_width=100):
81
- number_score_en = gr.Number(label="Global score EN", value=0, interactive=False)
82
  text_recording_ipa = gr.Textbox(
83
- lines=1, placeholder=None, label="Learner phonetic transcription"
84
  )
85
  text_ideal_ipa = gr.Textbox(
86
- lines=1, placeholder=None, label="Ideal phonetic transcription"
87
- )
88
- text_raw_json_output_hidden = gr.Textbox(lines=1, placeholder=None, label="text_raw_json_output_hidden", visible=False)
89
- html_output = gr.HTML(
90
- label="Speech accuracy output",
91
- elem_id="speech-output",
92
- show_label=True,
93
- visible=True,
94
- render=True,
95
- value=" - ",
96
- elem_classes="speech-output",
97
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  with gr.Row():
99
  btn = gr.Button(value="Recognize speech accuracy")
100
  with gr.Accordion("Click here to expand the table examples", open=False):
 
5
  from aip_trainer.lambdas import js, lambdaGetSample, lambdaSpeechToScore, lambdaTTS
6
 
7
 
8
+ css = """
9
+ .speech-output-label p {color: grey;}
10
+ .speech-output-container {align-items: center; min-height: 60px; padding-left: 8px; padding-right: 8px; margin-top: -12px; border-width: 1px; border-style: solid; border-color: lightgrey;}
11
+ """
12
+
13
+
14
  def clear():
15
  return None
16
 
 
19
  return None, None
20
 
21
 
22
+ with gr.Blocks(css=css) as gradio_app:
23
  local_storage = gr.BrowserState([0.0, 0.0])
24
  app_logger.info("start gradio app building...")
25
 
 
68
  )
69
  with gr.Column(scale=4, min_width=320):
70
  text_transcribed_hidden = gr.Textbox(
71
+ placeholder=None, label="Transcribed text", visible=False
72
  )
73
  text_letter_correctness = gr.Textbox(
 
74
  placeholder=None,
75
  label="Letters correctness",
76
  visible=False,
77
  )
 
 
 
 
 
 
 
 
 
78
  text_recording_ipa = gr.Textbox(
79
+ placeholder=None, label="Learner phonetic transcription"
80
  )
81
  text_ideal_ipa = gr.Textbox(
82
+ placeholder=None, label="Ideal phonetic transcription"
 
 
 
 
 
 
 
 
 
 
83
  )
84
+ text_raw_json_output_hidden = gr.Textbox(placeholder=None, label="text_raw_json_output_hidden", visible=False)
85
+ gr.Markdown("Speech accuracy output", elem_classes="speech-output-label")
86
+ with gr.Row(elem_classes="speech-output-container"):
87
+ html_output = gr.HTML(
88
+ label="Speech accuracy output",
89
+ elem_id="speech-output",
90
+ show_label=True,
91
+ visible=True,
92
+ render=True,
93
+ value=" - ",
94
+ elem_classes="speech-output",
95
+ )
96
+ with gr.Row():
97
+ gr.Markdown("### Speech accuracy score (%)", elem_classes="speech-accuracy-score-container row1")
98
+ with gr.Row():
99
+ with gr.Column(min_width=100, elem_classes="speech-accuracy-score-container row2 col1"):
100
+ number_pronunciation_accuracy = gr.Number(label="Current score")
101
+ with gr.Column(min_width=100, elem_classes="speech-accuracy-score-container row2 col2"):
102
+ number_score_de = gr.Number(label="Global score DE", value=0, interactive=False)
103
+ with gr.Column(min_width=100, elem_classes="speech-accuracy-score-container row2 col3"):
104
+ number_score_en = gr.Number(label="Global score EN", value=0, interactive=False)
105
  with gr.Row():
106
  btn = gr.Button(value="Recognize speech accuracy")
107
  with gr.Accordion("Click here to expand the table examples", open=False):