import gradio as gr from TTS.api import TTS # Load TTS model (first time might take 1–2 minutes) tts = TTS(model_name="tts_models/en/ljspeech/tacotron2-DDC", progress_bar=True, gpu=False) def synthesize(text): output_path = "output.wav" tts.tts_to_file(text=text, file_path=output_path) return output_path # Gradio UI gr.Interface( fn=synthesize, inputs=gr.Textbox(label="Enter text to synthesize"), outputs=gr.Audio(type="filepath", label="Generated Audio"), title="🗣️ Coqui TTS - CPU Demo", description="Enter text and generate speech using Coqui's Tacotron2-DDC model (free and fast).", ).launch()