Python OpenAI Whisper FileNotFoundError when running a standalone created with PyInstaller

huangapple go评论78阅读模式
英文:

Python OpenAI Whisper FileNotFoundError when running a standalone created with PyInstaller

问题

我创建了一个使用OpenAI whisper库的小型Python程序。在我的虚拟环境中一切正常。

我使用PyInstaller生成了整个项目的.exe文件,但当我运行生成的文件时,出现以下错误:

线程启动时忽略的异常: <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] 没有这样的文件或目录: 'C:\\Users\\Div-o\\AppData\\Local\\Temp\\_MEI236562\\whisper\\assets\\mel_filters.npz'

我尝试将数据对象添加到由PyInstaller生成的.spec文件:

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

我甚至在同一文件中的EXE()中添加了recursive_copy_metadata="whisper",但问题仍然存在。

知道是什么原因导致了这个问题吗?

英文:

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?

答案1

得分: 1

我通过使用 faster-whisper 解决了它。

另外,你的数据应该大致如下:

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

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'),],
//...
)

huangapple
  • 本文由 发表于 2023年4月11日 05:56:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75981036.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定