feat(ai-nutritionist): Coze TTS and streaming robustness
- Add Coze TTS endpoint and service; expose binary MP3 from controller. - Bypass ResponseFilter for /audio/speech so MP3 bodies are not UTF-8 wrapped. - UniApp: cozeTextToSpeech, TTS UI and play flow; SSE HTTP errors and diagnostics. - Document TTS in docs/features.md; extend test-0325-1 with curl verification. Made-with: Cursor
This commit is contained in:
32
docs/features.md
Normal file
32
docs/features.md
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
# 新功能增加
|
||||
|
||||
## 页面(pages/tool/ai-nutritionist)
|
||||
|
||||
### 语音合成(TTS)✅ 已实现
|
||||
|
||||
- 增加"语音合成"功能,通过 Coze TTS API 将 AI 回复的文本内容合成为自然流畅的音频播放出来
|
||||
- Header 区域增加 **播报开/关** 切换按钮(🔊),默认关闭
|
||||
- 每条 AI 回复气泡底部有 **▶ 播放** / **⏹ 停止** 按钮,可单独播放任意一条消息
|
||||
- 当语音播报开关打开时,AI 回复完成后**自动播报**最新一条消息
|
||||
- 音频由后端调用 Coze SDK `audio().speech().create()` 合成,以 MP3 格式返回,前端通过 `innerAudioContext` 播放
|
||||
|
||||
#### 涉及文件
|
||||
|
||||
| 文件 | 变更说明 |
|
||||
|---|---|
|
||||
| `msh_crmeb_22/.../ToolCozeService.java` | 新增 `textToSpeech` 接口方法 |
|
||||
| `msh_crmeb_22/.../ToolCozeServiceImpl.java` | 实现 TTS,调用 Coze SDK |
|
||||
| `msh_crmeb_22/.../CozeController.java` | 新增 `POST /api/front/coze/audio/speech` 端点 |
|
||||
| `msh_single_uniapp/api/models-api.js` | 新增 `cozeTextToSpeech()` 函数 |
|
||||
| `msh_single_uniapp/pages/tool/ai-nutritionist.vue` | 集成 TTS 开关、播放按钮、自动播报逻辑 |
|
||||
|
||||
#### voiceId 说明
|
||||
|
||||
- 后端默认音色 ID:`7468518753626652709`(中文女声,需确认可用性)
|
||||
- 可通过调用 `client.audio().voices().list()` 获取平台所有可用音色
|
||||
- 前端调用 `cozeTextToSpeech()` 时可传 `voiceId` 字段覆盖默认值
|
||||
|
||||
## 相关文档
|
||||
|
||||
api地址: https://docs.coze.cn/developer_guides/text_to_speech
|
||||
Reference in New Issue
Block a user