lorneluo commited on
Commit
9d26a29
1 Parent(s): a090989

refine uvr job

Browse files
Files changed (2) hide show
  1. inst.py +9 -6
  2. requirements.txt +1 -1
inst.py CHANGED
@@ -22,6 +22,11 @@ from separate import (
22
 
23
 
24
  def run_ensemble_models(audio_path, export_path, format=WAV, clean=True):
 
 
 
 
 
25
  start = datetime.now()
26
  process_datas = [mdx23c_8kfft_instvoc_hq_process_data, uvr_mdx_net_voc_ft_process_data,
27
  htdemucs_ft_process_data]
@@ -77,9 +82,6 @@ def run_ensemble_models(audio_path, export_path, format=WAV, clean=True):
77
  vocals_export_paths.append(str(vocals_path))
78
 
79
  # merge each model outputs
80
- vocals_final_path = Path(export_path) / f"{Path(audio_path).stem}.vocal.{format.lower()}"
81
- instrumental_final_path = Path(export_path) / f"{Path(audio_path).stem}.instrumental.{format.lower()}"
82
-
83
  ensemble(vocals_export_paths, vocals_final_path)
84
  ensemble(instrumental_export_paths, instrumental_final_path)
85
 
@@ -106,9 +108,10 @@ def uvr_job(song_id, platform='netease'):
106
  audio_file = f'{song_id}.m4a' if platform == 'youtube' else f'{song_id}.mp3'
107
  audio_path = os.path.join(audio_dir, audio_file)
108
 
109
- url = f"http://or.luotao.net/api/download_song?song_id={song_id}&platform={platform}"
110
- r = requests.get(url, allow_redirects=True)
111
- open(audio_path, 'wb').write(r.content)
 
112
 
113
  instrumental_path, vocals_path = run_ensemble_models(audio_file, audio_dir)
114
  return instrumental_path
 
22
 
23
 
24
  def run_ensemble_models(audio_path, export_path, format=WAV, clean=True):
25
+ vocals_final_path = Path(export_path) / f"{Path(audio_path).stem}.vocal.{format.lower()}"
26
+ instrumental_final_path = Path(export_path) / f"{Path(audio_path).stem}.instrumental.{format.lower()}"
27
+ if os.path.isfile(instrumental_final_path) and os.path.isfile(vocals_final_path):
28
+ return instrumental_final_path, vocals_final_path
29
+
30
  start = datetime.now()
31
  process_datas = [mdx23c_8kfft_instvoc_hq_process_data, uvr_mdx_net_voc_ft_process_data,
32
  htdemucs_ft_process_data]
 
82
  vocals_export_paths.append(str(vocals_path))
83
 
84
  # merge each model outputs
 
 
 
85
  ensemble(vocals_export_paths, vocals_final_path)
86
  ensemble(instrumental_export_paths, instrumental_final_path)
87
 
 
108
  audio_file = f'{song_id}.m4a' if platform == 'youtube' else f'{song_id}.mp3'
109
  audio_path = os.path.join(audio_dir, audio_file)
110
 
111
+ if not os.path.isfile(audio_path):
112
+ url = f"http://or.luotao.net/api/download_song?song_id={song_id}&platform={platform}"
113
+ r = requests.get(url, allow_redirects=True)
114
+ open(audio_path, 'wb').write(r.content)
115
 
116
  instrumental_path, vocals_path = run_ensemble_models(audio_file, audio_dir)
117
  return instrumental_path
requirements.txt CHANGED
@@ -1,7 +1,7 @@
1
  altgraph==0.17.3
2
  audioread==3.0.0
3
  certifi==2022.12.07
4
- cffi==1.15.1
5
  cryptography==3.4.6
6
  einops==0.6.0
7
  future==0.18.3
 
1
  altgraph==0.17.3
2
  audioread==3.0.0
3
  certifi==2022.12.07
4
+ cffi==1.16.0
5
  cryptography==3.4.6
6
  einops==0.6.0
7
  future==0.18.3