(Audio classification pipeline) ValueError: ffmpeg was not found but is required to load audio files from filename

Greetings Huggingface community!

I have been following the examples in the docs, for the example of audio pipeline under the ‘Pipelines for inference’ tutorial, I tried out the follwing example:

from transformers import pipeline
audio_classifier = pipeline(task='audio-classification',model = \
                            "ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition")
audio_classifier("1.wav")  # A .wav file stored locally in the same directory

I get the following error

ValueError: ffmpeg was not found but is required to load audio files from filename

I’m running all of this under a conda environment and made sure that ffmpeg was installed.

Any assistance would be greatly appreciated

1 Like

I have the same issue, any update on that?

For anyone encountering this issue, I found a solution. Apparently python ffmpeg-python package doesn’t install ffmpeg itself so you have to install it manually on your machine Download FFmpeg

1 Like

@Avienir Hey, I am facing the same issue in Windows 10. So I downsload the ffmpeg and where should I place the files? Could you please help me?

You can use choco in windows10,if you have,I use choco install ffmpeg solve the problem.

Installing ffmpeg also worked for me. I’m a mac user, and used brew to install ffmpeg.

$ brew install ffmpeg

1 Like

I fixed it in Windows 11 by following steps:

  1. Uninstall ffmpeg
  • pip3 uninstall ffmpeg
  • pip3 uninstall ffmpeg-python
  • pip uninstall ffmpeg
  • pip uninstall ffmpeg-python
  • brew uninstall ffmpeg
  1. Install ffmpeg binary using this guide.

  2. Install ffmpeg for python

  • pip3 install ffmpeg
  • pip3 install ffmpeg-python
  • pip install ffmpeg
  • pip install ffmpeg-python

That’s all it should work :slight_smile:

4 Likes

Also useful on win10

I’m on Visual Studio Code environment, and I have the same issue.
I did all the steps asked by jb-infivr, but I have the same error.
Thank you very much for the work :muscle:

Edit :
I tried to modify the code using this :
display(classifier(minds[0]['audio']['array']))

I don’t have errors anymore, but the output seems to not have a good answer :

[{'score': 0.9950760006904602, 'label': 'app_error'},
 {'score': 0.0014388954732567072, 'label': 'address'},
 {'score': 0.00135265220887959, 'label': 'high_value_payment'},
 {'score': 0.000736881687771529, 'label': 'card_issues'},
 {'score': 0.0003506052598822862, 'label': 'abroad'}]

The expected result :

[
    {"score": 0.9631525278091431, "label": "pay_bill"},
    {"score": 0.02819698303937912, "label": "freeze"},
    {"score": 0.0032787492964416742, "label": "card_issues"},
    {"score": 0.0019414445850998163, "label": "abroad"},
    {"score": 0.0008378693601116538, "label": "high_value_payment"},
]

If you have any idea, I’m interested !

Thank you :slight_smile: