ddlBoJack / emotion2vec

[ACL 2024] Official PyTorch code for extracting features and training downstream models with emotion2vec: Self-Supervised Pre-Training for Speech Emotion Representation
633 stars 46 forks source link

MaxRetryError #34

Closed sobek1886 closed 2 months ago

sobek1886 commented 4 months ago

When trying to run the prediction using the fine-tuned models through model scope

inference_pipeline = pipeline(
    task=Tasks.emotion_recognition,
    model="iic/emotion2vec_plus_large")  # Alternative: iic/emotion2vec_plus_seed, iic/emotion2vec_plus_base, iic/emotion2vec_plus_large and iic/emotion2vec_base_finetuned

rec_result = inference_pipeline('https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_zh.wav', output_dir="./outputs", granularity="utterance", extract_embedding=False)
print(rec_result)

I run into this error



The above exception was the direct cause of the following exception:

MaxRetryError                             Traceback (most recent call last)
Cell In[40], [line 7](vscode-notebook-cell:?execution_count=40&line=7)
      [1](vscode-notebook-cell:?execution_count=40&line=1) '''
      [2](vscode-notebook-cell:?execution_count=40&line=2) Using the emotion representation model
      [3](vscode-notebook-cell:?execution_count=40&line=3) rec_result only contains {'feats'}
...
--> [515](https://file+.vscode-resource.vscode-cdn.net/Users/piotr/Projects/SER-models/~/.pyenv/versions/3.8.18/envs/emo2vec/lib/python3.8/site-packages/urllib3/util/retry.py:515)     raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
    [517](https://file+.vscode-resource.vscode-cdn.net/Users/piotr/Projects/SER-models/~/.pyenv/versions/3.8.18/envs/emo2vec/lib/python3.8/site-packages/urllib3/util/retry.py:517) log.debug("Incremented Retry for (url='%s'): %r", url, new_retry)
    [519](https://file+.vscode-resource.vscode-cdn.net/Users/piotr/Projects/SER-models/~/.pyenv/versions/3.8.18/envs/emo2vec/lib/python3.8/site-packages/urllib3/util/retry.py:519) return new_retry

MaxRetryError: None: Max retries exceeded with url: https://www.modelscope.cn/api/v1/models/iic/emotion2vec_plus_large/repo?Revision=master&FilePath=emotion2vec+data.png (Caused by HTTPError('404 Client Error: Not Found for url: https://www.modelscope.cn/api/v1/models/iic/emotion2vec_plus_large/repo?Revision=master&FilePath=emotion2vec+data.png'))```
ddlBoJack commented 4 months ago

can you try to download the model first and then infer?

sobek1886 commented 4 months ago

Can I do that using the modelscope inference pipeline?

This did not work for me

inference_pipeline = pipeline(
    task=Tasks.emotion_recognition,
    model= '/Users/piotr/Projects/speech-emotion-recognition/emotion2vec_plus_large/model.pt')
Charles-yueyue831 commented 3 months ago

I have resolved this problem by downloading the emotion2vec model to local. Here's my code.

import os
import numpy as np

from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

mapper = ["angry", "disgust", "fear", "happy", "neutral", "other", "sad", "surprised", "unknown"]

current_directory = os.getcwd()
emotion2vec_path = rf"{current_directory}\emotion2vec"

audio_name = "yuexin"
audio_path = rf"{current_directory}\audio\{audio_name}.wav"

model_path="iic/emotion2vec_base_finetuned"
inference_pipeline = pipeline(
    task=Tasks.emotion_recognition,
    model=emotion2vec_path
)

rec_result = inference_pipeline(audio_path, granularity="utterance", extract_embedding=False)

max_emotion_score = np.argmax(rec_result[0]["scores"])
print(f"emotion: {mapper[max_emotion_score]}\tconfidence: {rec_result[0]['scores'][max_emotion_score]}")