Prgckwb commited on
Commit
9617188
1 Parent(s): 3352221
Files changed (2) hide show
  1. app.py +31 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import nltk
3
+ import os
4
+ os.system('python -m unidic download')
5
+ from melo.api import TTS
6
+
7
+ nltk.download('averaged_perceptron_tagger_eng')
8
+
9
+ # Get device
10
+ device = 'auto'
11
+ model = TTS(language='EN', device=device)
12
+ speaker_ids = model.hps.data.spk2id
13
+
14
+
15
+ def inference(text: str):
16
+ output_path = 'en-us.wav'
17
+ model.tts_to_file(text, speaker_ids['EN-US'], output_path, speed=1.0)
18
+ return output_path
19
+
20
+
21
+ if __name__ == "__main__":
22
+ demo = gr.Interface(
23
+ fn=inference,
24
+ inputs=[
25
+ gr.Textbox(),
26
+ ],
27
+ outputs=[
28
+ gr.Audio()
29
+ ],
30
+ )
31
+ demo.queue().launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ -e ./third_party/MeloTTS