jinggujiwoo7 commited on
Commit
c8b7959
1 Parent(s): 9723fb0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -21,10 +21,13 @@ def transcribe_audio(file_info):
21
  return f"Could not request results; {e}"
22
 
23
  def pronunciation_correction(expected_text, file_info):
 
24
  user_spoken_text = transcribe_audio(file_info)
 
 
25
  similarity = ratio(expected_text.lower(), user_spoken_text.lower())
26
  description = f"{similarity:.2f}"
27
-
28
  if similarity >= 0.9:
29
  feedback = "Excellent pronunciation!"
30
  elif similarity >= 0.7:
@@ -33,7 +36,8 @@ def pronunciation_correction(expected_text, file_info):
33
  feedback = "Needs improvement."
34
  else:
35
  feedback = "Poor pronunciation, try to focus more on clarity."
36
-
 
37
  return feedback, description
38
 
39
  def validate_sentence(sentence):
@@ -45,7 +49,7 @@ with gr.Blocks() as app:
45
  with gr.Row():
46
  sentence_input = gr.Textbox(label="Enter Your Sentence Here")
47
  validated_sentence = gr.Textbox(label="Valid Sentence", interactive=False)
48
- audio_input = gr.Audio(label="Upload Audio File", type="numpy")
49
  check_pronunciation_button = gr.Button("Check Pronunciation")
50
  pronunciation_feedback = gr.Textbox(label="Pronunciation Feedback")
51
  pronunciation_score = gr.Number(label="Pronunciation Accuracy Score: 0 (No Match) ~ 1 (Perfect)")
 
21
  return f"Could not request results; {e}"
22
 
23
  def pronunciation_correction(expected_text, file_info):
24
+ print(f"Expected text: {expected_text}")
25
  user_spoken_text = transcribe_audio(file_info)
26
+ print(f"User spoken text: {user_spoken_text}")
27
+
28
  similarity = ratio(expected_text.lower(), user_spoken_text.lower())
29
  description = f"{similarity:.2f}"
30
+
31
  if similarity >= 0.9:
32
  feedback = "Excellent pronunciation!"
33
  elif similarity >= 0.7:
 
36
  feedback = "Needs improvement."
37
  else:
38
  feedback = "Poor pronunciation, try to focus more on clarity."
39
+
40
+ print(f"Similarity: {similarity}, Feedback: {feedback}")
41
  return feedback, description
42
 
43
  def validate_sentence(sentence):
 
49
  with gr.Row():
50
  sentence_input = gr.Textbox(label="Enter Your Sentence Here")
51
  validated_sentence = gr.Textbox(label="Valid Sentence", interactive=False)
52
+ audio_input = gr.Audio(label="Upload or Record Audio File", type="numpy")
53
  check_pronunciation_button = gr.Button("Check Pronunciation")
54
  pronunciation_feedback = gr.Textbox(label="Pronunciation Feedback")
55
  pronunciation_score = gr.Number(label="Pronunciation Accuracy Score: 0 (No Match) ~ 1 (Perfect)")