mindspark121 commited on
Commit
d9d3c70
·
verified ·
1 Parent(s): cb7268f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from TTS.api import TTS
2
+ import gradio as gr
3
+
4
+ # Load TTS Model
5
+ tts = TTS("tts_models/en/ljspeech/tacotron2-DDC", progress_bar=False).to("cpu")
6
+
7
+ def text_to_speech(text):
8
+ """Generate Speech from Text"""
9
+ output_path = "output.wav"
10
+ tts.tts_to_file(text=text, file_path=output_path)
11
+ return output_path
12
+
13
+ # Gradio UI
14
+ gr.Interface(
15
+ fn=text_to_speech,
16
+ inputs=gr.Textbox(placeholder="Enter text to convert to speech"),
17
+ outputs=gr.Audio(),
18
+ title="Coqui TTS - Text to Speech",
19
+ description="Enter text and listen to the generated speech.",
20
+ ).launch()