feat(web): TTS 情绪扩展为 7 种 + 系统音色语言限 zh/en + 清理残留代码 #1915

Merged
auto-approve-bot merged 15 commits from feat/1915-tts-emotion-7options into develop 2026-09-15 01:45:51 +08:00
Owner

变更概览

1. TTS 情绪选项 4 种 → 7 种(对齐 CosyVoice)

旧:自然/兴奋/沉稳/亲切 → natural/excited/calm/friendly
新:

  • 自然 → neutral
  • 开心 → happy
  • 难过 → sad
  • 生气 → angry
  • 惊讶 → surprised
  • 恐惧 → fearful
  • 厌恶 → disgusted

影响文件:

  • pages/voices/components/tts-modal/constants.ts:TTS_EMOTION_OPTIONS 重写为 7 项,默认值 neutral
  • pages/voices/components/tts-modal/EmotionControl.tsx:沿用新常量
  • pages/ai-avatar/types.ts:VoiceEmotion 类型 + VOICE_EMOTION_OPTIONS 重写
  • pages/ai-avatar/utils/contract.ts:normalizeEmotion() 支持新枚举,并兼容旧 4 种英文枚举与旧中文标签(自然/兴奋/沉稳/亲切)自动映射,后端老数据不炸
  • pages/ai-avatar/hooks/useAiAvatar.ts:默认情绪 natural
  • pages/ai-avatar/api/aiAvatar.ts:注释更新
  • api/tts/types.ts:TTSPreviewRequest.emotion 注释更新

2. 系统预置音色语言限制为 zh/en

  • 预置音色(含默认音色):仅支持中文/英文;日文/韩文需使用克隆音色
  • 克隆音色:保留 4 语言(zh/en/ja/ko)
  • 切换到预置音色时若当前语言是 ja/ko,自动回退到 zh-CN,不会发出不受支持的请求
  • AI 数字人面板同步:预置音色语言选项只有中文/English,克隆音色才显示日/韩

影响文件:

  • pages/voices/components/tts-modal/constants.ts:拆分为 PRESET_TTS_LANGUAGE_OPTIONS / CLONE_TTS_LANGUAGE_OPTIONS
  • pages/voices/components/tts-modal/LanguageControl.tsx:新增 options prop,自动 fallback 非法值到中文
  • pages/voices/components/TtsModal.tsx:根据当前音色是否克隆决定语言选项
  • pages/voices/hooks/useTtsSynthesize.ts:新增 handleVoiceChange,切换音色时做语言回退;合成前防御校验
  • pages/voices/VoiceLibrary.tsx:接入 handleVoiceChange
  • pages/ai-avatar/types.ts:拆分为 PRESET_VOICE_LANGUAGE_OPTIONS / CLONE_VOICE_LANGUAGE_OPTIONS,预置默认 zh
  • pages/ai-avatar/components/PanelVoiceSelector.tsx:根据 voiceSource 动态过滤语言选项
  • pages/ai-avatar/hooks/useAiAvatar.ts:默认语言 zh

3. 清理残留

  • AI 数字人语言旧值 mandarin/english/cantonese 统一为 zh/en/ja/ko 短码,预置音色不再暴露粤语
  • 全量扫描 generate/ 目录与 router,确认 #1911 简化流程后无 EditingPlanner/MyTemplates/TemplateLibrary/useTemplateSelection/useTitleCoverSync 残留引用
  • tts 模块注释统一更新

测试

  • Prettier 3.9.5 已按仓库配置格式化
  • 类型与逻辑均做防御:旧数据(emotion=natural/excited/calm/friendly 或中文标签)进入 normalizeEmotion 会自动映射到新枚举,不破坏线上草稿/历史数据
  • 无后端依赖:后端 normalize_emotion() 对未知值默认 neutral,本次改动完全前向兼容
