Spaces:
Sleeping
Sleeping
Update helpers.py
Browse files- helpers.py +7 -9
helpers.py
CHANGED
@@ -26,16 +26,14 @@ def speech_to_text(audio_data):
|
|
26 |
return transcript["text"] # Extract the text from the response
|
27 |
|
28 |
|
|
|
|
|
29 |
def text_to_speech(input_text):
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
webm_file_path = "temp_audio_play.mp3"
|
36 |
-
with open(webm_file_path, "wb") as f:
|
37 |
-
response.stream_to_file(webm_file_path)
|
38 |
-
return webm_file_path
|
39 |
|
40 |
|
41 |
def autoplay_audio(file_path: str):
|
|
|
26 |
return transcript["text"] # Extract the text from the response
|
27 |
|
28 |
|
29 |
+
from gtts import gTTS
|
30 |
+
|
31 |
def text_to_speech(input_text):
|
32 |
+
"""Generates a TTS audio file from the input text."""
|
33 |
+
tts = gTTS(text=input_text, lang="en")
|
34 |
+
audio_file_path = "temp_audio_play.mp3"
|
35 |
+
tts.save(audio_file_path)
|
36 |
+
return audio_file_path
|
|
|
|
|
|
|
|
|
37 |
|
38 |
|
39 |
def autoplay_audio(file_path: str):
|