Namkoy commited on
Commit
b3dc9a2
·
1 Parent(s): 97ffdc0

inital app

Browse files
Files changed (1) hide show
  1. app.py +58 -0
app.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ from TTS.config import load_config
4
+ from TTS.utils.manage import ModelManager
5
+ from TTS.utils.synthesizer import Synthesizer
6
+
7
+
8
+ # vits_model = load_model()
9
+ # vits_model.tts('Alo')
10
+
11
+ config_path = '/home/nam/code_python/train_vits/config.json'
12
+ model_path = '/home/nam/code_python/train_vits/checkpoint_120000.pth'
13
+
14
+ synthesizer = Synthesizer(
15
+ model_path,
16
+ config_path,
17
+
18
+ )
19
+
20
+ # def Vits_model():
21
+
22
+
23
+ # tts = TTS(model_name = 'my_tts',
24
+ # model_path=checkpoint_path,
25
+ # config_path=config_path)
26
+
27
+ # return tts
28
+
29
+ # vits_model = Vits_model()
30
+
31
+
32
+ def predict(text):
33
+ text = text.lower()
34
+ text = text.replace(".", " ")
35
+ text = text.replace(",", "")
36
+ text = text.replace(";", "")
37
+ text = text.replace(":", "")
38
+ text = text.replace("!", "")
39
+ text = text.replace("?", "")
40
+ text = text.replace("(", "")
41
+ text = text.replace(")", "")
42
+ audio = synthesizer.tts(text)
43
+
44
+ audio = np.array(audio)
45
+ return 16000,audio
46
+
47
+ gr.Interface(
48
+ fn=predict,
49
+ inputs="text",
50
+ outputs="audio",
51
+
52
+ examples=[
53
+ "Sơn Tùng là ca sĩ nổi tiếng nhất Việt Nam.",
54
+ "Tôi tên là Chu Văn Nam, đến từ Bắc Ninh",
55
+ "Bác Hồ được biết đến không chỉ là một lãnh tụ xuất sắc mà còn là một nhà triết học, nhà cách mạng, và người tầm nhìn vĩ đại.",
56
+ ],
57
+ theme="default",
58
+ ).launch(debug=False)