Update lib/rvc.py
Browse files- lib/rvc.py +10 -23
lib/rvc.py
CHANGED
|
@@ -237,8 +237,7 @@ def voice_change(voice_model, vocals_path, output_path, pitch_change, f0_method,
|
|
| 237 |
"""
|
| 238 |
Convert the input vocals using the specified RVC model.
|
| 239 |
"""
|
| 240 |
-
|
| 241 |
-
|
| 242 |
inferred_audio = infer_audio(
|
| 243 |
MODEL_NAME=voice_model,
|
| 244 |
SOUND_PATH=vocals_path,
|
|
@@ -340,48 +339,36 @@ def song_cover_pipeline(song_input, voice_model, pitch_change, keep_files,
|
|
| 340 |
f'{base_song_name}_lead_{voice_model}_p{pitch_change}_i{index_rate}_fr{filter_radius}_'
|
| 341 |
f'rms{rms_mix_rate}_pro{protect}_{f0_method}{algo_suffix}.wav'
|
| 342 |
)
|
| 343 |
-
|
| 344 |
-
song_dir,
|
| 345 |
-
f'{base_song_name}_backing_{voice_model}_p{pitch_change}_i{index_rate}_fr{filter_radius}_'
|
| 346 |
-
f'rms{rms_mix_rate}_pro{protect}_{f0_method}{algo_suffix}.wav'
|
| 347 |
-
)
|
| 348 |
ai_cover_path = os.path.join(song_dir, f'{base_song_name} ({voice_model} Ver).{output_format}')
|
| 349 |
-
|
| 350 |
-
|
| 351 |
if not os.path.exists(ai_vocals_path):
|
| 352 |
-
display_progress('[~] Converting
|
| 353 |
voice_change(voice_model, main_vocals_dereverb_path, ai_vocals_path, pitch_change,
|
| 354 |
f0_method, index_rate, filter_radius, rms_mix_rate, protect, crepe_hop_length, is_webui)
|
| 355 |
|
| 356 |
-
|
| 357 |
-
voice_change(voice_model, backup_vocals_path, ai_backing_path, pitch_change,
|
| 358 |
-
f0_method, index_rate, filter_radius, rms_mix_rate, protect, crepe_hop_length, is_webui)
|
| 359 |
-
|
| 360 |
display_progress('[~] Applying audio effects to Vocals...', 0.8, is_webui, progress)
|
| 361 |
ai_vocals_mixed_path = add_audio_effects(ai_vocals_path, reverb_rm_size, reverb_wet, reverb_dry, reverb_damping)
|
| 362 |
-
|
| 363 |
-
|
| 364 |
if pitch_change_all != 0:
|
| 365 |
display_progress('[~] Applying overall pitch change', 0.85, is_webui, progress)
|
| 366 |
instrumentals_path = pitch_shift(instrumentals_path, pitch_change_all)
|
| 367 |
-
|
| 368 |
-
|
| 369 |
display_progress('[~] Combining AI Vocals and Instrumentals...', 0.9, is_webui, progress)
|
| 370 |
combine_audio([ai_vocals_mixed_path, backup_vocals_path, instrumentals_path],
|
| 371 |
ai_cover_path, main_gain, backup_gain, inst_gain, output_format)
|
| 372 |
-
|
| 373 |
-
ai_cover_backing_path, main_gain, backup_gain, inst_gain, output_format)
|
| 374 |
-
|
| 375 |
if not keep_files:
|
| 376 |
display_progress('[~] Removing intermediate audio files...', 0.95, is_webui, progress)
|
| 377 |
-
intermediate_files = [vocals_path, main_vocals_path, ai_vocals_mixed_path
|
| 378 |
if pitch_change_all != 0:
|
| 379 |
intermediate_files += [instrumentals_path, backup_vocals_path]
|
| 380 |
for file in intermediate_files:
|
| 381 |
if file and os.path.exists(file):
|
| 382 |
os.remove(file)
|
| 383 |
|
| 384 |
-
return ai_cover_path
|
| 385 |
|
| 386 |
except Exception as e:
|
| 387 |
raise_exception(str(e), is_webui)
|
|
|
|
| 237 |
"""
|
| 238 |
Convert the input vocals using the specified RVC model.
|
| 239 |
"""
|
| 240 |
+
|
|
|
|
| 241 |
inferred_audio = infer_audio(
|
| 242 |
MODEL_NAME=voice_model,
|
| 243 |
SOUND_PATH=vocals_path,
|
|
|
|
| 339 |
f'{base_song_name}_lead_{voice_model}_p{pitch_change}_i{index_rate}_fr{filter_radius}_'
|
| 340 |
f'rms{rms_mix_rate}_pro{protect}_{f0_method}{algo_suffix}.wav'
|
| 341 |
)
|
| 342 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
ai_cover_path = os.path.join(song_dir, f'{base_song_name} ({voice_model} Ver).{output_format}')
|
| 344 |
+
|
|
|
|
| 345 |
if not os.path.exists(ai_vocals_path):
|
| 346 |
+
display_progress('[~] Converting voice using RVC...', 0.5, is_webui, progress)
|
| 347 |
voice_change(voice_model, main_vocals_dereverb_path, ai_vocals_path, pitch_change,
|
| 348 |
f0_method, index_rate, filter_radius, rms_mix_rate, protect, crepe_hop_length, is_webui)
|
| 349 |
|
| 350 |
+
|
|
|
|
|
|
|
|
|
|
| 351 |
display_progress('[~] Applying audio effects to Vocals...', 0.8, is_webui, progress)
|
| 352 |
ai_vocals_mixed_path = add_audio_effects(ai_vocals_path, reverb_rm_size, reverb_wet, reverb_dry, reverb_damping)
|
| 353 |
+
|
|
|
|
| 354 |
if pitch_change_all != 0:
|
| 355 |
display_progress('[~] Applying overall pitch change', 0.85, is_webui, progress)
|
| 356 |
instrumentals_path = pitch_shift(instrumentals_path, pitch_change_all)
|
| 357 |
+
|
|
|
|
| 358 |
display_progress('[~] Combining AI Vocals and Instrumentals...', 0.9, is_webui, progress)
|
| 359 |
combine_audio([ai_vocals_mixed_path, backup_vocals_path, instrumentals_path],
|
| 360 |
ai_cover_path, main_gain, backup_gain, inst_gain, output_format)
|
| 361 |
+
|
|
|
|
|
|
|
| 362 |
if not keep_files:
|
| 363 |
display_progress('[~] Removing intermediate audio files...', 0.95, is_webui, progress)
|
| 364 |
+
intermediate_files = [vocals_path, main_vocals_path, ai_vocals_mixed_path]
|
| 365 |
if pitch_change_all != 0:
|
| 366 |
intermediate_files += [instrumentals_path, backup_vocals_path]
|
| 367 |
for file in intermediate_files:
|
| 368 |
if file and os.path.exists(file):
|
| 369 |
os.remove(file)
|
| 370 |
|
| 371 |
+
return ai_cover_path
|
| 372 |
|
| 373 |
except Exception as e:
|
| 374 |
raise_exception(str(e), is_webui)
|