sudhanm commited on
Commit
02b32bc
Β·
verified Β·
1 Parent(s): 25dc731

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -15
app.py CHANGED
@@ -334,11 +334,11 @@ def compare_pronunciation(audio, language_choice, intended_sentence):
334
 
335
  if audio is None:
336
  print("❌ No audio provided")
337
- return ("❌ Please record audio first.", "", "", "", "", "", "", "", "", "", "", "", "")
338
 
339
  if not intended_sentence.strip():
340
  print("❌ No intended sentence")
341
- return ("❌ Please generate a practice sentence first.", "", "", "", "", "", "", "", "", "", "", "", "")
342
 
343
  try:
344
  print(f"πŸ” Analyzing pronunciation for {language_choice}...")
@@ -359,7 +359,7 @@ def compare_pronunciation(audio, language_choice, intended_sentence):
359
  # Handle transcription errors
360
  if actual_text.startswith("Error:"):
361
  print(f"❌ Transcription error: {actual_text}")
362
- return (f"❌ {actual_text}", "", "", "", "", "", "", "", "", "", "", "", "")
363
 
364
  # Calculate error metrics
365
  try:
@@ -399,14 +399,8 @@ def compare_pronunciation(audio, language_choice, intended_sentence):
399
  corrected_text or "(No corrected transcription)",
400
  f"{wer_val:.3f} ({(1-wer_val)*100:.1f}% word accuracy)",
401
  f"{cer_val:.3f} ({(1-cer_val)*100:.1f}% character accuracy)",
402
- # New visual feedback outputs
403
- actual_text or "(No transcription)", # actual_text_display
404
- actual_hk, # actual_transliteration
405
- intended_sentence, # target_text_display
406
- target_hk, # target_transliteration
407
  diff_html, # diff_html_box
408
  char_html, # char_html_box
409
- intended_sentence, # intended_display (unchanged)
410
  f"🎯 Target: {intended_sentence}" # target_display
411
  )
412
 
@@ -415,7 +409,7 @@ def compare_pronunciation(audio, language_choice, intended_sentence):
415
  print(f"❌ FATAL ERROR: {e}")
416
  import traceback
417
  traceback.print_exc()
418
- return (error_msg, str(e), "", "", "", "", "", "", "", "", "", "", "")
419
 
420
  # ---------------- UI ---------------- #
421
  def create_interface():
@@ -532,13 +526,8 @@ def create_interface():
532
  pass2_out, # corrected_text
533
  wer_out, # wer formatted
534
  cer_out, # cer formatted
535
- gr.skip(), # actual_text (duplicate)
536
- gr.skip(), # actual_hk (not displayed)
537
- gr.skip(), # intended_sentence (duplicate)
538
- gr.skip(), # target_hk (not displayed)
539
  diff_html_box, # diff_html
540
  char_html_box, # char_html
541
- gr.skip(), # intended_sentence (duplicate)
542
  target_display # target_display
543
  ]
544
  )
 
334
 
335
  if audio is None:
336
  print("❌ No audio provided")
337
+ return ("❌ Please record audio first.", "", "", "", "", "", "", "")
338
 
339
  if not intended_sentence.strip():
340
  print("❌ No intended sentence")
341
+ return ("❌ Please generate a practice sentence first.", "", "", "", "", "", "", "")
342
 
343
  try:
344
  print(f"πŸ” Analyzing pronunciation for {language_choice}...")
 
359
  # Handle transcription errors
360
  if actual_text.startswith("Error:"):
361
  print(f"❌ Transcription error: {actual_text}")
362
+ return (f"❌ {actual_text}", "", "", "", "", "", "", "")
363
 
364
  # Calculate error metrics
365
  try:
 
399
  corrected_text or "(No corrected transcription)",
400
  f"{wer_val:.3f} ({(1-wer_val)*100:.1f}% word accuracy)",
401
  f"{cer_val:.3f} ({(1-cer_val)*100:.1f}% character accuracy)",
 
 
 
 
 
402
  diff_html, # diff_html_box
403
  char_html, # char_html_box
 
404
  f"🎯 Target: {intended_sentence}" # target_display
405
  )
406
 
 
409
  print(f"❌ FATAL ERROR: {e}")
410
  import traceback
411
  traceback.print_exc()
412
+ return (error_msg, str(e), "", "", "", "", "", "")
413
 
414
  # ---------------- UI ---------------- #
415
  def create_interface():
 
526
  pass2_out, # corrected_text
527
  wer_out, # wer formatted
528
  cer_out, # cer formatted
 
 
 
 
529
  diff_html_box, # diff_html
530
  char_html_box, # char_html
 
531
  target_display # target_display
532
  ]
533
  )