fix(tts): P1 TTS emotion instruction format per voice type + missing CN aliases #1934
Reference in New Issue
Block a user
Delete Branch "fix/p1-tts-emotion-enum"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
背景
灵应 13:10 派 P1 任务指出:
改动
1. emotion 映射补全(packages/application/cosyvoice_service.py)
补 中性→neutral / 伤心→sad / 吃惊→surprised 三个中文别名(灵应指定)。
2. instruction 格式按 voice 类型三路分支
新增
build_emotion_instruction(voice_id, emotion_enum):long*/loong*前缀"Speak in a {emotion} tone."(DashScope 克隆音色支持任意自然语言指令)longanyang/longanhuan/longhuhu_v3"你说话的情感是{emotion}。"(官方固定中文格式,结尾中文句号不可省)longxiaochun_v3)依据:阿里云百炼 CosyVoice 音色列表
3. voice_clones preview 白名单同步扩展
补 中性/吃惊/伤心 三个中文别名,错误提示文案更新。
4. 单测(210 个 emotion 相关用例全部通过)
test_cosyvoice_emotion.py:重构为按分支测,覆盖克隆音色英文格式 / 系统音色中文格式 / 默认音色不传 instruction / 大小写 / 别名 / 空值 / 未知值默认 neutraltest_ai_avatar_emotion_tts_lipsync.py:补克隆音色/longanyang/默认音色三路 payload 断言5. E2E 修复
apps/web/e2e/core-generation.spec.ts:128处已在 PR#1931(0e5127df)中改为GET /templates+ 默认模板兜底,方案A 已经生效,无需额外改动。验证
- Add missing CN aliases 中性→neutral, 伤心→sad, 吃惊→surprised (per 灵应 spec) - Split instruction format by voice type: · Cloned/custom voices (non long*/loong* prefix): English 'Speak in a {emotion} tone.' (DashScope allows free-form natural language for cloned voices) · System voices supporting emotion Instruct (longanyang/longanhuan/longhuhu_v3): strict Chinese fixed format '你说话的情感是{emotion}。' per 阿里云百炼 docs · Other system voices (incl. default longxiaochun_v3 which doesn't support Instruct): skip instruction entirely to avoid being silently dropped/errored by API - Expand preview emotion whitelist with new CN aliases - Add/expand unit tests (210 emotion tests passing, 15438 total unit tests passing) - E2E fix for templates CRUD was already done in PR#1931, no change needed🚀 预览环境已部署
🗑️ 预览环境已清理
PR #1934 已关闭或合并,对应的预览环境已被清理。
🗑️ 预览环境已清理
PR #1934 已关闭或合并,对应的预览环境已被清理。