import gradio as gr import soundfile as sf import tempfile from f5_tts_loader import F5TTS tts = F5TTS("hynt/F5-TTS-Vietnamese-100h") def generate_speech(text): if not text.strip(): return None audio, sr = tts.tts(text) # Save to temp WAV out_path = tempfile.mktemp(suffix=".wav") sf.write(out_path, audio, sr) return out_path with gr.Blocks(title="Vietnamese TTS Free") as demo: gr.Markdown("# 🇻🇳 Vietnamese Text-to-Speech (F5-TTS, Free)\nNhập tiếng Việt để tạo giọng nói:") text_input = gr.Textbox(lines=5, label="Văn bản") audio_output = gr.Audio(label="Âm thanh", type="filepath") btn = gr.Button("🎤 Convert") btn.click(fn=generate_speech, inputs=text_input, outputs=audio_output) demo.launch()