ollui commited on
Commit
a9652a8
·
verified ·
1 Parent(s): 05fb5f4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, VitsModel
3
+ import torch
4
+
5
+ # Load model and tokenizer
6
+ model = VitsModel.from_pretrained("facebook/mms-tts-che")
7
+ tokenizer = AutoTokenizer.from_pretrained("facebook/mms-tts-che")
8
+
9
+ def tts_chechen(text):
10
+ inputs = tokenizer(text, return_tensors="pt")
11
+ with torch.no_grad():
12
+ output = model(**inputs).waveform
13
+ return (model.config.sampling_rate, output.squeeze().numpy())
14
+
15
+ # Gradio UI
16
+ iface = gr.Interface(
17
+ fn=tts_chechen,
18
+ inputs=gr.Textbox(label="Nhập tiếng Chechen"),
19
+ outputs=gr.Audio(label="Giọng đọc Chechen"),
20
+ title="TTS Chechen - MMS by Meta",
21
+ description="Chuyển văn bản tiếng Chechen thành giọng nói"
22
+ )
23
+
24
+ iface.launch()