Irpan
commited on
Commit
•
6eb8cb9
1
Parent(s):
8da022a
util.py
CHANGED
@@ -99,7 +99,7 @@ def calculate_pronunciation_accuracy(reference_text, output_text, script_choice)
|
|
99 |
"""
|
100 |
Calculate pronunciation accuracy between reference and ASR output text using Epitran.
|
101 |
"""
|
102 |
-
|
103 |
# make sure input text is arabic script for IPA conversion
|
104 |
if script_choice == 'Uyghur Latin':
|
105 |
reference_text = ug_latn_to_arab(reference_text)
|
@@ -119,15 +119,12 @@ def calculate_pronunciation_accuracy(reference_text, output_text, script_choice)
|
|
119 |
# Convert to percentage
|
120 |
pronunciation_accuracy = match_ratio * 100
|
121 |
|
122 |
-
# Convert reference back to original script for feedback output
|
123 |
-
if script_choice == 'Uyghur Latin':
|
124 |
-
reference_text_clean = ug_arab_to_latn(reference_text_clean)
|
125 |
# Generate Markdown-compatible styled text
|
126 |
comparison_md = "<h4>Pronunciation Feedback</h4>\n" # Small header
|
127 |
comparison_md += "<div style='margin-top: 10px;'>\n" # Add some spacing
|
128 |
for opcode, i1, i2, j1, j2 in matcher.get_opcodes():
|
129 |
-
ref_segment =
|
130 |
-
out_segment =
|
131 |
|
132 |
if opcode == 'equal': # Matching characters
|
133 |
comparison_md += f'<span style="color: green; font-size: 20px;">{ref_segment}</span>'
|
|
|
99 |
"""
|
100 |
Calculate pronunciation accuracy between reference and ASR output text using Epitran.
|
101 |
"""
|
102 |
+
|
103 |
# make sure input text is arabic script for IPA conversion
|
104 |
if script_choice == 'Uyghur Latin':
|
105 |
reference_text = ug_latn_to_arab(reference_text)
|
|
|
119 |
# Convert to percentage
|
120 |
pronunciation_accuracy = match_ratio * 100
|
121 |
|
|
|
|
|
|
|
122 |
# Generate Markdown-compatible styled text
|
123 |
comparison_md = "<h4>Pronunciation Feedback</h4>\n" # Small header
|
124 |
comparison_md += "<div style='margin-top: 10px;'>\n" # Add some spacing
|
125 |
for opcode, i1, i2, j1, j2 in matcher.get_opcodes():
|
126 |
+
ref_segment = reference_ipa[i1:i2]
|
127 |
+
out_segment = output_ipa[j1:j2]
|
128 |
|
129 |
if opcode == 'equal': # Matching characters
|
130 |
comparison_md += f'<span style="color: green; font-size: 20px;">{ref_segment}</span>'
|