Irpan
commited on
Commit
•
5a4ac64
1
Parent(s):
af51f67
app
Browse files
app.py
CHANGED
@@ -1,7 +1,79 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
def generate_example_pronunciation(input_text, script):
|
4 |
+
# Placeholder for generating example pronunciation
|
5 |
+
example_audio = None # Replace with actual example audio generation logic
|
6 |
+
return example_audio
|
7 |
|
8 |
+
def check_pronunciation(input_text, script, user_audio):
|
9 |
+
# Placeholder logic for pronunciation checking
|
10 |
+
transcript = "Transcribed text here" # Replace with actual ASR result
|
11 |
+
correct_pronunciation = "Correct pronunciation in IPA"
|
12 |
+
user_pronunciation = "User pronunciation in IPA"
|
13 |
+
pronunciation_match = "Matching segments in green, mismatched in red"
|
14 |
+
pronunciation_score = 85.7 # Replace with actual score calculation
|
15 |
+
return transcript, correct_pronunciation, user_pronunciation, pronunciation_match, pronunciation_score
|
16 |
+
|
17 |
+
with gr.Blocks() as app:
|
18 |
+
with gr.Row():
|
19 |
+
# Input Column
|
20 |
+
with gr.Column(scale=1):
|
21 |
+
with gr.Row():
|
22 |
+
input_text = gr.Textbox(
|
23 |
+
label="Input Uyghur Text to Pronounce",
|
24 |
+
placeholder="Enter Uyghur text here...",
|
25 |
+
)
|
26 |
+
script_choice = gr.Radio(
|
27 |
+
choices=["Arabic Script", "Latin Script"],
|
28 |
+
label="Input Text Script",
|
29 |
+
value="Arabic Script"
|
30 |
+
)
|
31 |
+
with gr.Row():
|
32 |
+
example_audio = gr.Audio(label="Example Pronunciation", interactive=False)
|
33 |
+
generate_btn = gr.Button("Generate Example Pronunciation")
|
34 |
+
with gr.Row():
|
35 |
+
user_audio = gr.Audio(
|
36 |
+
label="Your Pronunciation",
|
37 |
+
sources=["microphone", "upload"],
|
38 |
+
type="filepath",
|
39 |
+
)
|
40 |
+
check_btn = gr.Button("Check My Pronunciation")
|
41 |
+
|
42 |
+
# Output Column
|
43 |
+
with gr.Column(scale=1):
|
44 |
+
transcript_box = gr.Textbox(
|
45 |
+
label="Transcript",
|
46 |
+
placeholder="Automatic transcription of your audio..."
|
47 |
+
)
|
48 |
+
correct_pronunciation_box = gr.Textbox(
|
49 |
+
label="Correct Pronunciation",
|
50 |
+
placeholder="IPA representation of the correct pronunciation..."
|
51 |
+
)
|
52 |
+
user_pronunciation_box = gr.Textbox(
|
53 |
+
label="User Pronunciation",
|
54 |
+
placeholder="IPA representation of your pronunciation..."
|
55 |
+
)
|
56 |
+
match_box = gr.Textbox(
|
57 |
+
label="Pronunciation Match",
|
58 |
+
placeholder="Matching and mismatched characters visualized here..."
|
59 |
+
)
|
60 |
+
score_box = gr.Textbox(
|
61 |
+
label="Pronunciation Score",
|
62 |
+
placeholder="Your pronunciation score as a percentage..."
|
63 |
+
)
|
64 |
+
|
65 |
+
# Bind functions to buttons
|
66 |
+
generate_btn.click(
|
67 |
+
generate_example_pronunciation,
|
68 |
+
inputs=[input_text, script_choice],
|
69 |
+
outputs=[example_audio]
|
70 |
+
)
|
71 |
+
|
72 |
+
check_btn.click(
|
73 |
+
check_pronunciation,
|
74 |
+
inputs=[input_text, script_choice, user_audio],
|
75 |
+
outputs=[transcript_box, correct_pronunciation_box, user_pronunciation_box, match_box, score_box]
|
76 |
+
)
|
77 |
+
|
78 |
+
if __name__ == "__main__":
|
79 |
+
app.launch()
|
asr.py
ADDED
File without changes
|
tts.py
ADDED
File without changes
|
util.py
ADDED
File without changes
|