Update app.py
Browse files
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 |
-
)
|
| 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=
|
| 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 |
)
|