smjain commited on
Commit
23181ac
1 Parent(s): ce66dde

Upload infer_new.py

Browse files
Files changed (1) hide show
  1. infer_new.py +13 -3
infer_new.py CHANGED
@@ -105,16 +105,26 @@ def clean():
105
  gr.Slider.update(visible=False)
106
  )
107
 
 
 
 
 
 
 
108
 
109
 
110
  def api_convert_voice(spk_id,voice_transform,input_audio_path):
111
 
112
  #split audio
 
113
  cut_vocal_and_inst(input_audio_path,spk_id)
114
  print("audio splitting performed")
115
- vocal_path = f"output/{split_model}/{spk_id}_input_audio/vocals.wav"
116
- inst = f"output/{split_model}/{spk_id}_input_audio/no_vocals.wav"
117
 
 
 
 
118
  output_path = convert_voice(spk_id, vocal_path, voice_transform)
119
  output_path1= combine_vocal_and_inst(output_path,inst)
120
  print(output_path1)
@@ -325,7 +335,7 @@ def get_vc(sid, to_return_protect0):
325
 
326
  def cut_vocal_and_inst(audio_path,spk_id):
327
 
328
- vocal_path = "output/result/audio.wav"
329
  os.makedirs("output/result", exist_ok=True)
330
  #wavfile.write(vocal_path, audio_data[0], audio_data[1])
331
  #logs.append("Starting the audio splitting process...")
 
105
  gr.Slider.update(visible=False)
106
  )
107
 
108
+ def get_file_base_name(file_path):
109
+ # Extract the base name (including extension)
110
+ base_name = os.path.basename(file_path)
111
+ # Split the base name into the name and extension, and return just the name
112
+ file_name_without_extension, _ = os.path.splitext(base_name)
113
+ return file_name_without_extension
114
 
115
 
116
  def api_convert_voice(spk_id,voice_transform,input_audio_path):
117
 
118
  #split audio
119
+ base_name = get_file_base_name(input_audio_path)
120
  cut_vocal_and_inst(input_audio_path,spk_id)
121
  print("audio splitting performed")
122
+ #vocal_path = f"output/{split_model}/{spk_id}_input_audio/vocals.wav"
123
+ #inst = f"output/{split_model}/{spk_id}_input_audio/no_vocals.wav"
124
 
125
+ vocal_path = f"output/{base_name}/vocals.wav"
126
+ inst = f"output/{base_name}/{spk_id}_input_audio/no_vocals.wav"
127
+
128
  output_path = convert_voice(spk_id, vocal_path, voice_transform)
129
  output_path1= combine_vocal_and_inst(output_path,inst)
130
  print(output_path1)
 
335
 
336
  def cut_vocal_and_inst(audio_path,spk_id):
337
 
338
+ #vocal_path = "output/result/audio.wav"
339
  os.makedirs("output/result", exist_ok=True)
340
  #wavfile.write(vocal_path, audio_data[0], audio_data[1])
341
  #logs.append("Starting the audio splitting process...")