tibetantts / app.py
Inial's picture
Create app.py
efc07a8 verified
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()