Download app.py from prerna-AI/my-tts-model: direct link, hf CLI and curl.
- Browser
- Download file 408 Bytes
-
https://huggingface.co/prerna-AI/my-tts-model/resolve/main/app.py
- Command line
-
hf download hf://prerna-AI/my-tts-model/app.py
-
curl -L -o app.py https://huggingface.co/prerna-AI/my-tts-model/resolve/main/app.py
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) | |