@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,477 @@
|
|
|
1
|
+
"""Narration tempo fitting and sample-accurate timeline WAV placement."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import wave
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from assemble_constants import SEGMENT_AUDIO_SCHEMA_VERSION
|
|
8
|
+
from lib import CONFIG, get_video_duration, log, narration_tempo_budget, run_cmd
|
|
9
|
+
|
|
10
|
+
def _apply_narration_speed(
|
|
11
|
+
tts_segments,
|
|
12
|
+
work_dir,
|
|
13
|
+
*,
|
|
14
|
+
command_runner=run_cmd,
|
|
15
|
+
duration_probe=get_video_duration,
|
|
16
|
+
logger=log,
|
|
17
|
+
):
|
|
18
|
+
"""Globally speed up narration audio via atempo (CONFIG['narration_speed']).
|
|
19
|
+
|
|
20
|
+
MiMo TTS reads a touch slowly for short-form recaps; a 1.1-1.2x bump makes it
|
|
21
|
+
snappier without the chipmunk effect. Rewrites each segment's audio_path/duration
|
|
22
|
+
to the sped copy so the rest of assembly is unchanged. No-op at speed 1.0.
|
|
23
|
+
"""
|
|
24
|
+
speed = float(CONFIG.get("narration_speed", 1.0) or 1.0)
|
|
25
|
+
if abs(speed - 1.0) <= 1e-3:
|
|
26
|
+
return
|
|
27
|
+
factor = max(0.5, min(2.0, speed))
|
|
28
|
+
done = 0
|
|
29
|
+
for seg in tts_segments:
|
|
30
|
+
src = seg.get("audio_path")
|
|
31
|
+
if not src or not os.path.exists(src):
|
|
32
|
+
continue
|
|
33
|
+
seg.setdefault("segment_audio_schema_version", SEGMENT_AUDIO_SCHEMA_VERSION)
|
|
34
|
+
seg.setdefault("narration", str(seg.get("narration") or seg.get("spoken_text") or ""))
|
|
35
|
+
seg.setdefault("spoken_text", str(seg.get("spoken_text") or seg.get("narration") or ""))
|
|
36
|
+
seg.setdefault("truncated", False)
|
|
37
|
+
seg.setdefault("truncate_reason", "none")
|
|
38
|
+
seg.setdefault("source_audio_duration", seg.get("audio_duration"))
|
|
39
|
+
seg["global_narration_speed"] = factor
|
|
40
|
+
out = str(Path(work_dir) / f"_spd_{seg.get('index', 0)}.wav")
|
|
41
|
+
res = command_runner(["ffmpeg", "-y", "-i", src, "-filter:a", f"atempo={factor:.3f}",
|
|
42
|
+
"-ar", "44100", "-ac", "1", "-acodec", "pcm_s16le", out])
|
|
43
|
+
if res.returncode == 0 and os.path.exists(out):
|
|
44
|
+
seg["audio_path"] = out
|
|
45
|
+
seg["audio_duration"] = duration_probe(out)
|
|
46
|
+
seg["effective_tempo"] = (
|
|
47
|
+
factor
|
|
48
|
+
* (1.0 + float(seg.get("tts_rate_offset", 0.0) or 0.0))
|
|
49
|
+
* float(seg.get("segment_tempo_factor", 1.0) or 1.0)
|
|
50
|
+
)
|
|
51
|
+
done += 1
|
|
52
|
+
logger(f"解说整体提速: atempo={factor:.2f} ({done} 段)")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _adjust_tts_speed(
|
|
56
|
+
audio_path,
|
|
57
|
+
target_duration,
|
|
58
|
+
work_dir,
|
|
59
|
+
tts_rate_offset=0.0,
|
|
60
|
+
*,
|
|
61
|
+
return_meta=True,
|
|
62
|
+
command_runner=run_cmd,
|
|
63
|
+
duration_probe=get_video_duration,
|
|
64
|
+
logger=log,
|
|
65
|
+
):
|
|
66
|
+
"""Fit overlong TTS with bounded atempo; never time-trim speech in assemble.
|
|
67
|
+
|
|
68
|
+
Assemble has no word/sentence timestamps, so if bounded atempo cannot make the
|
|
69
|
+
audio fit, it returns `fit_status=no_safe_fit` and leaves the original audio
|
|
70
|
+
untouched for QC to block instead of guessing a spoken_text truncation.
|
|
71
|
+
"""
|
|
72
|
+
del work_dir, return_meta # Retained for direct callers of the pre-v0.4 private helper.
|
|
73
|
+
audio_path = Path(audio_path)
|
|
74
|
+
current_dur = duration_probe(audio_path)
|
|
75
|
+
budget = narration_tempo_budget(tts_rate_offset)
|
|
76
|
+
meta = {
|
|
77
|
+
"fit_status": "fits",
|
|
78
|
+
"blocking": False,
|
|
79
|
+
"tempo_factor": 1.0,
|
|
80
|
+
"segment_tempo_factor": 1.0,
|
|
81
|
+
"truncated": False,
|
|
82
|
+
"truncate_reason": "none",
|
|
83
|
+
"tts_rate_offset": float(tts_rate_offset or 0.0),
|
|
84
|
+
"audio_duration": current_dur,
|
|
85
|
+
"placed_audio_duration": current_dur,
|
|
86
|
+
"global_narration_speed": budget["global_narration_speed"],
|
|
87
|
+
"effective_tempo": budget["global_narration_speed"] * budget["tts_rate_factor"],
|
|
88
|
+
"cumulative_tempo_max": budget["cumulative_tempo_max"],
|
|
89
|
+
"cumulative_tempo_hard_max": budget["cumulative_tempo_hard_max"],
|
|
90
|
+
}
|
|
91
|
+
if current_dur <= target_duration or current_dur == 0:
|
|
92
|
+
return (str(audio_path), current_dur, meta)
|
|
93
|
+
|
|
94
|
+
ratio = current_dur / target_duration
|
|
95
|
+
|
|
96
|
+
effective_max = budget["segment_tempo_max"]
|
|
97
|
+
|
|
98
|
+
if ratio > effective_max:
|
|
99
|
+
meta.update({
|
|
100
|
+
"fit_status": "no_safe_fit",
|
|
101
|
+
"blocking": True,
|
|
102
|
+
"truncate_reason": "no_safe_boundary",
|
|
103
|
+
"placed_audio_duration": 0.0,
|
|
104
|
+
"needed_tempo_factor": ratio,
|
|
105
|
+
"segment_tempo_factor": 1.0,
|
|
106
|
+
"tempo_factor": 1.0,
|
|
107
|
+
})
|
|
108
|
+
logger(
|
|
109
|
+
f" TTS 无安全放置: {current_dur:.1f}s 需 x{ratio:.2f},"
|
|
110
|
+
f"超过段内预算 x{effective_max:.2f}(assemble 不按时间硬切)"
|
|
111
|
+
)
|
|
112
|
+
return (str(audio_path), current_dur, meta)
|
|
113
|
+
|
|
114
|
+
# 温和加速。给 atempo/容器时长舍入留出 0.2% 安全余量;宁可极轻微
|
|
115
|
+
# 多加速,也不能在写入时间线时裁掉最后一个音节。
|
|
116
|
+
tempo = min(ratio * 1.002, effective_max)
|
|
117
|
+
adjusted_path = audio_path.with_name(f"{audio_path.stem}_adj{audio_path.suffix}")
|
|
118
|
+
cmd = ["ffmpeg", "-y", "-i", str(audio_path),
|
|
119
|
+
"-filter:a", f"atempo={tempo:.6f}",
|
|
120
|
+
"-ar", "44100", "-ac", "1", str(adjusted_path)]
|
|
121
|
+
result = command_runner(cmd)
|
|
122
|
+
if result.returncode == 0:
|
|
123
|
+
new_dur = duration_probe(adjusted_path)
|
|
124
|
+
if new_dur > target_duration + (1.0 / 44100.0):
|
|
125
|
+
adjusted_path.unlink(missing_ok=True)
|
|
126
|
+
meta.update({
|
|
127
|
+
"fit_status": "no_safe_fit",
|
|
128
|
+
"blocking": True,
|
|
129
|
+
"truncate_reason": "no_safe_boundary",
|
|
130
|
+
"placed_audio_duration": 0.0,
|
|
131
|
+
"needed_tempo_factor": new_dur / target_duration,
|
|
132
|
+
})
|
|
133
|
+
logger(
|
|
134
|
+
f" TTS 加速后仍超出安全窗口 {new_dur - target_duration:.3f}s;"
|
|
135
|
+
"禁止裁尾,交由 Agent 缩短/移动文本"
|
|
136
|
+
)
|
|
137
|
+
return (str(audio_path), current_dur, meta)
|
|
138
|
+
meta.update({
|
|
139
|
+
"fit_status": "tempo_adjusted",
|
|
140
|
+
"tempo_factor": tempo,
|
|
141
|
+
"segment_tempo_factor": tempo,
|
|
142
|
+
"placed_audio_duration": new_dur,
|
|
143
|
+
"effective_tempo": budget["global_narration_speed"] * budget["tts_rate_factor"] * tempo,
|
|
144
|
+
})
|
|
145
|
+
logger(f" TTS 温和加速: {current_dur:.1f}s → {new_dur:.1f}s (x{tempo:.2f})")
|
|
146
|
+
return (str(adjusted_path), new_dur, meta)
|
|
147
|
+
meta["fit_status"] = "speed_adjust_failed"
|
|
148
|
+
meta["truncate_reason"] = "resample_failed"
|
|
149
|
+
return (str(audio_path), current_dur, meta)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def _edge_quiet_samples(pcm16_mono, sample_count, *, from_start, threshold=260):
|
|
153
|
+
"""Count near-silent PCM16 samples at one edge of a mono buffer."""
|
|
154
|
+
indices = range(sample_count) if from_start else range(sample_count - 1, -1, -1)
|
|
155
|
+
quiet = 0
|
|
156
|
+
for index in indices:
|
|
157
|
+
offset = index * 2
|
|
158
|
+
value = int.from_bytes(pcm16_mono[offset:offset + 2], "little", signed=True)
|
|
159
|
+
if abs(value) > threshold:
|
|
160
|
+
break
|
|
161
|
+
quiet += 1
|
|
162
|
+
return quiet
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def _speech_safe_fade_lengths(pcm16_mono, sample_count, sample_rate, configured_ms):
|
|
166
|
+
"""Limit fades to edge silence so first/last syllables are never attenuated.
|
|
167
|
+
|
|
168
|
+
When TTS has no measurable edge silence, retain only a 5ms anti-click ramp.
|
|
169
|
+
"""
|
|
170
|
+
configured = min(int(max(0.0, float(configured_ms)) * sample_rate / 1000), sample_count // 4)
|
|
171
|
+
if configured <= 0:
|
|
172
|
+
return 0, 0
|
|
173
|
+
anti_click = min(int(0.005 * sample_rate), configured)
|
|
174
|
+
leading = _edge_quiet_samples(pcm16_mono, sample_count, from_start=True)
|
|
175
|
+
trailing = _edge_quiet_samples(pcm16_mono, sample_count, from_start=False)
|
|
176
|
+
return min(configured, max(anti_click, leading)), min(configured, max(anti_click, trailing))
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def _build_timed_narration(
|
|
180
|
+
tts_segments,
|
|
181
|
+
output_wav,
|
|
182
|
+
video_duration,
|
|
183
|
+
work_dir,
|
|
184
|
+
*,
|
|
185
|
+
adjust_speed=_adjust_tts_speed,
|
|
186
|
+
command_runner=run_cmd,
|
|
187
|
+
logger=log,
|
|
188
|
+
):
|
|
189
|
+
"""将 TTS 片段按时间轴放置到一条与视频等长的音轨上"""
|
|
190
|
+
sample_rate = 44100
|
|
191
|
+
total_samples = int(video_duration * sample_rate)
|
|
192
|
+
buffer = bytearray(total_samples * 2)
|
|
193
|
+
last_written_end = 0 # 追踪已写入位置,防止重叠
|
|
194
|
+
prev_pause_samples = 0 # 前一段的 pause_after_ms,控制段间间隔
|
|
195
|
+
skipped_count = 0 # 因 WAV 缺失/损坏/重采样失败而被跳过的段数
|
|
196
|
+
placed_count = 0 # 真正写入音频的段数;防止"成功"生成全静音旁白
|
|
197
|
+
no_safe_fit_count = 0 # 超预算但不能安全截断;交由 QC/manifest 阻断
|
|
198
|
+
prev_authored_end = None # 上一段作者标注的结束时间,用于判断"段落"边界
|
|
199
|
+
run_gap = float(CONFIG.get("narration_run_gap_seconds", 1.6)) # 作者留白 > 此值 = 新段落
|
|
200
|
+
tighten = bool(CONFIG.get("narration_tighten", True))
|
|
201
|
+
tight_pause_samples = int(max(0.0, float(CONFIG.get("narration_tight_pause_seconds", 0.35))) * sample_rate)
|
|
202
|
+
# 漂移上限:收紧时一句最多比作者标注的时间提前 max_pull 秒,避免整段解说被全部压到前面、与画面脱节
|
|
203
|
+
max_pull_samples = int(max(0.0, float(CONFIG.get("narration_max_pull_seconds", 2.5))) * sample_rate)
|
|
204
|
+
|
|
205
|
+
for seg in tts_segments:
|
|
206
|
+
seg.setdefault("segment_audio_schema_version", SEGMENT_AUDIO_SCHEMA_VERSION)
|
|
207
|
+
seg.setdefault("narration", str(seg.get("narration") or seg.get("spoken_text") or ""))
|
|
208
|
+
seg.setdefault("spoken_text", str(seg.get("spoken_text") or seg.get("narration") or ""))
|
|
209
|
+
seg.setdefault("truncated", False)
|
|
210
|
+
seg.setdefault("truncate_reason", "none")
|
|
211
|
+
seg.setdefault("fit_status", "pending_assembly")
|
|
212
|
+
seg.setdefault("blocking", False)
|
|
213
|
+
seg.setdefault("segment_tempo_factor", 1.0)
|
|
214
|
+
seg.setdefault("global_narration_speed", float(CONFIG.get("narration_speed", 1.0) or 1.0))
|
|
215
|
+
rate_factor = 1.0 + float(seg.get("tts_rate_offset", 0.0) or 0.0)
|
|
216
|
+
seg.setdefault("effective_tempo", float(seg["global_narration_speed"]) * rate_factor * float(seg.get("segment_tempo_factor", 1.0) or 1.0))
|
|
217
|
+
seg.setdefault("rms_dbfs_before", None)
|
|
218
|
+
seg.setdefault("rms_dbfs_after", None)
|
|
219
|
+
seg.setdefault("peak_after", None)
|
|
220
|
+
wav_path = seg["audio_path"]
|
|
221
|
+
seg_pause_ms = seg.get("pause_after_ms", CONFIG.get("breath_ms", 250))
|
|
222
|
+
# 段落收紧:同一段落内(与上一句作者留白 <= run_gap)把这一句紧贴上一句的实际收尾播放,
|
|
223
|
+
# 句间间隔固定为 tight_pause,不受 slot 内居中延迟 / TTS 时长波动影响。段落之间(作者特意留
|
|
224
|
+
# 的大留白,让精彩原声透出)才放回原声。这样句间间隔稳定、不会出现"一句解说一段空白"。
|
|
225
|
+
cur_authored_start = float(seg.get("start", 0.0))
|
|
226
|
+
is_run_start = (placed_count == 0 or prev_authored_end is None
|
|
227
|
+
or cur_authored_start - prev_authored_end > run_gap)
|
|
228
|
+
prev_authored_end = float(seg.get("end", cur_authored_start))
|
|
229
|
+
|
|
230
|
+
if not os.path.exists(wav_path):
|
|
231
|
+
seg["actual_place_start"] = seg["start"]
|
|
232
|
+
seg["actual_place_end"] = seg["start"]
|
|
233
|
+
seg["placed_audio_duration"] = 0.0
|
|
234
|
+
seg["fit_status"] = "skipped"
|
|
235
|
+
seg["truncate_reason"] = "missing_wav"
|
|
236
|
+
prev_pause_samples = int(seg_pause_ms * sample_rate / 1000)
|
|
237
|
+
skipped_count += 1
|
|
238
|
+
continue
|
|
239
|
+
|
|
240
|
+
# WAV 格式验证 + 采样率检查(合并为一次 wave.open)
|
|
241
|
+
original_wav_path = wav_path
|
|
242
|
+
_do_resample = False
|
|
243
|
+
try:
|
|
244
|
+
with wave.open(wav_path, 'rb') as wf_check:
|
|
245
|
+
wf_channels = wf_check.getnchannels()
|
|
246
|
+
wf_sampwidth = wf_check.getsampwidth()
|
|
247
|
+
if wf_sampwidth != 2 or wf_channels != 1:
|
|
248
|
+
logger(f" 跳过非标准 WAV: {wav_path} (channels={wf_channels}, sampwidth={wf_sampwidth}), 需要 mono 16-bit")
|
|
249
|
+
seg["actual_place_start"] = seg["start"]
|
|
250
|
+
seg["actual_place_end"] = seg["start"]
|
|
251
|
+
seg["placed_audio_duration"] = 0.0
|
|
252
|
+
seg["fit_status"] = "skipped"
|
|
253
|
+
seg["truncate_reason"] = "resample_failed"
|
|
254
|
+
prev_pause_samples = int(seg_pause_ms * sample_rate / 1000)
|
|
255
|
+
skipped_count += 1
|
|
256
|
+
continue
|
|
257
|
+
if wf_check.getframerate() != sample_rate:
|
|
258
|
+
_do_resample = True
|
|
259
|
+
except Exception as e:
|
|
260
|
+
logger(f" WAV 读取失败: {wav_path}: {e}")
|
|
261
|
+
seg["actual_place_start"] = seg["start"]
|
|
262
|
+
seg["actual_place_end"] = seg["start"]
|
|
263
|
+
seg["placed_audio_duration"] = 0.0
|
|
264
|
+
seg["fit_status"] = "skipped"
|
|
265
|
+
seg["truncate_reason"] = "missing_wav"
|
|
266
|
+
prev_pause_samples = int(seg_pause_ms * sample_rate / 1000)
|
|
267
|
+
skipped_count += 1
|
|
268
|
+
continue
|
|
269
|
+
|
|
270
|
+
tts_rate_offset = seg.get("tts_rate_offset", 0.0)
|
|
271
|
+
tts_dur = seg.get("audio_duration", 0)
|
|
272
|
+
|
|
273
|
+
configured_delay = max(0.0, float(CONFIG.get("narration_delay_seconds", 0.0) or 0.0))
|
|
274
|
+
tail_pad = max(0.0, float(CONFIG.get("narration_tail_pad_seconds", 0.1) or 0.0))
|
|
275
|
+
slot_duration = max(0.0, float(seg["end"]) - float(seg["start"]))
|
|
276
|
+
max_delay = max(0.0, slot_duration - float(tts_dur or 0.0) - tail_pad)
|
|
277
|
+
narration_delay = min(configured_delay, max_delay)
|
|
278
|
+
start_sample = int((seg["start"] + narration_delay) * sample_rate)
|
|
279
|
+
end_boundary = int(min(seg["end"], video_duration) * sample_rate)
|
|
280
|
+
|
|
281
|
+
# 段间间隔:使用前一段的 pause_after_ms(来自 narration.json)
|
|
282
|
+
min_start_with_pause = last_written_end + prev_pause_samples
|
|
283
|
+
if tighten and not is_run_start:
|
|
284
|
+
# 段落内:紧贴上一句的实际收尾播放,句间间隔固定为 tight_pause(不被 slot 内居中延迟撑大),
|
|
285
|
+
# 但不早于"作者标注起始 - max_pull",防止整段被压到前面与画面脱节。
|
|
286
|
+
drift_floor = int(cur_authored_start * sample_rate) - max_pull_samples
|
|
287
|
+
actual_start = max(last_written_end + tight_pause_samples, drift_floor)
|
|
288
|
+
else:
|
|
289
|
+
# 段落起点(或关闭收紧):尊重作者标注的起始 + 入场延迟,让画面/原声先立住
|
|
290
|
+
actual_start = max(start_sample, min_start_with_pause)
|
|
291
|
+
actual_start = min(actual_start, end_boundary) # 不超出 slot 边界
|
|
292
|
+
|
|
293
|
+
# 根据实际可用空间决定是否加速
|
|
294
|
+
available_samples = end_boundary - actual_start
|
|
295
|
+
available_duration = max(available_samples / sample_rate, 0)
|
|
296
|
+
if tts_dur > available_duration > 0:
|
|
297
|
+
adjusted_result = adjust_speed(
|
|
298
|
+
wav_path, available_duration, work_dir, tts_rate_offset)
|
|
299
|
+
if len(adjusted_result) == 2:
|
|
300
|
+
wav_path, _actual_dur = adjusted_result
|
|
301
|
+
budget = narration_tempo_budget(tts_rate_offset)
|
|
302
|
+
fit_meta = {
|
|
303
|
+
"fit_status": "tempo_adjusted" if wav_path != original_wav_path else "fits",
|
|
304
|
+
"segment_tempo_factor": 1.0,
|
|
305
|
+
"effective_tempo": budget["global_narration_speed"],
|
|
306
|
+
"global_narration_speed": budget["global_narration_speed"],
|
|
307
|
+
"truncate_reason": "none",
|
|
308
|
+
}
|
|
309
|
+
else:
|
|
310
|
+
wav_path, _actual_dur, fit_meta = adjusted_result
|
|
311
|
+
seg.update({
|
|
312
|
+
"fit_status": fit_meta["fit_status"],
|
|
313
|
+
"segment_tempo_factor": fit_meta.get("segment_tempo_factor", 1.0),
|
|
314
|
+
"effective_tempo": fit_meta.get("effective_tempo", seg.get("effective_tempo")),
|
|
315
|
+
"global_narration_speed": fit_meta.get("global_narration_speed", seg.get("global_narration_speed")),
|
|
316
|
+
"blocking": bool(fit_meta.get("blocking", False)),
|
|
317
|
+
})
|
|
318
|
+
if fit_meta["fit_status"] == "no_safe_fit":
|
|
319
|
+
seg["actual_place_start"] = actual_start / sample_rate
|
|
320
|
+
seg["actual_place_end"] = actual_start / sample_rate
|
|
321
|
+
seg["placed_audio_duration"] = 0.0
|
|
322
|
+
seg["truncate_reason"] = fit_meta["truncate_reason"]
|
|
323
|
+
prev_pause_samples = int(seg_pause_ms * sample_rate / 1000)
|
|
324
|
+
skipped_count += 1
|
|
325
|
+
no_safe_fit_count += 1
|
|
326
|
+
continue
|
|
327
|
+
else:
|
|
328
|
+
budget = narration_tempo_budget(tts_rate_offset)
|
|
329
|
+
seg["fit_status"] = "fits"
|
|
330
|
+
seg["segment_tempo_factor"] = 1.0
|
|
331
|
+
seg["global_narration_speed"] = budget["global_narration_speed"]
|
|
332
|
+
seg["effective_tempo"] = budget["global_narration_speed"] * budget["tts_rate_factor"]
|
|
333
|
+
|
|
334
|
+
# _adjust_tts_speed 输出固定 44100Hz mono 16bit,若文件被替换则无需 resample
|
|
335
|
+
if wav_path != original_wav_path:
|
|
336
|
+
_do_resample = False
|
|
337
|
+
if _do_resample:
|
|
338
|
+
tmp_path = str(Path(work_dir) / f"_rs_{seg.get('index', 0)}.wav")
|
|
339
|
+
rs_result = command_runner(["ffmpeg", "-y", "-i", wav_path,
|
|
340
|
+
"-ar", str(sample_rate), "-ac", "1",
|
|
341
|
+
"-acodec", "pcm_s16le", tmp_path])
|
|
342
|
+
if rs_result.returncode != 0 or not os.path.exists(tmp_path):
|
|
343
|
+
logger(f" 重采样失败,跳过本段: {wav_path}: {rs_result.stderr}")
|
|
344
|
+
seg["actual_place_start"] = seg["start"]
|
|
345
|
+
seg["actual_place_end"] = seg["start"]
|
|
346
|
+
seg["placed_audio_duration"] = 0.0
|
|
347
|
+
seg["fit_status"] = "skipped"
|
|
348
|
+
seg["truncate_reason"] = "resample_failed"
|
|
349
|
+
prev_pause_samples = int(seg_pause_ms * sample_rate / 1000)
|
|
350
|
+
skipped_count += 1
|
|
351
|
+
continue
|
|
352
|
+
wav_path = tmp_path
|
|
353
|
+
|
|
354
|
+
with wave.open(wav_path, "rb") as wf:
|
|
355
|
+
wf_data = bytearray(wf.readframes(wf.getnframes()))
|
|
356
|
+
|
|
357
|
+
# 按场景边界裁剪
|
|
358
|
+
audio_samples = len(wf_data) // 2
|
|
359
|
+
available = end_boundary - actual_start
|
|
360
|
+
write_samples = audio_samples
|
|
361
|
+
|
|
362
|
+
if write_samples <= 0 or available <= 0:
|
|
363
|
+
logger(f" 跳过: {seg['start']:.1f}s-{seg['end']:.1f}s (无空间)")
|
|
364
|
+
seg["actual_place_start"] = seg["start"]
|
|
365
|
+
seg["actual_place_end"] = seg["start"]
|
|
366
|
+
seg["placed_audio_duration"] = 0.0
|
|
367
|
+
seg["fit_status"] = "no_safe_fit"
|
|
368
|
+
seg["blocking"] = True
|
|
369
|
+
seg["truncate_reason"] = "no_room"
|
|
370
|
+
prev_pause_samples = int(seg_pause_ms * sample_rate / 1000)
|
|
371
|
+
no_safe_fit_count += 1
|
|
372
|
+
continue
|
|
373
|
+
|
|
374
|
+
if audio_samples > available:
|
|
375
|
+
# No tolerance-based trimming: even a few milliseconds may contain a
|
|
376
|
+
# consonant/vowel release. _adjust_tts_speed must produce a complete file
|
|
377
|
+
# that fits; otherwise block and ask the Agent to shorten/move the block.
|
|
378
|
+
over = (audio_samples - available) / sample_rate
|
|
379
|
+
logger(f" TTS 无安全放置: 段 {seg.get('index', '?')} 超出可用窗口 {over:.3f}s;禁止裁尾,交由 QC 阻断")
|
|
380
|
+
seg["actual_place_start"] = actual_start / sample_rate
|
|
381
|
+
seg["actual_place_end"] = actual_start / sample_rate
|
|
382
|
+
seg["placed_audio_duration"] = 0.0
|
|
383
|
+
seg["fit_status"] = "no_safe_fit"
|
|
384
|
+
seg["blocking"] = True
|
|
385
|
+
seg["truncate_reason"] = "no_safe_boundary"
|
|
386
|
+
prev_pause_samples = int(seg_pause_ms * sample_rate / 1000)
|
|
387
|
+
skipped_count += 1
|
|
388
|
+
no_safe_fit_count += 1
|
|
389
|
+
continue
|
|
390
|
+
|
|
391
|
+
# 重叠检测:跳过与前段重叠的部分(在 fade 之前,避免截断后丢失 fade-in)
|
|
392
|
+
if actual_start < last_written_end:
|
|
393
|
+
overlap_ms = (last_written_end - actual_start) * 1000 / sample_rate
|
|
394
|
+
if last_written_end >= actual_start + write_samples:
|
|
395
|
+
logger(f" 跳过重叠段: {actual_start/sample_rate:.1f}s "
|
|
396
|
+
f"(与前段重叠 {overlap_ms:.0f}ms)")
|
|
397
|
+
seg["actual_place_start"] = seg["start"]
|
|
398
|
+
seg["actual_place_end"] = seg["start"]
|
|
399
|
+
seg["placed_audio_duration"] = 0.0
|
|
400
|
+
seg["fit_status"] = "no_safe_fit"
|
|
401
|
+
seg["blocking"] = True
|
|
402
|
+
seg["truncate_reason"] = "no_room"
|
|
403
|
+
prev_pause_samples = int(seg_pause_ms * sample_rate / 1000)
|
|
404
|
+
no_safe_fit_count += 1
|
|
405
|
+
continue
|
|
406
|
+
actual_start = last_written_end
|
|
407
|
+
available = end_boundary - actual_start
|
|
408
|
+
if write_samples > available:
|
|
409
|
+
logger(f" 重叠 {overlap_ms:.0f}ms 后无安全完整窗口,跳过")
|
|
410
|
+
seg["actual_place_start"] = actual_start / sample_rate
|
|
411
|
+
seg["actual_place_end"] = actual_start / sample_rate
|
|
412
|
+
seg["placed_audio_duration"] = 0.0
|
|
413
|
+
seg["fit_status"] = "no_safe_fit"
|
|
414
|
+
seg["blocking"] = True
|
|
415
|
+
seg["truncate_reason"] = "no_safe_boundary"
|
|
416
|
+
prev_pause_samples = int(seg_pause_ms * sample_rate / 1000)
|
|
417
|
+
skipped_count += 1
|
|
418
|
+
no_safe_fit_count += 1
|
|
419
|
+
continue
|
|
420
|
+
|
|
421
|
+
# fade-in / fade-out(在 overlap 裁剪之后应用,确保正确的音频包络)
|
|
422
|
+
fade_in_len, fade_out_len = _speech_safe_fade_lengths(
|
|
423
|
+
wf_data, write_samples, sample_rate, CONFIG.get("fade_ms", 120)
|
|
424
|
+
)
|
|
425
|
+
for i in range(fade_in_len):
|
|
426
|
+
gain = i / fade_in_len
|
|
427
|
+
s = i * 2
|
|
428
|
+
sample = int.from_bytes(wf_data[s:s+2], 'little', signed=True)
|
|
429
|
+
sample = int(sample * gain)
|
|
430
|
+
wf_data[s:s+2] = sample.to_bytes(2, 'little', signed=True)
|
|
431
|
+
for i in range(fade_out_len):
|
|
432
|
+
gain = 1.0 - i / fade_out_len
|
|
433
|
+
s = (write_samples - 1 - i) * 2
|
|
434
|
+
if s < 0:
|
|
435
|
+
break
|
|
436
|
+
sample = int.from_bytes(wf_data[s:s+2], 'little', signed=True)
|
|
437
|
+
sample = int(sample * gain)
|
|
438
|
+
wf_data[s:s+2] = sample.to_bytes(2, 'little', signed=True)
|
|
439
|
+
|
|
440
|
+
# Persist the exact complete per-beat PCM used by the canonical mix. Editable
|
|
441
|
+
# exports must reference this file, not the longer pre-fit TTS input; otherwise
|
|
442
|
+
# their timeline_end silently chops the final word even when ffmpeg is correct.
|
|
443
|
+
placed_path = Path(work_dir) / f"_placed_{int(seg.get('index', placed_count)):04d}.wav"
|
|
444
|
+
with wave.open(str(placed_path), "wb") as placed_wav:
|
|
445
|
+
placed_wav.setnchannels(1)
|
|
446
|
+
placed_wav.setsampwidth(2)
|
|
447
|
+
placed_wav.setframerate(sample_rate)
|
|
448
|
+
placed_wav.writeframes(bytes(wf_data))
|
|
449
|
+
seg["placed_audio_path"] = str(placed_path)
|
|
450
|
+
|
|
451
|
+
buffer[actual_start * 2: actual_start * 2 + write_samples * 2] = wf_data
|
|
452
|
+
seg["actual_place_start"] = actual_start / sample_rate
|
|
453
|
+
seg["actual_place_end"] = (actual_start + write_samples) / sample_rate
|
|
454
|
+
seg["placed_audio_duration"] = write_samples / sample_rate
|
|
455
|
+
if seg.get("fit_status") == "pending_assembly":
|
|
456
|
+
seg["fit_status"] = "fits"
|
|
457
|
+
if seg.get("truncate_reason") in (None, ""):
|
|
458
|
+
seg["truncate_reason"] = "none"
|
|
459
|
+
last_written_end = actual_start + write_samples
|
|
460
|
+
prev_pause_samples = int(seg_pause_ms * sample_rate / 1000)
|
|
461
|
+
placed_count += 1
|
|
462
|
+
|
|
463
|
+
with wave.open(str(output_wav), "wb") as wf:
|
|
464
|
+
wf.setnchannels(1)
|
|
465
|
+
wf.setsampwidth(2)
|
|
466
|
+
wf.setframerate(sample_rate)
|
|
467
|
+
wf.writeframes(bytes(buffer))
|
|
468
|
+
|
|
469
|
+
if tts_segments and placed_count == 0 and no_safe_fit_count == 0:
|
|
470
|
+
output_wav.unlink(missing_ok=True)
|
|
471
|
+
raise RuntimeError(
|
|
472
|
+
f"全部 {len(tts_segments)} 段解说均被跳过或未能写入"
|
|
473
|
+
f"(WAV 缺失/损坏/重采样失败/无可用时间;跳过 {skipped_count} 段),"
|
|
474
|
+
"已中止以避免生成无解说视频"
|
|
475
|
+
)
|
|
476
|
+
|
|
477
|
+
logger(f"解说音轨: {video_duration:.1f}s, {len(tts_segments)} 段")
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Local ffmpeg capability preflight for subtitle burn-in."""
|
|
2
|
+
|
|
3
|
+
from lib import CONFIG
|
|
4
|
+
|
|
5
|
+
def _ffmpeg_filters():
|
|
6
|
+
"""Return ffmpeg's compiled-in filter names.
|
|
7
|
+
|
|
8
|
+
This skill keeps a local capability probe so it remains self-contained; keep the
|
|
9
|
+
parser behavior aligned through tests.
|
|
10
|
+
"""
|
|
11
|
+
import shutil
|
|
12
|
+
import subprocess
|
|
13
|
+
ffmpeg = shutil.which("ffmpeg")
|
|
14
|
+
if not ffmpeg:
|
|
15
|
+
return set()
|
|
16
|
+
try:
|
|
17
|
+
result = subprocess.run(["ffmpeg", "-hide_banner", "-filters"],
|
|
18
|
+
text=True, capture_output=True, timeout=20)
|
|
19
|
+
except (OSError, subprocess.SubprocessError):
|
|
20
|
+
return set()
|
|
21
|
+
if result.returncode != 0:
|
|
22
|
+
return set()
|
|
23
|
+
filters = set()
|
|
24
|
+
for line in result.stdout.splitlines():
|
|
25
|
+
parts = line.split()
|
|
26
|
+
if len(parts) >= 2 and parts[0] and parts[0][0] in ".TSCAPN|":
|
|
27
|
+
filters.add(parts[1])
|
|
28
|
+
return filters
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _preflight_burn_subtitles():
|
|
32
|
+
"""Fail before the (re-encoding) render when burn-in is on but ffmpeg lacks the libass
|
|
33
|
+
`subtitles` filter. _subtitle_burn_filter burns even the .ass through `subtitles=`, so
|
|
34
|
+
that is the required capability. Defense-in-depth: the orchestrator (recap.py) preflights
|
|
35
|
+
this earlier, but assemble.py can be run standalone. Only fires when ffmpeg EXISTS but
|
|
36
|
+
can't burn — an absent ffmpeg fails the render regardless and would also break the mocked,
|
|
37
|
+
ffmpeg-less test environment."""
|
|
38
|
+
import shutil
|
|
39
|
+
if not CONFIG.get("burn_subtitles", False):
|
|
40
|
+
return
|
|
41
|
+
if shutil.which("ffmpeg") is None:
|
|
42
|
+
return
|
|
43
|
+
if "subtitles" not in _ffmpeg_filters():
|
|
44
|
+
raise SystemExit(
|
|
45
|
+
"字幕烧录已开启,但当前 ffmpeg 不支持 subtitles/libass 滤镜,渲染会在最后一步失败。\n"
|
|
46
|
+
" 解决:安装带 libass 的 ffmpeg,或加 --no-burn-subtitles 关闭烧录(仍输出 .srt 外挂字幕)。")
|