Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -47,13 +47,9 @@ def transcribe_audio(audio):
|
|
47 |
# Step 2: Create pronunciation audio for incorrect words
|
48 |
def create_pronunciation_audio(word):
|
49 |
tts = gTTS(word)
|
50 |
-
audio_buffer = io.BytesIO()
|
51 |
-
tts.save(audio_buffer)
|
52 |
-
audio_buffer.seek(0)
|
53 |
audio_file_path = f"audio/{word}.mp3" # Save the audio to a file
|
54 |
-
|
55 |
-
|
56 |
-
return audio_file_path # Return the file path instead of BytesIO
|
57 |
|
58 |
# Step 3: Compare the transcribed text with the input paragraph
|
59 |
def compare_texts(reference_text, transcribed_text):
|
@@ -98,17 +94,9 @@ def compare_texts(reference_text, transcribed_text):
|
|
98 |
|
99 |
# Step 4: Text-to-Speech Function
|
100 |
def text_to_speech(paragraph):
|
101 |
-
if not paragraph:
|
102 |
-
return None # Handle the case when no text is provided
|
103 |
-
|
104 |
tts = gTTS(paragraph)
|
105 |
-
|
106 |
-
|
107 |
-
audio_buffer.seek(0)
|
108 |
-
audio_file_path = "audio/text_to_speech.mp3" # Save the audio to a file
|
109 |
-
with open(audio_file_path, 'wb') as f:
|
110 |
-
f.write(audio_buffer.read())
|
111 |
-
return audio_file_path # Return the file path instead of BytesIO
|
112 |
|
113 |
# Gradio Interface Function
|
114 |
def gradio_function(paragraph, audio):
|
|
|
47 |
# Step 2: Create pronunciation audio for incorrect words
|
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 |
+
audio=tts.save(audio_file_path)
|
52 |
+
return audio
|
|
|
53 |
|
54 |
# Step 3: Compare the transcribed text with the input paragraph
|
55 |
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 |
+
tts.save("paragraph.mp3")
|
99 |
+
return "paragraph.mp3"
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
# Gradio Interface Function
|
102 |
def gradio_function(paragraph, audio):
|