feat(kb-workflow): 优化无字幕视频处理逻辑
- kb-bilibili-content: extract_subtitle 返回 success=True 即使没有字幕 - 添加 download_subtitle 方法,支持下载官方字幕并转为 SRT 格式 - kb-workflow: 更新工作流逻辑,没有字幕是正常的,继续执行 Whisper - 添加条件分支:有字幕→深度分析,无字幕→Whisper
This commit is contained in:
+52
-24
@@ -94,36 +94,39 @@ python3 /path/to/zhihu_metadata.py --id "[ID]" --type question --output "${metad
|
||||
1. 获取目录路径:
|
||||
```bash
|
||||
python3 kb_workflow.py --content_downloads
|
||||
python3 kb_workflow.py --content_subtitles
|
||||
python3 kb_workflow.py --content
|
||||
```
|
||||
|
||||
2. 启动子代理调用对应平台的 content 技能:
|
||||
```bash
|
||||
# Bilibili 视频
|
||||
python3 /path/to/bilibili_content.py --id "[ID]" --type video --output [content_dir]
|
||||
# Bilibili 字幕下载(自动检测是否有官方字幕)
|
||||
python3 /path/to/bilibili_content.py --id "[ID]" --type subtitle-download --output [content_dir]
|
||||
|
||||
# Bilibili 字幕
|
||||
python3 /path/to/bilibili_content.py --id "[ID]" --type subtitle --output [subtitles_dir]
|
||||
# 返回 JSON 包含 has_subtitle 字段
|
||||
```
|
||||
|
||||
3. 解析输出 JSON,提取 video_filename 和 subtitle_filename(如有)
|
||||
3. 解析输出 JSON:
|
||||
- **has_subtitle = true**: 有官方字幕,直接进入步骤 6
|
||||
- **has_subtitle = false**: 没有官方字幕,继续步骤 5
|
||||
|
||||
### 步骤 5: 语音识别转文字(禁止跳过)
|
||||
> ⚠️ **重要提示**:没有找到官方字幕是**正常的**!很多视频没有自动生成的字幕。不要因为没有字幕就停止工作流,继续执行 Whisper 步骤即可。
|
||||
|
||||
> ⚠️ **重要**:此步骤为耗时步骤,使用 Whisper 进行语音识别。
|
||||
> - **严禁跳过**:即使等待时间较长,也必须等待识别完成
|
||||
> - **定时汇报**:每2-3分钟向用户汇报进度
|
||||
> - **超时时间**:30分钟
|
||||
> - **耐心等待**:不要中途启动其他步骤,必须串行执行
|
||||
### 步骤 5: 语音识别转文字(仅当没有官方字幕时执行)
|
||||
|
||||
如果步骤4没有获取到字幕,需要使用 Whisper 进行语音识别:
|
||||
> ⚠️ **重要**:此步骤仅在**没有官方字幕**时执行。如果有官方字幕,**跳过此步骤**。
|
||||
|
||||
此步骤使用 Whisper 进行语音识别:
|
||||
- **严禁跳过**:必须等待识别完成
|
||||
- **定时汇报**:每2-3分钟向用户汇报进度
|
||||
- **超时时间**:30分钟
|
||||
- **耐心等待**:不要中途启动其他步骤,必须串行执行
|
||||
|
||||
1. 获取目录路径:
|
||||
```bash
|
||||
python3 kb_workflow.py --content
|
||||
```
|
||||
|
||||
2. 启动子代理调用 kb-whisper(传入完整路径):
|
||||
2. 启动子代理调用 kb-whisper(传入视频路径):
|
||||
```bash
|
||||
# 必须传入 --output 完整路径
|
||||
python3 /path/to/whisper.py --input [video_path] --model base --output [content_dir]
|
||||
@@ -142,12 +145,15 @@ python3 kb_workflow.py --analyzed
|
||||
|
||||
2. 准备 content JSON 文件(包含 subtitle/description)
|
||||
|
||||
3. 启动子代理调用 kb-deep-analyzer:
|
||||
3. 如果有官方字幕,使用官方字幕的 SRT 文件
|
||||
4. 如果没有官方字幕,使用 Whisper 识别的结果
|
||||
|
||||
5. 启动子代理调用 kb-deep-analyzer:
|
||||
```bash
|
||||
python3 /path/to/deep_analyzer.py --metadata [meta_path] --content [content_path] --output [analyzed_dir]/[filename].md
|
||||
```
|
||||
|
||||
4. 解析输出 JSON,获取分析结果
|
||||
6. 解析输出 JSON,获取分析结果
|
||||
|
||||
### 步骤 7: 归档
|
||||
|
||||
@@ -167,14 +173,36 @@ python3 kb_workflow.py --archive-file "[分析报告文件路径]"
|
||||
|
||||
## 子技能清单
|
||||
|
||||
| 步骤 | 子技能 | 命令示例 | 输出 |
|
||||
|------|--------|----------|------|
|
||||
| 2 | kb-link-parser | `--url "BVxxx"` | `{p}_{id}.link.json` |
|
||||
| 3 | kb-bilibili-metadata | `--id "BVxxx" --type video` | `{p}_{id}.meta.json` |
|
||||
| 3 | kb-zhihu-metadata | `--id "xxx" --type question` | `{p}_{id}.meta.json` |
|
||||
| 4 | kb-bilibili-content | `--id "BVxxx" --type video` | `{p}_{id}.{ext}` |
|
||||
| 5 | kb-whisper | `--input xxx.mp4 --model base` | `{p}_{id}.json`, `{p}_{id}.txt` |
|
||||
| 6 | kb-deep-analyzer | `--metadata x.meta.json --content x.json --output x.md` | `{p}_{id}.md` |
|
||||
| 步骤 | 子技能 | 命令示例 | 输出 | 备注 |
|
||||
|------|--------|----------|------|------|
|
||||
| 2 | kb-link-parser | `--url "BVxxx"` | `{p}_{id}.link.json` | |
|
||||
| 3 | kb-bilibili-metadata | `--id "BVxxx" --type video` | `{p}_{id}.meta.json` | |
|
||||
| 3 | kb-zhihu-metadata | `--id "xxx" --type question` | `{p}_{id}.meta.json` | |
|
||||
| 4 | kb-bilibili-content | `--id "BVxxx" --type subtitle-download` | `{p}_{id}.srt` | 如果没有字幕是正常的 |
|
||||
| 4 | kb-bilibili-content | `--id "BVxxx" --type video` | `{p}_{id}.mp4` | 如果需要下载视频 |
|
||||
| 5 | kb-whisper | `--input xxx.mp4 --model base` | `{p}_{id}.json`, `{p}_{id}.txt` | 仅当没有官方字幕时执行 |
|
||||
| 6 | kb-deep-analyzer | `--metadata x.meta.json --content x.json --output x.md` | `{p}_{id}.md` | |
|
||||
|
||||
## 条件分支逻辑
|
||||
|
||||
```
|
||||
步骤3: 获取元数据
|
||||
↓
|
||||
步骤4: 下载字幕 (--type subtitle-download)
|
||||
↓
|
||||
┌─────────────────────────────────────┐
|
||||
│ has_subtitle = true? │
|
||||
├─────────────────────────────────────┤
|
||||
│ 是 → 直接进入步骤6(深度分析) │
|
||||
│ 否 → 进入步骤5(Whisper语音识别) │
|
||||
└─────────────────────────────────────┘
|
||||
↓
|
||||
步骤6: 深度分析
|
||||
```
|
||||
|
||||
> ⚠️ **重要**:没有找到官方字幕是**正常的**!很多视频没有自动生成的字幕。
|
||||
> - 如果 `has_subtitle = false`,继续执行 Whisper 步骤
|
||||
> - 如果 `has_subtitle = true`,跳过 Whisper 步骤,直接使用官方字幕
|
||||
|
||||
## 目录结构
|
||||
|
||||
|
||||
Reference in New Issue
Block a user