YouTube Transcriber
One-command transcription for any YouTube video — even when subtitles are disabled.
How it works:
- 1. Tries to fetch existing YouTube subtitles first (free, instant)
- If subtitles are disabled/unavailable → downloads audio → transcribes via OpenAI Whisper API
Prerequisites
- -
yt-dlp — brew install yt-dlp or INLINECODE2 - INLINECODE3 — INLINECODE4
- INLINECODE5 environment variable set
Usage
CODEBLOCK0
Options
| Option | Description | Default |
|---|
| INLINECODE6 | Language hint (ISO 639-1: en, zh, ja, ko, etc.) | auto-detect |
| INLINECODE7 |
Output transcript file path |
/tmp/yt_transcript_<VIDEO_ID>.txt |
|
--force-whisper | Skip subtitle check, always use Whisper API | off |
|
--keep-audio | Keep the downloaded audio file after transcription | off (deletes audio) |
|
--audio-bitrate <kbps> | Audio compression bitrate | 64 |
How It Works
CODEBLOCK1
Cost
- - With subtitles available: Free (uses existing captions)
- Whisper API: ~$0.006/minute of audio → 23-min video ≈ $0.14
Supported
- - Any YouTube video URL (full URL, youtu.be short link, or video ID)
- All languages supported by Whisper (99+ languages)
- Videos up to ~4 hours (audio compressed to fit 25MB API limit)
Troubleshooting
- - 403 from YouTube: Update yt-dlp (
pip install -U yt-dlp) - File too large for Whisper: Lower bitrate with INLINECODE13
- Missing API key: Set
OPENAI_API_KEY environment variable
YouTube 转录工具
一键转录任意YouTube视频——即使字幕被禁用也能工作。
工作原理:
- 1. 首先尝试获取YouTube现有字幕(免费、即时)
- 如果字幕被禁用/不可用 → 下载音频 → 通过OpenAI Whisper API进行转录
前置条件
- - yt-dlp — brew install yt-dlp 或 pip install yt-dlp
- ffmpeg — brew install ffmpeg
- 设置 OPENAIAPIKEY 环境变量
使用方法
bash
基础用法 — 自动检测最佳方法
{baseDir}/scripts/transcribe.sh https://www.youtube.com/watch?v=VIDEO_ID
指定语言(提高非英语视频的准确性)
{baseDir}/scripts/transcribe.sh https://www.youtube.com/watch?v=VIDEO_ID --lang zh
自定义输出路径
{baseDir}/scripts/transcribe.sh https://www.youtube.com/watch?v=VIDEO_ID --out /tmp/transcript.txt
强制使用Whisper(跳过字幕检查)
{baseDir}/scripts/transcribe.sh https://www.youtube.com/watch?v=VIDEO_ID --force-whisper
保留下载的音频文件
{baseDir}/scripts/transcribe.sh https://www.youtube.com/watch?v=VIDEO_ID --keep-audio
选项
| 选项 | 描述 | 默认值 |
|---|
| --lang <代码> | 语言提示(ISO 639-1:en、zh、ja、ko等) | 自动检测 |
| --out <路径> |
输出转录文件路径 | /tmp/yt
transcript.txt |
| --force-whisper | 跳过字幕检查,始终使用Whisper API | 关闭 |
| --keep-audio | 转录后保留下载的音频文件 | 关闭(删除音频) |
| --audio-bitrate | 音频压缩比特率 | 64 |
工作原理
YouTube URL
│
├─► 尝试 yt-dlp 字幕(免费、即时)
│ │
│ ├─ 找到 → 清理并输出转录文本 ✓
│ │
│ └─ 未找到/被禁用
│ │
│ ▼
└─► 下载音频(yt-dlp + ffmpeg)
│
├─ 压缩为单声道、低比特率(适配25MB API限制)
│
▼
OpenAI Whisper API → 转录文本 ✓
费用
- - 字幕可用时:免费(使用现有字幕)
- Whisper API:约$0.006/分钟音频 → 23分钟视频 ≈ $0.14
支持范围
- - 任意YouTube视频链接(完整URL、youtu.be短链接或视频ID)
- Whisper支持的所有语言(99+种语言)
- 最长约4小时的视频(音频压缩至25MB API限制内)
故障排除
- - YouTube返回403错误:更新yt-dlp(pip install -U yt-dlp)
- 文件过大无法使用Whisper:使用--audio-bitrate 32降低比特率
- 缺少API密钥:设置OPENAIAPIKEY环境变量