ttsofyakut / app.py
ollui's picture
Update app.py
6cb16a1 verified
raw
history blame contribute delete
779 Bytes
import torch
from transformers import pipeline
import gradio as gr
# Tự động dùng GPU nếu có
device = 0 if torch.cuda.is_available() else -1
# Tải pipeline TTS cho tiếng Yakut (mã ngôn ngữ: sah)
yakut_tts = pipeline("text-to-speech", model="facebook/mms-tts-sah", device=device)
# Hàm chuyển văn bản sang giọng nói
def yakut_voice(text):
result = yakut_tts(text)
return result["audio"]
# Giao diện Gradio
app = gr.Interface(
fn=yakut_voice,
inputs=gr.Textbox(label="Nhập văn bản tiếng Yakut"),
outputs=gr.Audio(label="Giọng nói Yakut"),
title="Yakut Text-to-Speech",
description="Chuyển văn bản Yakut (sah) thành giọng nói bằng mô hình Facebook MMS"
)
if __name__ == "__main__":
app.launch()