The emotion2vec+ models are foundation models for Speech Emotion Recognition (SER). They can classify audio into 9 specific emotion classes.
When using AutoModel.generate() with an emotion2vec+ model:
- Set
extract_embedding=False to get the 9-class emotion labels and scores. - Set
extract_embedding=True to get both the emotion labels/scores and the underlying features.
9-class emotion mapping:
0: angry, 1: disgusted, 2: fearful, 3: happy, 4: neutral, 5: other, 6: sad, 7: surprised, 8: unknown
Model IDs:
iic/emotion2vec_plus_seediic/emotion2vec_plus_baseiic/emotion2vec_plus_largeiic/emotion2vec_base_finetuned (Jan. 2024 release)
from funasr import AutoModel
# Use an emotion2vec+ model for 9-class emotion recognition
model_id = "iic/emotion2vec_plus_large"
model = AutoModel(
model=model_id,
hub="ms", # "ms" or "modelscope" for China mainland users; "hf" or "huggingface" for other overseas users
)
wav_file = f"{model.model_path}/example/test.wav"
# extract_embedding=False returns {'feats', 'labels', 'scores'}
rec_result = model.generate(wav_file, output_dir="./outputs", granularity="utterance", extract_embedding=False)
print(rec_result)