Irpan commited on
Commit
ff91a06
1 Parent(s): c510f60
Files changed (2) hide show
  1. app.py +1 -2
  2. util.py +4 -6
app.py CHANGED
@@ -76,8 +76,7 @@ with gr.Blocks() as app:
76
  )
77
  with gr.Row():
78
  match_box = gr.Markdown(
79
- """### Pronunciation Feedback
80
-
81
  Matching and mismatched characters will be visualized here...
82
  """
83
  )
 
76
  )
77
  with gr.Row():
78
  match_box = gr.Markdown(
79
+ """<h4>Pronunciation Feedback</h4>\n
 
80
  Matching and mismatched characters will be visualized here...
81
  """
82
  )
util.py CHANGED
@@ -102,10 +102,9 @@ def calculate_pronunciation_accuracy(reference_text, output_text, script):
102
  # Convert reference back to original script for feedback output
103
  if script == 'Uyghur Latin':
104
  reference_text_clean = ug_arab_to_latn(reference_text_clean)
105
- # Generate Markdown-compatible styled text
106
- comparison_md = """### Pronunciation Feedback
107
-
108
- """
109
  for opcode, i1, i2, j1, j2 in matcher.get_opcodes():
110
  ref_segment = reference_text_clean[i1:i2]
111
  out_segment = output_text_clean[j1:j2]
@@ -114,8 +113,7 @@ def calculate_pronunciation_accuracy(reference_text, output_text, script):
114
  comparison_md += f'<span style="color: blue; font-size: 20px;">{ref_segment}</span>'
115
  elif opcode in ['replace', 'delete', 'insert']: # Mismatched or missing
116
  comparison_md += f'<span style="color: red; font-size: 20px;">{ref_segment}</span>'
117
-
118
- comparison_md = f"<div>{comparison_md}</div>"
119
 
120
  return reference_ipa, output_ipa, comparison_md, pronunciation_accuracy
121
 
 
102
  # Convert reference back to original script for feedback output
103
  if script == 'Uyghur Latin':
104
  reference_text_clean = ug_arab_to_latn(reference_text_clean)
105
+ # Generate Markdown-compatible styled text
106
+ comparison_md = "<h4>Pronunciation Feedback</h4>\n" # Small header
107
+ comparison_md += "<div style='margin-top: 10px;'>\n" # Add some spacing
 
108
  for opcode, i1, i2, j1, j2 in matcher.get_opcodes():
109
  ref_segment = reference_text_clean[i1:i2]
110
  out_segment = output_text_clean[j1:j2]
 
113
  comparison_md += f'<span style="color: blue; font-size: 20px;">{ref_segment}</span>'
114
  elif opcode in ['replace', 'delete', 'insert']: # Mismatched or missing
115
  comparison_md += f'<span style="color: red; font-size: 20px;">{ref_segment}</span>'
116
+ comparison_md += "</div>"
 
117
 
118
  return reference_ipa, output_ipa, comparison_md, pronunciation_accuracy
119