kevinwang676 commited on
Commit
27a6f13
1 Parent(s): 5341d30

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -15
app.py CHANGED
@@ -1,9 +1,17 @@
1
  import re, os
2
  import requests
3
  import json
4
- import torch
5
 
6
- device = 'cuda' if torch.cuda.is_available() else 'cpu'
 
 
 
 
 
 
 
 
 
7
 
8
  headers = {
9
  "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
@@ -75,18 +83,17 @@ for name in os.listdir(weight_uvr5_root):
75
  uvr5_names.append(name.replace(".pth", ""))
76
 
77
  func = AudioPre
78
-
79
  pre_fun_hp2 = func(
80
  agg=int(10),
81
  model_path=os.path.join(weight_uvr5_root, "UVR-HP2.pth"),
82
- device=device,
83
  is_half=True,
84
  )
85
 
86
  pre_fun_hp5 = func(
87
  agg=int(10),
88
  model_path=os.path.join(weight_uvr5_root, "UVR-HP5.pth"),
89
- device=device,
90
  is_half=True,
91
  )
92
 
@@ -214,7 +221,7 @@ def youtube_downloader_100s(
214
  return f"./output/{split_model}/{filename}/vocal_{filename}.wav_10.wav", f"./output/{split_model}/{filename}/instrument_{filename}.wav_10.wav"
215
 
216
 
217
- def convert(start_time, song_name_src, song_name_ref, check_song, key_shift, vocal_vol, inst_vol):
218
  split_model = "UVR-HP5"
219
  song_name_ref = song_name_ref.strip().replace(" ", "")
220
  video_identifier = search_bilibili(song_name_ref)
@@ -243,10 +250,17 @@ def convert(start_time, song_name_src, song_name_ref, check_song, key_shift, voc
243
  os.remove("output_svc/NeuCoSVCv2.wav")
244
 
245
  if check_song == True:
246
- os.system(f"python inference.py --src_wav_path audio_src.wav --ref_wav_path voiced_audio.wav --key_shift {key_shift}")
 
 
 
 
247
  else:
248
- os.system(f"python inference.py --src_wav_path audio_src.wav --ref_wav_path voiced_audio.wav --key_shift {key_shift} --speech_enroll")
249
-
 
 
 
250
  audio_vocal = AudioSegment.from_file("output_svc/NeuCoSVCv2.wav", format="wav")
251
 
252
  # Load the second audio file
@@ -271,7 +285,7 @@ app = gr.Blocks()
271
  with app:
272
  gr.Markdown("# <center>🥳💕🎶 NeuCoSVC v2 AI歌手全明星,无需训练、一键翻唱、重磅更新!</center>")
273
  gr.Markdown("## <center>🌟 只需 1 个歌曲名,一键翻唱任意歌手的任意歌曲,支持说话语音翻唱,随时随地,听你想听!</center>")
274
- gr.Markdown("### <center>🌊 NeuCoSVC v2 先享版 Powered by Tencent ARC Lab & Tsinghua University 💕</center>")
275
  with gr.Row():
276
  with gr.Column():
277
  with gr.Row():
@@ -280,15 +294,16 @@ with app:
280
  with gr.Row():
281
  inp0 = gr.Number(value=0, label="起始时间 (秒)", info="此程序将自动从起始时间开始提取45秒的翻唱歌曲")
282
  inp3 = gr.Checkbox(label="参考音频是否为歌曲演唱,默认为是", info="如果参考音频为正常说话语音,请取消打勾", value=True)
283
- inp4 = gr.Slider(minimum=-12, maximum=12, value=0, step=1, label="歌曲人声升降调", info="默认为0,+2为升高2个key,以此类推")
 
284
  with gr.Row():
285
- inp5 = gr.Slider(minimum=-3, maximum=3, value=0, step=1, label="调节人声音量,默认为0")
286
- inp6 = gr.Slider(minimum=-3, maximum=3, value=0, step=1, label="调节伴奏音量,默认为0")
287
  btn = gr.Button("一键开启AI翻唱之旅吧💕", variant="primary")
288
  with gr.Column():
289
- out = gr.Audio(label="AI歌手为您倾情演唱的歌曲", type="filepath", interactive=True)
290
 
291
- btn.click(convert, [inp0, inp1, inp2, inp3, inp4, inp5, inp6], out)
292
 
293
  gr.Markdown("### <center>注意❗:请不要生成会对个人以及组织造成侵害的内容,此程序仅供科研、学习及个人娱乐使用。</center>")
294
  gr.HTML('''
 
1
  import re, os
2
  import requests
3
  import json
 
4
 
5
+ import urllib.request
6
+ urllib.request.urlretrieve("https://download.openxlab.org.cn/repos/file/Kevin676/NeuCoSVC-2/main?filepath=WavLM-Large.pt&sign=971a42d686a15fcd3aafae29c1c97220&nonce=1715413418821", "ckpt/WavLM-Large.pt")
7
+ urllib.request.urlretrieve("https://download.openxlab.org.cn/repos/file/Kevin676/NeuCoSVC-2/main?filepath=G_150k.pt&sign=07d507c87b7b9ed63556b7c094e6b0b5&nonce=1715413397933", "ckpt/G_150k.pt")
8
+ urllib.request.urlretrieve("https://download.openxlab.org.cn/repos/file/Kevin676/NeuCoSVC-v2/main?filepath=speech_XXL_cond.zip&sign=0520b3273355818d1ebee030bce88ee4&nonce=1715413443250", "speech_XXL_cond.zip")
9
+ urllib.request.urlretrieve("https://download.openxlab.org.cn/models/Kevin676/rvc-models/weight/UVR-HP2.pth", "uvr5/uvr_model/UVR-HP2.pth")
10
+ urllib.request.urlretrieve("https://download.openxlab.org.cn/models/Kevin676/rvc-models/weight/UVR-HP5.pth", "uvr5/uvr_model/UVR-HP5.pth")
11
+
12
+ import zipfile
13
+ with zipfile.ZipFile("speech_XXL_cond.zip", 'r') as zip_ref:
14
+ zip_ref.extractall("Phoneme_Hallucinator_v2/exp")
15
 
16
  headers = {
17
  "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
 
83
  uvr5_names.append(name.replace(".pth", ""))
84
 
85
  func = AudioPre
 
86
  pre_fun_hp2 = func(
87
  agg=int(10),
88
  model_path=os.path.join(weight_uvr5_root, "UVR-HP2.pth"),
89
+ device="cuda",
90
  is_half=True,
91
  )
92
 
93
  pre_fun_hp5 = func(
94
  agg=int(10),
95
  model_path=os.path.join(weight_uvr5_root, "UVR-HP5.pth"),
96
+ device="cuda",
97
  is_half=True,
98
  )
99
 
 
221
  return f"./output/{split_model}/{filename}/vocal_{filename}.wav_10.wav", f"./output/{split_model}/{filename}/instrument_{filename}.wav_10.wav"
222
 
223
 
224
+ def convert(start_time, song_name_src, song_name_ref, check_song, auto_key, key_shift, vocal_vol, inst_vol):
225
  split_model = "UVR-HP5"
226
  song_name_ref = song_name_ref.strip().replace(" ", "")
227
  video_identifier = search_bilibili(song_name_ref)
 
250
  os.remove("output_svc/NeuCoSVCv2.wav")
251
 
252
  if check_song == True:
253
+ if auto_key == True:
254
+ os.system(f"python inference.py --src_wav_path audio_src.wav --ref_wav_path voiced_audio.wav")
255
+ else:
256
+ os.system(f"python inference.py --src_wav_path audio_src.wav --ref_wav_path voiced_audio.wav --key_shift {key_shift}")
257
+
258
  else:
259
+ if auto_key == True:
260
+ os.system(f"python inference.py --src_wav_path audio_src.wav --ref_wav_path voiced_audio.wav --speech_enroll")
261
+ else:
262
+ os.system(f"python inference.py --src_wav_path audio_src.wav --ref_wav_path voiced_audio.wav --key_shift {key_shift} --speech_enroll")
263
+
264
  audio_vocal = AudioSegment.from_file("output_svc/NeuCoSVCv2.wav", format="wav")
265
 
266
  # Load the second audio file
 
285
  with app:
286
  gr.Markdown("# <center>🥳💕🎶 NeuCoSVC v2 AI歌手全明星,无需训练、一键翻唱、重磅更新!</center>")
287
  gr.Markdown("## <center>🌟 只需 1 个歌曲名,一键翻唱任意歌手的任意歌曲,支持说话语音翻唱,随时随地,听你想听!</center>")
288
+ gr.Markdown("### <center>🌊 [NeuCoSVC v2](https://github.com/thuhcsi/NeuCoSVC) 先享版 Powered by Tencent ARC Lab & Tsinghua University 💕</center>")
289
  with gr.Row():
290
  with gr.Column():
291
  with gr.Row():
 
294
  with gr.Row():
295
  inp0 = gr.Number(value=0, label="起始时间 (秒)", info="此程序将自动从起始时间开始提取45秒的翻唱歌曲")
296
  inp3 = gr.Checkbox(label="参考音频是否为歌曲演唱,默认为是", info="如果参考音频为正常说话语音,请取消打勾", value=True)
297
+ inp4 = gr.Checkbox(label="是否自动预测歌曲人声升降调,默认为是", info="如果需要手动调节歌曲人声升降调,请取消打勾", value=True)
298
+ inp5 = gr.Slider(minimum=-12, maximum=12, value=0, step=1, label="歌曲人声升降调", info="默认为0,+2为升高2个key,以此类推")
299
  with gr.Row():
300
+ inp6 = gr.Slider(minimum=-3, maximum=3, value=0, step=1, label="调节人声音量,默认为0")
301
+ inp7 = gr.Slider(minimum=-3, maximum=3, value=0, step=1, label="调节伴奏音量,默认为0")
302
  btn = gr.Button("一键开启AI翻唱之旅吧💕", variant="primary")
303
  with gr.Column():
304
+ out = gr.Audio(label="AI歌手为您倾情演唱的歌曲", type="filepath", interactive=False)
305
 
306
+ btn.click(convert, [inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7], out)
307
 
308
  gr.Markdown("### <center>注意❗:请不要生成会对个人以及组织造成侵害的内容,此程序仅供科研、学习及个人娱乐使用。</center>")
309
  gr.HTML('''