安装git

url: https://git-scm.com/downloads

whisper 音频提取文字安装教程_whisper

选择框中的下载git安装包

下载完成后双击文件进行安装,安装完成后再桌面右击出现下图即代表安装成功

whisper 音频提取文字安装教程_whisper_02

安装Anconda

url: https://www.anaconda.com/

whisper 音频提取文字安装教程_whisper_03

安装完成后打开 anconda

whisper 音频提取文字安装教程_音频提取_04

创建完成后打开激活环境

whisper 音频提取文字安装教程_whisper_05

安装pytroch

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

 参考 url:  https://pytorch.org/

安装whisper

pip install -U openai-whisper


whisper的使用

安装好后,我们使用下面的命令可以查看whisper如何使用。

whisper -h

我们现在就可以使用whisper来语音识别了。

whisper test.mp3 --model small --language Chinese

 我们选择简单的small模型,语言选择中文,这样我们就可以把test.mp3音频文件转为文本并输出了。

也可以指定输出的格式,他默认是输出所有格式文件。我们输入whisper -h 后控制台会打印命令的基础格式

--output_format {txt,vtt,srt,tsv,json,all}

也可以直接传入视频来识别音频生成文件。

whisper test.mp4 --model small --output_format srt --language Chinese

如果你的显存不过用会报下面的错误。

RuntimeError: CUDA out of memory.

可以通过参数--device来指定使用CPU进行提取和转换

whisper test.mp4 --model small --output_format srt --device cpu --language Chinese

当我们使用CPU运算时,我们还可以指定使用的线程数量。

whisper test.mp4 --model small --output_format srt --device cpu --language Chinese --threads 8

作者说: 还是推荐使用Gpu来操作,cpu处理的有点慢!

他再git上也开放了UI界面操作方式,这里mark一下

url: https://huggingface.co/spaces/aadnk/whisper-webui