First_agent_uasername / Code_Functions.py
uasername's picture
Create Code_Functions.py
1561720 verified
raw
history blame contribute delete
439 Bytes
from gtts import gTTS
# Определи путь для аудиофайла, можно использовать тот же путь, что и в app.py
AUDIO_OUTPUT_PATH = "/tmp/response.mp3"
def speak_text(text):
"""Convert text to speech using gTTS and save as an MP3 file."""
tts = gTTS(text=text, lang='en')
tts.save(AUDIO_OUTPUT_PATH)
return AUDIO_OUTPUT_PATH # Return the file path for Gradio Audio component