剪口播 v2(口述動画編集 v2)
火山引擎 文字起こし + AI 滑舌ミス検出 + Web レビュー
クイック使い方
ユーザー: この口述動画を編集して
ユーザー: この動画を処理して
出力ディレクトリ構造
output/
└── YYYY-MM-DD_動画名/
├── 剪口播/
│ ├── 1_转写/
│ │ ├── audio.mp3
│ │ ├── volcengine_result.json
│ │ └── subtitles_words.json
│ ├── 2_分析/
│ │ ├── readable.txt
│ │ ├── auto_selected.json
│ │ └── 口误分析.md
│ └── 3_レビュー/
│ └── review.html
└── 字幕/
└── ...
ルール:既存のディレクトリは再利用、なければ新規作成。
フロー
0. 出力ディレクトリを作成
↓
1. 音声を抽出 (ffmpeg)
↓
2. アップロードして公開URLを取得 (uguu.se)
↓
3. 火山引擎 API で文字起こし
↓
4. 単語レベルの字幕を生成 (subtitles_words.json)
↓
5. AI が滑りや無音を分析し、事前選択リストを生成 (auto_selected.json)
↓
6. レビュー用Webページを生成 (review.html)
↓
7. レビューサーバーを起動し、ユーザーがWebページで確認
↓
【ユーザー確認待ち】→ Webページで「編集を実行」をクリック または 手動で /クリップ
実行手順
手順 0: 出力ディレクトリを作成
# 変数設定(実際の動画に合わせて調整)
VIDEO_PATH="/path/to/動画.mp4"
VIDEO_NAME=$(basename "$VIDEO_PATH" .mp4)
DATE=$(date +%Y-%m-%d)
BASE_DIR="output/${DATE}_${VIDEO_NAME}/剪口播"
# サブディレクトリを作成
mkdir -p "$BASE_DIR/1_转写" "$BASE_DIR/2_分析" "$BASE_DIR/3_レビュー"
cd "$BASE_DIR"
手順 1-3: 文字起こし
cd 1_转写
# 1. 音声を抽出(ファイル名にコロンがある場合は file: プレフィックスを付ける)
ffmpeg -i "file:$VIDEO_PATH" -vn -acodec libmp3lame -y audio.mp3
# 2. アップロードして公開URLを取得
curl -s -F "files[][email protected]" https://uguu.se/upload
# 返却: {"success":true,"files":[{"url":"https://h.uguu.se/xxx.mp3"}]}
# 3. 火山引擎 API を呼び出す
SKILL_DIR="/Users/chengfeng/Desktop/AIos/剪辑Agent/.claude/skills/剪口播"
"$SKILL_DIR/scripts/volcengine_transcribe.sh" "https://h.uguu.se/xxx.mp3"
# 出力: volcengine_result.json
手順 4: 字幕を生成
node "$SKILL_DIR/scripts/generate_subtitles.js" volcengine_result.json
# 出力: subtitles_words.json
cd ..
手順 5: 滑舌ミスを分析(スクリプト+AI)
5.1 読みやすい形式を生成
cd 2_分析
node -e "
const data = require('../1_转写/subtitles_words.json');
let output = [];
data.forEach((w, i) => {
if (w.isGap) {
const dur = (w.end - w.start).toFixed(2);
if (dur >= 0.5) output.push(i + '|[无声' + dur + 's]|' + w.start.toFixed(2) + '-' + w.end.toFixed(2));
} else {
output.push(i + '|' + w.text + '|' + w.start.toFixed(2) + '-' + w.end.toFixed(2));
}
});
require('fs').writeFileSync('readable.txt', output.join('\\n'));
"
5.2 ユーザー習慣を読み込む
まず ユーザー習慣/ ディレクトリ内のすべてのルールファイルを読み込みます。
5.3 文のリストを生成(重要)
最初に文に分割してから分析する。無音を基準に文のリストに分割:
node -e "
const data = require('../1_转写/subtitles_words.json');
let sentences = [];
let curr = { text: '', startIdx: -1, endIdx: -1 };
data.forEach((w, i) => {
const isLongGap = w.isGap && (w.end - w.start) >= 0.5;
if (isLongGap) {
if (curr.text.length > 0) sentences.push({...curr});
curr = { text: '', startIdx: -1, endIdx: -1 };
} else if (!w.isGap) {
if (curr.startIdx === -1) curr.startIdx = i;
curr.text += w.text;
curr.endIdx = i;
}
});
if (curr.text.length > 0) sentences.push(curr);
sentences.forEach((s, i) => {
console.log(i + '|' + s.startIdx + '-' + s.endIdx + '|' + s.text);
});
" > sentences.txt
5.4 スクリプトで自動的に無音をマーク(必ず先に実行)
node -e "
const words = require('../1_转写/subtitles_words.json');
const selected = [];
words.forEach((w, i) => {
if (w.isGap && (w.end - w.start) >= 0.5) selected.push(i);
});
require('fs').writeFileSync('auto_selected.json', JSON.stringify(selected, null, 2));
console.log('≥0.5s 無音の数:', selected.length);
"
→ auto_selected.json を出力(無音のインデックスのみ)
5.5 AI が滑舌ミスを分析(auto_selected.json に追加)
検出ルール(優先順位順):
| # | タイプ | 判定方法 | 削除範囲 |
|---|---|---|---|
| 1 | 重複文 | 隣接する文の先頭5文字以上が同一 | 短い方の全文 |
| 2 | 1文挟んだ重複 | 間に不完全文がある場合、前後の文を比較 | 前文+不完全文 |
| 3 | 不完全文 | 言いかけて無音 | 不完全文全体 |
| 4 | 文内重複 | A+中間+A パターン | 前半部分 |
| 5 | つっかえ語 | あのあの、つまりつまり | 前半部分 |
| 6 | 言い直し・訂正 | 一部重複/否定の訂正 | 前半部分 |
| 7 | フィラー | えー、あー、あの | マークだけして自動削除はしない |
核心原則:
- 最初に文に分割し、その後に比較:sentences.txt を使って隣接する文を比較
- 全文削除:不完全文や重複文は、異常な単語だけではなく、文全体を削除
セグメント分析(ループ実行):
1. readable.txt の offset=N から 300 行を読み込み
2. この300行を sentences.txt と照らし合わせて分析
3. 滑舌ミスの idx を auto_selected.json に追加
4. 口误分析.md に記録
5. N += 300、手順1に戻る
🚨 重要:行番号 ≠ idx
readable.txt 形式: idx|内容|時間
↑ この値を使うこと
行番号1500 → "1568|[无声1.02s]|..." ← idx は 1568。行番号1500ではない!
口误分析.md の形式:
## 第Nセグメント (行番号範囲)
| idx | 時間 | タイプ | 内容 | 処理 |
|-----|------|--------|------|------|
| 65-75 | 15.80-17.66 | 重複文 | "这是我剪出来的一个案例" | 削除 |
手順 6-7: レビュー
cd ../3_レビュー
# 6. レビュー用Webページを生成
node "$SKILL_DIR/scripts/generate_review.js" ../1_转写/subtitles_words.json ../2_分析/auto_selected.json ../1_转写/audio.mp3
# 出力: review.html
# 7. レビューサーバーを起動
node "$SKILL_DIR/scripts/review_server.js" 8899 "$VIDEO_PATH"
# ブラウザで http://localhost:8899 を開く
ユーザーがWebページで:
- 動画の該当部分を再生して確認
- 削除項目のチェックをON/OFF
- 「编辑を実行」をクリック
データ形式
subtitles_words.json
[
{"text": "大", "start": 0.12, "end": 0.2, "isGap": false},
{"text": "", "start": 6.78, "end": 7.48, "isGap": true}
]
auto_selected.json
[72, 85, 120] // Claude が分析して生成した事前選択インデックス
設定
火山引擎 API キー
cd /Users/chengfeng/Desktop/AIos/剪辑Agent/.claude/skills
cp .env.example .env
# .env を編集して VOLCENGINE_API_KEY=xxx を設定