Irpan
commited on
Commit
•
734a7ea
1
Parent(s):
deb8ef3
app
Browse files
app.py
CHANGED
@@ -1,37 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
-
from umsc import UgMultiScriptConverter
|
4 |
-
|
5 |
-
|
6 |
-
# Lists of Uyghur short and long texts
|
7 |
-
short_texts = [
|
8 |
-
"سالام", "رەھمەت", "ياخشىمۇسىز"
|
9 |
-
]
|
10 |
-
long_texts = [
|
11 |
-
"مەكتەپكە بارغاندا تېخىمۇ بىلىملىك بولۇپ قېلىمەن.",
|
12 |
-
"يېزا مەنزىرىسى ھەقىقەتەن گۈزەل.",
|
13 |
-
"پېقىرلارغا ياردەم قىلىش مەنەم پەرزەندە."
|
14 |
-
]
|
15 |
|
16 |
# Functions
|
17 |
-
def generate_short_text(script_choice):
|
18 |
-
"""Generate a random Uyghur short text based on the type."""
|
19 |
-
ug_arab_to_latn = UgMultiScriptConverter('UAS', 'ULS')
|
20 |
-
|
21 |
-
text = random.choice(short_texts)
|
22 |
-
if script_choice == "Uyghur Latin":
|
23 |
-
return ug_arab_to_latn(text)
|
24 |
-
return text
|
25 |
-
|
26 |
-
def generate_long_text(script_choice):
|
27 |
-
"""Generate a random Uyghur long text based on the type."""
|
28 |
-
ug_arab_to_latn = UgMultiScriptConverter('UAS', 'ULS')
|
29 |
-
|
30 |
-
text = random.choice(long_texts)
|
31 |
-
if script_choice == "Uyghur Latin":
|
32 |
-
return ug_arab_to_latn(text)
|
33 |
-
return text
|
34 |
-
|
35 |
def generate_example_pronunciation(input_text, script):
|
36 |
# Placeholder for generating example pronunciation
|
37 |
example_audio = None # Replace with actual example audio generation logic
|
@@ -47,6 +17,7 @@ def check_pronunciation(input_text, script, user_audio):
|
|
47 |
pronunciation_score = 85.7 # Replace with actual score calculation
|
48 |
return transcript_ugArab_box, transcript_ugLatn_box, correct_pronunciation, user_pronunciation, pronunciation_match, pronunciation_score
|
49 |
|
|
|
50 |
with gr.Blocks() as app:
|
51 |
with gr.Row():
|
52 |
# Input Column
|
@@ -122,13 +93,13 @@ with gr.Blocks() as app:
|
|
122 |
|
123 |
# Bind functions to buttons
|
124 |
generate_short_btn.click(
|
125 |
-
generate_short_text,
|
126 |
inputs=[script_choice],
|
127 |
outputs=[input_text]
|
128 |
)
|
129 |
|
130 |
generate_long_btn.click(
|
131 |
-
generate_long_text,
|
132 |
inputs=[script_choice],
|
133 |
outputs=[input_text]
|
134 |
)
|
@@ -145,5 +116,6 @@ with gr.Blocks() as app:
|
|
145 |
outputs=[transcript_ugArab_box, transcript_ugLatn_box, correct_pronunciation_box, user_pronunciation_box, match_box, score_box]
|
146 |
)
|
147 |
|
|
|
148 |
if __name__ == "__main__":
|
149 |
app.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import util
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
# Functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
def generate_example_pronunciation(input_text, script):
|
6 |
# Placeholder for generating example pronunciation
|
7 |
example_audio = None # Replace with actual example audio generation logic
|
|
|
17 |
pronunciation_score = 85.7 # Replace with actual score calculation
|
18 |
return transcript_ugArab_box, transcript_ugLatn_box, correct_pronunciation, user_pronunciation, pronunciation_match, pronunciation_score
|
19 |
|
20 |
+
# Front-End
|
21 |
with gr.Blocks() as app:
|
22 |
with gr.Row():
|
23 |
# Input Column
|
|
|
93 |
|
94 |
# Bind functions to buttons
|
95 |
generate_short_btn.click(
|
96 |
+
util.generate_short_text,
|
97 |
inputs=[script_choice],
|
98 |
outputs=[input_text]
|
99 |
)
|
100 |
|
101 |
generate_long_btn.click(
|
102 |
+
util.generate_long_text,
|
103 |
inputs=[script_choice],
|
104 |
outputs=[input_text]
|
105 |
)
|
|
|
116 |
outputs=[transcript_ugArab_box, transcript_ugLatn_box, correct_pronunciation_box, user_pronunciation_box, match_box, score_box]
|
117 |
)
|
118 |
|
119 |
+
# Main
|
120 |
if __name__ == "__main__":
|
121 |
app.launch()
|
util.py
CHANGED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import random
|
2 |
+
from umsc import UgMultiScriptConverter
|
3 |
+
|
4 |
+
# Lists of Uyghur short and long texts
|
5 |
+
short_texts = [
|
6 |
+
"سالام", "رەھمەت", "ياخشىمۇسىز"
|
7 |
+
]
|
8 |
+
long_texts = [
|
9 |
+
"مەكتەپكە بارغاندا تېخىمۇ بىلىملىك بولۇپ قېلىمەن.",
|
10 |
+
"يېزا مەنزىرىسى ھەقىقەتەن گۈزەل.",
|
11 |
+
"پېقىرلارغا ياردەم قىلىش مەنەم پەرزەندە."
|
12 |
+
]
|
13 |
+
|
14 |
+
def generate_short_text(script_choice):
|
15 |
+
"""Generate a random Uyghur short text based on the type."""
|
16 |
+
ug_arab_to_latn = UgMultiScriptConverter('UAS', 'ULS')
|
17 |
+
|
18 |
+
text = random.choice(short_texts)
|
19 |
+
if script_choice == "Uyghur Latin":
|
20 |
+
return ug_arab_to_latn(text)
|
21 |
+
return text
|
22 |
+
|
23 |
+
def generate_long_text(script_choice):
|
24 |
+
"""Generate a random Uyghur long text based on the type."""
|
25 |
+
ug_arab_to_latn = UgMultiScriptConverter('UAS', 'ULS')
|
26 |
+
|
27 |
+
text = random.choice(long_texts)
|
28 |
+
if script_choice == "Uyghur Latin":
|
29 |
+
return ug_arab_to_latn(text)
|
30 |
+
return text
|