debian 上用虚拟环境运行python脚本,测试whisper
用虚拟环境安装依赖和包可以避免污染主机原本的语言环境。
# 安装ffmpeg,不然执行时会报错
apt update
apt install ffmpeg
# 安装完整Python环境(如果没装),会默认安装3.11版本
apt update && apt install -y python3-venv python3-pip
# 到项目目录
cd /project
# 创建虚拟环境
python3 -m venv whisper-env
# 激活虚拟环境
source ./whisper-env/bin/activate
# 然后在虚拟环境中安装whisper
pip install -U openai-whisper
用示例的脚本即可测试,将test.py 写入内容:
import whisper
model = whisper.load_model("turbo")
result = model.transcribe("audio.mp3")
print(result["text"])
运行脚本:
python3 test.py
faster whisper 的安装和使用过程类似,faster whisper 的github地址:https://github.com/SYSTRAN/faster-whisper

浙公网安备 33010602011771号