Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from gtts import gTTS
|
3 |
+
import os
|
4 |
+
|
5 |
+
def text_to_speech(text, lang='en'):
|
6 |
+
tts = gTTS(text=text, lang=lang, slow=False)
|
7 |
+
output_path = "output.mp3"
|
8 |
+
tts.save(output_path)
|
9 |
+
return output_path
|
10 |
+
|
11 |
+
with gr.Blocks() as demo:
|
12 |
+
gr.Markdown("# Text to Speech Converter")
|
13 |
+
|
14 |
+
text_input = gr.Textbox(label="Enter text")
|
15 |
+
lang_input = gr.Dropdown(choices=["en", "es", "fr", "de", "it"], value="en", label="Select language")
|
16 |
+
output_audio = gr.Audio(label="Generated Speech", type="filepath")
|
17 |
+
|
18 |
+
generate_button = gr.Button("Generate Speech")
|
19 |
+
generate_button.click(text_to_speech, inputs=[text_input, lang_input], outputs=output_audio)
|
20 |
+
|
21 |
+
if __name__ == "__main__":
|
22 |
+
demo.launch()
|