Jjhhjcbn / app.py
Skjafir's picture
Upload 2 files
8e63b0c verified
raw
history blame contribute delete
866 Bytes
import gradio as gr
from TTS.api import TTS
# Load XTTS model (voice cloning capable)
tts = TTS(model_name="tts_models/multilingual/multi-dataset/xtts_v2", progress_bar=True, gpu=False)
# Voice cloning function
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
# Gradio Interface
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()