plugin: video-editing updated: 2026-01-20
Whisperによる文字起こし
OpenAI Whisperを使用した音声・動画の文字起こしのための実戦的なパターン。
システム要件
インストールオプション
オプション1: OpenAI Whisper (Python)
# macOS/Linux/Windows
pip install openai-whisper
# 確認
whisper --help
オプション2: whisper.cpp (C++ - より高速)
# macOS
brew install whisper-cpp
# Linux - ソースからビルド
git clone https://github.com/ggerganov/whisper.cpp
cd whisper.cpp && make
# Windows - プリビルドバイナリまたはcmakeでビルド
オプション3: Insanely Fast Whisper (GPU高速化)
pip install insanely-fast-whisper
モデル選択
| モデル | サイズ | VRAM | 精度 | 速度 | ユースケース |
|---|---|---|---|---|---|
| tiny | 39M | ~1GB | 低い | 最速 | クイックプレビュー |
| base | 74M | ~1GB | 中程度 | 高速 | 下書き文字起こし |
| small | 244M | ~2GB | 良好 | 中程度 | 一般的な使用 |
| medium | 769M | ~5GB | より良い | 低速 | 品質の高い文字起こし |
| large-v3 | 1550M | ~10GB | 最高 | 最遅 | 最終プロダクション |
推奨: 速度と品質のバランスとしてsmallから始めてください。最終納品にはlarge-v3を使用してください。
基本の文字起こし
OpenAI Whisperの使用
# 基本の文字起こし(言語自動検出)
whisper audio.mp3 --model small
# 言語と出力形式を指定
whisper audio.mp3 --model medium --language en --output_format srt
# 複数の出力形式
whisper audio.mp3 --model small --output_format all
# タイムスタンプと単語単位のタイミング付き
whisper audio.mp3 --model small --word_timestamps True
whisper.cppの使用
# まずモデルをダウンロード
./models/download-ggml-model.sh base.en
# 文字起こし
./main -m models/ggml-base.en.bin -f audio.wav -osrt
# タイムスタンプ付き
./main -m models/ggml-base.en.bin -f audio.wav -ocsv
出力形式
SRT (SubRipサブタイトル)
1
00:00:01,000 --> 00:00:04,500
こんにちは、このビデオへようこそ。
2
00:00:05,000 --> 00:00:08,200
本日はビデオ編集について議論します。
VTT (WebVTT)
WEBVTT
00:00:01.000 --> 00:00:04.500
こんにちは、このビデオへようこそ。
00:00:05.000 --> 00:00:08.200
本日はビデオ編集について議論します。
JSON (単語単位のタイミング付き)
{
"text": "Hello and welcome to this video.",
"segments": [
{
"id": 0,
"start": 1.0,
"end": 4.5,
"text": " Hello and welcome to this video.",
"words": [
{"word": "Hello", "start": 1.0, "end": 1.3},
{"word": "and", "start": 1.4, "end": 1.5},
{"word": "welcome", "start": 1.6, "end": 2.0},
{"word": "to", "start": 2.1, "end": 2.2},
{"word": "this", "start": 2.3, "end": 2.5},
{"word": "video", "start": 2.6, "end": 3.0}
]
}
]
}
文字起こしのための音声抽出
文字起こしの前に、最適な形式で音声を抽出します:
# 音声をWAVとして抽出(16kHz、モノラル - Whisperに最適)
ffmpeg -i video.mp4 -ar 16000 -ac 1 -c:a pcm_s16le audio.wav
# アーカイブ用に高品質WAVとして抽出
ffmpeg -i video.mp4 -vn -c:a pcm_s16le audio.wav
# 圧縮MP3として抽出(より小さい、それでも動作)
ffmpeg -i video.mp4 -vn -c:a libmp3lame -q:a 2 audio.mp3
タイミング同期
Whisper JSONをFCPタイミングに変換
import json
def whisper_to_fcp_timing(whisper_json_path, fps=24):
"""Whisper JSON出力をFCP互換のタイミングに変換します。"""
with open(whisper_json_path) as f:
data = json.load(f)
segments = []
for seg in data.get("segments", []):
segments.append({
"start_time": seg["start"],
"end_time": seg["end"],
"start_frame": int(seg["start"] * fps),
"end_frame": int(seg["end"] * fps),
"text": seg["text"].strip(),
"words": seg.get("words", [])
})
return segments
フレーム精度のタイミング
# 正確なフレーム数と長さを取得
ffprobe -v error -count_frames -select_streams v:0 \
-show_entries stream=nb_read_frames,duration,r_frame_rate \
-of json video.mp4
話者分離
複数話者のコンテンツにはpyannote.audioを使用:
pip install pyannote.audio
from pyannote.audio import Pipeline
pipeline = Pipeline.from_pretrained("pyannote/[email protected]")
diarization = pipeline("audio.wav")
for turn, _, speaker in diarization.itertracks(yield_label=True):
print(f"{turn.start:.1f}s - {turn.end:.1f}s: {speaker}")
一括処理
#!/bin/bash
# ディレクトリ内のすべての動画を文字起こし
MODEL="small"
OUTPUT_DIR="transcripts"
mkdir -p "$OUTPUT_DIR"
for video in *.mp4 *.mov *.avi; do
[[ -f "$video" ]] || continue
base="${video%.*}"
# 音声抽出
ffmpeg -i "$video" -ar 16000 -ac 1 -c:a pcm_s16le "/tmp/${base}.wav" -y
# 文字起こし
whisper "/tmp/${base}.wav" --model "$MODEL" \
--output_format all \
--output_dir "$OUTPUT_DIR"
# 一時音声ファイルを削除
rm "/tmp/${base}.wav"
echo "Transcribed: $video"
done
品質最適化
精度向上
- 文字起こし前のノイズ除去:
ffmpeg -i noisy_audio.wav -af "highpass=f=200,lowpass=f=3000,afftdn=nf=-25" clean_audio.wav
- 言語ヒントの使用:
whisper audio.mp3 --language en --model medium
- コンテキストの初期プロンプトを提供:
whisper audio.mp3 --initial_prompt "ビデオ編集ソフトウェアに関する技術的な議論。"
パフォーマンスのヒント
- GPUアクセラレーション(利用可能な場合):
whisper audio.mp3 --model large-v3 --device cuda
- 長い動画はチャンクに分割して処理:
# 音声を10分チャンクに分割
# 各チャンクを文字起こし
# 時間オフセット調整で結果を結合
エラーハンドリング
# 文字起こし前に音声ファイルを検証
validate_audio() {
local file="$1"
if ffprobe -v error -select_streams a:0 -show_entries stream=codec_type -of csv=p=0 "$file" 2>/dev/null | grep -q "audio"; then
return 0
else
echo "エラー: $file に音声ストリームが見つかりません"
return 1
fi
}
# Whisperのインストールを確認
check_whisper() {
if command -v whisper &> /dev/null; then
echo "Whisperは利用可能です"
return 0
else
echo "エラー: Whisperがインストールされていません。実行: pip install openai-whisper"
return 1
fi
}
関連スキル
- ffmpeg-core - 音声抽出と前処理
- final-cut-pro - 文字起こしをタイトルやマーカーとしてインポート