Oranblock commited on
Commit
bc935e3
·
verified ·
1 Parent(s): 9add1ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -4,7 +4,7 @@ import json
4
  from difflib import SequenceMatcher
5
 
6
  # Load pre-trained speech-to-text model
7
- recognizer = pipeline("automatic-speech-recognition")
8
 
9
  # Load Qur'an verses from JSON file
10
  with open('quran_verses.json', 'r', encoding='utf-8') as f:
@@ -69,19 +69,19 @@ def process_audio(audio):
69
  f"Similarity: {highest_similarity * 100:.2f}%\n"
70
  f"Feedback: {feedback}\n"
71
  f"Progress: {progress:.2f}%"
72
- ), progress / 100 # Return progress as a decimal for the progress bar
73
  else:
74
  return (
75
  f"Transcription: {transcription}\n"
76
  f"No matching verse found or similarity too low.\n"
77
  f"Progress: {calculate_progress():.2f}%"
78
- ), calculate_progress() / 100 # Return progress as a decimal for the progress bar
79
 
80
  # Interface
81
  iface = gr.Interface(
82
  fn=process_audio,
83
  inputs=gr.Audio(type="filepath"), # No 'source' argument
84
- outputs=[gr.Textbox(), gr.Progress()], # Removed 'label' argument
85
  title="Qur'an Memorization Helper",
86
  description="Speak a verse, and we'll transcribe it, check your accuracy, and track your progress."
87
  )
 
4
  from difflib import SequenceMatcher
5
 
6
  # Load pre-trained speech-to-text model
7
+ recognizer = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-base-960h")
8
 
9
  # Load Qur'an verses from JSON file
10
  with open('quran_verses.json', 'r', encoding='utf-8') as f:
 
69
  f"Similarity: {highest_similarity * 100:.2f}%\n"
70
  f"Feedback: {feedback}\n"
71
  f"Progress: {progress:.2f}%"
72
+ )
73
  else:
74
  return (
75
  f"Transcription: {transcription}\n"
76
  f"No matching verse found or similarity too low.\n"
77
  f"Progress: {calculate_progress():.2f}%"
78
+ )
79
 
80
  # Interface
81
  iface = gr.Interface(
82
  fn=process_audio,
83
  inputs=gr.Audio(type="filepath"), # No 'source' argument
84
+ outputs=gr.Textbox(), # Only use a Textbox to display progress and feedback
85
  title="Qur'an Memorization Helper",
86
  description="Speak a verse, and we'll transcribe it, check your accuracy, and track your progress."
87
  )