Renovamen / Speech-Emotion-Recognition

Speech emotion recognition implemented in Keras (LSTM, CNN, SVM, MLP) | 语音情感识别
MIT License
967 stars 218 forks source link

predict.py not working with librosa feature extraction #38

Open soul0101 opened 2 years ago

soul0101 commented 2 years ago

When I try to use librosa for feature extraction I am met with the following error:

Traceback (most recent call last):
  File "C:\Users\91983\Documents\Speech-Emotion-Analyzer\Speech-Emotion-Recognition\predict.py", line 41, in <module>
    predict(config, audio_path, model)
  File "C:\Users\91983\Documents\Speech-Emotion-Analyzer\Speech-Emotion-Recognition\predict.py", line 29, in predict
    result = model.predict(test_feature)
  File "C:\Users\91983\Documents\Speech-Emotion-Analyzer\Speech-Emotion-Recognition\models\ml.py", line 62, in predict
    return self.model.predict(samples)
  File "C:\Users\91983\anaconda3\envs\face\lib\site-packages\sklearn\svm\_base.py", line 810, in predict
    y = super().predict(X)
  File "C:\Users\91983\anaconda3\envs\face\lib\site-packages\sklearn\svm\_base.py", line 433, in predict
    X = self._validate_for_predict(X)
  File "C:\Users\91983\anaconda3\envs\face\lib\site-packages\sklearn\svm\_base.py", line 611, in _validate_for_predict
    X = self._validate_data(
  File "C:\Users\91983\anaconda3\envs\face\lib\site-packages\sklearn\base.py", line 600, in _validate_data
    self._check_n_features(X, reset=reset)
  File "C:\Users\91983\anaconda3\envs\face\lib\site-packages\sklearn\base.py", line 400, in _check_n_features
    raise ValueError(
ValueError: X has 312 features, but SVC is expecting 1582 features as input.
Renovamen commented 2 years ago

Features extracted by librosa have 312 dimensions, while those extracted by Opensmile have 1582 dimensions. So I believe you are feeding librosa features (312) to the model trained on Opensmial features (1582). Try checking the feature_method and checkpoint_name in configs/svm.yaml.