kevinwang676 commited on
Commit
a9b336b
1 Parent(s): 58177cb

Update app_colab.py

Browse files
Files changed (1) hide show
  1. app_colab.py +22 -11
app_colab.py CHANGED
@@ -5,6 +5,10 @@ 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"
10
  }
@@ -75,7 +79,6 @@ 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"),
@@ -214,7 +217,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 +246,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 +281,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 +290,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('''
 
5
 
6
  device = 'cuda' if torch.cuda.is_available() else 'cpu'
7
 
8
+ import zipfile
9
+ with zipfile.ZipFile("speech_XXL_cond.zip", 'r') as zip_ref:
10
+ zip_ref.extractall("Phoneme_Hallucinator_v2/exp")
11
+
12
  headers = {
13
  "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"
14
  }
 
79
  uvr5_names.append(name.replace(".pth", ""))
80
 
81
  func = AudioPre
 
82
  pre_fun_hp2 = func(
83
  agg=int(10),
84
  model_path=os.path.join(weight_uvr5_root, "UVR-HP2.pth"),
 
217
  return f"./output/{split_model}/{filename}/vocal_{filename}.wav_10.wav", f"./output/{split_model}/{filename}/instrument_{filename}.wav_10.wav"
218
 
219
 
220
+ def convert(start_time, song_name_src, song_name_ref, check_song, auto_key, key_shift, vocal_vol, inst_vol):
221
  split_model = "UVR-HP5"
222
  song_name_ref = song_name_ref.strip().replace(" ", "")
223
  video_identifier = search_bilibili(song_name_ref)
 
246
  os.remove("output_svc/NeuCoSVCv2.wav")
247
 
248
  if check_song == True:
249
+ if auto_key == True:
250
+ os.system(f"python inference.py --src_wav_path audio_src.wav --ref_wav_path voiced_audio.wav")
251
+ else:
252
+ os.system(f"python inference.py --src_wav_path audio_src.wav --ref_wav_path voiced_audio.wav --key_shift {key_shift}")
253
+
254
  else:
255
+ if auto_key == True:
256
+ os.system(f"python inference.py --src_wav_path audio_src.wav --ref_wav_path voiced_audio.wav --speech_enroll")
257
+ else:
258
+ os.system(f"python inference.py --src_wav_path audio_src.wav --ref_wav_path voiced_audio.wav --key_shift {key_shift} --speech_enroll")
259
+
260
  audio_vocal = AudioSegment.from_file("output_svc/NeuCoSVCv2.wav", format="wav")
261
 
262
  # Load the second audio file
 
281
  with app:
282
  gr.Markdown("# <center>🥳💕🎶 NeuCoSVC v2 AI歌手全明星,无需训练、一键翻唱、重磅更新!</center>")
283
  gr.Markdown("## <center>🌟 只需 1 个歌曲名,一键翻唱任意歌手的任意歌曲,支持说话语音翻唱,随时随地,听你想听!</center>")
284
+ gr.Markdown("### <center>🌊 [NeuCoSVC v2](https://github.com/thuhcsi/NeuCoSVC) 先享版 Powered by Tencent ARC Lab & Tsinghua University 💕</center>")
285
  with gr.Row():
286
  with gr.Column():
287
  with gr.Row():
 
290
  with gr.Row():
291
  inp0 = gr.Number(value=0, label="起始时间 (秒)", info="此程序将自动从起始时间开始提取45秒的翻唱歌曲")
292
  inp3 = gr.Checkbox(label="参考音频是否为歌曲演唱,默认为是", info="如果参考音频为正常说话语音,请取消打勾", value=True)
293
+ inp4 = gr.Checkbox(label="是否自动预测歌曲人声升降调,默认为是", info="如果需要手动调节歌曲人声升降调,请取消打勾", value=True)
294
+ inp5 = gr.Slider(minimum=-12, maximum=12, value=0, step=1, label="歌曲人声升降调", info="默认为0,+2为升高2个key,以此类推")
295
  with gr.Row():
296
+ inp6 = gr.Slider(minimum=-3, maximum=3, value=0, step=1, label="调节人声音量,默认为0")
297
+ inp7 = gr.Slider(minimum=-3, maximum=3, value=0, step=1, label="调节伴奏音量,默认为0")
298
  btn = gr.Button("一键开启AI翻唱之旅吧💕", variant="primary")
299
  with gr.Column():
300
+ out = gr.Audio(label="AI歌手为您倾情演唱的歌曲", type="filepath", interactive=False)
301
 
302
+ btn.click(convert, [inp0, inp1, inp2, inp3, inp4, inp5, inp6, inp7], out)
303
 
304
  gr.Markdown("### <center>注意❗:请不要生成会对个人以及组织造成侵害的内容,此程序仅供科研、学习及个人娱乐使用。</center>")
305
  gr.HTML('''