Download app.py from QuickLearnerAI/Bengali_text-to_speech: direct link, hf CLI and curl.
- Browser
- Download file 632 Bytes
-
https://huggingface.co/spaces/QuickLearnerAI/Bengali_text-to_speech/resolve/main/app.py
- Command line
-
hf download hf://spaces/QuickLearnerAI/Bengali_text-to_speech/app.py
-
curl -L -o app.py https://huggingface.co/spaces/QuickLearnerAI/Bengali_text-to_speech/resolve/main/app.py
632 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= "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) | |