## 变更概览 ### 1. TTS 情绪选项 4 种 → 7 种(对齐 CosyVoice) 旧:自然/兴奋/沉稳/亲切 → natural/excited/calm/friendly 新: - 自然 → neutral - 开心 → happy - 难过 → sad - 生气 → angry - 惊讶 → surprised - 恐惧 → fearful - 厌恶 → disgusted 影响文件: - `pages/voices/components/tts-modal/constants.ts`:TTS_EMOTION_OPTIONS 重写为 7 项,默认值 neutral - `pages/voices/components/tts-modal/EmotionControl.tsx`:沿用新常量 - `pages/ai-avatar/types.ts`:VoiceEmotion 类型 + VOICE_EMOTION_OPTIONS 重写 - `pages/ai-avatar/utils/contract.ts`:normalizeEmotion() 支持新枚举,并兼容旧 4 种英文枚举与旧中文标签(自然/兴奋/沉稳/亲切)自动映射,后端老数据不炸 - `pages/ai-avatar/hooks/useAiAvatar.ts`:默认情绪 natural - `pages/ai-avatar/api/aiAvatar.ts`:注释更新 - `api/tts/types.ts`:TTSPreviewRequest.emotion 注释更新 ### 2. 系统预置音色语言限制为 zh/en - 预置音色(含默认音色):仅支持中文/英文;日文/韩文需使用克隆音色 - 克隆音色:保留 4 语言(zh/en/ja/ko) - 切换到预置音色时若当前语言是 ja/ko,自动回退到 zh-CN,不会发出不受支持的请求 - AI 数字人面板同步:预置音色语言选项只有中文/English,克隆音色才显示日/韩 影响文件: - `pages/voices/components/tts-modal/constants.ts`:拆分为 PRESET_TTS_LANGUAGE_OPTIONS / CLONE_TTS_LANGUAGE_OPTIONS - `pages/voices/components/tts-modal/LanguageControl.tsx`:新增 options prop,自动 fallback 非法值到中文 - `pages/voices/components/TtsModal.tsx`:根据当前音色是否克隆决定语言选项 - `pages/voices/hooks/useTtsSynthesize.ts`:新增 handleVoiceChange,切换音色时做语言回退;合成前防御校验 - `pages/voices/VoiceLibrary.tsx`:接入 handleVoiceChange - `pages/ai-avatar/types.ts`:拆分为 PRESET_VOICE_LANGUAGE_OPTIONS / CLONE_VOICE_LANGUAGE_OPTIONS,预置默认 zh - `pages/ai-avatar/components/PanelVoiceSelector.tsx`:根据 voiceSource 动态过滤语言选项 - `pages/ai-avatar/hooks/useAiAvatar.ts`:默认语言 zh ### 3. 清理残留 - AI 数字人语言旧值 mandarin/english/cantonese 统一为 zh/en/ja/ko 短码,预置音色不再暴露粤语 - 全量扫描 generate/ 目录与 router,确认 #1911 简化流程后无 EditingPlanner/MyTemplates/TemplateLibrary/useTemplateSelection/useTitleCoverSync 残留引用 - tts 模块注释统一更新 ## 测试 - Prettier 3.9.5 已按仓库配置格式化 - 类型与逻辑均做防御:旧数据(emotion=natural/excited/calm/friendly 或中文标签)进入 normalizeEmotion 会自动映射到新枚举,不破坏线上草稿/历史数据 - 无后端依赖:后端 normalize_emotion() 对未知值默认 neutral,本次改动完全前向兼容
xiaoxia added 12 commits 2026-09-15 01:09:57 +08:00
docs(api): TTSPreviewRequest emotion 字段注释更新为 7 种枚举
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 2s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1s
CI/CD Pipeline / Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker 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) Failing after 1m7s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 1m16s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 1m31s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 1m49s
CI/CD Pipeline / Validate - Style (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Security (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Web Image (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
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
5a2f66d251
xiaoxia added 1 commit 2026-09-15 01:12:18 +08:00
fix(voices): clonedVoices 可能为 undefined 兜底;TS 严格模式修复
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Has been cancelled
CI/CD Pipeline / Check if frontend-only change (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Style (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Security (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Lint (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / PR Build API Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Web Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Check push changed paths (pull_request) Has been cancelled
CI/CD Pipeline / Build Staging API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been cancelled
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been cancelled
CI/CD Pipeline / Staging API Integration 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 / ACR Image Cleanup (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
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
Preview Deploy / Deploy Preview Environment (pull_request) Has been cancelled
190c10e116
xiaoxia added 1 commit 2026-09-15 01:12:21 +08:00
fix(voices): PRESET_LANG_SET 泛型声明为 TtsLanguage 修复 TS2345
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 / Check push changed paths (pull_request) Has been skipped
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m19s
CI/CD Pipeline / Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 24s
CI/CD Pipeline / PR Build API Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 26s
CI/CD Pipeline / PR Build Worker 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 / Frontend Unit Tests (pull_request) Successful in 1m8s
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
CI/CD Pipeline / Validate - Style (pull_request) Successful in 4m15s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 4m53s
AI Code Review / AI Code Review (pull_request) Successful in 6m27s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 6m36s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 10m46s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Failing after 1s
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 / Production Browser E2E (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 4m22s
70b0aded28

🚀 预览环境已部署

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

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

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

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

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #1915 | | 预览链接 | [https://pr-1915.preview.xiaoxiajianji.com](https://pr-1915.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
xiaoxia added 1 commit 2026-09-15 01:33:56 +08:00
fix(voices): clonedList 移到 useMemo 回调内避免 react-hooks/exhaustive-deps warning
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 2s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker 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
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 1m39s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 1m39s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 1m48s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 1m53s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 3m49s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 4m19s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 4m40s
AI Code Review / AI Code Review (pull_request) Successful in 6m24s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 11m14s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
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 / CI Gate (pull_request) Successful in 2s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 10m6s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 11s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 39s
eac3b79b7b
auto-approve-bot approved these changes 2026-09-15 01:35:45 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
auto-approve-bot approved these changes 2026-09-15 01:35:45 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
auto-approve-bot merged commit 5d4e07d4f4 into develop 2026-09-15 01:45:51 +08:00
auto-approve-bot deleted branch feat/1915-tts-emotion-7options 2026-09-15 01:45:52 +08:00

🗑️ 预览环境已清理

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

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

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