修复并集成说话者分离功能
修复: - kb-whisper-diarization/whisper_diarization.py 变量名 bug 集成: - kb-workflow/SKILL.md 步骤5 添加说话者分离选项 - 自动检测 HF_TOKEN 选择识别模式 - 子技能清单添加 kb-whisper-diarization 文档: - kb-whisper-diarization/SKILL.md 完善 HF_TOKEN 获取步骤
This commit is contained in:
+38
-3
@@ -191,15 +191,49 @@ python3 /path/to/bilibili_content.py --id "[ID]" --type subtitle-download --outp
|
||||
python3 kb_workflow.py --content
|
||||
```
|
||||
|
||||
2. 启动子代理调用 kb-whisper(传入视频路径):
|
||||
2. **选择识别方式**:
|
||||
|
||||
**方式 A: 普通识别(不区分说话者)**
|
||||
```bash
|
||||
# 必须传入 --output 完整路径
|
||||
python3 /path/to/whisper.py --input [video_path] --model base --output [content_dir]
|
||||
```
|
||||
|
||||
**方式 B: 带说话者分离(推荐用于访谈、对话类视频)**
|
||||
```bash
|
||||
# 先检查 HF_TOKEN 环境变量
|
||||
if [ -z "$HF_TOKEN" ]; then
|
||||
echo "⚠️ HF_TOKEN 未设置,将使用普通识别(不区分说话者)"
|
||||
python3 /path/to/whisper.py --input [video_path] --model base --output [content_dir]
|
||||
else
|
||||
echo "✅ 使用说话者分离模式"
|
||||
python3 /path/to/whisper_diarization.py --input [video_path] --model base --diarize --output [content_dir]
|
||||
fi
|
||||
```
|
||||
|
||||
3. 等待 Whisper 完成(定时汇报进度)
|
||||
|
||||
4. 解析输出 JSON,生成 content 文件供步骤6使用
|
||||
4. 解析输出 JSON:
|
||||
- 普通识别:生成 `xxx.json`, `xxx.txt`, `xxx.srt`
|
||||
- 说话者分离:生成 `xxx_diarized.json`, `xxx_diarized.txt`, `xxx_diarized.srt`
|
||||
|
||||
#### 说话者分离环境变量
|
||||
|
||||
| 变量名 | 用途 | 获取方式 |
|
||||
|--------|------|----------|
|
||||
| `HF_TOKEN` | HuggingFace Token | 见下方说明 |
|
||||
|
||||
**获取 HuggingFace Token:**
|
||||
1. 注册 HuggingFace 账号:https://huggingface.co/join
|
||||
2. 申请 pyannote 模型访问权限:
|
||||
- https://huggingface.co/pyannote/speaker-diarization (点击 "Access")
|
||||
- https://huggingface.co/pyannote/segmentation (点击 "Access")
|
||||
3. 创建 Token:https://huggingface.co/settings/tokens → New token → Read
|
||||
4. 设置环境变量:
|
||||
```bash
|
||||
# 添加到 ~/.kb_env
|
||||
echo 'export HF_TOKEN="hf_xxxxxxxxxxxxxxxxxxxxxx"' >> ~/.kb_env
|
||||
source ~/.kb_env
|
||||
```
|
||||
|
||||
### 步骤 6: 深度分析
|
||||
|
||||
@@ -255,6 +289,7 @@ python3 kb_workflow.py --archive-file "[分析报告文件路径]"
|
||||
| 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` | 仅当没有官方字幕时执行 |
|
||||
| 5 | kb-whisper-diarization | `--input xxx.mp4 --model base --diarize` | `{p}_{id}_diarized.json` | 带说话者分离(需 HF_TOKEN) |
|
||||
| 6 | kb-deep-analyzer | `--metadata x.meta.json --content x.json --output x.md --provider zhipu --model glm-5` | `{p}_{id}.md` | **使用 g5 模型,必须成功** |
|
||||
|
||||
## 条件分支逻辑
|
||||
|
||||
Reference in New Issue
Block a user