Skip to content

Commit

Permalink
fix: Updated librosa to version 0.10.2
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tkyaji committed Jun 26, 2024
1 parent 1f1755f commit 330bdd9
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 41 deletions.
42 changes: 23 additions & 19 deletions infer/lib/uvr5_pack/lib_v5/spec_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def wave_to_spectrogram(
wave_left = np.asfortranarray(wave[0])
wave_right = np.asfortranarray(wave[1])

spec_left = librosa.stft(wave_left, n_fft, hop_length=hop_length)
spec_right = librosa.stft(wave_right, n_fft, hop_length=hop_length)
spec_left = librosa.stft(wave_left, n_fft=n_fft, hop_length=hop_length)
spec_right = librosa.stft(wave_right, n_fft=n_fft, hop_length=hop_length)

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

Expand Down Expand Up @@ -78,7 +78,7 @@ def run_thread(**kwargs):
kwargs={"y": wave_left, "n_fft": n_fft, "hop_length": hop_length},
)
thread.start()
spec_right = librosa.stft(wave_right, n_fft, hop_length=hop_length)
spec_right = librosa.stft(wave_right, n_fft=n_fft, hop_length=hop_length)
thread.join()

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

if d == len(mp.param["band"]): # high-end band
X_wave[d], _ = librosa.load(
mix_path, bp["sr"], False, dtype=np.float32, res_type=bp["res_type"]
mix_path,
sr=bp["sr"],
mono=False,
dtype=np.float32,
res_type=bp["res_type"]
)
y_wave[d], _ = librosa.load(
inst_path,
bp["sr"],
False,
sr=bp["sr"],
mono=False,
dtype=np.float32,
res_type=bp["res_type"],
)
else: # lower bands
X_wave[d] = librosa.resample(
X_wave[d + 1],
mp.param["band"][d + 1]["sr"],
bp["sr"],
orig_sr=mp.param["band"][d + 1]["sr"],
target_sr=bp["sr"],
res_type=bp["res_type"],
)
y_wave[d] = librosa.resample(
y_wave[d + 1],
mp.param["band"][d + 1]["sr"],
bp["sr"],
orig_sr=mp.param["band"][d + 1]["sr"],
target_sr=bp["sr"],
res_type=bp["res_type"],
)

Expand Down Expand Up @@ -401,8 +405,8 @@ def cmb_spectrogram_to_wave(spec_m, mp, extra_bins_h=None, extra_bins=None):
mp.param["mid_side_b2"],
mp.param["reverse"],
),
bp["sr"],
sr,
orig_sr=bp["sr"],
target_sr=sr,
res_type="sinc_fastest",
)
else: # mid
Expand All @@ -419,7 +423,7 @@ def cmb_spectrogram_to_wave(spec_m, mp, extra_bins_h=None, extra_bins=None):
),
)
# wave = librosa.core.resample(wave2, bp['sr'], sr, res_type="sinc_fastest")
wave = librosa.core.resample(wave2, bp["sr"], sr, res_type="scipy")
wave = librosa.resample(wave2, orig_sr=bp["sr"], target_sr=sr, res_type="scipy")

return wave.T

Expand Down Expand Up @@ -506,8 +510,8 @@ def ensembling(a, specs):
def stft(wave, nfft, hl):
wave_left = np.asfortranarray(wave[0])
wave_right = np.asfortranarray(wave[1])
spec_left = librosa.stft(wave_left, nfft, hop_length=hl)
spec_right = librosa.stft(wave_right, nfft, hop_length=hl)
spec_left = librosa.stft(wave_left, n_fft=nfft, hop_length=hl)
spec_right = librosa.stft(wave_right, n_fft=nfft, hop_length=hl)
spec = np.asfortranarray([spec_left, spec_right])

return spec
Expand Down Expand Up @@ -569,8 +573,8 @@ def istft(spec, hl):
if d == len(mp.param["band"]): # high-end band
wave[d], _ = librosa.load(
args.input[i],
bp["sr"],
False,
sr=bp["sr"],
mono=False,
dtype=np.float32,
res_type=bp["res_type"],
)
Expand All @@ -580,8 +584,8 @@ def istft(spec, hl):
else: # lower bands
wave[d] = librosa.resample(
wave[d + 1],
mp.param["band"][d + 1]["sr"],
bp["sr"],
orig_sr=mp.param["band"][d + 1]["sr"],
target_sr=bp["sr"],
res_type=bp["res_type"],
)

