Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -247,6 +247,12 @@ def transcribe_once(audio_path, language_choice, beam_size, temperature):
|
|
247 |
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
|
248 |
return transcription.strip()
|
249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
def create_tabular_feedback(intended, actual, lang_choice):
|
251 |
"""Create clean, readable tabular feedback without background colors"""
|
252 |
|
@@ -272,6 +278,18 @@ def create_tabular_feedback(intended, actual, lang_choice):
|
|
272 |
<h3 style='color: #2c3e50; margin-bottom: 20px; text-align: center;'>π Pronunciation Analysis</h3>
|
273 |
"""
|
274 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
# Overview table - completely clean
|
276 |
feedback_html += """
|
277 |
<div style='margin-bottom: 25px;'>
|
@@ -316,8 +334,10 @@ def create_tabular_feedback(intended, actual, lang_choice):
|
|
316 |
<tbody>
|
317 |
"""
|
318 |
|
319 |
-
# Compare words using difflib
|
320 |
-
|
|
|
|
|
321 |
word_index = 0
|
322 |
|
323 |
for tag, i1, i2, j1, j2 in sm.get_opcodes():
|
|
|
247 |
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
|
248 |
return transcription.strip()
|
249 |
|
250 |
+
def normalize_word(word):
|
251 |
+
"""Remove punctuation and normalize word for comparison"""
|
252 |
+
import string
|
253 |
+
# Remove punctuation and whitespace
|
254 |
+
return word.strip().translate(str.maketrans('', '', string.punctuation)).lower()
|
255 |
+
|
256 |
def create_tabular_feedback(intended, actual, lang_choice):
|
257 |
"""Create clean, readable tabular feedback without background colors"""
|
258 |
|
|
|
278 |
<h3 style='color: #2c3e50; margin-bottom: 20px; text-align: center;'>π Pronunciation Analysis</h3>
|
279 |
"""
|
280 |
|
281 |
+
# Show simple transliteration of target sentence for easier reading
|
282 |
+
if lang_choice in ["Tamil", "Malayalam"]:
|
283 |
+
feedback_html += f"""
|
284 |
+
<div style='margin-bottom: 25px; padding: 15px; border: 2px solid #3498db; border-radius: 8px; background: #f8f9fa;'>
|
285 |
+
<h4 style='color: #3498db; margin-bottom: 10px;'>π― Target Sentence (How to Read)</h4>
|
286 |
+
<div style='font-size: 20px; font-family: monospace; color: #2c3e50; line-height: 1.4;'>
|
287 |
+
<strong>Original:</strong> {intended}<br>
|
288 |
+
<strong>Read as:</strong> <span style='color: #e67e22; font-weight: bold;'>{intended_roman}</span>
|
289 |
+
</div>
|
290 |
+
</div>
|
291 |
+
"""
|
292 |
+
|
293 |
# Overview table - completely clean
|
294 |
feedback_html += """
|
295 |
<div style='margin-bottom: 25px;'>
|
|
|
334 |
<tbody>
|
335 |
"""
|
336 |
|
337 |
+
# Compare words using difflib with normalized comparison
|
338 |
+
normalized_intended = [normalize_word(w) for w in intended_words]
|
339 |
+
normalized_actual = [normalize_word(w) for w in actual_words]
|
340 |
+
sm = difflib.SequenceMatcher(None, normalized_intended, normalized_actual)
|
341 |
word_index = 0
|
342 |
|
343 |
for tag, i1, i2, j1, j2 in sm.get_opcodes():
|