File size: 418 Bytes
bf775a1 a634542 bf775a1 f559200 a634542 f559200 add925f a634542 add925f a634542 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
from gtts import gTTS
import os
def generate_tts(text):
"""Generates a Text-to-Speech (TTS) file from the given text."""
tts = gTTS(text=text, lang="en")
# Ensure 'assets/' directory exists
assets_dir = "assets"
if not os.path.exists(assets_dir):
os.makedirs(assets_dir)
tts_path = os.path.join(assets_dir, "news_summary.mp3")
tts.save(tts_path)
return tts_path
|