Skip to content

Commit 330bdd9

Browse files
committed
fix: Updated librosa to version 0.10.2
There is a bug in librosa 0.9.1. librosa/librosa#1594 As a result, an error occurs when executing the "Vocals/Accompaniment Separation & Reverberation Removal" function. To address this issue, librosa has been upgraded to version 0.10.2. Additionally, torchcrepe has been upgraded due to its dependency on librosa.
1 parent 1f1755f commit 330bdd9

File tree

7 files changed

+45
-41
lines changed

7 files changed

+45
-41
lines changed

infer/lib/uvr5_pack/lib_v5/spec_utils.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def wave_to_spectrogram(
4343
wave_left = np.asfortranarray(wave[0])
4444
wave_right = np.asfortranarray(wave[1])
4545

46-
spec_left = librosa.stft(wave_left, n_fft, hop_length=hop_length)
47-
spec_right = librosa.stft(wave_right, n_fft, hop_length=hop_length)
46+
spec_left = librosa.stft(wave_left, n_fft=n_fft, hop_length=hop_length)
47+
spec_right = librosa.stft(wave_right, n_fft=n_fft, hop_length=hop_length)
4848

4949
spec = np.asfortranarray([spec_left, spec_right])
5050

@@ -78,7 +78,7 @@ def run_thread(**kwargs):
7878
kwargs={"y": wave_left, "n_fft": n_fft, "hop_length": hop_length},
7979
)
8080
thread.start()
81-
spec_right = librosa.stft(wave_right, n_fft, hop_length=hop_length)
81+
spec_right = librosa.stft(wave_right, n_fft=n_fft, hop_length=hop_length)
8282
thread.join()
8383

8484
spec = np.asfortranarray([spec_left, spec_right])
@@ -230,26 +230,30 @@ def cache_or_load(mix_path, inst_path, mp):
230230

231231
if d == len(mp.param["band"]): # high-end band
232232
X_wave[d], _ = librosa.load(
233-
mix_path, bp["sr"], False, dtype=np.float32, res_type=bp["res_type"]
233+
mix_path,
234+
sr=bp["sr"],
235+
mono=False,
236+
dtype=np.float32,
237+
res_type=bp["res_type"]
234238
)
235239
y_wave[d], _ = librosa.load(
236240
inst_path,
237-
bp["sr"],
238-
False,
241+
sr=bp["sr"],
242+
mono=False,
239243
dtype=np.float32,
240244
res_type=bp["res_type"],
241245
)
242246
else: # lower bands
243247
X_wave[d] = librosa.resample(
244248
X_wave[d + 1],
245-
mp.param["band"][d + 1]["sr"],
246-
bp["sr"],
249+
orig_sr=mp.param["band"][d + 1]["sr"],
250+
target_sr=bp["sr"],
247251
res_type=bp["res_type"],
248252
)
249253
y_wave[d] = librosa.resample(
250254
y_wave[d + 1],
251-
mp.param["band"][d + 1]["sr"],
252-
bp["sr"],
255+
orig_sr=mp.param["band"][d + 1]["sr"],
256+
target_sr=bp["sr"],
253257
res_type=bp["res_type"],
254258
)
255259

@@ -401,8 +405,8 @@ def cmb_spectrogram_to_wave(spec_m, mp, extra_bins_h=None, extra_bins=None):
401405
mp.param["mid_side_b2"],
402406
mp.param["reverse"],
403407
),
404-
bp["sr"],
405-
sr,
408+
orig_sr=bp["sr"],
409+
target_sr=sr,
406410
res_type="sinc_fastest",
407411
)
408412
else: # mid
@@ -419,7 +423,7 @@ def cmb_spectrogram_to_wave(spec_m, mp, extra_bins_h=None, extra_bins=None):
419423
),
420424
)
421425
# wave = librosa.core.resample(wave2, bp['sr'], sr, res_type="sinc_fastest")
422-
wave = librosa.core.resample(wave2, bp["sr"], sr, res_type="scipy")
426+
wave = librosa.resample(wave2, orig_sr=bp["sr"], target_sr=sr, res_type="scipy")
423427

424428
return wave.T
425429

@@ -506,8 +510,8 @@ def ensembling(a, specs):
506510
def stft(wave, nfft, hl):
507511
wave_left = np.asfortranarray(wave[0])
508512
wave_right = np.asfortranarray(wave[1])
509-
spec_left = librosa.stft(wave_left, nfft, hop_length=hl)
510-
spec_right = librosa.stft(wave_right, nfft, hop_length=hl)
513+
spec_left = librosa.stft(wave_left, n_fft=nfft, hop_length=hl)
514+
spec_right = librosa.stft(wave_right, n_fft=nfft, hop_length=hl)
511515
spec = np.asfortranarray([spec_left, spec_right])
512516

513517
return spec
@@ -569,8 +573,8 @@ def istft(spec, hl):
569573
if d == len(mp.param["band"]): # high-end band
570574
wave[d], _ = librosa.load(
571575
args.input[i],
572-
bp["sr"],
573-
False,
576+
sr=bp["sr"],
577+
mono=False,
574578
dtype=np.float32,
575579
res_type=bp["res_type"],
576580
)
@@ -580,8 +584,8 @@ def istft(spec, hl):
580584
else: # lower bands
581585
wave[d] = librosa.resample(
582586
wave[d + 1],
583-
mp.param["band"][d + 1]["sr"],
584-
bp["sr"],
587+
orig_sr=mp.param["band"][d + 1]["sr"],
588+
target_sr=bp["sr"],
585589
res_type=bp["res_type"],
586590
)
587591

