Stage-Whisper安装及转录报错求助(macOS Mojave环境)
解决Stage-Whisper在macOS Mojave 10.14.6下的转录失败问题
一、修复Poetry找不到pyproject.toml的问题
- 必须在Stage-Whisper仓库根目录执行命令,
pyproject.toml文件存放在仓库根路径下 - 若直接执行命令仍报错,手动指定项目路径:
poetry --directory /Users/administrator/Desktop/Stage-Whisper run python stagewhisper --input /path/to/audio/file.mp3
- 或先进入仓库根目录再操作:
cd /Users/administrator/Desktop/Stage-Whisper poetry run python stagewhisper --input /path/to/audio/file.mp3
二、适配macOS Mojave的依赖版本限制
Homebrew 4.x对旧系统支持有限,需安装兼容版本的依赖:
- Node.js:安装支持Mojave的16.x版本(18+版本不再兼容Mojave)
brew install node@16 echo 'export PATH="/usr/local/opt/node@16/bin:$PATH"' >> ~/.zshrc # 若用bash则写入~/.bash_profile source ~/.zshrc node -v # 确认版本为16.x
- Python:安装Homebrew支持Mojave的最高版本3.9
brew install python@3.9 echo 'export PATH="/usr/local/opt/python@3.9/bin:$PATH"' >> ~/.zshrc source ~/.zshrc python3 -V # 确认版本为3.9.x
- Rust:通过rustup安装兼容版本,避免Homebrew最新版的兼容性问题
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh # 按终端提示完成安装后重启终端 rustc --version
- FFmpeg:安装支持Mojave的4.x版本
brew install ffmpeg@4 echo 'export PATH="/usr/local/opt/ffmpeg@4/bin:$PATH"' >> ~/.zshrc source ~/.zshrc ffmpeg -version
三、解决Whisper脚本运行失败(退出码1)的问题
退出码1通常由Whisper依赖缺失或环境不兼容导致,按以下步骤排查:
- 单独测试Whisper CLI:脱离Electron环境,直接用Poetry运行Whisper,获取详细错误信息:
cd /Users/administrator/Desktop/Stage-Whisper poetry run whisper /Users/administrator/Library/Application\ Support/stagewhisper/store/audio/harvard.mp3 --verbose true --output_dir /tmp/test-whisper --task translate --model base --device cpu
终端会输出具体错误(如模型下载失败、Python依赖缺失等),针对性修复。
2. 安装兼容的Whisper依赖:针对Python 3.9和Mojave,安装适配版本的torch与whisper:
cd /Users/administrator/Desktop/Stage-Whisper poetry add torch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 --python 3.9 poetry add openai-whisper==20230314
- 重新构建Electron原生绑定:更新Python依赖后,需重新构建native模块:
cd /Users/administrator/Desktop/Stage-Whisper yarn install npx electron-rebuild -f -w better-sqlite3 yarn dev
- 检查Whisper模型文件:base模型默认存储在
~/.cache/whisper/,若自动下载失败,手动将base.pt文件放入该目录,并确保文件权限为当前用户可读。
四、验证流程
- 先在Poetry环境中成功完成音频转录测试
- 启动Electron程序
yarn dev - 上传音频测试转录功能,观察终端日志确认是否正常运行
内容的提问来源于stack exchange,提问作者Tingtong
相关产品推荐
相关产品推荐

