I am trying to use librosa to extract audio features. I use a Raspberry Pi 4 running 32-bit RaspiOS running Python 3.8.7. When I try to run the code:
import librosa
import numpy as np
soundddata, fs = librosa.load('_a_3MB_sound_wav_file', sr=44100)
rolloff=librosa.feature.spectral_rolloff(y=ton, sr=fs)
the following error occures:
/usr/lib/python3.8/site-packages/librosa/util/decorators.py:88: UserWarning: PySoundFile failed. Trying audioread instead.
return f(*args, **kwargs)
Traceback (most recent call last):
File "/home/pi/Documents/librostest.py", line 20, in <module>
rolloff=librosa.feature.spectral_rolloff(y=ton, sr=fs)
File "/usr/lib/python3.8/site-packages/librosa/util/decorators.py", line 88, in inner_f
return f(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/librosa/feature/spectral.py", line 694, in spectral_rolloff
S, n_fft = _spectrogram(
File "/usr/lib/python3.8/site-packages/librosa/core/spectrum.py", line 2553, in _spectrogram
stft(
File "/usr/lib/python3.8/site-packages/librosa/util/decorators.py", line 88, in inner_f
return f(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/librosa/core/spectrum.py", line 234, in stft
y_frames = util.frame(y, frame_length=n_fft, hop_length=hop_length)
File "/usr/lib/python3.8/site-packages/librosa/util/decorators.py", line 88, in inner_f
return f(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/librosa/util/utils.py", line 196, in frame
xw = as_strided(
File "/usr/lib/python3.8/site-packages/numpy/lib/stride_tricks.py", line 105, in as_strided
array = np.asarray(DummyArray(interface, base=x))
ValueError: array is too big; `arr.size * arr.dtype.itemsize` is larger than the maximum possible size.
The array is somehow to large. The program is trying to create 'view'(don't really udnerstand what that is?) inside the array and therefore creates a DummyArray of the size of the real array if I understand correctly(??).
On windows running python 64bit this works like a charm. So I think the 32bit Python version is the problem. Is there any other solution than installing a 64bit OS?
Best regards, BlackOut
According to me, it is difficult to allocate memory in a 32bit system, and when the Librosa library is segmenting the audio into frames, the frame array size turns out to be big to handle. Try implementing the frame segmentation with numpy library after padding the signal. It is working, although taking some time.