alessandro trinca tornidor commited on
Commit
6777887
1 Parent(s): ca7e6be

feat: add score DE and EN components

Browse files
Files changed (2) hide show
  1. aip_trainer/lambdas/app_description.md +1 -1
  2. app.py +21 -18
aip_trainer/lambdas/app_description.md CHANGED
@@ -5,4 +5,4 @@ for more details.
5
 
6
  Selecting a new example invalidates all previous inputs (Text-to-Speech audio and Speech-to-Text recordings): in that case you should recorder again your audio speeceh.
7
 
8
- Right now this tool uses {} as sample rate value. From empirical tests the best sample rate value is 48000...
 
5
 
6
  Selecting a new example invalidates all previous inputs (Text-to-Speech audio and Speech-to-Text recordings): in that case you should recorder again your audio speeceh.
7
 
8
+ Right now this tool uses {sample_rate_start} as sample rate value. From empirical tests the best sample rate value is 48000.
app.py CHANGED
@@ -2,7 +2,7 @@ import json
2
  from pathlib import Path
3
  import gradio as gr
4
 
5
- from aip_trainer import PROJECT_ROOT_FOLDER, app_logger
6
  from aip_trainer.lambdas import js, lambdaGetSample, lambdaSpeechToScore, lambdaTTS
7
 
8
 
@@ -20,10 +20,7 @@ with gr.Blocks() as gradio_app:
20
  project_root_folder = Path(PROJECT_ROOT_FOLDER)
21
  with open(project_root_folder / "aip_trainer" / "lambdas" / "app_description.md", "r", encoding="utf-8") as app_description_src:
22
  app_description = app_description_src.read()
23
- gr.Markdown(app_description)
24
- with gr.Row():
25
- number_score_de = gr.Number(label="Score DE", value=0.0)
26
- number_score_en = gr.Number(label="Score EN", value=0.0)
27
  with gr.Row():
28
  with gr.Column(scale=4, min_width=300):
29
  with gr.Row():
@@ -64,18 +61,6 @@ with gr.Blocks() as gradio_app:
64
  show_download_button=True,
65
  )
66
  with gr.Column(scale=4, min_width=320):
67
- examples_text = gr.Examples(
68
- examples=[
69
- ["Hallo, wie geht es dir?", "de", 1],
70
- ["Hi there, how are you?", "en", 1],
71
- ["Die König-Ludwig-Eiche ist ein Naturdenkmal im Staatsbad Brückenau.", "de", 2,],
72
- ["Rome is home to some of the most beautiful monuments in the world.", "en", 2],
73
- ["Die König-Ludwig-Eiche ist ein Naturdenkmal im Staatsbad Brückenau, einem Ortsteil des drei Kilometer nordöstlich gelegenen Bad Brückenau im Landkreis Bad Kissingen in Bayern.", "de", 3],
74
- ["Some machine learning models are designed to understand and generate human-like text based on the input they receive.", "en", 3],
75
- ],
76
- inputs=[learner_transcription, language, difficulty],
77
- )
78
-
79
  transcripted_text = gr.Textbox(
80
  lines=2, placeholder=None, label="Transcripted text", visible=False
81
  )
@@ -85,7 +70,13 @@ with gr.Blocks() as gradio_app:
85
  label="Letters correctness",
86
  visible=False,
87
  )
88
- pronunciation_accuracy = gr.Number(label="Pronunciation accuracy %")
 
 
 
 
 
 
89
  recording_ipa = gr.Textbox(
90
  lines=1, placeholder=None, label="Learner phonetic transcription"
91
  )
@@ -104,6 +95,18 @@ with gr.Blocks() as gradio_app:
104
  )
105
  with gr.Row():
106
  btn = gr.Button(value="Recognize speech accuracy")
 
 
 
 
 
 
 
 
 
 
 
 
107
 
108
  def get_updated_score_by_language(text: str, audio_rec: str | Path, lang: str, score_de: float, score_en: float):
109
  _transcripted_text, _letter_correctness, _pronunciation_accuracy, _recording_ipa, _ideal_ipa, _res = lambdaSpeechToScore.get_speech_to_score_tuple(text, audio_rec, lang)
 
2
  from pathlib import Path
3
  import gradio as gr
4
 
5
+ from aip_trainer import PROJECT_ROOT_FOLDER, app_logger, sample_rate_start
6
  from aip_trainer.lambdas import js, lambdaGetSample, lambdaSpeechToScore, lambdaTTS
7
 
8
 
 
20
  project_root_folder = Path(PROJECT_ROOT_FOLDER)
21
  with open(project_root_folder / "aip_trainer" / "lambdas" / "app_description.md", "r", encoding="utf-8") as app_description_src:
22
  app_description = app_description_src.read()
23
+ gr.Markdown(app_description.format(sample_rate_start=sample_rate_start))
 
 
 
24
  with gr.Row():
25
  with gr.Column(scale=4, min_width=300):
26
  with gr.Row():
 
61
  show_download_button=True,
62
  )
63
  with gr.Column(scale=4, min_width=320):
 
 
 
 
 
 
 
 
 
 
 
 
64
  transcripted_text = gr.Textbox(
65
  lines=2, placeholder=None, label="Transcripted text", visible=False
66
  )
 
70
  label="Letters correctness",
71
  visible=False,
72
  )
73
+ with gr.Row():
74
+ with gr.Column(scale=3, min_width=100):
75
+ pronunciation_accuracy = gr.Number(label="Current pronunciation accuracy %")
76
+ with gr.Column(scale=2, min_width=100):
77
+ number_score_de = gr.Number(label="Score DE", value=0)
78
+ with gr.Column(scale=2, min_width=100):
79
+ number_score_en = gr.Number(label="Score EN", value=0)
80
  recording_ipa = gr.Textbox(
81
  lines=1, placeholder=None, label="Learner phonetic transcription"
82
  )
 
95
  )
96
  with gr.Row():
97
  btn = gr.Button(value="Recognize speech accuracy")
98
+ with gr.Accordion("Click here to expand the table examples", open=False):
99
+ examples_text = gr.Examples(
100
+ examples=[
101
+ ["Hallo, wie geht es dir?", "de", 1],
102
+ ["Hi there, how are you?", "en", 1],
103
+ ["Die König-Ludwig-Eiche ist ein Naturdenkmal im Staatsbad Brückenau.", "de", 2,],
104
+ ["Rome is home to some of the most beautiful monuments in the world.", "en", 2],
105
+ ["Die König-Ludwig-Eiche ist ein Naturdenkmal im Staatsbad Brückenau, einem Ortsteil des drei Kilometer nordöstlich gelegenen Bad Brückenau im Landkreis Bad Kissingen in Bayern.", "de", 3],
106
+ ["Some machine learning models are designed to understand and generate human-like text based on the input they receive.", "en", 3],
107
+ ],
108
+ inputs=[learner_transcription, language, difficulty],
109
+ )
110
 
111
  def get_updated_score_by_language(text: str, audio_rec: str | Path, lang: str, score_de: float, score_en: float):
112
  _transcripted_text, _letter_correctness, _pronunciation_accuracy, _recording_ipa, _ideal_ipa, _res = lambdaSpeechToScore.get_speech_to_score_tuple(text, audio_rec, lang)