以下の SKILL.md は
lj1270998580-crypto/JaygoCut(コミット
ecd7cab)から
Apache-2.0 ライセンスに基づいて転載しています。本文は変更しておらず、ファイル先頭のメタデータのみ省略し、画像はリンクとして表示し、非常に長いファイルは途中までの表示としています。Copyright owner or entity authorized by。ライセンス:
LICENSE。表示しているのは指示ファイルのみです。スクリプト等は元のリポジトリをご覧ください。
<!--
input: 视频文件 (*.mp4)
output: subtitles_words.json、auto_selected.json、review.html、视频介绍草稿.md
pos: 转录+识别,到用户网页审核为止
架构守护者:一旦我被修改,请同步更新:
1. ../README.md 的 Skill 清单
2. /CLAUDE.md 路由表
-->
talkcut v2
语音转录 + AI 口误识别 + 网页审核
补充资料:
快速使用
用户: 帮我剪这个口播视频
用户: 处理一下这个视频
输出目录结构
{DEFAULT_OUTPUT_DIR}/
└── YYYY-MM-DD_视频名/
├── talkcut/
│ ├── 1_transcribe/
│ │ ├── audio.wav
│ │ ├── audio_timeline.json
│ │ ├── volcengine_result.json (仅火山引擎方案)
│ │ └── subtitles_words.json
│ ├── 2_analysis/
│ │ ├── readable.txt
│ │ ├── sentences.txt
│ │ ├── auto_selected.json
│ │ └── 口误分析.md
│ └── 3_review/
│ ├── audio.wav
│ ├── audio_timeline.json
│ ├── review.html
│ └── 视频介绍草稿.md
└── subtitles/
└── ...
规则:已有文件夹则复用,否则新建。
流程
0. 创建输出目录
↓
1. 提取和视频时间轴对齐的审核音频
↓
2. 选择转录方案(读取 .env 的 ASR_ENGINE)
├─ volcengine: 上传 → 火山引擎 API → generate_subtitles.js
└─ whisper: 本地 whisper_transcribe.py
↓
3. 得到 subtitles_words.json(两条路径汇合)
↓
4. AI 分析口误/静音,生成预选列表 (auto_selected.json)
↓
4.2 规范化预选列表(补短停顿桥接)
↓
4.5 生成视频介绍草稿 (视频介绍草稿.md)
↓
5. 生成审核网页 (review.html)
↓
6. 启动审核服务器,用户网页确认
↓
【等待用户确认】→ 网页点击「执行剪辑」或手动 /剪辑
执行步骤
步骤 0: 创建输出目录
# 读取 .env 中的 DEFAULT_OUTPUT_DIR
SKILL_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
ENV_FILE="$SKILL_ROOT/.env"
OUTPUT_ROOT=$(grep DEFAULT_OUTPUT_DIR "$ENV_FILE" | cut -d'=' -f2)
如果 DEFAULT_OUTPUT_DIR 为空(首次使用):
- 询问用户希望将输出文件存放到哪个目录
- 将用户回答的路径写入
.env 的 DEFAULT_OUTPUT_DIR= 行
- 如果用户没有特别要求,使用视频文件所在目录的
output/ 子目录
# 变量设置(根据实际视频调整)
VIDEO_PATH="/path/to/视频.mp4"
VIDEO_NAME=$(basename "$VIDEO_PATH" .mp4)
DATE=$(date +%Y-%m-%d)
BASE_DIR="${OUTPUT_ROOT}/${DATE}_${VIDEO_NAME}/talkcut"
# 创建子目录
mkdir -p "$BASE_DIR/1_transcribe" "$BASE_DIR/2_analysis" "$BASE_DIR/3_review"
cd "$BASE_DIR"
步骤 1: 提取音频
cd 1_transcribe
# 提取和视频时间轴对齐的审核音频,并写出时间轴元数据
node "$SKILL_DIR/scripts/extract_review_audio.js" "$VIDEO_PATH" audio.wav audio_timeline.json
说明:
- 后续 Whisper 转录和审核页都基于这份
audio.wav
audio_timeline.json 用来把审核页时间轴和源视频时间轴对齐,避免不同视频的音频起点差异导致切点偏移
步骤 2: 转录(分支)
读取 .env 中的 ASR_ENGINE:
- 如果为空 → 询问用户选择转录方案
volcengine → 方案 A
whisper → 方案 B
方案 A:火山引擎 API
# 1. 转成便于上传的 mp3
ffmpeg -y -i audio.wav -c:a libmp3lame audio.mp3
# 2. 上传获取公网 URL
curl -s -F "files[]=@audio.mp3" https://uguu.se/upload
# 返回: {"success":true,"files":[{"url":"https://h.uguu.se/xxx.mp3"}]}
# 3. 调用火山引擎 API
node "$SKILL_DIR/scripts/volcengine_transcribe.js" "https://h.uguu.se/xxx.mp3"
# 输出: volcengine_result.json
# 4. 生成字级别subtitles
node "$SKILL_DIR/scripts/generate_subtitles.js" volcengine_result.json
# 输出: subtitles_words.json
方案 B:Whisper 本地模型
先检查 mlx-whisper 是否已install,未install则自动install:
python3 -c "import mlx_whisper" 2>/dev/null || pip3 install mlx-whisper
执行转录(首次运行会自动下载模型,约 1.5GB):
python3 "$SKILL_DIR/scripts/whisper_transcribe.py" audio.wav
# 直接输出: subtitles_words.json(已包含 gap 检测,无需再调 generate_subtitles.js)
cd ..
→ 两条路径都输出 subtitles_words.json,后续步骤完全一致。
步骤 3: 分析口误(脚本+AI)
3.1 生成易读格式
cd 2_analysis
node -e "
const data = require('../1_transcribe/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'));
"
3.2 读取user_rules
先读 user_rules/ 目录下所有规则文件。
3.3 生成句子列表(关键步骤)
必须先分句,再分析。按静音切分成句子列表:
node -e "
const data = require('../1_transcribe/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
3.4 脚本自动标记静音(必须先执行)
node -e "
const words = require('../1_transcribe/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(只含静音 idx)
3.5 AI 分析口误(追加到 auto_selected.json)
检测规则(按优先级):
| # |
类型 |
判断方法 |
删除范围 |
| 1 |
重复句 |
相邻句子开头≥5字相同 |
较短的整句 |
| 2 |
隔一句重复 |
中间是残句时,比对前后句 |
前句+残句 |
| 3 |
残句 |
话说一半+静音 |
整个残句 |
| 4 |
句内重复 |
A+中间+A 模式 |
前面部分 |
| 5 |
卡顿词 |
那个那个、就是就是 |
前面部分 |
| 6 |
重说纠正 |
部分重复/否定纠正 |
前面部分 |
| 7 |
语气词 |
嗯、啊、那个 |
标记但不自动删 |
核心原则:
- 先分句,再比对:用 sentences.txt 比对相邻句子
- 整句删除:残句、重复句都要删整句,不只是删异常的几个字
分段分析(循环执行):
1. Read readable.txt offset=N limit=300
2. 结合 sentences.txt 分析这300行
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 | 重复句 | "这是我剪出来的一个案例" | 删 |
3.6 自动清理孤立小间隙
被删句子之间夹着的短 gap 也应自动标记删除,避免审核页留下碎片:
node -e "
const words = require('../1_transcribe/subtitles_words.json');
const selected = new Set(require('./auto_selected.json'));
let added = 0;
words.forEach((w, i) => {
if (!w.isGap || selected.has(i)) return;
let prev = i - 1;
while (prev >= 0 && words[prev].isGap) prev--;
let next = i + 1;
while (next < words.length && words[next].isGap) next++;
if (prev >= 0 && next < words.length && selected.has(prev) && selected.has(next)) {
selected.add(i);
added++;
}
});
const sorted = Array.from(selected).sort((a, b) => a - b);
require('fs').writeFileSync('auto_selected.json', JSON.stringify(sorted, null, 2) + '\\n');
if (added) console.log('🧹 自动清理孤立小间隙:', added, '个');
"
3.7 规范化预选列表(必须执行)
AI 补完索引后,再执行一次规范化,补上夹在两个待删片段之间的短停顿:
node "$SKILL_DIR/scripts/refine_auto_selected.js" \
"../1_transcribe/subtitles_words.json" \
"auto_selected.json"
补充规则:
- 如果一个
<0.5s 的停顿,前后最近的口播词都已经在 auto_selected.json 里,这个停顿也默认删掉
- 长静音在
subtitles_words.json 里会按整段保留,不再拆成很多个 1.0s
步骤 4.5: 生成 AI 视频介绍草稿
这一步必须由 Claude 直接完成,不要用本地模板脚本代写。
按 show-notes.md 的要求,基于当前准备保留的内容生成:
../3_review/视频介绍草稿.md
要求:
- 风格像创作者自己会配在视频旁边发出的介绍文案
- 默认包含标题、正文、标签、内容摘要
- 如果当前口播还是半成品,正文也要跟着真实,不要编造视频里没讲过的内容
- 审核页里默认只展示和复制这份草稿,不依赖用户在页面里手工保存
- 必须把结果实际写入
../3_review/视频介绍草稿.md,不能只在对话里临时输出
- 如果这个文件还不存在,不允许继续生成
review.html
- 写完后先自行检查文件存在且非空,再继续后面的审核页步骤
步骤 4-5: 审核
cd ../3_review
# 先确认视频介绍草稿已经落盘
test -s "视频介绍草稿.md"
# 6. 生成审核网页
node "$SKILL_DIR/scripts/generate_review.js" ../1_transcribe/subtitles_words.json ../2_analysis/auto_selected.json ../1_transcribe/audio.wav
# 输出: review.html
# 7. 启动审核服务器
node "$SKILL_DIR/scripts/review_server.js" 8899 "$VIDEO_PATH"
# 打开 http://localhost:8899
用户在网页中:
- 播放视频片段确认
- 勾选/取消删除项
- 直接复制 AI 生成的视频介绍草稿
- 点击「执行剪辑」
如果 test -s "视频介绍草稿.md" 失败:
- 先回到上一步补写草稿
- 不要跳过
- 不要把“页面会自动尝试读取已生成的视频介绍草稿”当成已经生成
注意:
- 审核页会直接优先使用源视频主音轨对应的
audio_source.wav 试听;如果源路径失效,则继续复用当前目录已有的源音轨文件
audio_timeline.json 会一并复制到审核目录,导出时按每个视频动态校准时间轴,不写死固定偏移
数据格式
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 分析生成的预选索引
配置
.env 字段
VOLCENGINE_API_KEY=xxx # 火山引擎 API Key(方案 A 需要)
DEFAULT_OUTPUT_DIR=xxx # 默认输出目录
ASR_ENGINE= # 转录方案: volcengine / whisper,留空每次询问
CUT_KEEP_PADDING_MS=300 # 保留片段语音边界前后缓冲
CUT_MIN_DELETE_MS=120 # 小于该时长的删除段默认忽略
CROSSFADE_MS=30 # 片段音频接缝淡化
火山引擎 API Key
获取指南:https://my.feishu.cn/wiki/Gh0MwxHePidsYfkIx7zcvJQynqc?from=from_copylink
# 编辑 .env 填入 VOLCENGINE_API_KEY=xxx
ライセンス全文を見る(Apache-2.0)
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.