Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No such file or directory: 'ffmpeg' on MacOS in Python

I am using MacOS (Apple Silicon) and I am trying to use the whisper module from OpenAI in Python. My code is this:

import whisper

file_path = "4547.mp3"
model = whisper.load_model("base")

result = model.transcribe(file_path)
print(result["text"])

When running that code I get the error:

FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg': 'ffmpeg'

I think it is because Python is looking in the wrong folder for ffmpeg and therefore can't find it, but I don't know how to fix that if that is the issue.

I have installed homebrew and used the command 'brew install ffmpeg' and it has successfully installed with no errors. I have tried uninstalling ffmpeg and reinstalling it. I have tried uninstalling open_whisper but to no avail.

like image 341
Harper Bledsoe Avatar asked Mar 03 '26 17:03

Harper Bledsoe


1 Answers

In Mac OS Sonoma 14.1.1 with Apple Silicon M1, I installed ffmpeg in the terminal with brew install ffmpeg and the following script:

import whisper
import ssl

# use the line from below to avoid verification of certificate
ssl._create_default_https_context = ssl._create_unverified_context

model = whisper.load_model("base")
result = model.transcribe("./sample.mp3")

with open("sample.txt", "w") as f:
    f.write(result["text"])
like image 83
abautista Avatar answered Mar 05 '26 07:03

abautista