helloWorld199 commited on
Commit
eeea902
1 Parent(s): c54c08b

Update src/main.py

Browse files
Files changed (1) hide show
  1. src/main.py +58 -0
src/main.py CHANGED
@@ -301,7 +301,65 @@ def vocal_only_pipeline(song_input, voice_model, pitch_change, is_webui=0,index_
301
  except Exception as e:
302
  raise_exception(str(e), is_webui)
303
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
 
306
  def song_cover_pipeline(song_input, voice_model, pitch_change, keep_files,
307
  is_webui=0, main_gain=0, backup_gain=0, inst_gain=0, index_rate=0.5, filter_radius=3,
 
301
  except Exception as e:
302
  raise_exception(str(e), is_webui)
303
 
304
+ # Function defining the pipeline to create the AI cover of an audio containing only voice information.
305
+ # Returns the path of the cover vocal.
306
+ def vocal_only_pipeline_no_reverb(song_input, voice_model, pitch_change, is_webui=0,index_rate=0.5, filter_radius=3,
307
+ rms_mix_rate=0.25, f0_method='rmvpe', crepe_hop_length=128, protect=0.33, pitch_change_all=0,
308
+ reverb_rm_size=0.15, reverb_wet=0.2, reverb_dry=0.8, reverb_damping=0.7, output_format='mp3',progress=gr.Progress()):
309
+ try:
310
+ #Load mdx parameters
311
+ with open(os.path.join(mdxnet_models_dir, 'model_data.json')) as infile:
312
+ mdx_model_params = json.load(infile)
313
+
314
+ print("HERE pre song_id")
315
+ # Get path of loaded vocal file
316
+ input_type = 'local'
317
 
318
+ # Extract the file name without extension
319
+ name, extension = os.path.splitext(song_input)
320
+
321
+ # Append '_noreverb' to the file name
322
+ song_input = f"{name}_noreverb{extension}"
323
+ song_input = song_input.strip('\"')
324
+ if os.path.exists(song_input):
325
+ song_id = get_hash(song_input)
326
+ else:
327
+ error_msg = f'{song_input} does not exist.'
328
+ song_id = None
329
+ raise_exception(error_msg, is_webui)
330
+ print("HERE pre song_dir")
331
+ song_dir = os.path.join(output_dir, song_id, voice_model)
332
+
333
+ print("HERE pre IF")
334
+ if not os.path.exists(song_dir):
335
+ os.makedirs(song_dir)
336
+ #orig_song_path, vocals_path = preprocess_vocals_only(song_input, mdx_model_params, song_id, is_webui, input_type, progress)
337
+ else:
338
+ vocals_path = None
339
+ for file in os.listdir(song_dir):
340
+ vocals_path = os.path.join(song_dir, file)
341
+ return vocals_path
342
+
343
+ #if any of the audio files aren't available or keep intermediate files, rerun preprocess
344
+ #if any(path is None for path in paths):
345
+ # orig_song_path, vocals_path= preprocess_vocals_only(song_input, mdx_model_params, song_id, is_webui, input_type, progress)
346
+ #else:
347
+ # orig_song_path = paths
348
+ #orig_song_path, vocals_path = preprocess_vocals_only(song_input, mdx_model_params, song_id, is_webui, input_type, progress)
349
+
350
+ pitch_change = pitch_change * 12 + pitch_change_all
351
+ ai_vocals_path = os.path.join(song_dir, f'_{voice_model}_p{pitch_change}_i{index_rate}_fr{filter_radius}_rms{rms_mix_rate}_pro{protect}_{f0_method}{"" if f0_method != "mangio-crepe" else f"_{crepe_hop_length}"}_covervocals.wav')
352
+ display_progress(f'[~] Skipped Reverb {ai_vocals_path}', 0.5, is_webui, progress)
353
+ time.sleep(10)
354
+
355
+ display_progress('[~] Converting voice using RVC...', 0.5, is_webui, progress)
356
+ voice_change(voice_model, song_input, ai_vocals_path, pitch_change, f0_method, index_rate, filter_radius, rms_mix_rate, protect, crepe_hop_length, is_webui)
357
+ #display_progress('[~] Applying audio effects to Vocals...', 0.8, is_webui, progress)
358
+ #ai_vocals_mixed_path = add_audio_effects(ai_vocals_path, reverb_rm_size, reverb_wet, reverb_dry, reverb_damping)
359
+
360
+ return ai_vocals_path
361
+ except Exception as e:
362
+ raise_exception(str(e), is_webui)
363
 
364
  def song_cover_pipeline(song_input, voice_model, pitch_change, keep_files,
365
  is_webui=0, main_gain=0, backup_gain=0, inst_gain=0, index_rate=0.5, filter_radius=3,