当前位置:AIGC资讯 > AIGC > 正文

Windows部署语音转文字项目_Whisper

Windows部署语音转文字项目_Whisper

一、前置安装准备

Github源仓库,Whisper

下载安装whisper及其依赖项
官方有两种部署方法,一种是通过默认pip源拉取安装:
以管理员身份运行powershell,输入如下命令
pip install -U openai-whisper
因国内网络环境问题,pip下载缓慢,可以通过国内镜像源加速下载,使用方法:
pip install PACKAGE -i 国内源地址
国内常用镜像源:  
清华源:https://pypi.tuna.tsinghua.edu.cn/simple (速度与完成度均优,推荐)  
阿里源:https://mirrors.aliyun.com/pypi/simple/  
网易源:https://mirrors.163.com/pypi/simple/  
豆瓣源:https://pypi.douban.com/simple/  
百度云源:https://mirror.baidu.com/pypi/simple/
例如使用清华源加速下载:
pip install -U openai-whisper -i https://pypi.tuna.tsinghua.edu.cn/simple
另一种方法通过从github仓库拉取源码安装:
pip install git+https://github.com/openai/whisper.git
等待下载安装完成。
若安装成功,在powershell中输入whisper将得到以下输出:
安装chocolatey
安装chocolatey是为了方便后续在Windows中安装ffmpeg
继续在powershell中输入如下命令:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
在安装完成后,根据提示重启powershell,可输入choco检查是否成功安装:
安装ffmpeg
在以管理员身份运行的powershell中输入命令进行安装ffmpeg:
choco install ffmpeg
安装完成后在powershell中输入ffmpeg将得到以下输出:
NOTE
在官方文档中提到若在上述安装过程中报错还须安装rust,安装命令如下:
pip install setuptools-rust
本文此前已完成安装

二、使用Whisper

可以通过命令行调用Whisper:
whisper AUDIO.mp3 --model MODEL_TYPE
即,whisper 路径+文件名 --model 调用模型名称
使用例子:
whisper D:/downloads/ted演讲.mp4 --model tiny
whisper有五种不同的模型,详细开销和运行速度如下图表所示:

首次使用模型需要下载,若出现报错Error 10054代码,则说明网络环境出现问题,进行全局代理再次运行命令下载模型即可。
此外,也可以指定语言识别输出:
whisper AUDIO.mp3 --model MODEL_TYPE --language Chinese

更新时间 2024-06-13