nijisakai commited on
Commit
4776803
1 Parent(s): eb775da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -8
app.py CHANGED
@@ -270,15 +270,48 @@ interface_file = gr.Interface(
270
  article=article,
271
  )
272
 
273
- def combined_output(bilibili_url, start_time, end_time, speaker_choice, pitch_shift, f0_check, cluster_ratio, noise_scale, inference_method):
274
- # 根据你之前提供的参数调用predict_song_from_yt
275
- ai_with_instrumental, ai_vocal = predict_song_from_yt(bilibili_url, start_time, end_time, speaker_choice, pitch_shift, f0_check, cluster_ratio, noise_scale, inference_method)
276
-
277
- # 假设extract_vocal_demucs需要B站URL,起始时间和结束时间作为输入
278
- # 注意:你可能需要调整这一部分,以确保你为extract_vocal_demucs提供了正确的参数
279
- vocal_wav, instrumental_wav = extract_vocal_demucs(vocal_wav, instrumental_wav)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
 
281
- return ai_with_instrumental, ai_vocal, vocal_wav, instrumental_wav
 
 
 
 
 
 
 
 
 
282
 
283
 
284
 
 
270
  article=article,
271
  )
272
 
273
+ def combined_output(
274
+ ytid_or_url,
275
+ start,
276
+ end,
277
+ speaker=speakers[0],
278
+ transpose: int = 0,
279
+ auto_predict_f0: bool = False,
280
+ cluster_infer_ratio: float = 0,
281
+ noise_scale: float = 0.4,
282
+ f0_method: str = "dio",
283
+ db_thresh: int = -40,
284
+ pad_seconds: float = 0.5,
285
+ chunk_seconds: float = 0.5,
286
+ absolute_thresh: bool = False,
287
+ ):
288
+ # 调用原来的函数
289
+ full_song_output, cloned_vox_output = predict_song_from_yt(
290
+ ytid_or_url,
291
+ start,
292
+ end,
293
+ speaker,
294
+ transpose,
295
+ auto_predict_f0,
296
+ cluster_infer_ratio,
297
+ noise_scale,
298
+ f0_method,
299
+ db_thresh,
300
+ pad_seconds,
301
+ chunk_seconds,
302
+ absolute_thresh,
303
+ )
304
 
305
+ # 这里我们直接提取人声和伴奏,因为它们已经在predict_song_from_yt中被提取
306
+ original_track_filepath = download_youtube_clip(
307
+ ytid_or_url, start, end, "track.wav", force=True,
308
+ url_base="" if ytid_or_url.startswith("http") else "https://www.youtube.com/watch?v="
309
+ )
310
+ vox_wav, inst_wav = extract_vocal_demucs(demucs_model, original_track_filepath)
311
+
312
+ # 返回所有输出
313
+ return full_song_output, cloned_vox_output, (model.target_sample, vox_wav), (model.target_sample, inst_wav)
314
+
315
 
316
 
317