|
|
@@ -82,11 +82,14 @@ interface DialogueAPI {
|
|
|
**实现**: `MockDialogueAPI`(开发用)和 `RealDialogueAPI`(对接真实后端)
|
|
|
通过前端 prop `mode: 'preview' | 'real'` 切换
|
|
|
|
|
|
-### Decision 6: TTS 使用前端 Web Speech API(v1)
|
|
|
+### Decision 6: TTS 使用前端 Azure TTS
|
|
|
|
|
|
-**选择**: AI 消息 `done` 后调用 `speechSynthesis.speak()` 朗读
|
|
|
+**选择**: AI 消息 `done` 后,前端整段文本调用 Azure TTS 合成语音并播放
|
|
|
|
|
|
-**理由**: 零后端改动,3 行代码立即可用。质量不够后续升级 Azure TTS
|
|
|
+**理由**:
|
|
|
+- 前端已通过 SSE 接收完整文本,直接调 Azure TTS 最简单
|
|
|
+- AI 回复限定 1-2 句(system prompt 约束),不需要分句 TTS
|
|
|
+- 不做服务端 TTS,后端不涉及语音合成
|
|
|
|
|
|
---
|
|
|
|
|
|
@@ -115,7 +118,7 @@ cococlass-english-speaking-api(编排层)
|
|
|
| LLM | Chat Completions via One-Hub(openai SDK) |
|
|
|
| ASR | Azure Speech(纯转录模式) |
|
|
|
| 发音评估 | Azure Speech Pronunciation Assessment(后台) |
|
|
|
-| SSE | FastAPI StreamingResponse |
|
|
|
+| SSE | FastAPI 原生 EventSourceResponse + ServerSentEvent |
|
|
|
| 数据库 | MySQL + asyncmy + SQLAlchemy 2.0 |
|
|
|
| 存储 | S3(boto3) |
|
|
|
| 配置 | pydantic-settings + python-dotenv |
|
|
|
@@ -145,12 +148,12 @@ ASRProvider / LLMProvider / PronunciationAssessor / AudioStorage 四个 Protocol
|
|
|
```
|
|
|
POST /api/speaking/dialogue/session → JSON { sessionId, aiMessage }
|
|
|
POST /api/speaking/dialogue/speak → SSE { transcript, token, done }
|
|
|
-GET /api/speaking/dialogue/report → 延后(结果页方案待确认)
|
|
|
+GET /api/speaking/dialogue/report → JSON { 对话历史 + 评分 + LLM 总结 }
|
|
|
```
|
|
|
|
|
|
### 数据模型
|
|
|
|
|
|
-- **DialogueSession**: id, user_id, topic, role_config, total_rounds, current_round, status, system_prompt, created_at, completed_at
|
|
|
+- **DialogueSession**: id, user_id, topic, role_config, total_rounds, current_round, status, system_prompt, expires_at, summary, created_at, completed_at
|
|
|
- **DialogueMessage**: id, session_id, round, role, content, audio_url, created_at
|
|
|
- **PronunciationEvaluation**: id, message_id, session_id, round, status, accuracy/fluency/completeness/prosody scores, word_analysis, created_at, completed_at
|
|
|
|
|
|
@@ -162,4 +165,5 @@ GET /api/speaking/dialogue/report → 延后(结果页方案待确认)
|
|
|
- **[流式解析差异]** → 在 adapter 层做格式解析,engine 层只关心 token string
|
|
|
- **[录音权限拒绝]** → composable 暴露 permissionState,UI 显示引导提示
|
|
|
- **[内存泄漏]** → 在 composable 的 `onUnmounted` 中统一清理录音 Blob
|
|
|
-- **[后台评估未完成]** → /report 接口最多等 5 秒,超时返回部分结果
|
|
|
+- **[后台评估未完成]** → 前端轮询 GET /report(每 2 秒),30 秒超时后展示已有结果,缺失的标记为"评估不可用"。评估记录在 speak 主流程中创建(保证记录一定存在),后台任务只负责更新结果
|
|
|
+- **[定时结束]** → 后端通过 `expires_at` 判断,`/speak` 时检查是否超时。前端用 `expires_at` 显示倒计时,不再是纯前端控制
|