如何使用OpenAI的whisper

一、安装ffmpeg

yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
yum install ffmpeg ffmpeg-devel

二、安装torch等相关组件

conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
conda install pytorch==1.10.1 torchvision==0.11.2 torchaudio==0.10.1 cudatoolkit=10.2 -c pytorch

三、安装Whisper

pip install git+https://github.com/openai/whisper.git

如果上述报错,就改为下面的方法:

pip install --upgrade pip
git clone git@github.com:openai/whisper.git
cd whisper/
pip install setuptools-rust
pip install -r requirements.txt
python setup.py develop

四、下载模型

import whisper
model = whisper.load_model("large")  # 此处会下载模型

模型的默认下载路径在:~/.cache/whisper/large-v2.pt
如果网速不佳,可以先在网速好的服务器上先下载好模型,再拷贝到本机

五、测试效果

从下面cpu的结果看,tiny模型的结果不忍直视,而large_model的耗时,也无法忍受。

模型名称cpu执行时间结果gpu执行时间占显存
large_model15.5456秒喂 王阳 能听到我说话吗 今天天气怎么样超过16G超16G
medium_model9.1108秒喂,王阳,想听到我说话吗?今天天气怎么样?1.7336秒10G
small_model3.2420秒喂,完了,那听到我说话吗?今天天气怎么样?1.1716秒3.3G
base_model1.5984秒喂 王雅能聽到我說話嗎今天天氣怎麼樣0.3483秒1.6G
tiny_model1.0238秒喂 玩呀那听到我说话吗今天听见怎么样0.2637秒1.3G

六、cpu与gpu解码的耗时对比

在这里插入图片描述

参考文献

  • https://www.assemblyai.com/blog/how-to-run-openais-whisper-speech-recognition-model/
  • https://github.com/AppleHolic/chatgpt-streamlit
  • https://github.com/openai/whisper
  • https://github.com/Joooohan/audio-recorder-streamlit
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值