1、系统参数
Mac mini,Apple M4 Pro,Sequoia 15.5
2、安装相关配置
配置1,安装ffmpeg
在安装ffmpeg之前,先在系统内安装Homebrew,不然会提示:
zsh:command not found brew
安装Homebrew,操作如下
运行官方脚本,在终端中粘贴并回车运行:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
安装完成后,需要确保环境变量设置正确
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
验证,Homebrew是否安装成功
在macOS上利用homebrew安装ffmpeg还是有问题,提示
Error: No such file or directory @ rb_sysopen - |Users/linql/Library/Caches/Homebrew/downloads/d6791c82944fcf9ad 1bcecb968742b1c2970f0daf319ecc9c4233e24ef90f5f0--rav1e-0.8.1.arm64_sequoia.bottle.tar.gz
换手动安装
(1)在ffmpeg官网上下载
https://ffmpeg.org/download.html#build-mac
下载完成后,解压。
unzip ffmpeg-7.1.1.zip
sudo mv ffmpeg /usr/local/bin/
sudo chmod +x /usr/local/bin/ffmpeg
ffmpeg -version
配置2,安装rust
在终端输入并回车
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
这会启动一个安装向导,按提示选择:
输入 1(默认)表示安装 stable(稳定)版本
自动配置环境变量(一般无需手动修改)
安装完成后,重启终端或运行以下命令使 Rust 生效:
source $HOME/.cargo/env
验证是否安装成功
rustc --version
cargo --version
配置3,安装Whisper
(1)创建虚拟环境,基于Conda
conda create -n whisper python=3.10 -y
(2)激活虚拟环境
conda activate whisper
(3)安装whisper
pip install -U openai-whisper -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
安装依赖,因Whisper 依赖 PyTorch
pip install torch torchvision torchaudio -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
验证whisper是否安装成功
whisper --help
测试whisper
whisper your-audio-file.mp3 --model base --language Chinese