DurreSudoku commited on
Commit
a5ceb81
·
1 Parent(s): c58f484

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -41,6 +41,7 @@ def transcribe(audio):
41
  transcribed_audio = transcribed_audio.replace(".", "")
42
  transcribed_audio = transcribed_audio.replace("!", "")
43
  transcribed_audio = transcribed_audio.replace("?", "")
 
44
 
45
  text_list = transcribed_audio.split(" ")
46
 
@@ -55,7 +56,7 @@ def transcribe(audio):
55
  match_ratio = SequenceMatcher(None, text, correct_answer).ratio()
56
 
57
  if match_ratio > 0.8:
58
- return f"Partially correct. The answer is {correct_answer}, I heard {text}."
59
  # If no match is found.
60
  return f"Incorrect. The correct answer is {correct_answer}. I heard {transcribed_audio}."
61
 
@@ -78,7 +79,7 @@ with gr.Blocks(title="Interactive Language Learning") as demo:
78
  with gr.Column():
79
  image = gr.Image(value=open_image(),type="pil", interactive=False)
80
  with gr.Row():
81
- answer_box = gr.Text(placeholder="Answer appears here", interactive=False)
82
  with gr.Row():
83
  with gr.Column():
84
  process_input = gr.Button("Submit Answer")
 
41
  transcribed_audio = transcribed_audio.replace(".", "")
42
  transcribed_audio = transcribed_audio.replace("!", "")
43
  transcribed_audio = transcribed_audio.replace("?", "")
44
+ transcribed_audio = transcribed_audio.lower()
45
 
46
  text_list = transcribed_audio.split(" ")
47
 
 
56
  match_ratio = SequenceMatcher(None, text, correct_answer).ratio()
57
 
58
  if match_ratio > 0.8:
59
+ return f"Partially correct. The answer is {correct_answer}. I heard {text}."
60
  # If no match is found.
61
  return f"Incorrect. The correct answer is {correct_answer}. I heard {transcribed_audio}."
62
 
 
79
  with gr.Column():
80
  image = gr.Image(value=open_image(),type="pil", interactive=False)
81
  with gr.Row():
82
+ answer_box = gr.Text(label="Answer appears here", interactive=False)
83
  with gr.Row():
84
  with gr.Column():
85
  process_input = gr.Button("Submit Answer")