- 路径:/Users/eric_jiang/.openclaw/workspace/ai-video-dubber
- 虚拟环境:.venv/bin/python3
- 语言:Python 3.11+
- 架构:chunked pipeline + Gemini multimodal optimization + ElevenLabs TTS
每轮修改完后运行 .venv/bin/python3 -m pytest tests/ -x -q(如果没有 tests/ 则自己写基础测试)。 每轮最后 git commit 一次,消息格式 "review(round-N): 改了什么"。
目标文件:
- dubber/adapters/server_bridge.py — 检查是否还被引用,删除死代码
- dubber/adapters/claude_code.py — 检查是否被使用
- 所有 *.py — 找未使用 import(用 autoflake 或手动检查)
- 找重复定义:同一逻辑在 pipeline.py、orchestrator.py、init.py 里是否有重复
具体要做:
grep -rn "from dubber.adapters.server_bridge" . --include="*.py"找引用grep -rn "from dubber.adapters.claude_code" . --include="*.py"找引用- 找重复定义的
run_transcription、run_translation、run_tts、run_render - dubber/services/init.py 里有没有重复导出
- 删除确定没用的代码,合并重复实现
必须修复:
-
max_ratio统一:- dubber/services/audio.py
apply_atempo(max_ratio=1.5)默认值改为 1.3 - dubber/agent/orchestrator.py
PipelineConfig加speed_max: float = 1.3和speed_min: float = 0.75 - 所有调用
apply_atempo的地方都传max_ratio明确值
- dubber/services/audio.py
-
_fill_missing_translations在src != tgt时 fallback 用源文(中文字符)→ TTS 合成中文音频进英文轨- 修复:fallback 时应调用单条翻译,或跳过该 segment 的 TTS
-
segment_timingop 在 optimization_loop 里的 param normalization:- 已有
start_time→start, end_time→end映射,检查 orchestrator 里其他调用处是否也有同样问题
- 已有
-
sync_state调用:梳理哪些地方需要 sync,哪些是多余的,去掉重复 sync
gemini_analyzer.py 里的所有 prompt 需要:
-
analyze_transcriptionprompt:- 明确要求返回
start_time/end_time为 float 秒数(不是字符串) - 明确 speaker_id 格式:spk_0, spk_1, spk_2...
- 删除冗余描述
- 明确要求返回
-
analyze_translationprompt:suggested_params里的字段名必须和 ops 一致:- segment_timing: 用
start和end(float),不用start_time - emotion_change: 用
emotion(string) - translation_fix: 用
text(string) - speed_adjust: 用
factor(float)
- segment_timing: 用
segment_index改成index(和 ops 保持一致)
-
_build_prompt(optimization 迭代):- 同上,
suggested_params字段名和 ops 完全一致 - 增加 JSON schema 约束(列出每个 op 的参数类型)
- 限制一次最多返回 10 个 issues(防止批量覆盖)
- 同上,
-
analyze_speakersprompt:segment_assignments里必须有segment_index(int)和speaker_id(string)- 每个 speaker 必须有
gender: "male"/"female"/"unknown"
_run_chunked:chunk 处理失败时继续处理其他 chunk(wrap try/except,记录失败 chunk)_merge_chunk_segments:TTS 文件 copy 失败不中断,记录警告optimization_loop.py:- Gemini 返回非法 JSON → 跳过本轮迭代,不 crash
- score 解析 KeyError → 用默认值 50
subprocess.run调用全部加timeout=120和 stderr 捕获gemini_analyzer.py里_call方法:网络超时重试 2 次(间隔 5s)
- 把
orchestrator.py里的_optimize_transcription、_optimize_translation、_optimize_speakers方法拆到dubber/agent/step_optimizer.py - 速度常量集中:在
dubber/constants.py定义:SPEED_MIN = 0.75 SPEED_MAX = 1.3 DEFAULT_GEMINI_MODEL = "google/gemini-2.5-flash"
PipelineConfig引用 constants,不再硬编码gemini_analyzer.py价格计算加注释(来源:OpenRouter 定价页)
完成 Round 1-5 后,从"好用的 OpenClaw Skill"角度思考:
openclaw_skill.py的DubberSkill.execute()是否支持流式进度回调?Agent 调用时能看到 pipeline 进度skill.yaml的tools定义是否足够清晰,参数描述是否让 LLM 能正确调用- 是否需要增加
get_status工具(查询某个 project 的当前处理状态) - 是否需要增加
cancel_job工具 - Error 返回格式是否统一(建议统一为
{"success": false, "error": "...", "error_code": "TRANSCRIPTION_FAILED"})
写或完善 tests/ 目录下的测试:
test_segment_timing.py:测试 timing op 参数名 normalizationtest_rephrase_loop.py:测试两轮 rephrase 逻辑test_translation_retry.py:mock 网络失败,测试 3 次 retrytest_pipeline_e2e.py:用 mock 数据跑完整 pipeline(不真实调用 API)
所有测试通过后,git commit -m "review: all rounds complete"。
运行:openclaw system event --text "ai-video-dubber review complete: all 7 rounds done" --mode now