Spaces:
Runtime error
Runtime error
File size: 1,080 Bytes
efc07a8 |
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 33 |
import os
import subprocess
import gradio as gr
# Kiểm tra và cài đặt ekho nếu chưa có
def install_ekho():
try:
subprocess.run(["ekho", "-v"], check=True, stdout=subprocess.DEVNULL)
except FileNotFoundError:
print("Ekho chưa được cài, đang cài đặt...")
subprocess.run(["apt", "update"], check=True)
subprocess.run(["apt", "install", "-y", "ekho"], check=True)
print("Đã cài xong Ekho")
install_ekho()
# Hàm TTS
def tts_tibetan(text):
with open("input.txt", "w", encoding="utf-8") as f:
f.write(text)
os.system("ekho -v tibetan -o output.wav input.txt")
return "output.wav"
# Giao diện Gradio
demo = gr.Interface(fn=tts_tibetan,
inputs=gr.Textbox(label="Nhập tiếng Tây Tạng (Unicode)", lines=3),
outputs=gr.Audio(type="filepath", label="Âm thanh"),
title="TTS Tiếng Tây Tạng (Ekho)",
description="Nhập văn bản tiếng Tây Tạng để chuyển thành giọng nói")
demo.launch() |