@oh-story/dsh 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -12
- package/lib/client.js +2692 -268
- package/lib/client.js.map +4 -4
- package/lib/drama/manifest.json +136 -101
- package/lib/drama/skills/short-drama/SKILL.md +61 -1
- package/lib/drama/skills/short-drama/references/contract-and-ownership.md +7 -4
- package/lib/drama/skills/short-drama/references/creator-documents.md +133 -8
- package/lib/drama/skills/short-drama/references/creator-workflow.md +38 -2
- package/lib/drama/skills/short-drama/references/knowhow-index.md +3 -0
- package/lib/drama/skills/short-drama/references/reference-roles.md +10 -7
- package/lib/drama/skills/short-drama/references/runtime-preflight.md +3 -0
- package/lib/drama/skills/short-drama/scripts/creator_markdown_check.py +1002 -0
- package/lib/drama/skills/short-drama/scripts/project_tool.py +485 -5
- package/lib/drama/skills/short-drama-assets/SKILL.md +13 -3
- package/lib/drama/skills/short-drama-assets/references/continuity-lock.md +116 -0
- package/lib/drama/skills/short-drama-assets/references/identity-vs-variant.md +2 -1
- package/lib/drama/skills/short-drama-assets/references/prop-and-state.md +19 -0
- package/lib/drama/skills/short-drama-assets/references/stage-contract.md +2 -0
- package/lib/drama/skills/short-drama-assets/scripts/asset_check.py +1 -1
- package/lib/drama/skills/short-drama-image-prompts/SKILL.md +6 -2
- package/lib/drama/skills/short-drama-image-prompts/references/common-recipe.md +4 -3
- package/lib/drama/skills/short-drama-image-prompts/references/lookdev-frame.md +1 -1
- package/lib/drama/skills/short-drama-image-prompts/references/review-and-fixtures.md +1 -1
- package/lib/drama/skills/short-drama-image-prompts/references/stage-contract.md +3 -1
- package/lib/drama/skills/short-drama-image-prompts/scripts/image_prompt_check.py +8 -8
- package/lib/drama/skills/short-drama-image-prompts/scripts/selftest.py +4 -2
- package/lib/drama/skills/short-drama-produce/SKILL.md +46 -10
- package/lib/drama/skills/short-drama-produce/references/adapter-contract.md +65 -8
- package/lib/drama/skills/short-drama-produce/references/providers/minimax-h3-video.md +85 -0
- package/lib/drama/skills/short-drama-produce/references/providers/seedance.md +27 -10
- package/lib/drama/skills/short-drama-produce/scripts/production_tool.py +362 -3
- package/lib/drama/skills/short-drama-produce/scripts/provider_adapters.py +627 -40
- package/lib/drama/skills/short-drama-produce/scripts/selftest.py +5 -4
- package/lib/drama/skills/short-drama-review/references/rubric-visual-motion.md +12 -0
- package/lib/drama/skills/short-drama-review/scripts/review_check.py +1 -1
- package/lib/drama/skills/short-drama-storyboard/SKILL.md +76 -7
- package/lib/drama/skills/short-drama-storyboard/assets/shot-template.jsonl +1 -1
- package/lib/drama/skills/short-drama-storyboard/references/keyframe-craft.md +6 -2
- package/lib/drama/skills/short-drama-storyboard/references/production-shot-grammar.md +19 -4
- package/lib/drama/skills/short-drama-storyboard/references/review-and-fixtures.md +5 -2
- package/lib/drama/skills/short-drama-storyboard/references/screenplay-to-keyframe-example.md +16 -0
- package/lib/drama/skills/short-drama-storyboard/references/stage-contract.md +8 -3
- package/lib/drama/skills/short-drama-storyboard/scripts/storyboard_check.py +1 -1
- package/lib/drama/skills/short-drama-video-prompts/SKILL.md +81 -13
- package/lib/drama/skills/short-drama-video-prompts/assets/motion-spec.jsonl.md +6 -1
- package/lib/drama/skills/short-drama-video-prompts/assets/video-prompts.md +17 -1
- package/lib/drama/skills/short-drama-video-prompts/references/delivery-profile.md +21 -1
- package/lib/drama/skills/short-drama-video-prompts/references/minimax-h3.md +154 -0
- package/lib/drama/skills/short-drama-video-prompts/references/motion-recipe.md +24 -6
- package/lib/drama/skills/short-drama-video-prompts/references/production-prompt-grammar.md +11 -7
- package/lib/drama/skills/short-drama-video-prompts/references/seedance-2.0.md +41 -0
- package/lib/drama/skills/short-drama-video-prompts/references/seedance-2.5.md +66 -0
- package/lib/drama/skills/short-drama-video-prompts/references/stage-contract.md +5 -2
- package/lib/drama/skills/short-drama-video-prompts/references/target-model-profile.md +115 -0
- package/lib/drama/skills/short-drama-video-prompts/scripts/container_check.py +1 -1
- package/lib/drama/skills/short-drama-video-prompts/scripts/music_spec_check.py +1 -1
- package/lib/drama/skills/short-drama-write/SKILL.md +3 -2
- package/lib/drama/skills/short-drama-write/scripts/duration_estimate.py +1 -1
- package/lib/drama/skills/short-drama-write/scripts/screenplay_index.py +2 -2
- package/lib/drama/skills/short-drama-write/scripts/voice_sheet_check.py +1 -1
- package/lib/index.js +865 -33
- package/lib/index.js.map +4 -4
- package/lib/novel-to-game/LICENSE +21 -0
- package/lib/novel-to-game/README.md +180 -0
- package/lib/novel-to-game/README_ZH.md +178 -0
- package/lib/novel-to-game/VERSION +1 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/BUILD_BRIEF.md +217 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/.vercelignore +3 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/RUN.md +130 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/bg/compound_new_guofeng.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/finale/fate_coda.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/finale/meng.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/finale/pan.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/finale/pinger.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/finale/xuee.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/finale/yue.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/inner_court_accord_five.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/inner_court_afterglow_five.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/inner_court_alliance.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/public_day10.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/public_day15.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/public_day5.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/group/title_new_guofeng.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/joint/pan_pinger.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/joint/pan_xuee.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/joint/yue_meng.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/joint/yue_pan.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/joint/yue_pinger.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/meng/explicit.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/meng/prelude.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/milestone/meng.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/milestone/pan.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/milestone/pinger.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/milestone/xuee.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/milestone/yue.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/pan/explicit.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/pan/prelude.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/pinger/explicit.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/pinger/prelude.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/xuee/explicit.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/xuee/prelude.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/yue/explicit.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/cg/yue/prelude.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/heroine/meng/night.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/heroine/pan/night.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/heroine/pinger/night.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/heroine/xuee/night.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/heroine/yue/night.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/household/li_jiaoer.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/assets/scene/gate_collector.webp +0 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/css/new-guofeng.css +1105 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/css/style.css +2539 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/index.html +18 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/js/assets.js +147 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/js/audio.js +332 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/js/data.js +7472 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/js/engine.js +13077 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/js/main.js +3028 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/js/text.js +32 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/package.json +10 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/app/vercel.json +23 -0
- package/lib/novel-to-game/examples/jin-ping-mei/build/art/generated-art.json +161 -0
- package/lib/novel-to-game/examples/jin-ping-mei/example.json +12 -0
- package/lib/novel-to-game/examples/jin-ping-mei/qa/README.md +31 -0
- package/lib/novel-to-game/examples/jin-ping-mei/qa/playable-model.json +99 -0
- package/lib/novel-to-game/examples/jin-ping-mei/qa/verification.json +41 -0
- package/lib/novel-to-game/examples/jin-ping-mei/qa/verify_playable_model.mjs +129 -0
- package/lib/novel-to-game/manifest.json +508 -0
- package/lib/novel-to-game/skills/game-art-direction/SKILL.md +73 -0
- package/lib/novel-to-game/skills/game-art-direction/agents/openai.yaml +4 -0
- package/lib/novel-to-game/skills/game-art-direction/references/art-direction-method.md +119 -0
- package/lib/novel-to-game/skills/game-build/SKILL.md +84 -0
- package/lib/novel-to-game/skills/game-build/agents/openai.yaml +4 -0
- package/lib/novel-to-game/skills/game-build/references/build-brief-contract.md +109 -0
- package/lib/novel-to-game/skills/game-build/references/generative-media-pipeline.md +56 -0
- package/lib/novel-to-game/skills/game-build/references/playable-model-contract.md +81 -0
- package/lib/novel-to-game/skills/game-build/references/tts-production-contract.md +37 -0
- package/lib/novel-to-game/skills/game-concept/SKILL.md +72 -0
- package/lib/novel-to-game/skills/game-concept/agents/openai.yaml +4 -0
- package/lib/novel-to-game/skills/game-concept/references/concept-method.md +94 -0
- package/lib/novel-to-game/skills/game-qa/SKILL.md +50 -0
- package/lib/novel-to-game/skills/game-qa/agents/openai.yaml +4 -0
- package/lib/novel-to-game/skills/game-qa/references/qa-contract.md +66 -0
- package/lib/novel-to-game/skills/game-qa/references/test-design-method.md +45 -0
- package/lib/novel-to-game/skills/game-world-design/SKILL.md +63 -0
- package/lib/novel-to-game/skills/game-world-design/agents/openai.yaml +4 -0
- package/lib/novel-to-game/skills/game-world-design/references/dialogue-design-method.md +59 -0
- package/lib/novel-to-game/skills/game-world-design/references/game-writing-craft.md +53 -0
- package/lib/novel-to-game/skills/game-world-design/references/narrative-design-method.md +84 -0
- package/lib/novel-to-game/skills/game-world-design/references/numeric-design-method.md +56 -0
- package/lib/novel-to-game/skills/game-world-design/references/world-design-method.md +124 -0
- package/lib/novel-to-game/skills/novel-game-analyze/SKILL.md +77 -0
- package/lib/novel-to-game/skills/novel-game-analyze/agents/openai.yaml +4 -0
- package/lib/novel-to-game/skills/novel-game-analyze/references/gameability-protocol.md +65 -0
- package/lib/novel-to-game/skills/novel-to-game/SKILL.md +71 -0
- package/lib/novel-to-game/skills/novel-to-game/agents/openai.yaml +4 -0
- package/lib/novel-to-game/skills/novel-to-game/references/intake-benchmark-reference.md +42 -0
- package/lib/novel-to-game/skills/novel-to-game/references/intake-method.md +51 -0
- package/lib/novel-to-game/skills/novel-to-game/references/pipeline-contract.md +65 -0
- package/lib/oh-story/manifest.json +415 -305
- package/lib/oh-story/roles/consistency-checker.md +1 -1
- package/lib/oh-story/roles/narrative-writer.md +32 -33
- package/lib/oh-story/roles/story-architect.md +16 -26
- package/lib/oh-story/skills/browser-cdp/SKILL.md +1 -1
- package/lib/oh-story/skills/story/SKILL.md +16 -9
- package/lib/oh-story/skills/story/VERSION +1 -1
- package/lib/oh-story/skills/story/references/author-memory.md +163 -0
- package/lib/oh-story/skills/story/scripts/author_memory_commit.py +871 -0
- package/lib/oh-story/skills/story-cover/SKILL.md +1 -1
- package/lib/oh-story/skills/story-deslop/SKILL.md +10 -5
- package/lib/oh-story/skills/story-deslop/references/anti-ai-writing.md +2 -1
- package/lib/oh-story/skills/story-deslop/references/author-memory.md +163 -0
- package/lib/oh-story/skills/story-deslop/references/banned-words.md +6 -4
- package/lib/oh-story/skills/story-deslop/scripts/author_memory_commit.py +871 -0
- package/lib/oh-story/skills/story-deslop/scripts/check-ai-patterns.js +64 -1
- package/lib/oh-story/skills/story-import/SKILL.md +19 -10
- package/lib/oh-story/skills/story-import/references/format-and-structure.md +9 -10
- package/lib/oh-story/skills/story-import/references/structure-mapping-long.md +2 -2
- package/lib/oh-story/skills/story-import/references/structure-mapping-short.md +1 -1
- package/lib/oh-story/skills/story-import/references/tracking-transaction.md +14 -6
- package/lib/oh-story/skills/story-import/scripts/check-outline-contract.js +251 -0
- package/lib/oh-story/skills/story-import/scripts/tracking_commit.py +98 -9
- package/lib/oh-story/skills/story-import/scripts/wordcount_core.py +246 -0
- package/lib/oh-story/skills/story-long-analyze/SKILL.md +4 -4
- package/lib/oh-story/skills/story-long-scan/SKILL.md +1 -1
- package/lib/oh-story/skills/story-long-write/SKILL.md +35 -21
- package/lib/oh-story/skills/story-long-write/references/anti-ai-writing.md +2 -1
- package/lib/oh-story/skills/story-long-write/references/artifact-protocols.md +7 -3
- package/lib/oh-story/skills/story-long-write/references/author-memory.md +163 -0
- package/lib/oh-story/skills/story-long-write/references/banned-words.md +6 -4
- package/lib/oh-story/skills/story-long-write/references/cross-book-recall.md +6 -6
- package/lib/oh-story/skills/story-long-write/references/genre-prose-cards.md +1 -1
- package/lib/oh-story/skills/story-long-write/references/genre-readers.md +1 -1
- package/lib/oh-story/skills/{story-setup/references/agent-references/hooks-chapter.md → story-long-write/references/long-chapter-hooks.md} +5 -5
- package/lib/oh-story/skills/story-long-write/references/{quality-checklist.md → long-chapter-quality.md} +2 -1
- package/lib/oh-story/skills/story-long-write/references/long-format.md +42 -0
- package/lib/oh-story/skills/{story-setup/references/agent-references/genre-catalog.md → story-long-write/references/long-genre-catalog.md} +11 -97
- package/lib/oh-story/skills/{story-setup/references/agent-references/genre-core-mechanics.md → story-long-write/references/long-genre-mechanics.md} +1 -1
- package/lib/oh-story/skills/{story-short-write/references/reversal-toolkit.md → story-long-write/references/long-reversal.md} +18 -32
- package/lib/oh-story/skills/story-long-write/references/{hooks-suspense.md → long-suspense.md} +6 -6
- package/lib/oh-story/skills/story-long-write/references/opening-design.md +1 -1
- package/lib/oh-story/skills/story-long-write/references/outline-structure-theory.md +1 -1
- package/lib/oh-story/skills/story-long-write/references/style-genre-modules.md +1 -1
- package/lib/oh-story/skills/story-long-write/references/tracking-transaction.md +14 -6
- package/lib/oh-story/skills/story-long-write/references/workflow-chapter.md +32 -27
- package/lib/oh-story/skills/story-long-write/references/workflow-daily.md +4 -4
- package/lib/oh-story/skills/story-long-write/references/workflow-revision.md +2 -2
- package/lib/oh-story/skills/story-long-write/references/workflow-setup.md +14 -14
- package/lib/oh-story/skills/story-long-write/references/writing-craft.md +54 -54
- package/lib/oh-story/skills/story-long-write/scripts/author_memory_commit.py +871 -0
- package/lib/oh-story/skills/story-long-write/scripts/check-ai-patterns.js +64 -1
- package/lib/oh-story/skills/story-long-write/scripts/check-outline-contract.js +251 -0
- package/lib/oh-story/skills/story-long-write/scripts/storyctl.py +303 -0
- package/lib/oh-story/skills/story-long-write/scripts/tracking_commit.py +98 -9
- package/lib/oh-story/skills/story-long-write/scripts/wordcount_core.py +246 -0
- package/lib/oh-story/skills/story-review/SKILL.md +26 -17
- package/lib/oh-story/skills/story-review/references/anti-ai-writing.md +2 -1
- package/lib/oh-story/skills/story-review/references/author-memory.md +163 -0
- package/lib/oh-story/skills/story-review/references/banned-words.md +6 -4
- package/lib/oh-story/skills/story-review/references/{quality-checklist.md → review-quality.md} +22 -21
- package/lib/oh-story/skills/story-review/references/tracking-transaction.md +14 -6
- package/lib/oh-story/skills/story-review/scripts/author_memory_commit.py +871 -0
- package/lib/oh-story/skills/story-review/scripts/check-ai-patterns.js +64 -1
- package/lib/oh-story/skills/story-review/scripts/tracking_commit.py +98 -9
- package/lib/oh-story/skills/story-review/scripts/wordcount_core.py +246 -0
- package/lib/oh-story/skills/story-setup/SKILL.md +74 -33
- package/lib/oh-story/skills/story-setup/references/agent-references/agent-quality.md +72 -0
- package/lib/oh-story/skills/story-setup/references/agent-references/agent-reference-profiles.md +55 -0
- package/lib/oh-story/skills/story-setup/references/agent-references/anti-ai-writing.md +2 -1
- package/lib/oh-story/skills/story-setup/references/agent-references/banned-words.md +6 -4
- package/lib/oh-story/skills/story-setup/references/agent-references/format-and-structure.md +9 -10
- package/lib/oh-story/skills/story-setup/references/agent-references/genre-prose-cards.md +1 -1
- package/lib/oh-story/skills/story-setup/references/agent-references/genre-readers.md +1 -1
- package/lib/oh-story/skills/{story-short-analyze/references/hooks-chapter.md → story-setup/references/agent-references/long-chapter-hooks.md} +5 -5
- package/lib/oh-story/skills/story-setup/references/agent-references/long-emotional-methods.md +209 -0
- package/lib/oh-story/skills/{story-long-write/references/genre-catalog.md → story-setup/references/agent-references/long-genre-catalog.md} +11 -97
- package/lib/oh-story/skills/{story-long-write/references/genre-core-mechanics.md → story-setup/references/agent-references/long-genre-mechanics.md} +1 -1
- package/lib/oh-story/skills/story-setup/references/agent-references/long-quality.md +40 -0
- package/lib/oh-story/skills/story-setup/references/agent-references/{reversal-toolkit.md → long-reversal.md} +18 -32
- package/lib/oh-story/skills/{story-short-write/references/hooks-suspense.md → story-setup/references/agent-references/long-suspense.md} +6 -6
- package/lib/oh-story/skills/story-setup/references/agent-references/opening-design.md +1 -1
- package/lib/oh-story/skills/story-setup/references/agent-references/{emotional-methods.md → short-emotional-methods.md} +4 -4
- package/lib/oh-story/skills/{story-long-write/references/genre-writing-formulas.md → story-setup/references/agent-references/short-genre-formulas.md} +32 -44
- package/lib/oh-story/skills/story-setup/references/agent-references/short-quality.md +39 -0
- package/lib/oh-story/skills/{story-long-write/references/reversal-toolkit.md → story-setup/references/agent-references/short-reversal.md} +29 -23
- package/lib/oh-story/skills/story-setup/references/agent-references/{hooks-suspense.md → short-suspense.md} +31 -31
- package/lib/oh-story/skills/story-setup/references/agent-references/style-genre-modules.md +1 -1
- package/lib/oh-story/skills/story-setup/references/agent-references/writing-craft.md +55 -55
- package/lib/oh-story/skills/story-short-analyze/SKILL.md +28 -28
- package/lib/oh-story/skills/story-short-analyze/references/{character-basics.md → analysis-character-basics.md} +1 -1
- package/lib/oh-story/skills/story-short-analyze/references/{character-design-methods.md → analysis-character-design.md} +1 -1
- package/lib/oh-story/skills/story-short-analyze/references/{character-relations.md → analysis-character-relations.md} +1 -1
- package/lib/oh-story/skills/story-short-analyze/references/{hooks-paragraph.md → analysis-paragraph-hooks.md} +1 -1
- package/lib/oh-story/skills/story-short-analyze/references/{genre-readers.md → analysis-reader-profile.md} +2 -2
- package/lib/oh-story/skills/story-short-analyze/references/analysis-report-style.md +45 -0
- package/lib/oh-story/skills/story-short-analyze/references/analysis-short-genres.md +65 -0
- package/lib/oh-story/skills/story-short-analyze/references/analysis-short-hooks.md +77 -0
- package/lib/oh-story/skills/story-short-analyze/references/analysis-short-mechanics.md +82 -0
- package/lib/oh-story/skills/story-short-analyze/references/analysis-short-patterns.md +50 -0
- package/lib/oh-story/skills/story-short-analyze/references/analysis-short-suspense.md +98 -0
- package/lib/oh-story/skills/story-short-analyze/references/{genre-writing-techniques.md → analysis-writing-techniques.md} +21 -19
- package/lib/oh-story/skills/story-short-analyze/references/deconstruction-examples.md +1 -1
- package/lib/oh-story/skills/story-short-analyze/references/material-decomposition.md +21 -28
- package/lib/oh-story/skills/story-short-analyze/references/output-contract.md +1 -1
- package/lib/oh-story/skills/story-short-analyze/references/output-templates.md +17 -17
- package/lib/oh-story/skills/story-short-analyze/references/{quality-checklist.md → source-story-quality.md} +28 -49
- package/lib/oh-story/skills/story-short-analyze/references/zhihu-style.md +2 -2
- package/lib/oh-story/skills/story-short-scan/SKILL.md +1 -1
- package/lib/oh-story/skills/story-short-write/SKILL.md +78 -55
- package/lib/oh-story/skills/story-short-write/references/author-memory.md +163 -0
- package/lib/oh-story/skills/story-short-write/references/banned-words.md +6 -4
- package/lib/oh-story/skills/story-short-write/references/cross-book-recall.md +3 -3
- package/lib/oh-story/skills/story-short-write/references/emotional-methods.md +4 -4
- package/lib/oh-story/skills/story-short-write/references/genre-styles//344/270/226/346/203/205/346/211/223/350/204/270.md +3 -3
- package/lib/oh-story/skills/story-short-write/references/genre-styles//345/217/214/347/224/267/344/270/273.md +2 -2
- package/lib/oh-story/skills/story-short-write/references/genre-styles//345/244/215/344/273/207/346/211/223/350/204/270.md +3 -3
- package/lib/oh-story/skills/story-short-write/references/genre-styles//345/256/205/346/226/227/345/256/253/346/226/227.md +6 -6
- package/lib/oh-story/skills/story-short-write/references/genre-styles//346/200/273/350/243/201/350/261/252/351/227/250.md +3 -3
- package/lib/oh-story/skills/story-short-write/references/genre-styles//346/202/254/347/226/221.md +4 -4
- package/lib/oh-story/skills/story-short-write/references/genre-styles//346/260/221/344/277/227/346/200/252/350/260/210.md +7 -7
- package/lib/oh-story/skills/story-short-write/references/genre-styles//346/262/231/351/233/225/350/204/221/346/264/236.md +5 -5
- package/lib/oh-story/skills/story-short-write/references/genre-styles//347/224/234/345/256/240.md +4 -4
- package/lib/oh-story/skills/story-short-write/references/genre-styles//350/277/275/345/246/273/347/201/253/350/221/254/345/234/272.md +3 -3
- package/lib/oh-story/skills/story-short-write/references/genre-writing-formulas.md +32 -44
- package/lib/oh-story/skills/story-short-write/references/genre-writing-techniques.md +20 -18
- package/lib/oh-story/skills/story-short-write/references/output-contract.md +1 -1
- package/lib/oh-story/skills/story-short-write/references/short-craft.md +18 -18
- package/lib/oh-story/skills/story-short-write/references/short-deslop.md +1 -1
- package/lib/oh-story/skills/story-short-write/references/short-format.md +38 -8
- package/lib/oh-story/skills/story-short-write/references/{quality-checklist.md → short-prose-quality.md} +22 -21
- package/lib/oh-story/skills/story-short-write/references/short-reversal.md +355 -0
- package/lib/oh-story/skills/{story-short-analyze/references/hooks-suspense.md → story-short-write/references/short-suspense.md} +31 -31
- package/lib/oh-story/skills/story-short-write/references/submission-craft.md +2 -2
- package/lib/oh-story/skills/story-short-write/references/writing-workflow.md +31 -22
- package/lib/oh-story/skills/story-short-write/scripts/author_memory_commit.py +871 -0
- package/lib/oh-story/skills/story-short-write/scripts/check-ai-patterns.js +64 -1
- package/lib/oh-story/skills/story-short-write/scripts/check-delivery-contract.js +212 -0
- package/lib/oh-story/skills/story-short-write/scripts/check-phase2-contract.js +363 -0
- package/lib/types/client/drama-production-view.d.ts +34 -0
- package/lib/types/client/drama-production-view.d.ts.map +1 -0
- package/lib/types/client/drama-production.d.ts +92 -0
- package/lib/types/client/drama-production.d.ts.map +1 -0
- package/lib/types/client/file-activity.d.ts +4 -2
- package/lib/types/client/file-activity.d.ts.map +1 -1
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/production-intents.d.ts +9 -0
- package/lib/types/client/production-intents.d.ts.map +1 -0
- package/lib/types/client/production-prompts.d.ts +9 -0
- package/lib/types/client/production-prompts.d.ts.map +1 -0
- package/lib/types/client/production-runtime.d.ts +58 -0
- package/lib/types/client/production-runtime.d.ts.map +1 -0
- package/lib/types/client/video-studio.d.ts +41 -0
- package/lib/types/client/video-studio.d.ts.map +1 -0
- package/lib/types/client/workbench-ui.d.ts +5 -0
- package/lib/types/client/workbench-ui.d.ts.map +1 -0
- package/lib/types/game-verification.d.ts +16 -0
- package/lib/types/game-verification.d.ts.map +1 -0
- package/lib/types/index.d.ts +3 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/production-intent.d.ts +21 -0
- package/lib/types/production-intent.d.ts.map +1 -0
- package/lib/types/production-tool.d.ts +5 -0
- package/lib/types/production-tool.d.ts.map +1 -0
- package/lib/types/role-tool.d.ts.map +1 -1
- package/lib/types/skill-provider.d.ts +7 -0
- package/lib/types/skill-provider.d.ts.map +1 -1
- package/lib/types/video-project.d.ts +42 -0
- package/lib/types/video-project.d.ts.map +1 -0
- package/lib/types/workspace-request-trust.d.ts +6 -0
- package/lib/types/workspace-request-trust.d.ts.map +1 -1
- package/lib/types/workspace-route.d.ts +20 -0
- package/lib/types/workspace-route.d.ts.map +1 -1
- package/lib/video-recap/CHANGELOG.md +282 -0
- package/lib/video-recap/LICENSE +21 -0
- package/lib/video-recap/README.en.md +257 -0
- package/lib/video-recap/README.md +255 -0
- package/lib/video-recap/manifest.json +684 -0
- package/lib/video-recap/skills/video-assemble/SKILL.md +97 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/LICENSE.duo-video +21 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/SOURCE.md +15 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_draft_meta_info.json +69 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_combination_segment.json +84 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_combination_video_material.json +98 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_draft.json +204 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_material_video.json +83 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_meta_material_value.json +23 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_project_info.json +133 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_segment.json +70 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_jy_text_styles.json +30 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_yj_material_audio.json +41 -0
- package/lib/video-recap/skills/video-assemble/references/jianying/empty_yj_material_text.json +109 -0
- package/lib/video-recap/skills/video-assemble/scripts/artifacts.py +88 -0
- package/lib/video-recap/skills/video-assemble/scripts/assemble.py +345 -0
- package/lib/video-recap/skills/video-assemble/scripts/assemble_constants.py +34 -0
- package/lib/video-recap/skills/video-assemble/scripts/assembly_contract.py +305 -0
- package/lib/video-recap/skills/video-assemble/scripts/assembly_settings.py +94 -0
- package/lib/video-recap/skills/video-assemble/scripts/audio_automation.py +205 -0
- package/lib/video-recap/skills/video-assemble/scripts/audio_mix.py +555 -0
- package/lib/video-recap/skills/video-assemble/scripts/export_jianying.py +261 -0
- package/lib/video-recap/skills/video-assemble/scripts/jianying_builders.py +767 -0
- package/lib/video-recap/skills/video-assemble/scripts/jianying_model.py +111 -0
- package/lib/video-recap/skills/video-assemble/scripts/jianying_optional.py +24 -0
- package/lib/video-recap/skills/video-assemble/scripts/jianying_schema.py +109 -0
- package/lib/video-recap/skills/video-assemble/scripts/jianying_templates.py +37 -0
- package/lib/video-recap/skills/video-assemble/scripts/jianying_timeline_contract.py +191 -0
- package/lib/video-recap/skills/video-assemble/scripts/jianying_tracks.py +75 -0
- package/lib/video-recap/skills/video-assemble/scripts/jianying_writer.py +394 -0
- package/lib/video-recap/skills/video-assemble/scripts/lib.py +239 -0
- package/lib/video-recap/skills/video-assemble/scripts/media.py +243 -0
- package/lib/video-recap/skills/video-assemble/scripts/narration_audio.py +477 -0
- package/lib/video-recap/skills/video-assemble/scripts/render_preflight.py +46 -0
- package/lib/video-recap/skills/video-assemble/scripts/source_subtitles.py +486 -0
- package/lib/video-recap/skills/video-assemble/scripts/subtitle_core.py +376 -0
- package/lib/video-recap/skills/video-assemble/scripts/subtitle_render.py +88 -0
- package/lib/video-recap/skills/video-assemble/scripts/timeline.py +248 -0
- package/lib/video-recap/skills/video-assemble/scripts/timeline_emit.py +89 -0
- package/lib/video-recap/skills/video-assemble/scripts/visual_render.py +512 -0
- package/lib/video-recap/skills/video-cut/SKILL.md +90 -0
- package/lib/video-recap/skills/video-cut/scripts/cut.py +67 -0
- package/lib/video-recap/skills/video-cut/scripts/cut_cli.py +320 -0
- package/lib/video-recap/skills/video-cut/scripts/cut_contract.py +545 -0
- package/lib/video-recap/skills/video-cut/scripts/cut_render.py +348 -0
- package/lib/video-recap/skills/video-cut/scripts/lib.py +77 -0
- package/lib/video-recap/skills/video-cut/scripts/media_geometry.py +341 -0
- package/lib/video-recap/skills/video-cut/scripts/narration_mapping.py +249 -0
- package/lib/video-recap/skills/video-cut/scripts/sentence_boundaries.py +745 -0
- package/lib/video-recap/skills/video-recap/SKILL.md +216 -0
- package/lib/video-recap/skills/video-recap/references/config-playbook.md +61 -0
- package/lib/video-recap/skills/video-recap/references/creative-editing-playbook.md +225 -0
- package/lib/video-recap/skills/video-recap/references/data-schema.md +534 -0
- package/lib/video-recap/skills/video-recap/references/research-guide.md +74 -0
- package/lib/video-recap/skills/video-recap/references/shift-left-qc-schema.md +23 -0
- package/lib/video-recap/skills/video-recap/references/timeline-and-jianying.md +251 -0
- package/lib/video-recap/skills/video-recap/scripts/doctor.py +483 -0
- package/lib/video-recap/skills/video-recap/scripts/final_qc.py +737 -0
- package/lib/video-recap/skills/video-recap/scripts/lib.py +242 -0
- package/lib/video-recap/skills/video-recap/scripts/materials.py +457 -0
- package/lib/video-recap/skills/video-recap/scripts/mimo_qc.py +95 -0
- package/lib/video-recap/skills/video-recap/scripts/mimo_qc_client.py +18 -0
- package/lib/video-recap/skills/video-recap/scripts/mimo_qc_contract.py +9 -0
- package/lib/video-recap/skills/video-recap/scripts/mimo_qc_evidence.py +371 -0
- package/lib/video-recap/skills/video-recap/scripts/mimo_qc_observations.py +201 -0
- package/lib/video-recap/skills/video-recap/scripts/mimo_qc_payload.py +227 -0
- package/lib/video-recap/skills/video-recap/scripts/mimo_qc_report.py +362 -0
- package/lib/video-recap/skills/video-recap/scripts/mimo_qc_runner.py +129 -0
- package/lib/video-recap/skills/video-recap/scripts/qc_contract.py +338 -0
- package/lib/video-recap/skills/video-recap/scripts/recap.py +9 -0
- package/lib/video-recap/skills/video-recap/scripts/recap_cli.py +140 -0
- package/lib/video-recap/skills/video-recap/scripts/recap_inspect.py +550 -0
- package/lib/video-recap/skills/video-recap/scripts/recap_review.py +77 -0
- package/lib/video-recap/skills/video-recap/scripts/recap_runner.py +654 -0
- package/lib/video-recap/skills/video-recap/scripts/recap_runtime.py +335 -0
- package/lib/video-recap/skills/video-recap/scripts/recap_stage_qc.py +217 -0
- package/lib/video-recap/skills/video-recap/scripts/recap_timeline.py +795 -0
- package/lib/video-recap/skills/video-script/SKILL.md +248 -0
- package/lib/video-recap/skills/video-script/references/creative-editing-playbook.md +225 -0
- package/lib/video-recap/skills/video-script/references/research-guide.md +75 -0
- package/lib/video-recap/skills/video-script/scripts/agent_brief.py +399 -0
- package/lib/video-recap/skills/video-script/scripts/agent_text.py +410 -0
- package/lib/video-recap/skills/video-script/scripts/brief_context.py +403 -0
- package/lib/video-recap/skills/video-script/scripts/brief_inputs.py +332 -0
- package/lib/video-recap/skills/video-script/scripts/brief_timeline.py +442 -0
- package/lib/video-recap/skills/video-script/scripts/deslop_qc.py +237 -0
- package/lib/video-recap/skills/video-script/scripts/evidence_bundle.py +492 -0
- package/lib/video-recap/skills/video-script/scripts/lib.py +327 -0
- package/lib/video-recap/skills/video-script/scripts/narration.py +12 -0
- package/lib/video-recap/skills/video-script/scripts/narration_lint.py +678 -0
- package/lib/video-recap/skills/video-script/scripts/review.py +42 -0
- package/lib/video-recap/skills/video-script/scripts/review_grounding.py +262 -0
- package/lib/video-recap/skills/video-script/scripts/review_response.py +761 -0
- package/lib/video-recap/skills/video-script/scripts/review_runner.py +200 -0
- package/lib/video-recap/skills/video-script/scripts/speech_ownership.py +204 -0
- package/lib/video-recap/skills/video-script/scripts/timeline_fusion.py +199 -0
- package/lib/video-recap/skills/video-script/scripts/validate.py +164 -0
- package/lib/video-recap/skills/video-understanding/SKILL.md +75 -0
- package/lib/video-recap/skills/video-understanding/references/data-schema.md +299 -0
- package/lib/video-recap/skills/video-understanding/references/prompt-templates.md +37 -0
- package/lib/video-recap/skills/video-understanding/references/research-guide.md +74 -0
- package/lib/video-recap/skills/video-understanding/scripts/agent_brief.py +399 -0
- package/lib/video-recap/skills/video-understanding/scripts/agent_text.py +410 -0
- package/lib/video-recap/skills/video-understanding/scripts/asr.py +260 -0
- package/lib/video-recap/skills/video-understanding/scripts/brief.py +12 -0
- package/lib/video-recap/skills/video-understanding/scripts/brief_context.py +403 -0
- package/lib/video-recap/skills/video-understanding/scripts/brief_inputs.py +332 -0
- package/lib/video-recap/skills/video-understanding/scripts/brief_timeline.py +442 -0
- package/lib/video-recap/skills/video-understanding/scripts/consolidate.py +647 -0
- package/lib/video-recap/skills/video-understanding/scripts/deslop_qc.py +237 -0
- package/lib/video-recap/skills/video-understanding/scripts/detect.py +513 -0
- package/lib/video-recap/skills/video-understanding/scripts/extract.py +62 -0
- package/lib/video-recap/skills/video-understanding/scripts/lib.py +470 -0
- package/lib/video-recap/skills/video-understanding/scripts/narration_lint.py +678 -0
- package/lib/video-recap/skills/video-understanding/scripts/speech_ownership.py +204 -0
- package/lib/video-recap/skills/video-understanding/scripts/storyboard.py +507 -0
- package/lib/video-recap/skills/video-understanding/scripts/timeline_fusion.py +199 -0
- package/lib/video-recap/skills/video-understanding/scripts/understand.py +9 -0
- package/lib/video-recap/skills/video-understanding/scripts/understanding_brief.py +216 -0
- package/lib/video-recap/skills/video-understanding/scripts/understanding_cache.py +327 -0
- package/lib/video-recap/skills/video-understanding/scripts/understanding_runner.py +367 -0
- package/lib/video-recap/skills/video-understanding/scripts/understanding_storyboard.py +162 -0
- package/lib/video-recap/skills/video-understanding/scripts/vlm.py +705 -0
- package/lib/video-recap/skills/video-voiceover/SKILL.md +81 -0
- package/lib/video-recap/skills/video-voiceover/scripts/dub.py +637 -0
- package/lib/video-recap/skills/video-voiceover/scripts/fish_audio.py +109 -0
- package/lib/video-recap/skills/video-voiceover/scripts/lib.py +421 -0
- package/lib/video-recap/skills/video-voiceover/scripts/tts_audio.py +113 -0
- package/lib/video-recap/skills/video-voiceover/scripts/voiceover.py +782 -0
- package/package.json +55 -40
- package/lib/oh-story/skills/story-deslop/scripts/check-outline-copy.js +0 -241
- package/lib/oh-story/skills/story-long-write/references/format-and-structure.md +0 -169
- package/lib/oh-story/skills/story-setup/references/agent-references/genre-writing-formulas.md +0 -444
- package/lib/oh-story/skills/story-setup/references/agent-references/quality-checklist.md +0 -247
- package/lib/oh-story/skills/story-short-analyze/references/anti-ai-writing.md +0 -582
- package/lib/oh-story/skills/story-short-analyze/references/banned-words.md +0 -147
- package/lib/oh-story/skills/story-short-analyze/references/genre-catalog.md +0 -490
- package/lib/oh-story/skills/story-short-analyze/references/genre-core-mechanics.md +0 -425
- package/lib/oh-story/skills/story-short-analyze/references/genre-writing-formulas.md +0 -453
- /package/lib/oh-story/skills/{story-long-write/references/hooks-chapter.md → story-setup/references/agent-references/short-chapter-hooks.md} +0 -0
- /package/lib/oh-story/skills/{story-long-write/references/hooks-paragraph.md → story-setup/references/agent-references/short-paragraph-hooks.md} +0 -0
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
"""English→Chinese dubbing — the render engine behind `recap.py --edit-mode dub`.
|
|
2
|
+
|
|
3
|
+
Invoked by the orchestrator (NOT run by hand). It replaces the original English speech with a
|
|
4
|
+
faithful Chinese translation spoken in the ORIGINAL speaker's cloned voice
|
|
5
|
+
(`mimo-v2.5-tts-voiceclone`, same MIMO_API_KEY, pure stdlib + ffmpeg, no GPU). This differs
|
|
6
|
+
from recap/解说, which overlays Chinese commentary on ducked original audio.
|
|
7
|
+
|
|
8
|
+
Division of labour (the same as recap): CODE does only the mechanical parts; the AGENT does all
|
|
9
|
+
the judgment. So there are NO text heuristics here (no sentence-splitting, hook-dedup, or junk
|
|
10
|
+
filters) — those are exactly the things an LLM does better, and trying to do them in code is
|
|
11
|
+
brittle and case-by-case. Two stages around an agent-authored pause:
|
|
12
|
+
|
|
13
|
+
--stage prepare : extract audio → English ASR (timed windows) → pull one reference clip →
|
|
14
|
+
write dub_transcript.json + dub_brief.md, then stop.
|
|
15
|
+
--stage render : read the agent's dub_script.json ([{"start", "zh"}] on the source timeline)
|
|
16
|
+
→ clone the original voice per line → time-fit each to its slot (anchored at
|
|
17
|
+
its start; only compress when it would overrun the next line — never a global
|
|
18
|
+
speed-up, so the voice never finishes ahead of the picture) → full-replace
|
|
19
|
+
the audio track → mux → dub_<name>.mp4.
|
|
20
|
+
"""
|
|
21
|
+
import argparse
|
|
22
|
+
import base64
|
|
23
|
+
import hashlib
|
|
24
|
+
import json
|
|
25
|
+
import re
|
|
26
|
+
import unicodedata
|
|
27
|
+
import wave
|
|
28
|
+
from pathlib import Path
|
|
29
|
+
|
|
30
|
+
from lib import (
|
|
31
|
+
CONFIG,
|
|
32
|
+
get_video_duration,
|
|
33
|
+
log,
|
|
34
|
+
mimo_asr_api_call,
|
|
35
|
+
mimo_tts_api_call,
|
|
36
|
+
run_cmd,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
CLONE_MODEL = "mimo-v2.5-tts-voiceclone"
|
|
40
|
+
CLONE_SR = 24000 # mimo voiceclone returns 24kHz mono PCM16 wav
|
|
41
|
+
DUB_DELIVERY_SR = 48000 # explicit delivery rate; loudnorm otherwise exposes its 96kHz internal rate
|
|
42
|
+
ASR_MIME = "audio/wav"
|
|
43
|
+
ATEMPO_CAP = 2.0 # max compression before we trim instead (atempo>2 also sounds rushed)
|
|
44
|
+
DUB_FAST_SPEECH_CPS = 7.0
|
|
45
|
+
DUB_TRIM_RISK_CPS = 7.0
|
|
46
|
+
DUB_MIN_ASR_WINDOW_SECONDS = 0.5
|
|
47
|
+
DUB_TTS_CACHE_VERSION = 1
|
|
48
|
+
DUB_TTS_STYLE_PROMPT = "自然、清晰,保持原说话人的音色与节奏,语气平稳。"
|
|
49
|
+
|
|
50
|
+
DUB_SCHEMA_VERSION = 1
|
|
51
|
+
# Tolerate ~1-frame rounding in agent-estimated timings so the gate blocks only GENUINE
|
|
52
|
+
# errors, not rounding noise (the old render clamped such cases via min(slot_end, nxt)).
|
|
53
|
+
DUB_TIMING_EPS = 0.05
|
|
54
|
+
DUB_LINT_SCHEMA = {
|
|
55
|
+
"schema_version": DUB_SCHEMA_VERSION,
|
|
56
|
+
"artifact": "dub_lint.json",
|
|
57
|
+
"fields": {
|
|
58
|
+
"verdict": "PASS|FAIL",
|
|
59
|
+
"issues": "[{severity, code, line, message, start, end}]",
|
|
60
|
+
"summary": "{lines, errors, warnings, max_chars_per_second, trim_risk_lines}",
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
DUB_REVIEW_SCHEMA = {
|
|
64
|
+
"schema_version": DUB_SCHEMA_VERSION,
|
|
65
|
+
"artifact": "dub_review.json",
|
|
66
|
+
"fields": {
|
|
67
|
+
"verdict": "PASS|REVISE|FAIL",
|
|
68
|
+
"checks": "{faithful_to_source, spoken_chinese, speaker_tone, timing_fit, platform_fit}",
|
|
69
|
+
"highest_return_edits": "[{line, start, issue, suggestion}]",
|
|
70
|
+
"notes": "human/agent review notes; script-level output is deterministic pre-review guidance",
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
DUB_ARTIFACT_SCHEMAS = {
|
|
74
|
+
"dub_transcript.json": {
|
|
75
|
+
"schema_version": DUB_SCHEMA_VERSION,
|
|
76
|
+
"shape": {"video": "path", "duration": "seconds", "windows": [{"start": 0.0, "end": 6.0, "text": "English ASR"}]},
|
|
77
|
+
},
|
|
78
|
+
"dub_script.json": {
|
|
79
|
+
"schema_version": DUB_SCHEMA_VERSION,
|
|
80
|
+
"shape": [{"start": 0.0, "end": 2.4, "zh": "中文台词"}],
|
|
81
|
+
},
|
|
82
|
+
"dub_manifest.json": {
|
|
83
|
+
"schema_version": DUB_SCHEMA_VERSION,
|
|
84
|
+
"shape": {"video": "path", "duration": "seconds", "lines": [{"start": 0.0, "end": 2.4, "zh": "中文台词", "tts_cache": "hit|miss", "fitted_wav": "path", "fitted_dur": 1.8, "room": 2.4}]},
|
|
85
|
+
},
|
|
86
|
+
"dub_lint.json": DUB_LINT_SCHEMA,
|
|
87
|
+
"dub_review.json": DUB_REVIEW_SCHEMA,
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _chars_per_second(text, room):
|
|
92
|
+
room = max(float(room or 0.0), 0.001)
|
|
93
|
+
effective = 0
|
|
94
|
+
for ch in str(text or ""):
|
|
95
|
+
if ch.isspace():
|
|
96
|
+
continue
|
|
97
|
+
cat = unicodedata.category(ch)
|
|
98
|
+
if cat.startswith("P") or cat.startswith("S"):
|
|
99
|
+
continue
|
|
100
|
+
effective += 1
|
|
101
|
+
return effective / room
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def _issue(severity, code, line, message, start=None, end=None):
|
|
105
|
+
item = {"severity": severity, "code": code, "line": line, "message": message}
|
|
106
|
+
if start is not None:
|
|
107
|
+
item["start"] = round(float(start), 3)
|
|
108
|
+
if end is not None:
|
|
109
|
+
item["end"] = round(float(end), 3)
|
|
110
|
+
return item
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _normalize_dub_script(script):
|
|
114
|
+
if not isinstance(script, list):
|
|
115
|
+
raise ValueError("dub_script.json must be a list")
|
|
116
|
+
lines = []
|
|
117
|
+
for i, item in enumerate(script):
|
|
118
|
+
if not isinstance(item, dict):
|
|
119
|
+
lines.append({"_input_index": i, "start": None, "end": None, "zh": ""})
|
|
120
|
+
continue
|
|
121
|
+
start = item.get("start")
|
|
122
|
+
end = item.get("end")
|
|
123
|
+
try:
|
|
124
|
+
start = float(start)
|
|
125
|
+
except (TypeError, ValueError):
|
|
126
|
+
start = None
|
|
127
|
+
try:
|
|
128
|
+
end = float(end) if end is not None else None
|
|
129
|
+
except (TypeError, ValueError):
|
|
130
|
+
end = None
|
|
131
|
+
lines.append({"_input_index": i, "start": start, "end": end,
|
|
132
|
+
"zh": str(item.get("zh", "")).strip()})
|
|
133
|
+
return sorted(lines, key=lambda x: (float("inf") if x["start"] is None else x["start"], x["_input_index"]))
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def lint_dub_script(script, duration, work_dir=None):
|
|
137
|
+
"""Deterministic hard gate for dub_script.json before expensive voiceclone render."""
|
|
138
|
+
duration = float(duration)
|
|
139
|
+
issues = []
|
|
140
|
+
if not isinstance(script, list):
|
|
141
|
+
# A malformed (non-list) script is a hard FAIL, not a crash: keep the "fail fast,
|
|
142
|
+
# see dub_lint.json" promise so the agent gets a clean message instead of a traceback.
|
|
143
|
+
bad = _issue("error", "script_not_a_list", None, "dub_script.json must be a JSON array of {start,end,zh}")
|
|
144
|
+
report = {
|
|
145
|
+
"schema_version": DUB_SCHEMA_VERSION,
|
|
146
|
+
"verdict": "FAIL",
|
|
147
|
+
"blocking": True,
|
|
148
|
+
"errors": [bad],
|
|
149
|
+
"issues": [bad],
|
|
150
|
+
"summary": {"lines": 0, "errors": 1, "warnings": 0, "max_chars_per_second": 0.0, "trim_risk_lines": []},
|
|
151
|
+
}
|
|
152
|
+
if work_dir is not None:
|
|
153
|
+
_write_json(Path(work_dir) / "dub_lint.json", report)
|
|
154
|
+
return report
|
|
155
|
+
lines = _normalize_dub_script(script)
|
|
156
|
+
max_cps = 0.0
|
|
157
|
+
trim_risk = []
|
|
158
|
+
for i, ln in enumerate(lines):
|
|
159
|
+
start, end, zh = ln["start"], ln["end"], ln["zh"]
|
|
160
|
+
line_no = ln["_input_index"]
|
|
161
|
+
nxt = lines[i + 1]["start"] if i + 1 < len(lines) else duration
|
|
162
|
+
if start is None:
|
|
163
|
+
issues.append(_issue("error", "missing_start", line_no, "line start must be a number"))
|
|
164
|
+
continue
|
|
165
|
+
out_of_range = start < -DUB_TIMING_EPS or start > duration + DUB_TIMING_EPS
|
|
166
|
+
if end is not None and (end <= start or end > duration + DUB_TIMING_EPS):
|
|
167
|
+
out_of_range = True
|
|
168
|
+
timing_valid = not out_of_range
|
|
169
|
+
if out_of_range:
|
|
170
|
+
issues.append(_issue("error", "time_out_of_range", line_no, "line timing must be within video duration and end must be > start", start, end))
|
|
171
|
+
if not zh:
|
|
172
|
+
issues.append(_issue("error", "empty_translation", line_no, "zh must not be empty", start, end))
|
|
173
|
+
if (i + 1 < len(lines) and end is not None and lines[i + 1]["start"] is not None
|
|
174
|
+
and end > lines[i + 1]["start"] + DUB_TIMING_EPS):
|
|
175
|
+
issues.append(_issue("error", "overlap", line_no, "line end overlaps the next line start", start, end))
|
|
176
|
+
slot_end = end if end is not None else nxt
|
|
177
|
+
if timing_valid and start is not None and slot_end is not None:
|
|
178
|
+
room = max(0.0, min(slot_end, nxt if nxt is not None else slot_end) - start)
|
|
179
|
+
cps = _chars_per_second(zh, room)
|
|
180
|
+
max_cps = max(max_cps, cps)
|
|
181
|
+
if room < 0.4:
|
|
182
|
+
issues.append(_issue("error", "room_too_short", line_no, "line has less than 0.4s room for speech", start, end))
|
|
183
|
+
elif zh and cps >= DUB_FAST_SPEECH_CPS:
|
|
184
|
+
issues.append(_issue("warning", "fast_speech", line_no, f"translation is dense ({cps:.1f} chars/s)", start, end))
|
|
185
|
+
if zh and cps >= DUB_TRIM_RISK_CPS:
|
|
186
|
+
trim_risk.append(line_no)
|
|
187
|
+
issues.append(_issue("warning", "trim_risk", line_no, "likely to be compressed hard or trimmed by render", start, end))
|
|
188
|
+
error_items = [x for x in issues if x["severity"] == "error"]
|
|
189
|
+
priority = {"empty_translation": 0, "overlap": 1, "time_out_of_range": 2}
|
|
190
|
+
error_items = sorted(error_items, key=lambda x: (priority.get(x["code"], 99), x.get("line", 0)))
|
|
191
|
+
warnings = sum(1 for x in issues if x["severity"] == "warning")
|
|
192
|
+
report = {
|
|
193
|
+
"schema_version": DUB_SCHEMA_VERSION,
|
|
194
|
+
"verdict": "FAIL" if error_items else "PASS",
|
|
195
|
+
"blocking": bool(error_items),
|
|
196
|
+
"errors": error_items,
|
|
197
|
+
"issues": issues,
|
|
198
|
+
"summary": {
|
|
199
|
+
"lines": len(lines),
|
|
200
|
+
"errors": len(error_items),
|
|
201
|
+
"warnings": warnings,
|
|
202
|
+
"max_chars_per_second": round(max_cps, 2),
|
|
203
|
+
"trim_risk_lines": trim_risk,
|
|
204
|
+
},
|
|
205
|
+
}
|
|
206
|
+
if work_dir is not None:
|
|
207
|
+
_write_json(Path(work_dir) / "dub_lint.json", report)
|
|
208
|
+
return report
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def build_dub_review(script, transcript, lint=None):
|
|
212
|
+
"""Script-level review scaffold: deterministic timing/naturalness signals for agent review."""
|
|
213
|
+
duration = float(transcript.get("duration", 0.0))
|
|
214
|
+
lint = lint or lint_dub_script(script, duration)
|
|
215
|
+
try:
|
|
216
|
+
lines = _normalize_dub_script(script)
|
|
217
|
+
except ValueError:
|
|
218
|
+
lines = [] # non-list script already FAILs lint; review is just a scaffold here
|
|
219
|
+
edits = []
|
|
220
|
+
for issue in lint.get("issues", []):
|
|
221
|
+
if issue["severity"] in {"error", "warning"}:
|
|
222
|
+
edits.append({
|
|
223
|
+
"line": issue.get("line"),
|
|
224
|
+
"start": issue.get("start"),
|
|
225
|
+
"issue": f"{issue['code']}: {issue['message']}",
|
|
226
|
+
"suggestion": "缩短译文、调整 start/end,或回到 transcript 核对原句边界。",
|
|
227
|
+
})
|
|
228
|
+
verdict = "FAIL" if lint.get("verdict") == "FAIL" else ("REVISE" if edits else "PASS")
|
|
229
|
+
return {
|
|
230
|
+
"schema_version": DUB_SCHEMA_VERSION,
|
|
231
|
+
"verdict": verdict,
|
|
232
|
+
"checks": {
|
|
233
|
+
"faithful_to_source": "needs_agent_review",
|
|
234
|
+
"spoken_chinese": "REVISE" if any(i.get("code") == "fast_speech" for i in lint.get("issues", [])) else "PASS",
|
|
235
|
+
"speaker_tone": "needs_agent_review",
|
|
236
|
+
"timing_fit": "FAIL" if lint.get("verdict") == "FAIL" else ("REVISE" if edits else "PASS"),
|
|
237
|
+
"platform_fit": "needs_agent_review",
|
|
238
|
+
},
|
|
239
|
+
"highest_return_edits": edits[:8],
|
|
240
|
+
"notes": "Deterministic script-level review; an agent/human should fill semantic fidelity and tone judgments against dub_transcript.json.",
|
|
241
|
+
"coverage": {"transcript_windows": len(transcript.get("windows", [])), "script_lines": len(lines)},
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def _write_json(path, payload):
|
|
246
|
+
Path(path).write_text(json.dumps(payload, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
247
|
+
return path
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
# ── ffmpeg / wav helpers ─────────────────────────────────────────────
|
|
251
|
+
|
|
252
|
+
def _ffmpeg_extract_wav(video, out_wav, sr=16000):
|
|
253
|
+
run_cmd(["ffmpeg", "-y", "-i", str(video), "-vn", "-ar", str(sr), "-ac", "1", str(out_wav)])
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def _cut_wav(src_wav, out_wav, start, dur, sr=16000):
|
|
257
|
+
run_cmd(["ffmpeg", "-y", "-i", str(src_wav), "-ss", str(start), "-t", str(dur),
|
|
258
|
+
"-ar", str(sr), "-ac", "1", str(out_wav)])
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def _atempo_chain(factor):
|
|
262
|
+
"""ffmpeg atempo only accepts 0.5–2.0 per stage; chain for larger factors."""
|
|
263
|
+
factor = max(0.5, factor)
|
|
264
|
+
stages, remaining = [], factor
|
|
265
|
+
while remaining > 2.0:
|
|
266
|
+
stages.append("atempo=2.0")
|
|
267
|
+
remaining /= 2.0
|
|
268
|
+
stages.append(f"atempo={remaining:.4f}")
|
|
269
|
+
return ",".join(stages)
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
def _wav_frames(path):
|
|
273
|
+
with wave.open(str(path), "rb") as w:
|
|
274
|
+
return w.getframerate(), w.getnchannels(), w.readframes(w.getnframes())
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
# ── ASR (timed windows) ──────────────────────────────────────────────
|
|
278
|
+
|
|
279
|
+
def _strip_reasoning_residue(text):
|
|
280
|
+
"""Remove MiMo reasoning-model <think>…</think> leakage from ASR content.
|
|
281
|
+
|
|
282
|
+
Thinking-disable is not applied to -asr models (lib._prepare_api_payload), so a reasoning
|
|
283
|
+
model can leak a <think> block — full, truncated/unclosed, or a leading orphan/residual tag
|
|
284
|
+
(observed as a bare "think>" prefix) — into the transcript. Strip all shapes; the generic
|
|
285
|
+
marker strip in _run_asr then handles the remaining "<chinese>"-style tags.
|
|
286
|
+
"""
|
|
287
|
+
text = re.sub(r"(?is)<think\b.*?</think\s*>", "", text) # full <think>…</think> block
|
|
288
|
+
text = re.sub(r"(?is)<think\b.*\Z", "", text) # unclosed/truncated <think tail
|
|
289
|
+
text = re.sub(r"(?i)^\s*<?/?think\s*>\s*", "", text) # leading orphan/residual think tag
|
|
290
|
+
return text
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def _run_asr(wav_path, lang="en"):
|
|
294
|
+
try:
|
|
295
|
+
with wave.open(str(wav_path), "rb") as source:
|
|
296
|
+
if source.getnframes() <= 0:
|
|
297
|
+
return ""
|
|
298
|
+
except (OSError, EOFError, wave.Error):
|
|
299
|
+
return ""
|
|
300
|
+
raw = Path(wav_path).read_bytes()
|
|
301
|
+
if not raw:
|
|
302
|
+
return ""
|
|
303
|
+
b64 = base64.b64encode(raw).decode("ascii")
|
|
304
|
+
payload = {
|
|
305
|
+
"model": CONFIG.get("mimo_asr_model", "mimo-v2.5-asr"),
|
|
306
|
+
"messages": [{"role": "user", "content": [
|
|
307
|
+
{"type": "input_audio", "input_audio": {"data": f"data:{ASR_MIME};base64,{b64}"}},
|
|
308
|
+
]}],
|
|
309
|
+
"asr_options": {"language": lang},
|
|
310
|
+
}
|
|
311
|
+
resp = mimo_asr_api_call(payload)
|
|
312
|
+
try:
|
|
313
|
+
text = str(resp["choices"][0]["message"]["content"] or "").strip()
|
|
314
|
+
except (KeyError, IndexError, TypeError):
|
|
315
|
+
return ""
|
|
316
|
+
return re.sub(r"<[^>]{1,20}>", "", _strip_reasoning_residue(text)).strip() # strip reasoning + ASR markers like "<chinese>"
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
def _asr_windows(audio_wav, segs_dir, duration, window):
|
|
320
|
+
"""Transcribe fixed-time windows → [{start, end, text}]. Coarse timing anchors for the agent;
|
|
321
|
+
the agent does the sentence/segment judgment, not this code."""
|
|
322
|
+
windows = []
|
|
323
|
+
start, idx = 0.0, 0
|
|
324
|
+
while start < duration:
|
|
325
|
+
end = min(start + window, duration)
|
|
326
|
+
if end - start < DUB_MIN_ASR_WINDOW_SECONDS:
|
|
327
|
+
log(f" ASR {start:.0f}-{end:.0f}s: 跳过不足 {DUB_MIN_ASR_WINDOW_SECONDS:.1f}s 的编码尾巴")
|
|
328
|
+
break
|
|
329
|
+
seg_wav = segs_dir / f"asr_{idx:03d}.wav"
|
|
330
|
+
_cut_wav(audio_wav, seg_wav, start, end - start)
|
|
331
|
+
text = _run_asr(seg_wav)
|
|
332
|
+
if text:
|
|
333
|
+
windows.append({"start": round(start, 2), "end": round(end, 2), "text": text})
|
|
334
|
+
log(f" ASR {start:.0f}-{end:.0f}s: {len(text)} chars")
|
|
335
|
+
start, idx = end, idx + 1
|
|
336
|
+
return windows
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
# ── clone TTS + time-fit + mix ───────────────────────────────────────
|
|
340
|
+
|
|
341
|
+
def _clone_tts(text, ref_b64, out_wav):
|
|
342
|
+
payload = {
|
|
343
|
+
"model": CLONE_MODEL,
|
|
344
|
+
"messages": [
|
|
345
|
+
{"role": "user", "content": DUB_TTS_STYLE_PROMPT},
|
|
346
|
+
{"role": "assistant", "content": text},
|
|
347
|
+
],
|
|
348
|
+
"audio": {"format": "wav", "voice": f"data:audio/wav;base64,{ref_b64}"},
|
|
349
|
+
}
|
|
350
|
+
resp = mimo_tts_api_call(payload)
|
|
351
|
+
data = resp["choices"][0]["message"]["audio"]["data"]
|
|
352
|
+
Path(out_wav).write_bytes(base64.b64decode(data))
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
def _clone_cache_fingerprint(text, ref_bytes):
|
|
356
|
+
payload = {
|
|
357
|
+
"cache_version": DUB_TTS_CACHE_VERSION,
|
|
358
|
+
"model": CLONE_MODEL,
|
|
359
|
+
"style_prompt": DUB_TTS_STYLE_PROMPT,
|
|
360
|
+
"text": str(text),
|
|
361
|
+
"reference_sha256": hashlib.sha256(ref_bytes).hexdigest(),
|
|
362
|
+
}
|
|
363
|
+
encoded = json.dumps(payload, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode("utf-8")
|
|
364
|
+
return hashlib.sha256(encoded).hexdigest()
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def _clone_cache_meta_path(raw_wav):
|
|
368
|
+
raw_wav = Path(raw_wav)
|
|
369
|
+
return raw_wav.with_name(f"{raw_wav.name}.meta.json")
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
def _usable_clone_wav(path):
|
|
373
|
+
try:
|
|
374
|
+
sample_rate, channels, frames = _wav_frames(path)
|
|
375
|
+
except (FileNotFoundError, OSError, EOFError, wave.Error):
|
|
376
|
+
return False
|
|
377
|
+
return sample_rate > 0 and channels > 0 and bool(frames)
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
def _write_clone_cache_meta(raw_wav, text, ref_bytes):
|
|
381
|
+
meta = {
|
|
382
|
+
"schema_version": DUB_TTS_CACHE_VERSION,
|
|
383
|
+
"fingerprint": _clone_cache_fingerprint(text, ref_bytes),
|
|
384
|
+
"model": CLONE_MODEL,
|
|
385
|
+
}
|
|
386
|
+
return _write_json(_clone_cache_meta_path(raw_wav), meta)
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
def _ensure_clone_tts(text, ref_b64, ref_bytes, raw_wav):
|
|
390
|
+
raw_wav = Path(raw_wav)
|
|
391
|
+
expected = _clone_cache_fingerprint(text, ref_bytes)
|
|
392
|
+
meta_path = _clone_cache_meta_path(raw_wav)
|
|
393
|
+
try:
|
|
394
|
+
meta = json.loads(meta_path.read_text(encoding="utf-8"))
|
|
395
|
+
except (FileNotFoundError, OSError, ValueError, TypeError):
|
|
396
|
+
meta = {}
|
|
397
|
+
if meta.get("fingerprint") == expected and _usable_clone_wav(raw_wav):
|
|
398
|
+
return True
|
|
399
|
+
|
|
400
|
+
_clone_tts(text, ref_b64, raw_wav)
|
|
401
|
+
if not _usable_clone_wav(raw_wav):
|
|
402
|
+
raise RuntimeError(f"MiMo voiceclone returned an invalid WAV: {raw_wav}")
|
|
403
|
+
_write_clone_cache_meta(raw_wav, text, ref_bytes)
|
|
404
|
+
return False
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
def _time_fit(raw_wav, fitted_wav, room_seconds):
|
|
408
|
+
"""Anchor-at-start fit: only compress when the dub would overrun `room_seconds` (the gap until
|
|
409
|
+
the next line). Never globally speed up; a short dub keeps the natural pause. Returns the
|
|
410
|
+
fitted duration."""
|
|
411
|
+
dur = get_video_duration(raw_wav)
|
|
412
|
+
if dur <= 0:
|
|
413
|
+
return 0.0
|
|
414
|
+
if dur <= room_seconds + 0.05:
|
|
415
|
+
run_cmd(["ffmpeg", "-y", "-i", str(raw_wav), "-ar", str(CLONE_SR), "-ac", "1", str(fitted_wav)])
|
|
416
|
+
return dur
|
|
417
|
+
factor = dur / room_seconds
|
|
418
|
+
if factor <= ATEMPO_CAP:
|
|
419
|
+
run_cmd(["ffmpeg", "-y", "-i", str(raw_wav), "-filter:a", _atempo_chain(factor),
|
|
420
|
+
"-ar", str(CLONE_SR), "-ac", "1", str(fitted_wav)])
|
|
421
|
+
return get_video_duration(fitted_wav)
|
|
422
|
+
run_cmd(["ffmpeg", "-y", "-i", str(raw_wav),
|
|
423
|
+
"-filter:a", f"{_atempo_chain(ATEMPO_CAP)},atrim=0:{room_seconds:.3f},"
|
|
424
|
+
f"afade=t=out:st={max(0, room_seconds - 0.15):.3f}:d=0.15",
|
|
425
|
+
"-ar", str(CLONE_SR), "-ac", "1", str(fitted_wav)])
|
|
426
|
+
return get_video_duration(fitted_wav)
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
def _build_dub_track(lines, duration, out_wav):
|
|
430
|
+
canvas = bytearray(int(duration * CLONE_SR) * 2) # 16-bit mono silence
|
|
431
|
+
for ln in lines:
|
|
432
|
+
fw = ln.get("fitted_wav")
|
|
433
|
+
if not fw or not Path(fw).exists():
|
|
434
|
+
continue
|
|
435
|
+
sr, ch, frames = _wav_frames(fw)
|
|
436
|
+
if sr != CLONE_SR or ch != 1:
|
|
437
|
+
continue
|
|
438
|
+
off = int(ln["start"] * CLONE_SR) * 2
|
|
439
|
+
end = min(off + len(frames), len(canvas))
|
|
440
|
+
canvas[off:end] = frames[: end - off]
|
|
441
|
+
with wave.open(str(out_wav), "wb") as w:
|
|
442
|
+
w.setnchannels(1)
|
|
443
|
+
w.setsampwidth(2)
|
|
444
|
+
w.setframerate(CLONE_SR)
|
|
445
|
+
w.writeframes(bytes(canvas))
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
def _mux(video, dub_wav, out_video):
|
|
449
|
+
run_cmd(["ffmpeg", "-y", "-i", str(video), "-i", str(dub_wav),
|
|
450
|
+
"-map", "0:v:0", "-map", "1:a:0", "-c:v", "copy",
|
|
451
|
+
"-af", "loudnorm=I=-16:TP=-1.5:LRA=11", "-c:a", "aac", "-b:a", "192k",
|
|
452
|
+
"-ar", str(DUB_DELIVERY_SR),
|
|
453
|
+
"-shortest", str(out_video)])
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
# ── stages ───────────────────────────────────────────────────────────
|
|
457
|
+
|
|
458
|
+
def _ref_window(duration, ref_start, ref_dur):
|
|
459
|
+
start = max(0.0, min(ref_start, max(0.0, duration - 2.0)))
|
|
460
|
+
return start, max(2.0, min(ref_dur, duration - start))
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
def stage_prepare(video, work, asr_window, ref_start, ref_dur):
|
|
464
|
+
work.mkdir(parents=True, exist_ok=True)
|
|
465
|
+
segs_dir = work / "dub_asr"
|
|
466
|
+
segs_dir.mkdir(exist_ok=True)
|
|
467
|
+
duration = get_video_duration(video)
|
|
468
|
+
log(f"[dub:prepare] video {duration:.1f}s")
|
|
469
|
+
|
|
470
|
+
audio_wav = work / "dub_source.wav"
|
|
471
|
+
_ffmpeg_extract_wav(video, audio_wav)
|
|
472
|
+
windows = _asr_windows(audio_wav, segs_dir, duration, asr_window)
|
|
473
|
+
if not windows:
|
|
474
|
+
raise SystemExit("[dub] no speech transcribed")
|
|
475
|
+
log(f"[dub:prepare] {len(windows)} ASR windows")
|
|
476
|
+
|
|
477
|
+
rs, rd = _ref_window(duration, ref_start, ref_dur)
|
|
478
|
+
_cut_wav(audio_wav, work / "dub_reference.wav", rs, rd)
|
|
479
|
+
|
|
480
|
+
(work / "dub_transcript.json").write_text(
|
|
481
|
+
json.dumps({"video": str(video), "duration": duration, "windows": windows},
|
|
482
|
+
ensure_ascii=False, indent=2), encoding="utf-8")
|
|
483
|
+
(work / "dub_brief.md").write_text(_brief_md(windows, duration), encoding="utf-8")
|
|
484
|
+
print(json.dumps({"status": "dub_prepared", "windows": len(windows),
|
|
485
|
+
"brief": str(work / "dub_brief.md")}, ensure_ascii=False))
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
def _brief_md(windows, duration):
|
|
489
|
+
lines = [
|
|
490
|
+
"# 配音翻译任务(dub)",
|
|
491
|
+
"",
|
|
492
|
+
f"视频时长 {duration:.1f}s。下面是英文原声的分窗转写(时间戳偏粗,仅作锚点)。",
|
|
493
|
+
"把它**忠实翻译并配音**,写入 `dub_script.json`——核心是**和原视频节奏一致**,不是做解说、"
|
|
494
|
+
"也不是做精简版。",
|
|
495
|
+
"",
|
|
496
|
+
"要点:",
|
|
497
|
+
"1. 逐句忠实翻译,原声说什么就配什么;**不要删内容、不要合并、不要自作主张去掉开场 hook**;"
|
|
498
|
+
"原声重复,配音也跟着重复。",
|
|
499
|
+
"2. 每句放在它在原声里被说出的时间,`start`/`end` 取那句话的起止——这样配音才跟着原声节奏走"
|
|
500
|
+
"(该停顿处自然留白)。",
|
|
501
|
+
"3. 译文忠实精简,能在自己的 `start`→`end` 区间内用正常语速说完(约 5 字/秒)。",
|
|
502
|
+
"4. 只有完全被截断、没法说完整的残句,才取其中说得完整的部分。",
|
|
503
|
+
"",
|
|
504
|
+
"输出 `dub_script.json` = `[{\"start\": 起秒, \"end\": 止秒, \"zh\": \"中文台词\"}, ...]`,按 start "
|
|
505
|
+
"升序,[start,end] 是该句在原声里的时间区间,相邻句不要重叠。",
|
|
506
|
+
"",
|
|
507
|
+
"## 英文原声转写(按时间窗)",
|
|
508
|
+
"",
|
|
509
|
+
"| 起–止 | 英文 |",
|
|
510
|
+
"|---|---|",
|
|
511
|
+
]
|
|
512
|
+
for w in windows:
|
|
513
|
+
lines.append(f"| {w['start']}–{w['end']}s | {w['text'].replace('|', '/')} |")
|
|
514
|
+
return "\n".join(lines) + "\n"
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
def stage_render(video, work, ref_start, ref_dur):
|
|
518
|
+
transcript = json.loads((work / "dub_transcript.json").read_text(encoding="utf-8"))
|
|
519
|
+
duration = transcript["duration"]
|
|
520
|
+
script = json.loads((work / "dub_script.json").read_text(encoding="utf-8"))
|
|
521
|
+
# Mechanical hard gate BEFORE any voiceclone spend: empty/overlapping/out-of-range lines
|
|
522
|
+
# cannot produce a publishable dub, so fail fast instead of paying for a broken render.
|
|
523
|
+
lint = lint_dub_script(script, duration)
|
|
524
|
+
_write_json(work / "dub_lint.json", lint)
|
|
525
|
+
review = build_dub_review(script, transcript, lint)
|
|
526
|
+
_write_json(work / "dub_review.json", review)
|
|
527
|
+
if lint["verdict"] != "PASS":
|
|
528
|
+
raise SystemExit(f"[dub] dub_script.json failed lint; see {work / 'dub_lint.json'}")
|
|
529
|
+
lines = [{"start": ln["start"], "end": ln["end"], "zh": ln["zh"]}
|
|
530
|
+
for ln in _normalize_dub_script(script) if ln["zh"]]
|
|
531
|
+
if not lines:
|
|
532
|
+
raise SystemExit("[dub] dub_script.json has no lines")
|
|
533
|
+
|
|
534
|
+
ref_wav = work / "dub_reference.wav"
|
|
535
|
+
if not ref_wav.exists():
|
|
536
|
+
rs, rd = _ref_window(duration, ref_start, ref_dur)
|
|
537
|
+
_cut_wav(work / "dub_source.wav", ref_wav, rs, rd)
|
|
538
|
+
ref_bytes = ref_wav.read_bytes()
|
|
539
|
+
ref_b64 = base64.b64encode(ref_bytes).decode("ascii")
|
|
540
|
+
|
|
541
|
+
tts_dir = work / "dub_tts"
|
|
542
|
+
tts_dir.mkdir(exist_ok=True)
|
|
543
|
+
log("[dub:render] clone-TTS + time-fit per line…")
|
|
544
|
+
for i, ln in enumerate(lines):
|
|
545
|
+
nxt = lines[i + 1]["start"] if i + 1 < len(lines) else duration
|
|
546
|
+
slot_end = ln["end"] if ln["end"] is not None else nxt
|
|
547
|
+
# fit to the original utterance's span (rhythm-faithful), but never overrun the next line
|
|
548
|
+
room = max(0.4, min(slot_end, nxt) - ln["start"])
|
|
549
|
+
raw = tts_dir / f"line_{i:03d}_raw.wav"
|
|
550
|
+
fitted = tts_dir / f"line_{i:03d}.wav"
|
|
551
|
+
cache_hit = _ensure_clone_tts(ln["zh"], ref_b64, ref_bytes, raw)
|
|
552
|
+
ln["tts_cache"] = "hit" if cache_hit else "miss"
|
|
553
|
+
ln["fitted_wav"] = str(fitted)
|
|
554
|
+
ln["fitted_dur"] = round(_time_fit(raw, fitted, room), 2)
|
|
555
|
+
ln["room"] = round(room, 2)
|
|
556
|
+
log(
|
|
557
|
+
f" line {i}: {ln['start']:.1f}s fit={ln['fitted_dur']}s/room {ln['room']}s "
|
|
558
|
+
f"cache={ln['tts_cache']} «{ln['zh'][:18]}»"
|
|
559
|
+
)
|
|
560
|
+
|
|
561
|
+
dub_wav = work / "dub_track.wav"
|
|
562
|
+
_build_dub_track(lines, duration, dub_wav)
|
|
563
|
+
out_video = work / f"dub_{Path(video).stem}.mp4"
|
|
564
|
+
_mux(video, dub_wav, out_video)
|
|
565
|
+
(work / "dub_manifest.json").write_text(
|
|
566
|
+
json.dumps({"schema_version": DUB_SCHEMA_VERSION, "video": str(video), "duration": duration, "lines": lines},
|
|
567
|
+
ensure_ascii=False, indent=2), encoding="utf-8")
|
|
568
|
+
log(f"[dub:render] done → {out_video}")
|
|
569
|
+
print(json.dumps({"status": "dubbed", "output": str(out_video), "lines": len(lines)},
|
|
570
|
+
ensure_ascii=False))
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
def stage_lint(work):
|
|
574
|
+
transcript = json.loads((work / "dub_transcript.json").read_text(encoding="utf-8"))
|
|
575
|
+
script = json.loads((work / "dub_script.json").read_text(encoding="utf-8"))
|
|
576
|
+
lint = lint_dub_script(script, transcript["duration"])
|
|
577
|
+
path = _write_json(work / "dub_lint.json", lint)
|
|
578
|
+
print(json.dumps({"status": "dub_linted", "verdict": lint["verdict"], "issues": len(lint["issues"]), "dub_lint": str(path)}, ensure_ascii=False))
|
|
579
|
+
return lint
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
def stage_review(work):
|
|
583
|
+
transcript = json.loads((work / "dub_transcript.json").read_text(encoding="utf-8"))
|
|
584
|
+
script = json.loads((work / "dub_script.json").read_text(encoding="utf-8"))
|
|
585
|
+
lint = lint_dub_script(script, transcript["duration"])
|
|
586
|
+
_write_json(work / "dub_lint.json", lint)
|
|
587
|
+
review = build_dub_review(script, transcript, lint)
|
|
588
|
+
path = _write_json(work / "dub_review.json", review)
|
|
589
|
+
print(json.dumps({"status": "dub_reviewed", "verdict": review["verdict"], "edits": len(review["highest_return_edits"]), "dub_review": str(path)}, ensure_ascii=False))
|
|
590
|
+
return review
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
def print_schemas():
|
|
594
|
+
print(json.dumps(DUB_ARTIFACT_SCHEMAS, ensure_ascii=False, indent=2))
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
def main():
|
|
598
|
+
ap = argparse.ArgumentParser(
|
|
599
|
+
description=(
|
|
600
|
+
"English→Chinese dub workflow. Artifacts: dub_transcript.json, "
|
|
601
|
+
"agent-authored dub_script.json, dub_lint.json, dub_review.json, dub_manifest.json. "
|
|
602
|
+
"Uses MiMo ASR plus mimo-v2.5-tts-voiceclone; ordinary narration TTS config is separate."
|
|
603
|
+
)
|
|
604
|
+
)
|
|
605
|
+
ap.add_argument("--stage", choices=["prepare", "lint", "review", "render"], required=False,
|
|
606
|
+
help="prepare ASR brief; lint/review dub_script.json; render writes lint/review before voiceclone")
|
|
607
|
+
ap.add_argument("--video", required=False, help="source video (required for prepare/render)")
|
|
608
|
+
ap.add_argument("--work-dir", required=False, help="work directory containing dub artifacts")
|
|
609
|
+
ap.add_argument("--asr-window", type=float, default=6.0)
|
|
610
|
+
ap.add_argument("--ref-start", type=float, default=2.0)
|
|
611
|
+
ap.add_argument("--ref-dur", type=float, default=10.0)
|
|
612
|
+
ap.add_argument("--print-schema", action="store_true",
|
|
613
|
+
help="print JSON schemas for dub_transcript/script/lint/review/manifest and exit")
|
|
614
|
+
args = ap.parse_args()
|
|
615
|
+
if args.print_schema:
|
|
616
|
+
print_schemas()
|
|
617
|
+
return
|
|
618
|
+
if not args.stage:
|
|
619
|
+
ap.error("--stage is required unless --print-schema is used")
|
|
620
|
+
if not args.work_dir:
|
|
621
|
+
ap.error("--work-dir is required")
|
|
622
|
+
work = Path(args.work_dir)
|
|
623
|
+
if args.stage in {"prepare", "render"} and not args.video:
|
|
624
|
+
ap.error("--video is required for prepare/render")
|
|
625
|
+
video = Path(args.video) if args.video else None
|
|
626
|
+
if args.stage == "prepare":
|
|
627
|
+
stage_prepare(video, work, args.asr_window, args.ref_start, args.ref_dur)
|
|
628
|
+
elif args.stage == "lint":
|
|
629
|
+
stage_lint(work)
|
|
630
|
+
elif args.stage == "review":
|
|
631
|
+
stage_review(work)
|
|
632
|
+
else:
|
|
633
|
+
stage_render(video, work, args.ref_start, args.ref_dur)
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
if __name__ == "__main__":
|
|
637
|
+
main()
|