Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -155,6 +155,25 @@ def _disp_scorertype(scorertype):
|
|
| 155 |
scoring_model_type = '...'
|
| 156 |
return f"### Scoring model for this exercise was: [{scoring_model_type}]"
|
| 157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
def display0(score_output):
|
| 159 |
task_feedback = score_output['task_feedback']
|
| 160 |
word_feedback = score_output['word_feedback']
|
|
@@ -208,26 +227,36 @@ with bl:
|
|
| 208 |
with gr.Column(scale=1):
|
| 209 |
placeholder_output = gr.Markdown("## Einkunn/gæði: ...")
|
| 210 |
with gr.Column(scale=3):
|
| 211 |
-
blocks_output = gr.Plot()
|
| 212 |
blocks_info = gr.Markdown("""*This colour feedback was not calibrated by exercise/phone,
|
| 213 |
-
relative colours may mismatch other scores""")
|
| 214 |
-
|
| 215 |
|
| 216 |
with gr.Row():
|
| 217 |
with gr.Column():
|
| 218 |
-
phone_output_keyinfo = gr.Markdown("""### Lykill: <span style='color:#26701C;'>Meira nálægt</span>, <span style='color:#E85907;'>Minna nálægt</span>, <span style='color:#BBBBBB;'>Ekki hægt að greina (of stutt hljóð)</span>, <span style='color:#88447F;'>••• Pitch</span>
|
| 219 |
-
|
| 220 |
-
|
|
|
|
| 221 |
cali_info=gr.Markdown("""
|
| 222 |
#### ◄ Re-calibrate scoring
|
| 223 |
|
| 224 |
Too easy, always 100? Raise the maximum. Too hard, always 0? Lower the minimum.
|
| 225 |
|
| 226 |
### Note: Does not affect Monophone model.
|
| 227 |
-
""")
|
| 228 |
|
| 229 |
-
new_prompt_button.click(refresh_prompt_fn,
|
| 230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
score_speech_button.click(score_speech_fn,
|
| 232 |
inputs=[current_prompt, user_speech, fb],
|
| 233 |
outputs = [placeholder_output, modeltype_info, plot_output, blocks_output])
|
|
|
|
| 155 |
scoring_model_type = '...'
|
| 156 |
return f"### Scoring model for this exercise was: [{scoring_model_type}]"
|
| 157 |
|
| 158 |
+
# toggle on/off some components
|
| 159 |
+
def dev_opts_fn(check_box,phone_output_keyinfo):
|
| 160 |
+
energy_key = """, <span style='color:#F49098;'>--- Energy</span>"""
|
| 161 |
+
reset_fb = gr.State(FeedbackConverter(fb_params['t_key'], fb_params['p_key'], fb_params['lb'], fb_params['ub']))
|
| 162 |
+
if check_box: # user has just turned ON extra options
|
| 163 |
+
new_key = phone_output_keyinfo + energy_key
|
| 164 |
+
new_vis = True
|
| 165 |
+
|
| 166 |
+
else:
|
| 167 |
+
new_key = phone_output_keyinfo[:-len(energy_key)]
|
| 168 |
+
new_vis = False
|
| 169 |
+
|
| 170 |
+
return [new_key,
|
| 171 |
+
gr.update(value= _disp_scorertype('...'),visible=new_vis),
|
| 172 |
+
gr.update(value=(fb_params['lb'], fb_params['ub']),visible=new_vis),
|
| 173 |
+
reset_fb,
|
| 174 |
+
gr.update(visible=new_vis), gr.update(visible=new_vis), gr.update(visible=new_vis)]
|
| 175 |
+
|
| 176 |
+
|
| 177 |
def display0(score_output):
|
| 178 |
task_feedback = score_output['task_feedback']
|
| 179 |
word_feedback = score_output['word_feedback']
|
|
|
|
| 227 |
with gr.Column(scale=1):
|
| 228 |
placeholder_output = gr.Markdown("## Einkunn/gæði: ...")
|
| 229 |
with gr.Column(scale=3):
|
| 230 |
+
blocks_output = gr.Plot(visible=False)
|
| 231 |
blocks_info = gr.Markdown("""*This colour feedback was not calibrated by exercise/phone,
|
| 232 |
+
relative colours may mismatch other scores""",visible=False)
|
|
|
|
| 233 |
|
| 234 |
with gr.Row():
|
| 235 |
with gr.Column():
|
| 236 |
+
phone_output_keyinfo = gr.Markdown("""### Lykill: <span style='color:#26701C;'>Meira nálægt</span>, <span style='color:#E85907;'>Minna nálægt</span>, <span style='color:#BBBBBB;'>Ekki hægt að greina (of stutt hljóð)</span>, <span style='color:#88447F;'>••• Pitch</span>""")
|
| 237 |
+
dev_checkbox = gr.Checkbox(label="[Debug]", value=False)
|
| 238 |
+
modeltype_info = gr.Markdown(_disp_scorertype('...'),visible=False)
|
| 239 |
+
calibrate_slider = RangeSlider(minimum=-1, maximum=1, value=(fb_lb, fb_ub), interactive=True, visible=False)
|
| 240 |
cali_info=gr.Markdown("""
|
| 241 |
#### ◄ Re-calibrate scoring
|
| 242 |
|
| 243 |
Too easy, always 100? Raise the maximum. Too hard, always 0? Lower the minimum.
|
| 244 |
|
| 245 |
### Note: Does not affect Monophone model.
|
| 246 |
+
""", visible=False)
|
| 247 |
|
| 248 |
+
new_prompt_button.click(refresh_prompt_fn,
|
| 249 |
+
inputs = [],
|
| 250 |
+
outputs = [current_prompt, prompt_text, user_speech, modeltype_info, plot_output, blocks_output])
|
| 251 |
+
|
| 252 |
+
dev_checkbox.input(dev_opts_fn,
|
| 253 |
+
inputs = [dev_checkbox,phone_output_keyinfo],
|
| 254 |
+
outputs = [phone_output_keyinfo, modeltype_info, calibrate_slider, fb, cali_info, blocks_output, blocks_info])
|
| 255 |
+
|
| 256 |
+
calibrate_slider.release(recal_fb_fn,
|
| 257 |
+
inputs = [calibrate_slider],
|
| 258 |
+
outputs = [fb] )
|
| 259 |
+
|
| 260 |
score_speech_button.click(score_speech_fn,
|
| 261 |
inputs=[current_prompt, user_speech, fb],
|
| 262 |
outputs = [placeholder_output, modeltype_info, plot_output, blocks_output])
|