Spaces:
Running
Running
alessandro trinca tornidor
commited on
Commit
•
d51ffe7
1
Parent(s):
bafb40b
feat: update the example section, add a random choice for the phrase
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
from aip_trainer import app_logger
|
4 |
-
from aip_trainer.lambdas import lambdaSpeechToScore, lambdaTTS
|
5 |
|
6 |
|
7 |
js = """
|
@@ -28,6 +28,12 @@ function updateCssText(text, letters) {
|
|
28 |
}
|
29 |
"""
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
with gr.Blocks() as gradio_app:
|
32 |
app_logger.info("start gradio app building...")
|
33 |
|
@@ -42,36 +48,52 @@ with gr.Blocks() as gradio_app:
|
|
42 |
with gr.Row():
|
43 |
with gr.Column(scale=4, min_width=300):
|
44 |
with gr.Row():
|
45 |
-
with gr.Column(scale=
|
46 |
language = gr.Radio(["de", "en"], label="Language", value="en")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
with gr.Column(scale=7, min_width=300):
|
48 |
learner_transcription = gr.Textbox(
|
49 |
lines=3,
|
50 |
label="Learner Transcription",
|
51 |
value="Hi there, how are you?",
|
52 |
)
|
|
|
|
|
|
|
|
|
|
|
53 |
with gr.Row():
|
54 |
learner_recording = gr.Audio(
|
55 |
label="Learner Recording",
|
56 |
sources=["microphone", "upload"],
|
57 |
type="filepath",
|
58 |
)
|
59 |
-
|
60 |
-
|
61 |
-
btn = gr.Button(value="TTS")
|
62 |
-
btn.click(
|
63 |
-
fn=lambdaTTS.get_tts,
|
64 |
-
inputs=[learner_transcription, language],
|
65 |
-
outputs=tts,
|
66 |
-
)
|
67 |
-
gr.Examples(
|
68 |
examples=[
|
69 |
-
["Hi there, how are you?", "en"],
|
70 |
-
["Hallo, wie geht es dir?", "de"],
|
|
|
|
|
|
|
|
|
71 |
],
|
72 |
-
inputs=[learner_transcription, language],
|
73 |
)
|
74 |
-
|
75 |
transcripted_text = gr.Textbox(
|
76 |
lines=2, placeholder=None, label="Transcripted text", visible=False
|
77 |
)
|
@@ -100,9 +122,13 @@ with gr.Blocks() as gradio_app:
|
|
100 |
value=" - ",
|
101 |
elem_classes="speech-output",
|
102 |
)
|
103 |
-
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
|
|
106 |
btn.click(
|
107 |
lambdaSpeechToScore.get_speech_to_score_tuple,
|
108 |
inputs=[learner_transcription, learner_recording, language],
|
@@ -115,6 +141,11 @@ with gr.Blocks() as gradio_app:
|
|
115 |
res,
|
116 |
],
|
117 |
)
|
|
|
|
|
|
|
|
|
|
|
118 |
html_output.change(
|
119 |
None,
|
120 |
inputs=[transcripted_text, letter_correctness],
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
from aip_trainer import app_logger
|
4 |
+
from aip_trainer.lambdas import lambdaGetSample, lambdaSpeechToScore, lambdaTTS
|
5 |
|
6 |
|
7 |
js = """
|
|
|
28 |
}
|
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:
|
38 |
app_logger.info("start gradio app building...")
|
39 |
|
|
|
48 |
with gr.Row():
|
49 |
with gr.Column(scale=4, min_width=300):
|
50 |
with gr.Row():
|
51 |
+
with gr.Column(scale=2, min_width=80):
|
52 |
language = gr.Radio(["de", "en"], label="Language", value="en")
|
53 |
+
with gr.Column(scale=5, min_width=160):
|
54 |
+
difficulty = gr.Radio(
|
55 |
+
label="Difficulty",
|
56 |
+
value=0,
|
57 |
+
choices=[
|
58 |
+
("random", 0),
|
59 |
+
("easy", 1),
|
60 |
+
("medium", 2),
|
61 |
+
("hard", 3),
|
62 |
+
],
|
63 |
+
)
|
64 |
+
with gr.Column(scale=1, min_width=100):
|
65 |
+
btn_random_phrase = gr.Button(value="Choose a random phrase")
|
66 |
+
with gr.Row():
|
67 |
with gr.Column(scale=7, min_width=300):
|
68 |
learner_transcription = gr.Textbox(
|
69 |
lines=3,
|
70 |
label="Learner Transcription",
|
71 |
value="Hi there, how are you?",
|
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(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
examples=[
|
87 |
+
["Hi there, how are you?", "en", 1],
|
88 |
+
["Hallo, wie geht es dir?", "de", 1],
|
89 |
+
["Die König-Ludwig-Eiche ist ein Naturdenkmal im Staatsbad Brückenau.", "de", 2,],
|
90 |
+
["Rome is home to some of the most beautiful monuments in the world.", "en", 2],
|
91 |
+
["Some machine learning models are designed to understand and generate human-like text based on the input they receive.", "en", 3],
|
92 |
+
["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],
|
93 |
],
|
94 |
+
inputs=[learner_transcription, language, difficulty],
|
95 |
)
|
96 |
+
|
97 |
transcripted_text = gr.Textbox(
|
98 |
lines=2, placeholder=None, label="Transcripted text", visible=False
|
99 |
)
|
|
|
122 |
value=" - ",
|
123 |
elem_classes="speech-output",
|
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],
|
|
|
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,
|
151 |
inputs=[transcripted_text, letter_correctness],
|