File size: 710 Bytes
12486b9
8a19451
 
 
 
12486b9
8a19451
d9d3c70
8a19451
12486b9
d9d3c70
 
 
 
 
8a19451
d9d3c70
 
 
 
 
8a19451
d9d3c70
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os

# Install espeak-ng before running the model
os.system("apt-get update && apt-get install -y espeak-ng")

from TTS.api import TTS
import gradio as gr

# Load Coqui TTS Model (VITS)
tts = TTS("tts_models/en/ljspeech/vits", progress_bar=False).to("cpu")

def text_to_speech(text):
    """Generate Speech from Text"""
    output_path = "output.wav"
    tts.tts_to_file(text=text, file_path=output_path)
    return output_path

# Gradio UI
gr.Interface(
    fn=text_to_speech,
    inputs=gr.Textbox(placeholder="Enter text to convert to speech"),
    outputs=gr.Audio(type="filepath"),
    title="Coqui TTS - Text to Speech",
    description="Enter text and listen to the generated speech.",
).launch()