Irpan commited on
Commit
716237b
1 Parent(s): deab4af
Files changed (2) hide show
  1. app.py +47 -15
  2. requirements.txt +1 -0
app.py CHANGED
@@ -1,4 +1,32 @@
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  def generate_example_pronunciation(input_text, script):
4
  # Placeholder for generating example pronunciation
@@ -28,13 +56,17 @@ with gr.Blocks() as app:
28
  )
29
  with gr.Row():
30
  input_text = gr.Textbox(
31
- label="2. Input Uyghur Text to Pronounce",
32
  placeholder="Enter Uyghur text here...",
33
  )
 
 
 
 
34
  with gr.Row():
35
  example_audio = gr.Audio(label="3. Click \"Generate Example Pronunciation\"")
36
  with gr.Row():
37
- generate_btn = gr.Button("Generate Example Pronunciation")
38
  with gr.Row():
39
  user_audio = gr.Audio(
40
  label="4. Record/Upload Your Pronunciation",
@@ -83,21 +115,21 @@ with gr.Blocks() as app:
83
  label="Phonetic Score",
84
  placeholder="Your pronunciation score as a percentage..."
85
  )
86
-
87
- # with gr.Group():
88
- # with gr.Row():
89
- # match_box = gr.Textbox(
90
- # label="Phonetic Match",
91
- # placeholder="Matching and mismatched characters visualized here..."
92
- # )
93
- # with gr.Row():
94
- # score_box = gr.Textbox(
95
- # label="Phonetic Score",
96
- # placeholder="Your pronunciation score as a percentage..."
97
- # )
98
 
99
  # Bind functions to buttons
100
- generate_btn.click(
 
 
 
 
 
 
 
 
 
 
 
 
101
  generate_example_pronunciation,
102
  inputs=[input_text, script_choice],
103
  outputs=[example_audio]
 
1
  import gradio as gr
2
+ import random
3
+
4
+
5
+ # Lists of Uyghur short and long texts
6
+ short_texts = [
7
+ "سالام", "رەھمەت", "ياخشىمۇسىز"
8
+ ]
9
+ long_texts = [
10
+ "مەكتەپكە بارغاندا تېخىمۇ بىلىملىك بولۇپ قېلىمەن.",
11
+ "يېزا مەنزىرىسى ھەقىقەتەن گۈزەل.",
12
+ "پېقىرلارغا ياردەم قىلىش مەنەم پەرزەندە."
13
+ ]
14
+
15
+ # Functions
16
+ def generate_text(type, script_choice):
17
+ """Generate a random Uyghur short or long text based on type."""
18
+ from umsc import UgMultiScriptConverter
19
+ ug_arab_to_latn = UgMultiScriptConverter('UAS', 'ULS')
20
+ if type == "short":
21
+ if script_choice == "Uyghur Arabic":
22
+ return random.choice(short_texts)
23
+ else:
24
+ return ug_arab_to_latn(random.choice(short_texts))
25
+ elif type == "long":
26
+ if script_choice == "Uyghur Arabic":
27
+ return random.choice(long_texts)
28
+ else:
29
+ return ug_arab_to_latn(random.choice(long_texts))
30
 
31
  def generate_example_pronunciation(input_text, script):
32
  # Placeholder for generating example pronunciation
 
56
  )
57
  with gr.Row():
58
  input_text = gr.Textbox(
59
+ label="2. Input Uyghur Text to Pronounce or Generate Text with Buttons below",
60
  placeholder="Enter Uyghur text here...",
61
  )
62
+ # Add buttons for generating short and long texts
63
+ with gr.Row():
64
+ generate_short_btn = gr.Button("Generate Short Text")
65
+ generate_long_btn = gr.Button("Generate Long Text")
66
  with gr.Row():
67
  example_audio = gr.Audio(label="3. Click \"Generate Example Pronunciation\"")
68
  with gr.Row():
69
+ tts_btn = gr.Button("Generate Example Pronunciation")
70
  with gr.Row():
71
  user_audio = gr.Audio(
72
  label="4. Record/Upload Your Pronunciation",
 
115
  label="Phonetic Score",
116
  placeholder="Your pronunciation score as a percentage..."
117
  )
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
  # Bind functions to buttons
120
+ generate_short_btn.click(
121
+ generate_text,
122
+ inputs=["short", script_choice],
123
+ outputs=input_text
124
+ )
125
+
126
+ generate_long_btn.click(
127
+ generate_text,
128
+ inputs=["long", script_choice],
129
+ outputs=input_text
130
+ )
131
+
132
+ tts_btn.click(
133
  generate_example_pronunciation,
134
  inputs=[input_text, script_choice],
135
  outputs=[example_audio]
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
  gradio==2.9.1
2
  torch
3
  transformers
 
 
1
  gradio==2.9.1
2
  torch
3
  transformers
4
+ umsc