当前位置:   article > 正文

如何使用OpenAI的whisper_openai whisper怎么使用

openai whisper怎么使用

一、安装ffmpeg

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

二、安装torch等相关组件

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

三、安装Whisper

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

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

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

四、下载模型

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

模型的默认下载路径在:~/.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
本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/在线问答5/article/detail/837328
推荐阅读
相关标签
  

闽ICP备14008679号