my-tts-model / app.py
prerna-AI's picture
Create app.py
4c1c01b verified
Raw History Blame Contribute Delete
408 Bytes
from gtts import gTTS
import tempfile
def generate_tts(text, lang="en"):
if not text:
return None
with tempfile.NamedTemporaryFile(suffix=".mp3", delete=False) as f:
tts = gTTS(text=text, lang=lang)
tts.save(f.name)
return f.name
# Example function that Hugging Face will call
def inference(inputs):
text = inputs.get("inputs", "")
return generate_tts(text)