Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import subprocess
|
| 3 |
+
import os
|
| 4 |
+
import uuid
|
| 5 |
+
|
| 6 |
+
def tts_tibetan(text):
|
| 7 |
+
if not text.strip():
|
| 8 |
+
return "Vui lòng nhập văn bản."
|
| 9 |
+
|
| 10 |
+
output_path = f"/tmp/{uuid.uuid4().hex}.wav"
|
| 11 |
+
|
| 12 |
+
try:
|
| 13 |
+
result = subprocess.run(
|
| 14 |
+
["espeak-ng", "-v", "bo", "-s", "140", "-w", output_path, text],
|
| 15 |
+
check=True,
|
| 16 |
+
stderr=subprocess.PIPE
|
| 17 |
+
)
|
| 18 |
+
if not os.path.exists(output_path):
|
| 19 |
+
return "Không tạo được file âm thanh."
|
| 20 |
+
return output_path
|
| 21 |
+
except subprocess.CalledProcessError as e:
|
| 22 |
+
return f"Lỗi khi gọi espeak-ng: {e.stderr.decode()}"
|
| 23 |
+
|
| 24 |
+
iface = gr.Interface(
|
| 25 |
+
fn=tts_tibetan,
|
| 26 |
+
inputs=gr.Textbox(label="Nhập văn bản tiếng Tây Tạng (Unicode)"),
|
| 27 |
+
outputs=gr.Audio(type="filepath", label="Kết quả giọng đọc"),
|
| 28 |
+
title="TTS tiếng Tây Tạng với eSpeak NG",
|
| 29 |
+
description="Tạo giọng đọc tiếng Tây Tạng sử dụng eSpeak NG (nếu hỗ trợ)"
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
iface.launch()
|