File size: 558 Bytes
f55256c
8a9886c
f55256c
37288b6
 
f55256c
8a9886c
37288b6
 
 
21a4a18
37288b6
 
 
 
 
 
 
734b08c
37288b6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
from TTS.api import TTS

# Initialize TTS model (default English)
tts = TTS(model_name="tts_models/en/ljspeech/tacotron2-DDC", progress_bar=False, gpu=False)

def text_to_speech(text):
    output_file = "output.wav"
    tts.tts_to_file(text=text, file_path=output_file)
    return output_file

iface = gr.Interface(
    fn=text_to_speech,
    inputs=gr.Textbox(label="Enter Text"),
    outputs=gr.Audio(label="Generated Speech"),
    title="TTS with Python",
    description="Type text and get speech using TTS==0.13.0"
)

iface.launch()