ローカル Whisper を使う
1つのスクリプト、3つのバックエンド、1つの出力形式。下流のすべての処理(カットリスト、キャプションタイミング、同期ゲート)は <stem>.words.json を読み取ります:
[
{"w": "Your", "s": 0.02, "e": 0.27},
{"w": "AI", "s": 0.27, "e": 0.4}
]
w = 認識された単語、s/e = 秒単位の開始/終了時刻。
必要条件(Claude Code、コンピュータ上)
ffmpeg(任意のビルド):brew install ffmpeg/apt install ffmpeg- Python 3.9+
- 1つのバックエンド:
| バックエンド | インストール | デフォルトモデル | 使用すべきケース |
|---|---|---|---|
mlx | pip install mlx-whisper | mlx-community/whisper-large-v3-turbo | Apple Silicon。3つの中で最も単語タイミングが正確 |
faster-whisper | pip install faster-whisper | large-v3-turbo | Linux/Windows、または CUDA |
whisper-cpp | brew install whisper-cpp(バイナリは whisper-cli) | なし、--model を指定 | PythonのMLスタックを使いたくない場合 |
whisper.cpp モデルのダウンロード(466 MB、英語):
mkdir -p ~/whisper-models
curl -L -o ~/whisper-models/ggml-small.en.bin \
https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small.en.bin
インストール確認(auto がどのバックエンドを使用するかを表示):
ffmpeg -version | head -1
python3 -c "import mlx_whisper" 2>/dev/null && echo mlx || \
python3 -c "import faster_whisper" 2>/dev/null && echo faster-whisper || \
command -v whisper-cli || echo "NO BACKEND: install one from the table"
Claude.ai では利用できません(シェルがないため)。その場合は、ユーザーに SRT をアップロードするよう依頼してください。
実行方法
python3 scripts/transcribe.py take.mov # 自動バックエンド、英語
python3 scripts/transcribe.py take.mov --backend whisper-cpp --model ~/whisper-models/ggml-small.en.bin
python3 scripts/transcribe.py final.mp4 --out qa/ --words-per-cue 2
python3 scripts/transcribe.py interview.m4a --lang auto # 言語を自動検出
まず ffmpeg で16kHzモノラルに抽出するため、任意のコンテナ(mov、mp4、m4a、wav)が使用できます。
出力は --out が指定されない限り入力ファイルの隣に配置されます:
<stem>.words.json、<stem>.txt、<stem>.srt。
各ジョブに適したモデル
| ジョブ | 使用するモデル | 理由 |
|---|---|---|
| キャプションキューのタイミング、同期ゲート | large-v3-turbo(mlx または faster-whisper) | 小規模モデルは同じ音声で単語あたり0.1〜0.4秒ずれる |
| 文字起こしテキスト、カットリスト、リテイク検出 | small.en または turbo | テキスト品質はほぼ同等。small.en はCPUで高速 |
| 非英語 | large-v3-turbo に --lang <コード> を指定 | .en モデルは英語のみ対応 |
やり直しを防ぐルール
- スクリプトのテキストを、Whisperのタイミングに合わせる。 Whisper は固有名詞を聞き間違えます("Cloud" を "Claude" と誤認識など)。キャプションでは、
words.jsonにスクリプトの単語をアラインし、スクリプトのスペルを維持します(edit-style のtools/make_cues.pyがこれを行います)。スクリプトにないものについては、修正マップ({"cloud code": "Claude Code"})を保持してください。 - スクリプト内の数字は数字として記述する。 Whisper は
2,000と出力し、「two thousand」とは出力しないため、スペルアウトされたスクリプトではアライメントに失敗します。 - 公開するSRTと同期チェックのために、最終レンダリングを再文字起こしする。 生テイクのタイミングは、カット後はすべてずれています。
- Whisper は、実際の発話開始が後であっても、最初の単語を 0.00 付近にスタンプする。 頭をトリミングする前に、オーディオのエネルギーから実際の開始点を見つけ、最初の2秒間を再文字起こしして最初の単語が生き残ったことを確認します。
- 長いファイル(約30分以上):3つのバックエンドすべてで問題なく動作します。Apple Silicon + turbo ではおよそ実時間/10程度を想定してください。同じマシンで録音中であれば
nice -n 15で実行してください。
障害対応
| 症状 | 対処方法 |
|---|---|
no local Whisper found | テーブルから1つのバックエンドをインストールする |
whisper-cpp needs --model | ggml モデルをダウンロードする(上記)または WHISPER_MODEL を設定する |
whisper-cli not found と表示されるがインストールされている | WHISPER_BIN=/path/to/whisper-cli を設定する(launchd/cronのPATHには /opt/homebrew/bin が含まれていないことが多い) |
| 空の出力、または単語数0 | ファイルにオーディオがあるか確認する:ffprobe -v error -select_streams a -show_entries stream=codec_name -of csv=p=0 FILE |
| 間違った言語 / 支離滅裂な出力 | --lang <コード> を明示的に指定する |
| 単語がくっついて出力される("2,000files") | 一部のビルドでの whisper.cpp の癖。タイミング作業には mlx または faster-whisper を使用する |
報告する出力
whisper-cpp: 17 words, 5.68s -> o/take.words.json / .txt / .srt
その後、words.json のパスを次のスキル(edit-style、longform-edit、reel-captions)に渡します。