Spaces:
Sleeping
Sleeping
app.py
Browse files
app.py
DELETED
|
@@ -1,31 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from gtts import gTTS
|
| 3 |
-
import tempfile
|
| 4 |
-
import os
|
| 5 |
-
|
| 6 |
-
def text_to_speech(text, lang):
|
| 7 |
-
if not text.strip():
|
| 8 |
-
return None
|
| 9 |
-
|
| 10 |
-
# Temporary unique file name
|
| 11 |
-
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".mp3")
|
| 12 |
-
tts = gTTS(text=text, lang=lang)
|
| 13 |
-
tts.save(temp_file.name)
|
| 14 |
-
|
| 15 |
-
return temp_file.name # Return path for gr.Audio
|
| 16 |
-
|
| 17 |
-
with gr.Blocks() as demo:
|
| 18 |
-
gr.Markdown("# 🔊 Text to Voice Generator")
|
| 19 |
-
|
| 20 |
-
text_input = gr.Textbox(label="Enter Text", placeholder="Type something here...")
|
| 21 |
-
lang_input = gr.Dropdown(
|
| 22 |
-
choices=["en", "hi", "ur", "fr", "es"],
|
| 23 |
-
value="en",
|
| 24 |
-
label="Language Code"
|
| 25 |
-
)
|
| 26 |
-
generate_btn = gr.Button("Generate Voice")
|
| 27 |
-
output_audio = gr.Audio(label="Generated Voice", type="filepath")
|
| 28 |
-
|
| 29 |
-
generate_btn.click(text_to_speech, inputs=[text_input, lang_input], outputs=output_audio)
|
| 30 |
-
|
| 31 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|