feat: #1768 节奏曲线模板多样化 — 8种预设 + 时长钳制 + 误差校验 #1788

Merged
xiaoxia merged 1 commits from feat/rhythm-templates-diversify-1768 into develop 2026-09-08 11:04:04 +08:00
Owner

#1768 节奏曲线模板多样化

变更内容

1. 模板池扩展(6 → 8 种)

  • 新增 [2,2,1,1,2](前重后轻节奏)
  • 新增 [3,2,1,2,1](渐弱节奏)
  • 原 6 种模板完整保留

2. Bug 修复

  • 修复 MIN_CLIP_DURATION 被重复定义为 1.0 的 bug(恢复为 2.0s)

3. 最大片段时长钳制

  • plan_clip_durations() 新增 asset_durations 参数
  • 当提供素材时长时,钳制每个片段 ≤ 素材可用时长 × 90%
  • 不传 asset_durations 时完全向后兼容

4. 时长总和误差校验

  • 分配完成后校验成片净时长与配音时长误差 ≤ 0.5s
  • 超限时自动末段补偿修正

5. 调用方更新

  • edit_plan_service.apply_voice_duration_to_plan 传入素材时长参与钳制

文件变更

  • packages/domain/voice_duration_planner.py — 核心模块
  • apps/api/app/services/edit_plan_service.py — 调用方传入素材时长
  • tests/unit/domain/test_rhythm_templates_v2.py — 48 个新增单元测试

测试

48 个新测试全部通过
78 个已有测试无回归

约束

  • 目标分支:develop
  • 不涉及前端(apps/web)
  • 向后兼容:asset_durations 默认 None
## #1768 节奏曲线模板多样化 ### 变更内容 #### 1. 模板池扩展(6 → 8 种) - 新增 `[2,2,1,1,2]`(前重后轻节奏) - 新增 `[3,2,1,2,1]`(渐弱节奏) - 原 6 种模板完整保留 #### 2. Bug 修复 - 修复 `MIN_CLIP_DURATION` 被重复定义为 1.0 的 bug(恢复为 2.0s) #### 3. 最大片段时长钳制 - `plan_clip_durations()` 新增 `asset_durations` 参数 - 当提供素材时长时,钳制每个片段 ≤ 素材可用时长 × 90% - 不传 `asset_durations` 时完全向后兼容 #### 4. 时长总和误差校验 - 分配完成后校验成片净时长与配音时长误差 ≤ 0.5s - 超限时自动末段补偿修正 #### 5. 调用方更新 - `edit_plan_service.apply_voice_duration_to_plan` 传入素材时长参与钳制 ### 文件变更 - `packages/domain/voice_duration_planner.py` — 核心模块 - `apps/api/app/services/edit_plan_service.py` — 调用方传入素材时长 - `tests/unit/domain/test_rhythm_templates_v2.py` — 48 个新增单元测试 ### 测试 ✅ 48 个新测试全部通过 ✅ 78 个已有测试无回归 ### 约束 - 目标分支:develop - 不涉及前端(apps/web) - 向后兼容:`asset_durations` 默认 None

🚀 预览环境已部署

项目 详情
PR号 #1788
预览链接 https://pr-1788.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #1788 | | 预览链接 | [https://pr-1788.preview.xiaoxiajianji.com](https://pr-1788.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
xiaoxia force-pushed feat/rhythm-templates-diversify-1768 from 2024086e5f to acac17d8f2 2026-09-08 10:32:22 +08:00 Compare
xiaoxia force-pushed feat/rhythm-templates-diversify-1768 from 569e5aa3dc to 1ebc9295e8 2026-09-08 10:37:48 +08:00 Compare
xiaoxia added 1 commit 2026-09-08 10:57:20 +08:00
feat: #1768 节奏曲线模板多样化 — 8种预设 + 时长钳制 + 误差校验
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 30s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 55s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m27s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 1m30s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m32s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 1m48s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 1m56s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 2m51s
AI Code Review / AI Code Review (pull_request) Successful in 6m18s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 6m17s
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 4s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 8s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 4m13s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 34s
ee4636e087
变更:
- RHYTHM_TEMPLATES 从 6 种扩展到 8 种(新增 [2,2,1,1,2] 和 [3,2,1,2,1])
- 修复 MIN_CLIP_DURATION 被重复定义为 1.0 的 bug(恢复为 2.0)
- plan_clip_durations 新增 asset_durations 参数,钳制最大片段时长 <= 素材可用时长 × 90%
- 新增时长总和误差校验(成片净时长与配音时长误差 <= 0.5s),超限时末段补偿修正
- edit_plan_service.apply_voice_duration_to_plan 传入素材时长参与钳制
- 48 个新增单元测试全部通过

向后兼容:asset_durations 默认 None,不影响现有调用方
xiaoxia force-pushed feat/rhythm-templates-diversify-1768 from 7069c9edc1 to ee4636e087 2026-09-08 10:57:20 +08:00 Compare
xiaoxia merged commit cf195685b9 into develop 2026-09-08 11:04:04 +08:00
xiaoxia deleted branch feat/rhythm-templates-diversify-1768 2026-09-08 11:04:04 +08:00

🗑️ 预览环境已清理

PR #1788 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #1788 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Sign in to join this conversation.