Abdurahman
commited on
Commit
•
43ce49e
1
Parent(s):
aab3ee4
app
Browse files
app.py
CHANGED
@@ -15,27 +15,30 @@ with gr.Blocks() as app:
|
|
15 |
value="Uyghur Arabic",
|
16 |
interactive=True
|
17 |
)
|
18 |
-
with gr.
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
39 |
|
40 |
# Output Column
|
41 |
with gr.Column(scale=1):
|
|
|
15 |
value="Uyghur Arabic",
|
16 |
interactive=True
|
17 |
)
|
18 |
+
with gr.Group():
|
19 |
+
with gr.Row():
|
20 |
+
input_text = gr.Textbox(
|
21 |
+
label="2. Input Uyghur Text in Selected Script or Generate Text with Buttons below",
|
22 |
+
placeholder="Enter Uyghur text here...",
|
23 |
+
)
|
24 |
+
# Add buttons for generating short and long texts
|
25 |
+
with gr.Row():
|
26 |
+
generate_short_btn = gr.Button("Generate Short Text")
|
27 |
+
generate_long_btn = gr.Button("Generate Long Text")
|
28 |
+
with gr.Group():
|
29 |
+
with gr.Row():
|
30 |
+
example_audio = gr.Audio(label="3. Click \"Generate Machine Pronunciation\"")
|
31 |
+
with gr.Row():
|
32 |
+
tts_btn = gr.Button("Generate Machine Pronunciation")
|
33 |
+
with gr.Group():
|
34 |
+
with gr.Row():
|
35 |
+
user_audio = gr.Audio(
|
36 |
+
label="4. Record or Upload Your Pronunciation",
|
37 |
+
sources=["microphone", "upload"],
|
38 |
+
type="filepath",
|
39 |
+
)
|
40 |
+
with gr.Row():
|
41 |
+
check_btn = gr.Button("Check My Pronunciation")
|
42 |
|
43 |
# Output Column
|
44 |
with gr.Column(scale=1):
|
util.py
CHANGED
@@ -80,7 +80,7 @@ def calculate_pronunciation_accuracy(reference_text, output_text, language_code=
|
|
80 |
output_ipa = ipa_converter.transliterate(output_text_clean)
|
81 |
|
82 |
# Calculate pronunciation accuracy using SequenceMatcher
|
83 |
-
matcher = SequenceMatcher(None,
|
84 |
match_ratio = matcher.ratio() # This is the fraction of matching characters
|
85 |
|
86 |
# Convert to percentage
|
@@ -89,8 +89,8 @@ def calculate_pronunciation_accuracy(reference_text, output_text, language_code=
|
|
89 |
# Generate Markdown-compatible styled text
|
90 |
comparison_md = ""
|
91 |
for opcode, i1, i2, j1, j2 in matcher.get_opcodes():
|
92 |
-
ref_segment =
|
93 |
-
out_segment =
|
94 |
|
95 |
if opcode == 'equal': # Matching characters
|
96 |
comparison_md += f'<span style="color: blue;">{ref_segment}</span>'
|
|
|
80 |
output_ipa = ipa_converter.transliterate(output_text_clean)
|
81 |
|
82 |
# Calculate pronunciation accuracy using SequenceMatcher
|
83 |
+
matcher = SequenceMatcher(None, reference_text_clean, output_text_clean)
|
84 |
match_ratio = matcher.ratio() # This is the fraction of matching characters
|
85 |
|
86 |
# Convert to percentage
|
|
|
89 |
# Generate Markdown-compatible styled text
|
90 |
comparison_md = ""
|
91 |
for opcode, i1, i2, j1, j2 in matcher.get_opcodes():
|
92 |
+
ref_segment = reference_text_clean[i1:i2]
|
93 |
+
out_segment = output_text_clean[j1:j2]
|
94 |
|
95 |
if opcode == 'equal': # Matching characters
|
96 |
comparison_md += f'<span style="color: blue;">{ref_segment}</span>'
|