|
|
|
import gradio as gr |
|
from TTS.api import TTS |
|
|
|
|
|
tts = TTS(model_name="tts_models/multilingual/multi-dataset/xtts_v2", progress_bar=True, gpu=False) |
|
|
|
|
|
def clone_and_speak(text, ref_audio): |
|
output_path = "output.wav" |
|
tts.tts_to_file(text=text, speaker_wav=ref_audio, language="en", file_path=output_path) |
|
return output_path |
|
|
|
|
|
interface = gr.Interface( |
|
fn=clone_and_speak, |
|
inputs=[ |
|
gr.Textbox(label="Enter text to synthesize", lines=5), |
|
gr.Audio(source="upload", type="filepath", label="Reference Voice (wav/mp3)") |
|
], |
|
outputs=gr.Audio(type="filepath", label="Generated Speech"), |
|
title="Free Voice Cloning with XTTS v2", |
|
description="Upload reference voice and generate cloned speech for free (up to 3000 words)." |
|
) |
|
|
|
interface.launch() |
|
|