@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,555 @@
|
|
|
1
|
+
"""Loudness, source handoffs, ducking envelopes, and audio mix graphs."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import math
|
|
5
|
+
import re
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from artifacts import _load_work_json, _value_fingerprint
|
|
9
|
+
from audio_automation import (
|
|
10
|
+
coalesce_duck_windows,
|
|
11
|
+
default_bridge,
|
|
12
|
+
ducking_expression,
|
|
13
|
+
release_ducking_expression,
|
|
14
|
+
)
|
|
15
|
+
from lib import CONFIG, log, run_cmd
|
|
16
|
+
|
|
17
|
+
def _limiter_filter():
|
|
18
|
+
peak = float(CONFIG.get("final_limiter_peak", 0.98) or 0.98)
|
|
19
|
+
return f"alimiter=limit={peak:.2f}:level=false"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _loudness_mode(measured=None):
|
|
23
|
+
if not CONFIG.get("final_loudnorm", True):
|
|
24
|
+
return "limiter_only"
|
|
25
|
+
return "two_pass_linear" if measured else "equivalent"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def final_loudnorm_filter(measured=None):
|
|
29
|
+
"""Final-mix loudness normalization/limiter filter from CONFIG.
|
|
30
|
+
|
|
31
|
+
Ducking branches set only relative balance; this single stage owns the
|
|
32
|
+
absolute output loudness so the recap is not left too quiet. When `measured`
|
|
33
|
+
is supplied from a first loudnorm pass, ffmpeg runs the deterministic second
|
|
34
|
+
pass; without it we still force the same target and peak limiter as a
|
|
35
|
+
documented equivalent/fallback path.
|
|
36
|
+
"""
|
|
37
|
+
if not CONFIG.get("final_loudnorm", True):
|
|
38
|
+
return _limiter_filter()
|
|
39
|
+
filt = (
|
|
40
|
+
f"loudnorm=I={CONFIG.get('target_lufs', -14.0)}"
|
|
41
|
+
f":TP={CONFIG.get('target_true_peak', -1.0)}"
|
|
42
|
+
f":LRA={CONFIG.get('target_lra', 11.0)}"
|
|
43
|
+
f":linear=true"
|
|
44
|
+
)
|
|
45
|
+
if measured:
|
|
46
|
+
for src, dst in (
|
|
47
|
+
("input_i", "measured_I"),
|
|
48
|
+
("input_tp", "measured_TP"),
|
|
49
|
+
("input_lra", "measured_LRA"),
|
|
50
|
+
("input_thresh", "measured_thresh"),
|
|
51
|
+
("target_offset", "offset"),
|
|
52
|
+
):
|
|
53
|
+
if src in measured:
|
|
54
|
+
filt += f":{dst}={measured[src]}"
|
|
55
|
+
filt += ":print_format=summary"
|
|
56
|
+
return f"{filt},{_limiter_filter()}"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _parse_loudnorm_json(text):
|
|
60
|
+
"""Extract ffmpeg loudnorm JSON from stderr/stdout."""
|
|
61
|
+
for match in reversed(list(re.finditer(r"\{[\s\S]*?\}", str(text or "")))):
|
|
62
|
+
try:
|
|
63
|
+
data = json.loads(match.group(0))
|
|
64
|
+
except ValueError:
|
|
65
|
+
continue
|
|
66
|
+
if isinstance(data, dict) and {"input_i", "input_tp", "input_lra", "input_thresh", "target_offset"} <= set(data):
|
|
67
|
+
return data
|
|
68
|
+
return None
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _loudnorm_first_pass_filter():
|
|
72
|
+
return (
|
|
73
|
+
f"loudnorm=I={CONFIG.get('target_lufs', -14.0)}"
|
|
74
|
+
f":TP={CONFIG.get('target_true_peak', -1.0)}"
|
|
75
|
+
f":LRA={CONFIG.get('target_lra', 11.0)}"
|
|
76
|
+
f":print_format=json"
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _run_loudnorm_first_pass(input_video, narration_wav, original_audio_input,
|
|
81
|
+
bgm_input, filter_complex, work_dir):
|
|
82
|
+
"""Measure the exact mixed audio graph before final render.
|
|
83
|
+
|
|
84
|
+
Returns ffmpeg loudnorm JSON, or None when probing fails. The caller then
|
|
85
|
+
falls back to the documented equivalent single-pass target+limiter filter.
|
|
86
|
+
"""
|
|
87
|
+
if not CONFIG.get("final_loudnorm", True):
|
|
88
|
+
return None
|
|
89
|
+
probe_fc = f"{filter_complex};[aout]{_loudnorm_first_pass_filter()}[lnprobe]"
|
|
90
|
+
probe_script = Path(work_dir) / ".filter_complex_loudnorm_probe.txt"
|
|
91
|
+
probe_script.write_text(probe_fc, encoding="utf-8")
|
|
92
|
+
cmd = [
|
|
93
|
+
"ffmpeg", "-y",
|
|
94
|
+
"-i", str(input_video),
|
|
95
|
+
"-i", str(narration_wav),
|
|
96
|
+
*original_audio_input,
|
|
97
|
+
*bgm_input,
|
|
98
|
+
"-filter_complex_script", str(probe_script),
|
|
99
|
+
"-map", "[lnprobe]",
|
|
100
|
+
"-f", "null", "-",
|
|
101
|
+
]
|
|
102
|
+
try:
|
|
103
|
+
result = run_cmd(cmd)
|
|
104
|
+
finally:
|
|
105
|
+
probe_script.unlink(missing_ok=True)
|
|
106
|
+
if result.returncode != 0:
|
|
107
|
+
log(f" ⚠️ loudnorm 首遍测量失败,降级到目标滤镜+limiter: {result.stderr}")
|
|
108
|
+
return None
|
|
109
|
+
measured = _parse_loudnorm_json((result.stdout or "") + "\n" + (result.stderr or ""))
|
|
110
|
+
if not measured:
|
|
111
|
+
log(" ⚠️ loudnorm 首遍未返回 JSON,降级到目标滤镜+limiter")
|
|
112
|
+
return None
|
|
113
|
+
return measured
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _seg_place_window(seg):
|
|
117
|
+
"""Return a segment's actual placed (start, end) on the output timeline."""
|
|
118
|
+
s = seg.get("actual_place_start", seg.get("start", 0))
|
|
119
|
+
e = seg.get("actual_place_end", seg.get("end", 0))
|
|
120
|
+
return s, e
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def _load_sentence_handoff_anchors(work_dir):
|
|
124
|
+
"""Load high/medium sentence anchors and their measured pause windows."""
|
|
125
|
+
work_dir = Path(work_dir)
|
|
126
|
+
cut_mode = (work_dir / "edited_source.mp4").exists() or (
|
|
127
|
+
work_dir / "clip_plan_validated.json"
|
|
128
|
+
).exists()
|
|
129
|
+
candidates = [
|
|
130
|
+
work_dir
|
|
131
|
+
/ (
|
|
132
|
+
"speech_boundary_anchors_output.json"
|
|
133
|
+
if cut_mode
|
|
134
|
+
else "speech_boundary_anchors.json"
|
|
135
|
+
)
|
|
136
|
+
]
|
|
137
|
+
for path in candidates:
|
|
138
|
+
if not path.exists():
|
|
139
|
+
continue
|
|
140
|
+
try:
|
|
141
|
+
payload = json.loads(path.read_text(encoding="utf-8"))
|
|
142
|
+
except (OSError, json.JSONDecodeError):
|
|
143
|
+
continue
|
|
144
|
+
if cut_mode:
|
|
145
|
+
plan = _load_work_json(work_dir, "clip_plan_validated.json")
|
|
146
|
+
if not (
|
|
147
|
+
isinstance(payload, dict)
|
|
148
|
+
and payload.get("schema_version") == 2
|
|
149
|
+
and payload.get("timeline") == "cut_output"
|
|
150
|
+
and isinstance(plan, dict)
|
|
151
|
+
and payload.get("clip_plan_fingerprint") == _value_fingerprint(plan)
|
|
152
|
+
):
|
|
153
|
+
return [], None, {"require_measured": True}
|
|
154
|
+
payload = {**payload, "require_measured": True}
|
|
155
|
+
raw = payload.get("sentence_anchors", []) if isinstance(payload, dict) else []
|
|
156
|
+
anchors = []
|
|
157
|
+
for item in raw:
|
|
158
|
+
if not isinstance(item, dict) or item.get("confidence") not in {"high", "medium"}:
|
|
159
|
+
continue
|
|
160
|
+
try:
|
|
161
|
+
when = float(item.get("time"))
|
|
162
|
+
except (TypeError, ValueError):
|
|
163
|
+
continue
|
|
164
|
+
if math.isfinite(when) and when >= 0:
|
|
165
|
+
try:
|
|
166
|
+
pause_start = float(item.get("pause_start", when - 0.12))
|
|
167
|
+
except (TypeError, ValueError):
|
|
168
|
+
pause_start = when - 0.12
|
|
169
|
+
anchors.append({
|
|
170
|
+
"time": round(when, 4),
|
|
171
|
+
"pause_start": round(max(0.0, min(pause_start, when)), 4),
|
|
172
|
+
})
|
|
173
|
+
unique = {(row["time"], row["pause_start"]): row for row in anchors}
|
|
174
|
+
return sorted(unique.values(), key=lambda row: row["time"]), path.name, payload
|
|
175
|
+
return [], None, {"require_measured": cut_mode}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def _handoff_timed_rows(payload, key):
|
|
179
|
+
rows = payload.get(key, []) if isinstance(payload, dict) else []
|
|
180
|
+
out = []
|
|
181
|
+
for row in rows if isinstance(rows, list) else []:
|
|
182
|
+
if not isinstance(row, dict):
|
|
183
|
+
continue
|
|
184
|
+
try:
|
|
185
|
+
start, end = float(row.get("start")), float(row.get("end"))
|
|
186
|
+
except (TypeError, ValueError):
|
|
187
|
+
continue
|
|
188
|
+
if math.isfinite(start) and math.isfinite(end) and end > start:
|
|
189
|
+
out.append({"start": start, "end": end})
|
|
190
|
+
return out
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def _handoff_speech_evidence(work_dir, artifact, payload):
|
|
194
|
+
speech = _handoff_timed_rows(payload, "speech_spans")
|
|
195
|
+
quiet = _handoff_timed_rows(payload, "quiet_windows")
|
|
196
|
+
if payload.get("require_measured"):
|
|
197
|
+
return speech, quiet
|
|
198
|
+
if artifact == "speech_boundary_anchors_output.json":
|
|
199
|
+
return speech, quiet
|
|
200
|
+
if not speech:
|
|
201
|
+
for name in ("asr_clean.json", "asr_result.json"):
|
|
202
|
+
raw = _load_work_json(work_dir, name)
|
|
203
|
+
if isinstance(raw, list):
|
|
204
|
+
raw = {"speech_spans": raw}
|
|
205
|
+
elif isinstance(raw, dict):
|
|
206
|
+
raw = {"speech_spans": raw.get("segments", [])}
|
|
207
|
+
speech = _handoff_timed_rows(raw, "speech_spans")
|
|
208
|
+
if speech:
|
|
209
|
+
break
|
|
210
|
+
if not quiet:
|
|
211
|
+
raw = _load_work_json(work_dir, "silence_periods.json")
|
|
212
|
+
raw = {"quiet_windows": [
|
|
213
|
+
row for row in raw
|
|
214
|
+
if isinstance(row, dict) and not bool(row.get("has_speech", False))
|
|
215
|
+
]} if isinstance(raw, list) else {}
|
|
216
|
+
quiet = _handoff_timed_rows(raw, "quiet_windows")
|
|
217
|
+
return speech, quiet
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def _merged_handoff_intervals(start, end, rows):
|
|
221
|
+
intervals = sorted(
|
|
222
|
+
(max(start, row["start"]), min(end, row["end"]))
|
|
223
|
+
for row in rows
|
|
224
|
+
if row["end"] > start and row["start"] < end
|
|
225
|
+
)
|
|
226
|
+
merged = []
|
|
227
|
+
for left, right in intervals:
|
|
228
|
+
if right <= left:
|
|
229
|
+
continue
|
|
230
|
+
if merged and left <= merged[-1][1]:
|
|
231
|
+
merged[-1] = (merged[-1][0], max(merged[-1][1], right))
|
|
232
|
+
else:
|
|
233
|
+
merged.append((left, right))
|
|
234
|
+
return merged
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def _speech_overlap_excluding_quiet(start, end, speech, quiet):
|
|
238
|
+
speech_intervals = _merged_handoff_intervals(start, end, speech)
|
|
239
|
+
quiet_intervals = _merged_handoff_intervals(start, end, quiet)
|
|
240
|
+
overlap = sum(right - left for left, right in speech_intervals)
|
|
241
|
+
for speech_left, speech_right in speech_intervals:
|
|
242
|
+
overlap -= sum(
|
|
243
|
+
max(0.0, min(speech_right, quiet_right) - max(speech_left, quiet_left))
|
|
244
|
+
for quiet_left, quiet_right in quiet_intervals
|
|
245
|
+
)
|
|
246
|
+
return max(0.0, overlap)
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def _measured_speech_owned(
|
|
250
|
+
start, end, speech, quiet, anchors, authored, require_measured=False
|
|
251
|
+
):
|
|
252
|
+
duration = max(0.0, end - start)
|
|
253
|
+
quiet_min = max(
|
|
254
|
+
0.3,
|
|
255
|
+
duration * float(CONFIG.get("quiet_overlap_min_ratio", 0.8) or 0.8),
|
|
256
|
+
)
|
|
257
|
+
if speech:
|
|
258
|
+
return _speech_overlap_excluding_quiet(start, end, speech, quiet) > 0.05
|
|
259
|
+
quiet_overlap = sum(
|
|
260
|
+
right - left for left, right in _merged_handoff_intervals(start, end, quiet)
|
|
261
|
+
)
|
|
262
|
+
if quiet and quiet_overlap >= quiet_min:
|
|
263
|
+
return False
|
|
264
|
+
return True if anchors or require_measured else bool(authored)
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
def _entry_speech_owned(
|
|
268
|
+
start, speech, quiet, anchors, authored, require_measured=False, tolerance=0.05
|
|
269
|
+
):
|
|
270
|
+
if any(row["start"] - tolerance <= start <= row["end"] + tolerance for row in quiet):
|
|
271
|
+
return False
|
|
272
|
+
if any(row["start"] - tolerance <= start < row["end"] - tolerance for row in speech):
|
|
273
|
+
return True
|
|
274
|
+
if speech:
|
|
275
|
+
return False
|
|
276
|
+
return True if anchors or require_measured else bool(authored)
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def _work_has_source_speech(work_dir, speech_spans=None, require_measured=False):
|
|
280
|
+
if speech_spans or require_measured:
|
|
281
|
+
return True
|
|
282
|
+
for name in ("asr_clean.json", "asr_result.json"):
|
|
283
|
+
payload = _load_work_json(work_dir, name)
|
|
284
|
+
if isinstance(payload, dict):
|
|
285
|
+
payload = payload.get("segments", [])
|
|
286
|
+
if isinstance(payload, list) and any(
|
|
287
|
+
isinstance(item, dict) and str(item.get("text") or "").strip()
|
|
288
|
+
for item in payload
|
|
289
|
+
):
|
|
290
|
+
return True
|
|
291
|
+
return False
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
def _apply_source_sentence_handoffs(tts_segments, work_dir, video_duration):
|
|
295
|
+
"""Keep source audio ducked until a safe sentence boundary after narration.
|
|
296
|
+
|
|
297
|
+
This does not move or trim narration. It only extends the ORIGINAL-audio duck
|
|
298
|
+
envelope so returning the source track cannot reveal the middle of a sentence.
|
|
299
|
+
"""
|
|
300
|
+
fade = max(0.0, float(CONFIG.get("duck_fade_seconds", 0.3) or 0.0))
|
|
301
|
+
bridge = max(0.0, float(CONFIG.get("duck_bridge_seconds", 1.5) or 0.0))
|
|
302
|
+
anchors, artifact, evidence_payload = _load_sentence_handoff_anchors(work_dir)
|
|
303
|
+
speech_spans, quiet_windows = _handoff_speech_evidence(
|
|
304
|
+
work_dir, artifact, evidence_payload
|
|
305
|
+
)
|
|
306
|
+
require_measured = bool(evidence_payload.get("require_measured"))
|
|
307
|
+
placed = []
|
|
308
|
+
for seg in tts_segments or []:
|
|
309
|
+
if not isinstance(seg, dict):
|
|
310
|
+
continue
|
|
311
|
+
try:
|
|
312
|
+
start, end = map(float, _seg_place_window(seg))
|
|
313
|
+
except (TypeError, ValueError):
|
|
314
|
+
continue
|
|
315
|
+
if end > start:
|
|
316
|
+
placed.append((start, end, seg))
|
|
317
|
+
placed.sort(key=lambda item: (item[0], item[1]))
|
|
318
|
+
if not placed:
|
|
319
|
+
return []
|
|
320
|
+
|
|
321
|
+
runs = []
|
|
322
|
+
for start, end, seg in placed:
|
|
323
|
+
if runs and start - runs[-1]["end"] <= bridge + 1e-6:
|
|
324
|
+
runs[-1]["end"] = max(runs[-1]["end"], end)
|
|
325
|
+
runs[-1]["segments"].append(seg)
|
|
326
|
+
else:
|
|
327
|
+
runs.append({"start": start, "end": end, "segments": [seg]})
|
|
328
|
+
|
|
329
|
+
source_has_speech = _work_has_source_speech(
|
|
330
|
+
work_dir, speech_spans, require_measured=require_measured
|
|
331
|
+
)
|
|
332
|
+
report = []
|
|
333
|
+
for run in runs:
|
|
334
|
+
ownership = []
|
|
335
|
+
for seg in run["segments"]:
|
|
336
|
+
start, end = map(float, _seg_place_window(seg))
|
|
337
|
+
measured = _measured_speech_owned(
|
|
338
|
+
start,
|
|
339
|
+
end,
|
|
340
|
+
speech_spans,
|
|
341
|
+
quiet_windows,
|
|
342
|
+
anchors,
|
|
343
|
+
seg.get("overlaps_speech", True),
|
|
344
|
+
require_measured=require_measured,
|
|
345
|
+
)
|
|
346
|
+
seg["overlaps_speech"] = measured
|
|
347
|
+
ownership.append(measured)
|
|
348
|
+
first = run["segments"][0]
|
|
349
|
+
entry_owned = _entry_speech_owned(
|
|
350
|
+
run["start"],
|
|
351
|
+
speech_spans,
|
|
352
|
+
quiet_windows,
|
|
353
|
+
anchors,
|
|
354
|
+
first.get("overlaps_speech", True),
|
|
355
|
+
require_measured=require_measured,
|
|
356
|
+
)
|
|
357
|
+
speech_owned = entry_owned or any(ownership)
|
|
358
|
+
if not speech_owned:
|
|
359
|
+
report.append({"start": run["start"], "end": run["end"], "status": "quiet_source"})
|
|
360
|
+
continue
|
|
361
|
+
last = run["segments"][-1]
|
|
362
|
+
start_safe = run["start"] <= 0.25 or any(
|
|
363
|
+
anchor["pause_start"] - 0.05 <= run["start"] <= anchor["time"] + 0.08
|
|
364
|
+
for anchor in anchors
|
|
365
|
+
)
|
|
366
|
+
if entry_owned and anchors and not start_safe:
|
|
367
|
+
first["source_handoff_blocking"] = True
|
|
368
|
+
first["source_entry_status"] = "unsafe_entry"
|
|
369
|
+
elif not entry_owned:
|
|
370
|
+
first["source_entry_status"] = "quiet_source"
|
|
371
|
+
else:
|
|
372
|
+
first["source_entry_status"] = "sentence_boundary" if anchors else "unverified"
|
|
373
|
+
|
|
374
|
+
restore_anchor = next(
|
|
375
|
+
(anchor for anchor in anchors if anchor["time"] >= run["end"] - 0.01),
|
|
376
|
+
None,
|
|
377
|
+
)
|
|
378
|
+
if restore_anchor is not None:
|
|
379
|
+
# Hold the source low through its last spoken sample, then fit the release
|
|
380
|
+
# entirely inside the measured pause. Never begin the ramp `fade` seconds
|
|
381
|
+
# before the anchor when that would expose the final source phoneme.
|
|
382
|
+
duck_end = max(run["end"], restore_anchor["pause_start"])
|
|
383
|
+
restore_at = max(duck_end, restore_anchor["time"])
|
|
384
|
+
status = "sentence_boundary"
|
|
385
|
+
elif anchors:
|
|
386
|
+
# No later complete source sentence: never expose a fragment at the tail.
|
|
387
|
+
restore_at = float(video_duration)
|
|
388
|
+
duck_end = float(video_duration)
|
|
389
|
+
status = "held_to_timeline_end"
|
|
390
|
+
elif source_has_speech:
|
|
391
|
+
first["source_handoff_blocking"] = True
|
|
392
|
+
first["source_entry_status"] = "anchors_unavailable"
|
|
393
|
+
restore_at = run["end"] + fade
|
|
394
|
+
duck_end = run["end"]
|
|
395
|
+
status = "anchors_unavailable"
|
|
396
|
+
else:
|
|
397
|
+
restore_at = run["end"] + fade
|
|
398
|
+
duck_end = run["end"]
|
|
399
|
+
status = "no_source_speech"
|
|
400
|
+
|
|
401
|
+
last["source_duck_end"] = round(min(float(video_duration), duck_end), 4)
|
|
402
|
+
last["source_restore_at"] = round(min(float(video_duration), restore_at), 4)
|
|
403
|
+
last["source_handoff_status"] = status
|
|
404
|
+
report.append({
|
|
405
|
+
"start": round(run["start"], 4),
|
|
406
|
+
"end": round(run["end"], 4),
|
|
407
|
+
"restore_at": last["source_restore_at"],
|
|
408
|
+
"status": status,
|
|
409
|
+
"anchor_artifact": artifact,
|
|
410
|
+
})
|
|
411
|
+
return report
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
def _amix_tail(narr_vol, bgm_chain=""):
|
|
415
|
+
"""Mix the prepared original track [orig] (+ optional BGM bed) with the boosted
|
|
416
|
+
narration [narr] into [aout]. bgm_chain, when given, defines [bgm] from input [2:a]."""
|
|
417
|
+
narr = f"[1:a]volume={narr_vol},aresample=48000[narr];"
|
|
418
|
+
if bgm_chain:
|
|
419
|
+
return bgm_chain + narr + "[orig][bgm][narr]amix=inputs=3:duration=first:dropout_transition=0:normalize=0[aout]"
|
|
420
|
+
return narr + "[orig][narr]amix=inputs=2:duration=first:dropout_transition=0:normalize=0[aout]"
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
def _placement_windows(tts_segments, level_for, *, source_safe_end=False):
|
|
424
|
+
"""Collect [(start, end, level)] placement windows for the placed beats, using
|
|
425
|
+
`level_for(seg)` to pick each beat's duck level. Skips non-dicts and empty spans."""
|
|
426
|
+
windows = []
|
|
427
|
+
for seg in tts_segments:
|
|
428
|
+
if not isinstance(seg, dict):
|
|
429
|
+
continue
|
|
430
|
+
s, e = _seg_place_window(seg)
|
|
431
|
+
if source_safe_end:
|
|
432
|
+
try:
|
|
433
|
+
e = max(float(e), float(seg.get("source_duck_end", e)))
|
|
434
|
+
except (TypeError, ValueError):
|
|
435
|
+
pass
|
|
436
|
+
if e - s <= 0:
|
|
437
|
+
continue
|
|
438
|
+
windows.append((s, e, level_for(seg)))
|
|
439
|
+
return windows
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
def _duck_envelope(tts_segments, idle, speech_vol, quiet_vol, fade, bridge=None):
|
|
443
|
+
"""Per-beat ducking automation for the ORIGINAL track.
|
|
444
|
+
|
|
445
|
+
Uses the shared ducking contract: [start-fade,start] pre-roll ramp down,
|
|
446
|
+
[start,end] held at the selected duck level, and [end,end+fade] release.
|
|
447
|
+
Bridged spans use the most-ducked (lowest) level, matching timeline.json /
|
|
448
|
+
JianYing keyframes. Returns a volume= expression, or None when no beat carries
|
|
449
|
+
placement info (caller falls back to a constant).
|
|
450
|
+
"""
|
|
451
|
+
if bridge is None:
|
|
452
|
+
bridge = default_bridge(fade)
|
|
453
|
+
windows = []
|
|
454
|
+
for seg in tts_segments or []:
|
|
455
|
+
if not isinstance(seg, dict):
|
|
456
|
+
continue
|
|
457
|
+
try:
|
|
458
|
+
start, narration_end = map(float, _seg_place_window(seg))
|
|
459
|
+
hold_end = max(narration_end, float(seg.get("source_duck_end", narration_end)))
|
|
460
|
+
restore_at = max(hold_end, float(seg.get("source_restore_at", hold_end + fade)))
|
|
461
|
+
except (TypeError, ValueError):
|
|
462
|
+
continue
|
|
463
|
+
if narration_end <= start:
|
|
464
|
+
continue
|
|
465
|
+
level = speech_vol if seg.get("overlaps_speech", True) else quiet_vol
|
|
466
|
+
windows.append((start, hold_end, level, restore_at))
|
|
467
|
+
return release_ducking_expression(windows, idle, fade, bridge=bridge)
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
def _bgm_envelope(tts_segments, base, duck, fade, bridge=None):
|
|
471
|
+
"""Per-beat ducking automation for the BGM track using the shared contract."""
|
|
472
|
+
if bridge is None:
|
|
473
|
+
bridge = default_bridge(fade)
|
|
474
|
+
windows = _placement_windows(tts_segments, lambda _: duck)
|
|
475
|
+
merged = coalesce_duck_windows(windows, bridge)
|
|
476
|
+
return ducking_expression(merged, base, fade)
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
def _build_audio_filter_complex(
|
|
480
|
+
tts_segments,
|
|
481
|
+
has_bgm=False,
|
|
482
|
+
*,
|
|
483
|
+
original_audio_label="0:a",
|
|
484
|
+
bgm_audio_label=None,
|
|
485
|
+
):
|
|
486
|
+
"""Compose the audio tracks into [aout], like a cut-software timeline.
|
|
487
|
+
|
|
488
|
+
Tracks:
|
|
489
|
+
- original (input [0:a], the video's own audio): ducked under each narration
|
|
490
|
+
window by a per-beat volume envelope, but held up at `idle_orig_volume` in
|
|
491
|
+
the gaps so the recap never drops to dead air between sentences.
|
|
492
|
+
- bgm (input [2:a], optional): a looped music bed, gently ducked under narration.
|
|
493
|
+
- narration (input [1:a]): the TTS, boosted and laid on top.
|
|
494
|
+
CONFIG["ducking_mode"] (default "fixed") selects the original-track strategy:
|
|
495
|
+
fixed = the gap-fill envelope above; sidechaincompress = auto-duck keyed off the
|
|
496
|
+
narration; none = no ducking. Placement comes from actual_place_start/end.
|
|
497
|
+
"""
|
|
498
|
+
ducking_mode = CONFIG.get("ducking_mode", "fixed")
|
|
499
|
+
if ducking_mode == "sidechaincompress" and any(
|
|
500
|
+
isinstance(seg, dict)
|
|
501
|
+
and float(seg.get("source_duck_end", seg.get("actual_place_end", 0)) or 0)
|
|
502
|
+
> float(seg.get("actual_place_end", 0) or 0) + 1e-6
|
|
503
|
+
for seg in tts_segments or []
|
|
504
|
+
):
|
|
505
|
+
log("sidechaincompress 无法保持句末交接窗口,已回退 fixed ducking")
|
|
506
|
+
ducking_mode = "fixed"
|
|
507
|
+
narr_vol = CONFIG.get("ducking_narr_weight", 1.5)
|
|
508
|
+
fade = CONFIG.get("duck_fade_seconds", 0.3)
|
|
509
|
+
original_in = f"[{original_audio_label}]"
|
|
510
|
+
bgm_in = f"[{bgm_audio_label or '2:a'}]"
|
|
511
|
+
|
|
512
|
+
# BGM bed (input [2:a]): ducked under each narration window when present.
|
|
513
|
+
bgm_chain = ""
|
|
514
|
+
if has_bgm:
|
|
515
|
+
base = CONFIG.get("bgm_volume", 0.18)
|
|
516
|
+
bgm_expr = _bgm_envelope(tts_segments, base, CONFIG.get("bgm_ducking_volume", 0.10), fade,
|
|
517
|
+
bridge=CONFIG.get("duck_bridge_seconds", 1.5))
|
|
518
|
+
if bgm_expr:
|
|
519
|
+
bgm_chain = f"{bgm_in}volume='{bgm_expr}':eval=frame,aresample=48000[bgm];"
|
|
520
|
+
else:
|
|
521
|
+
bgm_chain = f"{bgm_in}volume={base},aresample=48000[bgm];"
|
|
522
|
+
|
|
523
|
+
if ducking_mode == "sidechaincompress":
|
|
524
|
+
# The narration keys the compressor; split it so it can also be mixed in.
|
|
525
|
+
head = (
|
|
526
|
+
f"{original_in}aresample=48000[o0];"
|
|
527
|
+
"[1:a]aresample=48000,asplit=2[sckey][scnarr];"
|
|
528
|
+
f"[o0][sckey]sidechaincompress="
|
|
529
|
+
f"threshold={CONFIG['ducking_threshold']}:ratio={CONFIG['ducking_ratio']}"
|
|
530
|
+
f":attack={CONFIG['ducking_attack']}:release={CONFIG['ducking_release']}"
|
|
531
|
+
f":knee=2.5:makeup={CONFIG['ducking_makeup']}:level_sc={CONFIG['ducking_level_sc']}[orig];"
|
|
532
|
+
)
|
|
533
|
+
narr = f"[scnarr]volume={narr_vol}[narr];"
|
|
534
|
+
if bgm_chain:
|
|
535
|
+
return head + bgm_chain + narr + "[orig][bgm][narr]amix=inputs=3:duration=first:dropout_transition=0:normalize=0[aout]"
|
|
536
|
+
return head + narr + "[orig][narr]amix=inputs=2:duration=first:dropout_transition=0:normalize=0[aout]"
|
|
537
|
+
|
|
538
|
+
if ducking_mode == "none":
|
|
539
|
+
return f"{original_in}aresample=48000[orig];" + _amix_tail(narr_vol, bgm_chain)
|
|
540
|
+
|
|
541
|
+
# fixed (default): gap-fill ducking envelope on the original track.
|
|
542
|
+
idle = CONFIG.get("idle_orig_volume", 1.0)
|
|
543
|
+
speech_vol = CONFIG.get("speech_ducking_volume", 0.2)
|
|
544
|
+
quiet_vol = CONFIG.get("zone_ducking_volume", 0.12)
|
|
545
|
+
bridge = CONFIG.get("duck_bridge_seconds", 1.5)
|
|
546
|
+
expr = _duck_envelope(tts_segments, idle, speech_vol, quiet_vol, fade, bridge=bridge)
|
|
547
|
+
if expr:
|
|
548
|
+
n_overlap = sum(1 for s in tts_segments if isinstance(s, dict) and s.get("overlaps_speech", True))
|
|
549
|
+
n_quiet = sum(1 for s in tts_segments if isinstance(s, dict) and not s.get("overlaps_speech", True))
|
|
550
|
+
log(f"gap-fill ducking: 间隙原声={idle}, 对白段={speech_vol}({n_overlap}), 安静段={quiet_vol}({n_quiet}), 桥接间隙<{bridge}s")
|
|
551
|
+
orig = f"{original_in}volume='{expr}':eval=frame,aresample=48000[orig];"
|
|
552
|
+
else:
|
|
553
|
+
# No placement info at all: hold the original at a constant level.
|
|
554
|
+
orig = f"{original_in}volume={CONFIG.get('ducking_orig_volume', 0.3)},aresample=48000[orig];"
|
|
555
|
+
return orig + _amix_tail(narr_vol, bgm_chain)
|