File size: 940 Bytes
560bcfb 0149ced 186f296 58d8c1b b1e2598 186f296 0149ced 58d8c1b 0149ced 58d8c1b 0149ced 58d8c1b |
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 27 28 |
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) |