Abdurahman commited on
Commit
43ce49e
1 Parent(s): aab3ee4
Files changed (2) hide show
  1. app.py +24 -21
  2. util.py +3 -3
app.py CHANGED
@@ -15,27 +15,30 @@ with gr.Blocks() as app:
15
  value="Uyghur Arabic",
16
  interactive=True
17
  )
18
- with gr.Row():
19
- input_text = gr.Textbox(
20
- label="2. Input Uyghur Text to Pronounce or Generate Text with Buttons below",
21
- placeholder="Enter Uyghur text here...",
22
- )
23
- # Add buttons for generating short and long texts
24
- with gr.Row():
25
- generate_short_btn = gr.Button("Generate Short Text")
26
- generate_long_btn = gr.Button("Generate Long Text")
27
- with gr.Row():
28
- example_audio = gr.Audio(label="3. Click \"Generate Example Pronunciation\"")
29
- with gr.Row():
30
- tts_btn = gr.Button("Generate Example Pronunciation")
31
- with gr.Row():
32
- user_audio = gr.Audio(
33
- label="4. Record/Upload Your Pronunciation",
34
- sources=["microphone", "upload"],
35
- type="filepath",
36
- )
37
- with gr.Row():
38
- check_btn = gr.Button("Check My Pronunciation")
 
 
 
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, reference_ipa, output_ipa)
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 = reference_ipa[i1:i2]
93
- out_segment = output_ipa[j1:j2]
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>'