Spaces:
Sleeping
Sleeping
Download app.py from prerna-AI/my-tts-api: direct link, hf CLI and curl.
- Browser
- Download file 601 Bytes
-
https://huggingface.co/spaces/prerna-AI/my-tts-api/resolve/main/app.py
- Command line
-
hf download hf://spaces/prerna-AI/my-tts-api/app.py
-
curl -L -o app.py https://huggingface.co/spaces/prerna-AI/my-tts-api/resolve/main/app.py
601 Bytes
| import gradio as gr | |
| from gtts import gTTS | |
| import tempfile | |
| def 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 | |
| iface = gr.Interface( | |
| fn=tts, | |
| inputs=[gr.Textbox(label="Text to Speak"), gr.Textbox(label="Language (default=en)")], | |
| outputs=gr.Audio(type="filepath"), | |
| title="My Free TTS API", | |
| description="Enter text and get an MP3 using gTTS." | |
| ) | |
| iface.launch(server_name="0.0.0.0", server_port=7860, share=True) | |