Search code examples
pythonpyinstalleropenai-whisper

Python OpenAI Whisper FileNotFoundError when running a standalone created with PyInstaller


I made a small Python program that uses OpenAI whisper's library. Everything works fine in my virtual environment.

I generated a .exe of the whole thing with PyInstaller, but when I run the resulting file, I get the following error:

Exception ignored in thread started by: <function start_interpretor at 0x000001F9EC80F430>
Traceback (most recent call last):
  File "interpretor.py", line 67, in start_interpretor
  File "transcriber.py", line 125, in run_transcription
  File "transcriber.py", line 88, in progress_transcription
  File "whisper\transcribe.py", line 121, in transcribe
  File "whisper\audio.py", line 141, in log_mel_spectrogram
  File "whisper\audio.py", line 94, in mel_filters
  File "numpy\lib\npyio.py", line 405, in load
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Div-o\\AppData\\Local\\Temp\\_MEI236562\\whisper\\assets\\mel_filters.npz'

I have tried to add the datas object to the .spec file generated by PyInstaller:

a = Analysis(
//...
datas=[('.venv/Lib/site-packages/whisper/assets/mel_filters.npz', '.venv/Lib/site-packages/whisper/assets'),],
//...
)

I even added recursive_copy_metadata="whisper" to the EXE() in the same file, but the issue persists.

Any idea what is causing that?


Solution

  • I solved it by using faster-whisper.

    Also your datas should probably look like this:

    a = Analysis(
    //...
    datas=[('.venv\\Lib\\site-packages\\whisper\\assets\\mel_filters.npz', '\\whisper\\assets'),],
    //...
    )