1 篇文章带有标签 “srt”

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