Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -48,12 +48,11 @@ def transcribe_audio(audio):
|
|
48 |
def create_pronunciation_audio(word):
|
49 |
tts = gTTS(word)
|
50 |
audio_file_path = f"audio/{word}.mp3" # Save the audio to a file
|
51 |
-
|
52 |
-
return audio
|
53 |
|
54 |
# Step 3: Compare the transcribed text with the input paragraph
|
55 |
def compare_texts(reference_text, transcribed_text):
|
56 |
-
word_scores = []
|
57 |
reference_words = reference_text.split()
|
58 |
transcribed_words = transcribed_text.split()
|
59 |
incorrect_words_audios = [] # Store audio paths for incorrect words
|
@@ -94,9 +93,13 @@ def compare_texts(reference_text, transcribed_text):
|
|
94 |
|
95 |
# Step 4: Text-to-Speech Function
|
96 |
def text_to_speech(paragraph):
|
|
|
|
|
|
|
97 |
tts = gTTS(paragraph)
|
98 |
-
|
99 |
-
|
|
|
100 |
|
101 |
# Gradio Interface Function
|
102 |
def gradio_function(paragraph, audio):
|
|
|
48 |
def create_pronunciation_audio(word):
|
49 |
tts = gTTS(word)
|
50 |
audio_file_path = f"audio/{word}.mp3" # Save the audio to a file
|
51 |
+
tts.save(audio_file_path)
|
52 |
+
return audio_file_path # Return the file path of the saved audio
|
53 |
|
54 |
# Step 3: Compare the transcribed text with the input paragraph
|
55 |
def compare_texts(reference_text, transcribed_text):
|
|
|
56 |
reference_words = reference_text.split()
|
57 |
transcribed_words = transcribed_text.split()
|
58 |
incorrect_words_audios = [] # Store audio paths for incorrect words
|
|
|
93 |
|
94 |
# Step 4: Text-to-Speech Function
|
95 |
def text_to_speech(paragraph):
|
96 |
+
if not paragraph:
|
97 |
+
return None # Handle the case when no text is provided
|
98 |
+
|
99 |
tts = gTTS(paragraph)
|
100 |
+
audio_file_path = "audio/paragraph.mp3" # Save the audio to a file
|
101 |
+
tts.save(audio_file_path)
|
102 |
+
return audio_file_path # Return the file path instead of None
|
103 |
|
104 |
# Gradio Interface Function
|
105 |
def gradio_function(paragraph, audio):
|