fix(#1898): TTS 情绪枚举统一为7种标准英文标签(P1) #1932

Merged
auto-approve-bot merged 1 commits from fix/tts-emotion-p1-neutral-enum into develop 2026-09-15 14:02:49 +08:00
Owner

背景

TTS P1 修复:EMOTION_MAP 以英文枚举为标准 key,neutral 为默认,instruction 格式 你说话的情感是{emotion}。

改动

  • packages/application/cosyvoice_service.py
    • EMOTION_MAP 重排:7 种标准英文枚举(neutral/happy/sad/angry/surprised/fearful/disgusted)第一组;旧英文 4 枚举(natural/excited/calm/friendly)兼容;中文别名保留
    • normalize_emotion 空白直接返回空、大小写不敏感、未知值 warning 日志
    • docstring 更新为枚举说明
  • apps/api/app/schemas/lipsync.py:emotion 默认 natural → neutral,描述更新
  • apps/api/app/services/lipsync_service.py:默认 emotion natural → neutral
  • apps/api/app/api/routes/voice_clones.py:_ALLOWED_PREVIEW_EMOTIONS 扩展为 7 新枚举+旧值;query 描述和错误信息更新
  • tests/unit/test_cosyvoice_emotion.py(新):74 单测,覆盖 7 枚举、大小写、中文别名、旧 4 枚举、空串/空白/未知值、instruction 格式(开头/结尾/单句号)
  • tests/unit/test_voice_clone_preview.py:非法 emotion 用例改为 invalid_emotion_xyz(angry 现合法)

验证

  • 15318 passed, 28 skipped(基线 15244 + 74 新测试)
  • ruff check / black --check 全过

关联

## 背景 TTS P1 修复:EMOTION_MAP 以英文枚举为标准 key,neutral 为默认,instruction 格式 `你说话的情感是{emotion}。` ## 改动 - `packages/application/cosyvoice_service.py` - EMOTION_MAP 重排:7 种标准英文枚举(neutral/happy/sad/angry/surprised/fearful/disgusted)第一组;旧英文 4 枚举(natural/excited/calm/friendly)兼容;中文别名保留 - normalize_emotion 空白直接返回空、大小写不敏感、未知值 warning 日志 - docstring 更新为枚举说明 - `apps/api/app/schemas/lipsync.py`:emotion 默认 natural → neutral,描述更新 - `apps/api/app/services/lipsync_service.py`:默认 emotion natural → neutral - `apps/api/app/api/routes/voice_clones.py`:_ALLOWED_PREVIEW_EMOTIONS 扩展为 7 新枚举+旧值;query 描述和错误信息更新 - `tests/unit/test_cosyvoice_emotion.py`(新):74 单测,覆盖 7 枚举、大小写、中文别名、旧 4 枚举、空串/空白/未知值、instruction 格式(开头/结尾/单句号) - `tests/unit/test_voice_clone_preview.py`:非法 emotion 用例改为 invalid_emotion_xyz(angry 现合法) ## 验证 - 15318 passed, 28 skipped(基线 15244 + 74 新测试) - ruff check / black --check 全过 ## 关联 - 修复 #1898 - 替代过时 PR#1929(基于旧基线,已关闭)
xiaoxia added 1 commit 2026-09-15 13:51:16 +08:00
fix(#1898): TTS 情绪枚举统一为 7 种标准英文标签
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 5s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 5s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 2m13s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 58s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 51s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 3m5s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 3m31s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m56s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m45s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 7m4s
AI Code Review / AI Code Review (pull_request) Successful in 7m4s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 9m30s
CI/CD Pipeline / CI Gate (pull_request) Successful in 1s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 6m21s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 15s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 30s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 25h21m30s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 25h28m45s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 25h30m32s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 25h28m59s
CI/CD Pipeline / Build Production Worker Image (pull_request) Failing after 25h20m52s
CI/CD Pipeline / Build Production Web Image (pull_request) Failing after 25h20m52s
CI/CD Pipeline / Build Production API Image (pull_request) Failing after 25h20m52s
CI/CD Pipeline / PR Build Web Image (pull_request) Failing after 25h29m48s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 25h29m53s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 25h28m10s
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Failing after 25h28m14s
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Failing after 25h28m15s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 25h28m54s
CI/CD Pipeline / Canary Release to Production (pull_request) Failing after 25h20m51s
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 25h28m5s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 25h28m5s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Failing after 25h28m15s
CI/CD Pipeline / Check push changed paths (pull_request) Failing after 25h31m28s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 26h4m31s
72e712c6ff
- EMOTION_MAP 以 neutral/happy/sad/angry/surprised/fearful/disgusted 为第一组标准 key
- neutral 作为默认值(替代旧 natural),旧英文 4 枚举和中文标签保持兼容
- normalize_emotion 空串/空白直接返回空,大小写不敏感
- schemas/lipsync.py、lipsync_service.py 默认 emotion 从 natural → neutral
- voice_clones preview 白名单扩展为 7 新枚举+旧值
- 新增 test_cosyvoice_emotion.py 单测 74 个覆盖 7 枚举/大小写/别名/边界/instruction 格式
- 修正 test_voice_clone_preview 非法 emotion 用例(angry 现合法)

🚀 预览环境已部署

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

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

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

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

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #1932 | | 预览链接 | [https://pr-1932.preview.xiaoxiajianji.com](https://pr-1932.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
auto-approve-bot merged commit 19eeb1b475 into develop 2026-09-15 14:02:49 +08:00
auto-approve-bot deleted branch fix/tts-emotion-p1-neutral-enum 2026-09-15 14:02:50 +08:00

🗑️ 预览环境已清理

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

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

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