Download app.py from QuickLearnerAI/Text-to-speech: direct link, hf CLI and curl.
- Browser
- Download file 710 Bytes
-
https://huggingface.co/spaces/QuickLearnerAI/Text-to-speech/resolve/main/app.py
- Command line
-
hf download hf://spaces/QuickLearnerAI/Text-to-speech/app.py
-
curl -L -o app.py https://huggingface.co/spaces/QuickLearnerAI/Text-to-speech/resolve/main/app.py
710 Bytes
| import gradio as gr | |
| from gtts import gTTS | |
| import os | |
| def text_to_speech(text): | |
| if not text.strip(): | |
| return None | |
| tts = gTTS(text=text, lang="en") # চাইলে "bn" দিলে বাংলা হবে | |
| file_path = "output.mp3" | |
| tts.save(file_path) | |
| return file_path | |
| with gr.Blocks() as demo: | |
| gr.Markdown("## 🗣️ Text to Speech App") | |
| text_input = gr.Textbox(label="Enter your text", placeholder="Type something...") | |
| output_audio = gr.Audio(label="Generated Voice", type="filepath") | |
| submit_btn = gr.Button("🔊 Submit") | |
| submit_btn.click(fn=text_to_speech, inputs=text_input, outputs=output_audio) | |
| demo.launch(show_error=True) | |