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()