infer/modules/uvr5/vr.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,20 @@ def _path_audio_(
6060
(
6161
X_wave[d],
6262
_,
63-
) = librosa.core.load( # 理论上librosa读取可能对某些音频有bug,应该上ffmpeg读取,但是太麻烦了弃坑
63+
) = librosa.load( # 理论上librosa读取可能对某些音频有bug,应该上ffmpeg读取,但是太麻烦了弃坑
6464
music_file,
65-
bp["sr"],
66-
False,
65+
sr=bp["sr"],
66+
mono=False,
6767
dtype=np.float32,
6868
res_type=bp["res_type"],
6969
)
7070
if X_wave[d].ndim == 1:
7171
X_wave[d] = np.asfortranarray([X_wave[d], X_wave[d]])
7272
else: # lower bands
73-
X_wave[d] = librosa.core.resample(
73+
X_wave[d] = librosa.resample(
7474
X_wave[d + 1],
75-
self.mp.param["band"][d + 1]["sr"],
76-
bp["sr"],
75+
orig_sr=self.mp.param["band"][d + 1]["sr"],
76+
target_sr=bp["sr"],
7777
res_type=bp["res_type"],
7878
)
7979
# Stft of wave source
@@ -241,20 +241,20 @@ def _path_audio_(
241241
(
242242
X_wave[d],
243243
_,
244-
) = librosa.core.load( # 理论上librosa读取可能对某些音频有bug,应该上ffmpeg读取,但是太麻烦了弃坑
244+
) = librosa.load( # 理论上librosa读取可能对某些音频有bug,应该上ffmpeg读取,但是太麻烦了弃坑
245245
music_file,
246-
bp["sr"],
247-
False,
246+
sr=bp["sr"],
247+
mono=False,
248248
dtype=np.float32,
249249
res_type=bp["res_type"],
250250
)
251251
if X_wave[d].ndim == 1:
252252
X_wave[d] = np.asfortranarray([X_wave[d], X_wave[d]])
253253
else: # lower bands
254-
X_wave[d] = librosa.core.resample(
254+
X_wave[d] = librosa.resample(
255255
X_wave[d + 1],
256-
self.mp.param["band"][d + 1]["sr"],
257-
bp["sr"],
256+
orig_sr=self.mp.param["band"][d + 1]["sr"],
257+
target_sr=bp["sr"],
258258
res_type=bp["res_type"],
259259
)
260260
# Stft of wave source

requirements-amd.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ joblib>=1.1.0
33
numba==0.56.4
44
numpy==1.23.5
55
scipy
6-
librosa==0.9.1
6+
librosa==0.10.2
77
llvmlite==0.39.0
88
fairseq==0.12.2
99
faiss-cpu==1.7.3
@@ -41,7 +41,7 @@ pyworld==0.3.2
4141
httpx
4242
onnxruntime
4343
onnxruntime-gpu
44-
torchcrepe==0.0.20
44+
torchcrepe==0.0.23
4545
fastapi==0.88
4646
ffmpy==0.3.1
4747
python-dotenv>=1.0.0

requirements-dml.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ joblib>=1.1.0
22
numba==0.56.4
33
numpy==1.23.5
44
scipy
5-
librosa==0.9.1
5+
librosa==0.10.2
66
llvmlite==0.39.0
77
fairseq==0.12.2
88
faiss-cpu==1.7.3
@@ -39,7 +39,7 @@ colorama>=0.4.5
3939
pyworld==0.3.2
4040
httpx
4141
onnxruntime-directml
42-
torchcrepe==0.0.20
42+
torchcrepe==0.0.23
4343
fastapi==0.88
4444
ffmpy==0.3.1
4545
python-dotenv>=1.0.0

requirements-ipex.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ joblib>=1.1.0
77
numba==0.56.4
88
numpy==1.23.5
99
scipy
10-
librosa==0.9.1
10+
librosa==0.10.2
1111
llvmlite==0.39.0
1212
fairseq==0.12.2
1313
faiss-cpu==1.7.3
@@ -45,7 +45,7 @@ pyworld==0.3.2
4545
httpx
4646
onnxruntime; sys_platform == 'darwin'
4747
onnxruntime-gpu; sys_platform != 'darwin'
48-
torchcrepe==0.0.20
48+
torchcrepe==0.0.23
4949
fastapi==0.88
5050
ffmpy==0.3.1
5151
python-dotenv>=1.0.0

requirements-py311.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ joblib>=1.1.0
22
numba
33
numpy
44
scipy
5-
librosa==0.9.1
5+
librosa==0.10.2
66
llvmlite
77
fairseq @ git+https://github.com/One-sixth/fairseq.git
88
faiss-cpu
@@ -40,7 +40,7 @@ pyworld==0.3.2
4040
httpx
4141
onnxruntime; sys_platform == 'darwin'
4242
onnxruntime-gpu; sys_platform != 'darwin'
43-
torchcrepe==0.0.20
43+
torchcrepe==0.0.23
4444
fastapi==0.88
4545
torchfcpe
4646
ffmpy==0.3.1

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ joblib>=1.1.0
22
numba
33
numpy
44
scipy
5-
librosa==0.9.1
5+
librosa==0.10.2
66
llvmlite
77
fairseq
88
faiss-cpu
@@ -40,7 +40,7 @@ pyworld==0.3.2
4040
httpx
4141
onnxruntime; sys_platform == 'darwin'
4242
onnxruntime-gpu; sys_platform != 'darwin'
43-
torchcrepe==0.0.20
43+
torchcrepe==0.0.23
4444
fastapi==0.88
4545
torchfcpe
4646
ffmpy==0.3.1

0 commit comments

Comments
 (0)