导入OpenAI的Whisper后无法使用PyInstaller创建.exe

问题描述 投票:0回答:3

我正在尝试创建一个与 OpenAI 的 Whisper 配合使用的小程序。然后,我使用 PyInstaller (auto-py-to-exe) 将 Python 脚本构建到 .exe 文件。当我运行 .exe 文件时,出现以下错误:

Traceback (most recent call last):
  File "transformers\utils\versions.py", line 108, in require_version
  File "importlib\metadata\__init__.py", line 996, in version
  File "importlib\metadata\__init__.py", line 969, in distribution
  File "importlib\metadata\__init__.py", line 548, in from_name
importlib.metadata.PackageNotFoundError: No package metadata was found for tqdm

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Whisper.py", line 2, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
  File "whisper\__init__.py", line 12, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
  File "whisper\decoding.py", line 11, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
  File "whisper\tokenizer.py", line 8, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
  File "transformers\__init__.py", line 30, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
  File "transformers\dependency_versions_check.py", line 41, in <module>
  File "transformers\utils\versions.py", line 123, in require_version_core
  File "transformers\utils\versions.py", line 110, in require_version
importlib.metadata.PackageNotFoundError: No package metadata was found for The 'tqdm>=4.27' distribution was not found and is required by this application.
Try: pip install transformers -U or pip install -e '.[dev]' if you're working with git main
[10092] Failed to execute script 'Whisper' due to unhandled exception!

这是我的程序的源代码:

import whisper
import os
from timeit import default_timer as timer

start = timer()

audio_file = "MyAudioFile.wav"

model = whisper.load_model("small")

options = {"language": "de"}

res = model.transcribe(f"C:/Users/Username/Desktop/Transcribe/{audio_file}", **options)

end = timer()

os.system("cls")


print(res["text"])
print("\nFinished in " + str(end-start) + " seconds!")
input("Press ENTER to close the program.")

当我从控制台或 VS code 运行 Python 脚本时,一切正常。但是,不幸的是,当我将其作为 .exe 启动时,情况并非如此。

我已经尝试用pip重新安装tqdm等软件包,但没有成功。

我感谢任何帮助和提示!

python python-3.x pyinstaller auto-py-to-exe openai-whisper
3个回答
3
投票

似乎

.exe
缺少
tqdm
依赖项。在 pyinstaller 中有一个
--hidden-import
选项,根据 auto-py-to-exe
官方博客
,您必须打开高级选项卡并找到
--hidden-import
输入,并在您的情况下包括
tqdm


2
投票

我的问题通过添加解决了

--recursive-copy-metadata "openai-whisper"

PyInstaller 命令。


0
投票

你能帮我创建耳语库吗? 你能分享一下你所做的过程吗?

我试图在没有Python的情况下在不同的计算机上运行耳语,但无论如何它都不起作用

© www.soinside.com 2019 - 2024. All rights reserved.