Expand Down
24 changes: 12 additions & 12 deletions infer/modules/uvr5/vr.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ def _path_audio_(
(
X_wave[d],
_,
) = librosa.core.load( # 理论上librosa读取可能对某些音频有bug,应该上ffmpeg读取,但是太麻烦了弃坑
) = librosa.load( # 理论上librosa读取可能对某些音频有bug,应该上ffmpeg读取,但是太麻烦了弃坑
music_file,
bp["sr"],
False,
sr=bp["sr"],
mono=False,
dtype=np.float32,
res_type=bp["res_type"],
)
if X_wave[d].ndim == 1:
X_wave[d] = np.asfortranarray([X_wave[d], X_wave[d]])
else: # lower bands
X_wave[d] = librosa.core.resample(
X_wave[d] = librosa.resample(
X_wave[d + 1],
self.mp.param["band"][d + 1]["sr"],
bp["sr"],
orig_sr=self.mp.param["band"][d + 1]["sr"],
target_sr=bp["sr"],
res_type=bp["res_type"],
)
# Stft of wave source
Expand Down Expand Up @@ -241,20 +241,20 @@ def _path_audio_(
(
X_wave[d],
_,
) = librosa.core.load( # 理论上librosa读取可能对某些音频有bug,应该上ffmpeg读取,但是太麻烦了弃坑
) = librosa.load( # 理论上librosa读取可能对某些音频有bug,应该上ffmpeg读取,但是太麻烦了弃坑
music_file,
bp["sr"],
False,
sr=bp["sr"],
mono=False,
dtype=np.float32,
res_type=bp["res_type"],
)
if X_wave[d].ndim == 1:
X_wave[d] = np.asfortranarray([X_wave[d], X_wave[d]])
else: # lower bands
X_wave[d] = librosa.core.resample(
X_wave[d] = librosa.resample(
X_wave[d + 1],
self.mp.param["band"][d + 1]["sr"],
bp["sr"],
orig_sr=self.mp.param["band"][d + 1]["sr"],
target_sr=bp["sr"],
res_type=bp["res_type"],
)
# Stft of wave source
Expand Down
4 changes: 2 additions & 2 deletions requirements-amd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ joblib>=1.1.0
numba==0.56.4
numpy==1.23.5
scipy
librosa==0.9.1
librosa==0.10.2
llvmlite==0.39.0
fairseq==0.12.2
faiss-cpu==1.7.3
Expand Down Expand Up @@ -41,7 +41,7 @@ pyworld==0.3.2
httpx
onnxruntime
onnxruntime-gpu
torchcrepe==0.0.20
torchcrepe==0.0.23
fastapi==0.88
ffmpy==0.3.1
python-dotenv>=1.0.0
Expand Down
4 changes: 2 additions & 2 deletions requirements-dml.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ joblib>=1.1.0
numba==0.56.4
numpy==1.23.5
scipy
librosa==0.9.1
librosa==0.10.2
llvmlite==0.39.0
fairseq==0.12.2
faiss-cpu==1.7.3
Expand Down Expand Up @@ -39,7 +39,7 @@ colorama>=0.4.5
pyworld==0.3.2
httpx
onnxruntime-directml
torchcrepe==0.0.20
torchcrepe==0.0.23
fastapi==0.88
ffmpy==0.3.1
python-dotenv>=1.0.0
Expand Down
4 changes: 2 additions & 2 deletions requirements-ipex.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ joblib>=1.1.0
numba==0.56.4
numpy==1.23.5
scipy
librosa==0.9.1
librosa==0.10.2
llvmlite==0.39.0
fairseq==0.12.2
faiss-cpu==1.7.3
Expand Down Expand Up @@ -45,7 +45,7 @@ pyworld==0.3.2
httpx
onnxruntime; sys_platform == 'darwin'
onnxruntime-gpu; sys_platform != 'darwin'
torchcrepe==0.0.20
torchcrepe==0.0.23
fastapi==0.88
ffmpy==0.3.1
python-dotenv>=1.0.0
Expand Down
4 changes: 2 additions & 2 deletions requirements-py311.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ joblib>=1.1.0
numba
numpy
scipy
librosa==0.9.1
librosa==0.10.2
llvmlite
fairseq @ git+https://github.com/One-sixth/fairseq.git
faiss-cpu
Expand Down Expand Up @@ -40,7 +40,7 @@ pyworld==0.3.2
httpx
onnxruntime; sys_platform == 'darwin'
onnxruntime-gpu; sys_platform != 'darwin'
torchcrepe==0.0.20
torchcrepe==0.0.23
fastapi==0.88
torchfcpe
ffmpy==0.3.1
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ joblib>=1.1.0
numba
numpy
scipy
librosa==0.9.1
librosa==0.10.2
llvmlite
fairseq
faiss-cpu
Expand Down Expand Up @@ -40,7 +40,7 @@ pyworld==0.3.2
httpx
onnxruntime; sys_platform == 'darwin'
onnxruntime-gpu; sys_platform != 'darwin'
torchcrepe==0.0.20
torchcrepe==0.0.23
fastapi==0.88
torchfcpe
ffmpy==0.3.1
Expand Down

0 comments on commit 330bdd9

Please sign in to comment.