feat(tts): style语气风格参数全链路接入 + 语速/音量/音调透传修复 #2005

Merged
auto-approve-bot merged 2 commits from fix/tts-style-emotion into develop 2026-09-21 04:23:08 +08:00
Owner

背景

前端 PR#2002 已合入 develop,所有 TTS 接口现在传 style 参数(natural/sweet/excited/professional/news/livestream)。此前后端 schema 无 style 字段,前端传值被 Pydantic 忽略,风格选择不生效。

改动内容

1. style 语气风格参数(对齐前端)

  • cosyvoice_service.py:新增 STYLE_INSTRUCTION_MAPVALID_STYLESbuild_style_instruction()
  • 显式 style → style instruct;无 style 回退旧 emotion 逻辑(向后兼容)
  • style 优先级高于 emotion
  • 4 个 schema 新增 style:TTSSynthesizeRequest / TTSPreviewRequest / CreateLipsyncJobRequest / AiAvatarTtsPreviewRequest
  • lipsync_jobs 表新增 style 列(migration 084)

2. 语速/音量/音调透传修复

  • 修复 volume/pitch 在 start_synthesis / segment 路径丢失
  • preview/synthesize/lipsync_tts 全链路透传 speed/volume/pitch

测试

  • 新增 12 个 style 相关单测
  • 144 个相关测试全部通过,ruff 检查通过

影响范围

  • 仅 TTS / lipsync 后端,不涉及前端
## 背景 前端 PR#2002 已合入 develop,所有 TTS 接口现在传 `style` 参数(natural/sweet/excited/professional/news/livestream)。此前后端 schema 无 style 字段,前端传值被 Pydantic 忽略,风格选择不生效。 ## 改动内容 ### 1. style 语气风格参数(对齐前端) - `cosyvoice_service.py`:新增 `STYLE_INSTRUCTION_MAP`、`VALID_STYLES`、`build_style_instruction()` - 显式 style → style instruct;无 style 回退旧 emotion 逻辑(向后兼容) - style 优先级高于 emotion - 4 个 schema 新增 style:TTSSynthesizeRequest / TTSPreviewRequest / CreateLipsyncJobRequest / AiAvatarTtsPreviewRequest - `lipsync_jobs` 表新增 style 列(migration 084) ### 2. 语速/音量/音调透传修复 - 修复 volume/pitch 在 start_synthesis / segment 路径丢失 - preview/synthesize/lipsync_tts 全链路透传 speed/volume/pitch ## 测试 - 新增 12 个 style 相关单测 - 144 个相关测试全部通过,ruff 检查通过 ## 影响范围 - 仅 TTS / lipsync 后端,不涉及前端
xiaoxia added 1 commit 2026-09-21 04:07:14 +08:00
feat(tts): style语气风格参数全链路接入 + 语速/音量/音调透传修复
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 / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
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 / 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 / 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
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m51s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m4s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 3m2s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 4m29s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 4m30s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 4m49s
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Security (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Style (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
9c6d98fff4
后端新增 style 参数(对齐前端 PR#2002):
- 支持 6 种语气风格:natural/sweet/excited/professional/news/livestream
- cosyvoice_service 新增 STYLE_INSTRUCTION_MAP、VALID_STYLES、build_style_instruction()
- 显式 style 走 style instruct;无 style 回退旧 emotion 逻辑(向后兼容)
- style 优先级高于 emotion
- 4 个 schema(TTSSynthesize/TTSPreview/CreateLipsyncJob/AiAvatarTtsPreview)新增 style
- 数据库 lipsync_jobs 新增 style 列(migration 084)

语速/音量/音调透传修复:
- 修复 volume/pitch 在 start_synthesis/segment 路径丢失的问题
- preview/synthesize/lipsync_tts 全链路透传 speed/volume/pitch

测试:新增 12 个 style 相关单测,全部 144 个相关测试通过

🚀 预览环境已部署

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

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

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

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

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #2005 | | 预览链接 | [https://pr-2005.preview.xiaoxiajianji.com](https://pr-2005.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
auto-approve-bot added 1 commit 2026-09-21 04:12:23 +08:00
style: auto-format with black + isort + ruff + prettier [skip ci-format-check]
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
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 / Frontend Unit Tests (pull_request) Has been skipped
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 / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m19s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m57s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m9s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 3m29s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 3m47s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 6m4s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 6m38s
AI Code Review / AI Code Review (pull_request) Successful in 6m44s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 7m21s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 9m55s
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 / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 1s
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 7m36s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 26s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 7m31s
cac73744a4
auto-approve-bot merged commit a9f596fca3 into develop 2026-09-21 04:23:08 +08:00
auto-approve-bot deleted branch fix/tts-style-emotion 2026-09-21 04:23:11 +08:00

🗑️ 预览环境已清理

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

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

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