Spaces:
Runtime error
Runtime error
Update src/main.py
Browse files- src/main.py +9 -31
src/main.py
CHANGED
@@ -179,7 +179,7 @@ def preprocess_song(song_input, mdx_model_params, song_id, is_webui, input_type,
|
|
179 |
orig_song_path = convert_to_stereo(orig_song_path)
|
180 |
|
181 |
display_progress('[~] Separating Vocals from Instrumental...', 0.1, is_webui, progress)
|
182 |
-
vocals_path, instrumentals_path = run_mdx(mdx_model_params, song_output_dir, os.path.join(mdxnet_models_dir, 'UVR-MDX-NET-Voc_FT.onnx'), orig_song_path, denoise=True, keep_orig=keep_orig)
|
183 |
|
184 |
display_progress('[~] Separating Main Vocals from Backup Vocals...', 0.2, is_webui, progress)
|
185 |
backup_vocals_path, main_vocals_path = run_mdx(mdx_model_params, song_output_dir, os.path.join(mdxnet_models_dir, 'UVR_MDXNET_KARA_2.onnx'), vocals_path, suffix='Backup', invert_suffix='Main', denoise=True)
|
@@ -271,6 +271,8 @@ def song_cover_pipeline(song_input, voice_model, pitch_change, keep_files,
|
|
271 |
if not os.path.exists(song_dir):
|
272 |
os.makedirs(song_dir)
|
273 |
orig_song_path, vocals_path, instrumentals_path, main_vocals_path, backup_vocals_path, main_vocals_dereverb_path = preprocess_song(song_input, mdx_model_params, song_id, is_webui, input_type, progress)
|
|
|
|
|
274 |
|
275 |
else:
|
276 |
vocals_path, main_vocals_path = None, None
|
@@ -279,38 +281,14 @@ def song_cover_pipeline(song_input, voice_model, pitch_change, keep_files,
|
|
279 |
# if any of the audio files aren't available or keep intermediate files, rerun preprocess
|
280 |
if any(path is None for path in paths) or keep_files:
|
281 |
orig_song_path, vocals_path, instrumentals_path, main_vocals_path, backup_vocals_path, main_vocals_dereverb_path = preprocess_song(song_input, mdx_model_params, song_id, is_webui, input_type, progress)
|
|
|
|
|
282 |
else:
|
283 |
orig_song_path, instrumentals_path, main_vocals_dereverb_path, backup_vocals_path = paths
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
if not os.path.exists(ai_vocals_path):
|
290 |
-
display_progress('[~] Converting voice using RVC...', 0.5, is_webui, progress)
|
291 |
-
voice_change(voice_model, main_vocals_dereverb_path, ai_vocals_path, pitch_change, f0_method, index_rate, filter_radius, rms_mix_rate, protect, crepe_hop_length, is_webui)
|
292 |
-
|
293 |
-
display_progress('[~] Applying audio effects to Vocals...', 0.8, is_webui, progress)
|
294 |
-
ai_vocals_mixed_path = add_audio_effects(ai_vocals_path, reverb_rm_size, reverb_wet, reverb_dry, reverb_damping)
|
295 |
-
|
296 |
-
if pitch_change_all != 0:
|
297 |
-
display_progress('[~] Applying overall pitch change', 0.85, is_webui, progress)
|
298 |
-
instrumentals_path = pitch_shift(instrumentals_path, pitch_change_all)
|
299 |
-
backup_vocals_path = pitch_shift(backup_vocals_path, pitch_change_all)
|
300 |
-
|
301 |
-
display_progress('[~] Combining AI Vocals and Instrumentals...', 0.9, is_webui, progress)
|
302 |
-
combine_audio([ai_vocals_mixed_path, backup_vocals_path, instrumentals_path], ai_cover_path, main_gain, backup_gain, inst_gain, output_format)
|
303 |
-
|
304 |
-
if not keep_files:
|
305 |
-
display_progress('[~] Removing intermediate audio files...', 0.95, is_webui, progress)
|
306 |
-
intermediate_files = [vocals_path, main_vocals_path, ai_vocals_mixed_path]
|
307 |
-
if pitch_change_all != 0:
|
308 |
-
intermediate_files += [instrumentals_path, backup_vocals_path]
|
309 |
-
for file in intermediate_files:
|
310 |
-
if file and os.path.exists(file):
|
311 |
-
os.remove(file)
|
312 |
-
|
313 |
-
return ai_cover_path
|
314 |
|
315 |
except Exception as e:
|
316 |
raise_exception(str(e), is_webui)
|
|
|
179 |
orig_song_path = convert_to_stereo(orig_song_path)
|
180 |
|
181 |
display_progress('[~] Separating Vocals from Instrumental...', 0.1, is_webui, progress)
|
182 |
+
vocals_path, instrumentals_path = run_mdx(mdx_model_params, song_output_dir, os.path.join(mdxnet_models_dir, 'UVR-MDX-NET-Voc_FT.onnx'), orig_song_path, denoise=True, keep_orig=keep_orig, _stemname1 = "_origvocals", _stemname2="_originstr")
|
183 |
|
184 |
display_progress('[~] Separating Main Vocals from Backup Vocals...', 0.2, is_webui, progress)
|
185 |
backup_vocals_path, main_vocals_path = run_mdx(mdx_model_params, song_output_dir, os.path.join(mdxnet_models_dir, 'UVR_MDXNET_KARA_2.onnx'), vocals_path, suffix='Backup', invert_suffix='Main', denoise=True)
|
|
|
271 |
if not os.path.exists(song_dir):
|
272 |
os.makedirs(song_dir)
|
273 |
orig_song_path, vocals_path, instrumentals_path, main_vocals_path, backup_vocals_path, main_vocals_dereverb_path = preprocess_song(song_input, mdx_model_params, song_id, is_webui, input_type, progress)
|
274 |
+
print(vocals_path, instrumentals_path)
|
275 |
+
return vocals_path, instrumentals_path
|
276 |
|
277 |
else:
|
278 |
vocals_path, main_vocals_path = None, None
|
|
|
281 |
# if any of the audio files aren't available or keep intermediate files, rerun preprocess
|
282 |
if any(path is None for path in paths) or keep_files:
|
283 |
orig_song_path, vocals_path, instrumentals_path, main_vocals_path, backup_vocals_path, main_vocals_dereverb_path = preprocess_song(song_input, mdx_model_params, song_id, is_webui, input_type, progress)
|
284 |
+
print(vocals_path, instrumentals_path)
|
285 |
+
return vocals_path, instrumentals_path
|
286 |
else:
|
287 |
orig_song_path, instrumentals_path, main_vocals_dereverb_path, backup_vocals_path = paths
|
288 |
+
|
289 |
+
print("ARRIVATO QUA, ERRORE")
|
290 |
+
return
|
291 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
|
293 |
except Exception as e:
|
294 |
raise_exception(str(e), is_webui)
|