I'm trying to open a AudioFile in Librosa. Trim it, and then modify it using pydub. This is my code:
sound = AudioSegment.from_file(filePath)
samples = sound.get_array_of_samples()
arr = np.array(samples)
print(type(arr))
print(arr)
# then modify samples...
y, index = librosa.effects.trim(arr)
The problem is that even if I follow the solution outlined here:
https://github.com/jiaaro/pydub/issues/289
I can't seem to use librosa's trim() function. It's giving me this error:
librosa.util.exceptions.ParameterError: Audio data must be floating-point
The reason for this, is that Librosa expects a floating point numpy array (and works with them), while pydub exports an integer array (which I convert to an np array). I don't know how to convert the numpy array between the 2.
I can export to file from Pydub and then load it with Librosa - but that seems like a very inefficient way of doing things.
Package Versions:
Librosa - 0.7.1.
Pydub - 0.23.1