import os from TTS.api import TTS import gradio as gr # ⛳ License agreement auto accept os.environ["COQUI_TOS_AGREED"] = "1" # 🎤 Load model tts = TTS(model_name="tts_models/multilingual/multi-dataset/xtts_v2", progress_bar=False, gpu=False) # 📢 Voice clone + TTS function def clone_and_speak(audio, text, speed): if audio is None or text.strip() == "": return "Please upload a voice sample and enter some text." output_path = "output.wav" tts.tts_to_file(text=text, speaker_wav=audio, file_path=output_path, speed=speed) return output_path # 🎨 UI Design with gr.Blocks() as demo: gr.Markdown("