Ailyth commited on
Commit
a3654b1
1 Parent(s): b31dbfa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -15,10 +15,10 @@ import pytz
15
 
16
  net_g = None
17
  models = {
18
- "Gladear": "./MODELS/adorabledarling.pth",
19
  "MistyNikki": "./MODELS/nikki9400.pth",
20
  "Silverleg": "./MODELS/J8900.pth",
21
- "Takemura": "./MODELS/take2.pth",
22
  "LucidMoon": "./MODELS/lucid.pth",
23
  "Rrabbitt": "./MODELS/rabbit4900.pth",
24
  "VivaciousViolet": "./MODELS/vv.pth",
@@ -71,10 +71,14 @@ def infer(text, sdp_ratio, noise_scale, noise_scale_w, length_scale, sid, model_
71
  sf.write("tmp.wav", audio, 44100)
72
  return audio
73
 
74
- def convert_wav_to_mp3(wav_file):
75
  tz = pytz.timezone('Asia/Shanghai')
76
  now = datetime.now(tz).strftime('%m%d%H%M%S')
 
 
 
77
  os.makedirs('out', exist_ok=True)
 
78
  output_path_mp3 = os.path.join('out', f"{now}.mp3")
79
 
80
  renamed_input_path = os.path.join('in', f"in.wav")
@@ -88,7 +92,7 @@ def tts_generator(text, sdp_ratio, noise_scale, noise_scale_w, length_scale, mod
88
  global net_g,speakers
89
  model_path = models[model]
90
  net_g, _, _, _ = utils.load_checkpoint(model_path, net_g, None, skip_optimizer=True)
91
- print(text)
92
  try:
93
  with torch.no_grad():
94
  audio = infer(text, sdp_ratio=sdp_ratio, noise_scale=noise_scale, noise_scale_w=noise_scale_w, length_scale=length_scale, sid=speaker,model_dir=model)
@@ -121,12 +125,12 @@ if __name__ == "__main__":
121
 
122
  gr.Markdown('''
123
  **测试用**\n
124
- 模型路径:\n
125
- huggingface.co/spaces/Ailyth/Multi-voice-TTS/tree/main 的MODELS里面
126
  ''')
127
  text = gr.TextArea(label="输入需要生成语音的文字", placeholder="输入文字",
128
  value="在不在?能不能借给我三百块钱买可乐",
129
- info="使用huggingface的免费CPU进行推理,因此速度不快,一次性不要输入超过500汉字。字数越多,生成速度越慢,请耐心等待",
130
  )
131
  model = gr.Radio(choices=list(models.keys()), value=list(models.keys())[0], label='音声模型')
132
  with gr.Accordion(label="展开设置生成参数", open=False):
 
15
 
16
  net_g = None
17
  models = {
18
+ "Mellowdear": "./MODELS/adorabledarling.pth",
19
  "MistyNikki": "./MODELS/nikki9400.pth",
20
  "Silverleg": "./MODELS/J8900.pth",
21
+ "Umemura": "./MODELS/take2.pth",
22
  "LucidMoon": "./MODELS/lucid.pth",
23
  "Rrabbitt": "./MODELS/rabbit4900.pth",
24
  "VivaciousViolet": "./MODELS/vv.pth",
 
71
  sf.write("tmp.wav", audio, 44100)
72
  return audio
73
 
74
+ def now():
75
  tz = pytz.timezone('Asia/Shanghai')
76
  now = datetime.now(tz).strftime('%m%d%H%M%S')
77
+ return now
78
+
79
+ def convert_wav_to_mp3(wav_file):
80
  os.makedirs('out', exist_ok=True)
81
+ now=now()
82
  output_path_mp3 = os.path.join('out', f"{now}.mp3")
83
 
84
  renamed_input_path = os.path.join('in', f"in.wav")
 
92
  global net_g,speakers
93
  model_path = models[model]
94
  net_g, _, _, _ = utils.load_checkpoint(model_path, net_g, None, skip_optimizer=True)
95
+ print(now()+text)
96
  try:
97
  with torch.no_grad():
98
  audio = infer(text, sdp_ratio=sdp_ratio, noise_scale=noise_scale, noise_scale_w=noise_scale_w, length_scale=length_scale, sid=speaker,model_dir=model)
 
125
 
126
  gr.Markdown('''
127
  **测试用**\n
128
+ 项目文件:\n
129
+ huggingface.co/spaces/Ailyth/Multi-voice-TTS/tree/main
130
  ''')
131
  text = gr.TextArea(label="输入需要生成语音的文字", placeholder="输入文字",
132
  value="在不在?能不能借给我三百块钱买可乐",
133
+ info="使用huggingface的免费CPU进行推理,因此速度不快,一次性不要输入超过500汉字。字数越多,生成速度越慢,请耐心等待,只会说中文。",
134
  )
135
  model = gr.Radio(choices=list(models.keys()), value=list(models.keys())[0], label='音声模型')
136
  with gr.Accordion(label="展开设置生成参数", open=False):