Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MP3 loading using librosa return empty data when start_time metadata is 0

I have a dataset of thousands of bird chirps audios (mp3) and I try to load them using librosa.load()

MP3 files are loaded but, most of the time, resulting data is an empty np.ndarray instead of a np.ndarray filled with floats

Using pydub.utils.mediainfo() I wanted to compare MP3 metadata. This function return information such as sampling_rate, codec, duration, bitrate, start_time, ...

I found out that start_time information was the explanation of failed loadings. Indeed, every file where start_time is 0 are not loaded correctly. At the contrary every file where start_time is over 0 are loaded correctly.

I have no problem listening every single MP3 file using VLC audio player.

Is there anything that can explain this behavior? Is there any solution to make these loadings succeed?

like image 937
Clément Avatar asked Mar 26 '26 08:03

Clément


1 Answers

I had the same very specific error. The error message I was getting was "Input signal length=0 is too small to resample from 48000->22050", which was because librosa was loading empty arrays in the same circumstances as you mention.

My workaround for it was to specify a duration parameter, in this case I set it to the full length of the file:

dur = pydub.utils.mediainfo(filepath)["duration"]

data, sr = librosa.load(filepath,  duration = math.floor(float(dur)))

This solved the empty arrays for me

like image 182
Fenna ten Haaf Avatar answered Mar 28 '26 20:03

Fenna ten Haaf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!