Irpan
commited on
Commit
•
deb8ef3
1
Parent(s):
ea0e1cd
app
Browse files
app.py
CHANGED
@@ -14,20 +14,23 @@ long_texts = [
|
|
14 |
]
|
15 |
|
16 |
# Functions
|
17 |
-
def
|
18 |
-
"""Generate a random Uyghur short
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
|
|
|
|
20 |
ug_arab_to_latn = UgMultiScriptConverter('UAS', 'ULS')
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
elif type == "long":
|
27 |
-
if script_choice == "Uyghur Arabic":
|
28 |
-
return random.choice(long_texts)
|
29 |
-
else:
|
30 |
-
return ug_arab_to_latn(random.choice(long_texts))
|
31 |
|
32 |
def generate_example_pronunciation(input_text, script):
|
33 |
# Placeholder for generating example pronunciation
|
@@ -119,14 +122,14 @@ with gr.Blocks() as app:
|
|
119 |
|
120 |
# Bind functions to buttons
|
121 |
generate_short_btn.click(
|
122 |
-
|
123 |
-
inputs=[
|
124 |
outputs=[input_text]
|
125 |
)
|
126 |
-
|
127 |
generate_long_btn.click(
|
128 |
-
|
129 |
-
inputs=[
|
130 |
outputs=[input_text]
|
131 |
)
|
132 |
|
|
|
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
|
|
|
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 |
)
|
135 |
|