File size: 1,004 Bytes
b8781a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 subprocess
import os
import uuid

def tts_tibetan(text):
    if not text.strip():
        return "Vui lòng nhập văn bản."

    output_path = f"/tmp/{uuid.uuid4().hex}.wav"

    try:
        result = subprocess.run(
            ["espeak-ng", "-v", "bo", "-s", "140", "-w", output_path, text],
            check=True,
            stderr=subprocess.PIPE
        )
        if not os.path.exists(output_path):
            return "Không tạo được file âm thanh."
        return output_path
    except subprocess.CalledProcessError as e:
        return f"Lỗi khi gọi espeak-ng: {e.stderr.decode()}"

iface = gr.Interface(
    fn=tts_tibetan,
    inputs=gr.Textbox(label="Nhập văn bản tiếng Tây Tạng (Unicode)"),
    outputs=gr.Audio(type="filepath", label="Kết quả giọng đọc"),
    title="TTS tiếng Tây Tạng với eSpeak NG",
    description="Tạo giọng đọc tiếng Tây Tạng sử dụng eSpeak NG (nếu hỗ trợ)"
)

iface.launch()