Reputation: 127
I am trying to use Librosa library(Python 3.x) for the first time to extract features from multiple audio files which are in wav format. I am facing a issue where it says the data should be of type numpy.ndarray even when it is of that type. Here is my code:
mylist is a list of all the wav audio files in my directory.
import os
import librosa
mylist= os.listdir('RawData/')
for y in mylist:
X, sample_rate = librosa.load('RawData/'+y, res_type='kaiser_fast')
print(type(sample_rate))
sample_rate = np.array(sample_rate)
print(type(X))
print(type(sample_rate))
mfccs = np.mean(librosa.feature.mfcc(x=X, sr=sample_rate, n_mfcc=40),axis=0)
And this is the output and the error that pops up:
class 'int'
class 'numpy.ndarray'
class 'numpy.ndarray'
ParameterError Traceback (most recent call last)
ipython-input-23-817ec793d6c4 in module()
7 mfccs = np.mean(librosa.feature.mfcc(x=X,
8 sr=sample_rate,
----> 9 n_mfcc=40),
10 axis=0)
.
.
.
ParameterError: data must be of type numpy.ndarray
Any help is appreciated
Upvotes: 1
Views: 8149
Reputation: 1455
you perhaps meant to say librosa.feature.mfcc(y=X,
https://librosa.github.io/librosa/generated/librosa.feature.mfcc.html
Upvotes: 1