說起來語音轉(zhuǎn)換文字,openai旗下的whisper很是好用,推理也很快,同時(shí)支持cpu和GPU。
GitHub:GitHub - openai/whisper: Robust Speech Recognition via Large-Scale Weak Supervision
相關(guān)的參數(shù)和內(nèi)存使用如下:
Size | Parameters | English-only model | Multilingual model | Required VRAM | Relative speed |
---|---|---|---|---|---|
tiny | 39 M | tiny.en |
tiny |
~1 GB | ~32x |
base | 74 M | base.en |
base |
~1 GB | ~16x |
small | 244 M | small.en |
small |
~2 GB | ~6x |
medium | 769 M | medium.en |
medium |
~5 GB | ~2x |
large | 1550 M | N/A | large |
~10 GB | 1x |
CPU推理會慢一些,一般機(jī)器使用small模型即可,該模型內(nèi)存占用不是很高
1.安裝
a.直接通過pip安裝?
pip install -U openai-whisper
pip install setuptools-rust
b.通過git倉庫安裝
pip install git+https://github.com/openai/whisper.git
c.將安裝包升級到倉庫最新版
pip install --upgrade --no-deps --force-reinstall git+https://github.com/openai/whisper.git
d.安裝 ffmpeg,本次系統(tǒng)是centos8stream,可以通過下面命令安裝
dnf install -y https://download1.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm
dnf install -y install http://rpmfind.net/linux/epel/7/x86_64/Packages/s/SDL2-2.0.14-2.el7.x86_64.rpm
dnf install ffmpeg -y
其他系統(tǒng)可參考如下:
# on Ubuntu or Debian
sudo apt update && sudo apt install ffmpeg
# on Arch Linux
sudo pacman -S ffmpeg
# on MacOS using Homebrew (https://brew.sh/)
brew install ffmpeg
# on Windows using Chocolatey (https://chocolatey.org/)
choco install ffmpeg
# on Windows using Scoop (https://scoop.sh/)
scoop install ffmpeg
2.使用
可以通過Python進(jìn)行下面操作
import whisper
model = whisper.load_model("small") # 如果模型不存在,會自動下載,默認(rèn)下載路徑 "~/.cache/whisper"
result = model.transcribe("temp.wav")
print(result["text"])
?文章來源:http://www.zghlxwxcb.cn/news/detail-499448.html
?文章來源地址http://www.zghlxwxcb.cn/news/detail-499448.html
到了這里,關(guān)于whisper 強(qiáng)大且開源的語音轉(zhuǎn)文字的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!