File size: 820 Bytes
330f4a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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()