2 篇文章带有标签 “openai-whisper”

audio2sub — 音频转字幕工具

基于 OpenAI Whisper 的命令行工具,将音频文件批量转写为 VTT / SRT 格式字幕。

环境要求

依赖 说明
Python ≥ 3.8
PyTorch Whisper 的运行时依赖,自动安装
openai-whisper 语音识别引擎
ffmpeg 音频解码,系统级安装

安装步骤

1. 安装 ffmpeg

  • macOS:
brew install ffmpeg
  • Ubuntu / Debian:
sudo apt update && sudo apt install ffmpeg

2. 安装 openai-whisper

pip install openai-whisper

该命令会自动拉取 torch 等依赖。首次运行时 Whisper 模型文件会下载到 ~/.cache/whisper/

⚠️ macOS 环境注意事项

使用系统 Python 或 miniconda 安装 whisper:

# miniconda(推荐,已预装 torch)
/opt/miniconda/bin/pip install openai-whisper

# 或系统 Python
/usr/bin/python3 -m pip install openai-whisper

脚本文件

编写文件:audio2sub.py

whisper.cpp 实战指南(Jetson Thor 平台)

编译 whisper.cpp

克隆仓库

git clone https://github.com/ggml-org/whisper.cpp.git
cd whisper.cpp

编译 whisper.cpp

cmake -B build -DGGML_CUDA=1 -DCMAKE_CUDA_ARCHITECTURES="110"
cmake --build build -j --config Release

下载模型

sh ./models/download-ggml-model.sh small
sh ./models/download-ggml-model.sh large-v3-turbo
  • tiny.en
  • tiny
  • base.en
  • base
  • small.en
  • small
  • medium.en
  • medium
  • large-v1
  • large-v2
  • large-v3
  • large-v3-turbo

运行 whisper-cli

./build/bin/whisper-cli -f samples/jfk.wav
./build/bin/whisper-cli -m /models/whisper.cpp/models/ggml-large-v3-turbo.bin -f samples/jfk.wav

whisper-server