from transformers import pipeline import gradio as gr import tempfile # Load TTS pipeline with a model that works in Spaces tts = pipeline("text-to-speech", model="facebook/fastspeech2-en-ljspeech") def greet(name): greeting = f"Hello {name}!! You're amazing!" audio_data = tts(greeting)["audio"] # Save to a temp WAV file with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as f: f.write(audio_data) return f.name demo = gr.Interface(fn=greet, inputs="text", outputs=gr.Audio(type="filepath")) demo.launch()