229 - 《用 Whisper + Deepl 给 Youtube 视频加中文字幕》
发布于 2022年12月11日
跑通了的流程,踩了几个小坑,简单做下笔记。不仅适用于 Youtube,可以给任意语言的视频加中文字幕。我是在 Win 上跑的,因为可以利用显卡用 GPU 跑,比 CPU 跑快太多了。
1、安装 Whisper。
git 配代理。(安装 whisper 不开会报错)
git config --global http.proxy http://127.0.0.1:7890
安装 scoop。(用来安装 ffmpeg)
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
irm get.scoop.sh -outfile 'install.ps1'
.\install.ps1 'D:\Work\Scoop' -RunAsAdmin
安装 ffmpeg。(whisper 依赖他)
scoop install ffmpeg
安装 Python 3.9。(不能安装最新的 3.11,有些库不兼容)
scoop bucket add versions
scoop install python39
安装 whisper。
pip install git+https://github.com/openai/whisper.git
whisper -h
安装带 cuda 版的 torch。(默认是不带 cuda 版的,只能用 cpu 跑,慢地很)
pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu116
2、下载 Youtube 视频。
我是用 Downie 下的,可以选择视频或音频。我是两个都下一份,然后把音频的给 whisper 转换,会快好多。
3、提取英文字幕。
whisper ./f