Fixes #3178 - Librosa requires 1-dimensional array for mono samples
This commit is contained in:
parent
38f6afdba8
commit
ecbdf46940
|
@ -349,8 +349,13 @@ class Resample(SampleAugmentation):
|
||||||
audio = sample.audio
|
audio = sample.audio
|
||||||
orig_len = len(audio)
|
orig_len = len(audio)
|
||||||
audio = np.swapaxes(audio, 0, 1)
|
audio = np.swapaxes(audio, 0, 1)
|
||||||
audio = resample(audio, sample.audio_format.rate, rate)
|
if audio.shape[0] < 2:
|
||||||
audio = resample(audio, rate, sample.audio_format.rate)
|
# since v0.8 librosa enforces a shape of (samples,) instead of (channels, samples) for mono samples
|
||||||
|
resampled = resample(audio[0], sample.audio_format.rate, rate)
|
||||||
|
audio[0] = resample(resampled, rate, sample.audio_format.rate)[:orig_len]
|
||||||
|
else:
|
||||||
|
audio = resample(audio, sample.audio_format.rate, rate)
|
||||||
|
audio = resample(audio, rate, sample.audio_format.rate)
|
||||||
audio = np.swapaxes(audio, 0, 1)[0:orig_len]
|
audio = np.swapaxes(audio, 0, 1)[0:orig_len]
|
||||||
sample.audio = audio
|
sample.audio = audio
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue