TriNguyenPO commited on
Commit
bb51650
·
verified ·
1 Parent(s): 3940075

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForSpeechSeq2Seq, AutoTokenizer, pipeline
3
+
4
+ tokenizer = AutoTokenizer.from_pretrained("MarcNg/fastspeech2-vi-infore")
5
+ model = AutoModelForSpeechSeq2Seq.from_pretrained("MarcNg/fastspeech2-vi-infore")
6
+
7
+ tts_pipeline = pipeline("text-to-speech", model=model, tokenizer=tokenizer)
8
+
9
+ def text_to_speech(text):
10
+ output = tts_pipeline(text)
11
+ return output["audio"].numpy()
12
+
13
+ iface = gr.Interface(
14
+ fn=text_to_speech,
15
+ inputs="text",
16
+ outputs="audio",
17
+ title="Vietnamese Text-to-Speech",
18
+ description="Enter Vietnamese text to convert to speech using FastSpeech 2 model."
19
+ )
20
+
21
+ iface.launch()