opentts / app.py
pr0fixi's picture
Update app.py
58d8c1b verified
raw
history blame
940 Bytes
import gradio as gr
from TTS.api import TTS
# Initialize Coqui TTS with XTTS-v2
tts = TTS(model_name="coqui/XTTS-v2", progress_bar=False)
def generate_speech(text):
output_file = "/tmp/output.wav"
tts.tts_to_file(
text=text,
file_path=output_file,
speaker_wav="reference.wav", # Replace with the path to your reference audio
language="en" # Specify the language (e.g., "en" for English)
)
return output_file
# Create a Gradio interface
with gr.Blocks() as demo:
gr.Markdown("# Coqui XTTS-v2 Demo")
gr.Markdown("Type some text and hear it spoken!")
input_text = gr.Textbox(label="Enter Text", placeholder="Type something...")
output_audio = gr.Audio(label="Generated Speech", type="filepath")
submit_button = gr.Button("Generate Speech")
submit_button.click(generate_speech, inputs=input_text, outputs=output_audio)
demo.launch(share=True)