音频转文字-在线工具包及使用记录
资料来源:https://zhuanlan.zhihu.com/p/269603431(多种方案)
视频教程:https://www.youtube.com/watch?v=L1H5ov4WTBg
https://github.com/openai/whisper
// 创建虚拟环境
python -m venv myvnev// 激活虚拟环境
source myvnev/bin/activatepip install --upgrade pip
升级pip,在虚拟环境安装package的工具安装openai-whisper
pip install -U openai-whisper -i https://pypi.tuna.tsinghua.edu.cn/simple// 安装brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"// 安装ffmpeg
brew install ffmpeg
// 安装setuptools-rust
pip install setuptools-rust
pip show setuptools-rust 检测// 编译 替换xx-filePath
whisper xx-filePath --language Chinese --model base --device mps --output_format srt --output_dir ~/Desktop// --device mps 去掉去执行CPU
whisper xx-filePath --language Chinese --model base --output_format srt --output_dir ~/Desktop
https://github.com/ggml-org/whisper.cpp
这个只支持wav格式,可能更快吧
sh ./models/download-ggml-model.sh large-v3-turbo// 模型下载地址:
https://huggingface.co/ggerganov/whisper.cpp/tree/main// 验证执行命令(只能识别wav文件,需要ffmpeg提前转译):
./build/bin/whisper-cli -m models/ggml-large-v3.bin -f samples/jfk.wav -osrt ~/Desktop/large-v3.srt// ffmpeg转wav
ffmpeg -i input.mp3 -ar 16000 -ac 1 -c:a pcm_s16le output.wav