音频转文字

2023-09-27 08:22:40 浏览数 (1)

项目地址#https://github.com/openai/whisper

安装环境

代码语言:javascript复制
# 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
代码语言:javascript复制
pip install -U openai-whisper
pip install git https://github.com/openai/whisper.git 
pip install --upgrade --no-deps --force-reinstall git https://github.com/openai/whisper.git
pip install setuptools-rust

示例代码

代码语言:javascript复制
import whisper
model = whisper.load_model("large")
prompt = f'提示内容'
result = model.transcribe(audio_save_path, initial_prompt=prompt)
print("result:",result["text"])

0 人点赞