feat(voice): 下行打字机文本流 + 首块快出,即时反馈
- protocol.go: 新增 ServerReply("reply") 消息——Agent 回答增量文本
- voice_tts.go: token 一到即转发客户端(打字机),同时攒句喂 TTS(音频随后)
- sentence_buffer.go: 本轮首句用低阈值(5 rune)抢首字延迟,之后回常规 12
- 桌面端 voice.ts onReply + VoiceDock 对话气泡(我说的 + JARVIS 打字机回答,思考态光标)
管线已最优:文字在 LLM 首 token 即刻上屏、音频紧随。剩余时延=大模型 TTFT(deepseek-v4-pro
4-7s 且波动大,疑似推理模型),这是模型的账、非管线——真要"马上响应"需换快模型。
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,7 @@ const (
|
||||
type ServerMsg struct {
|
||||
Type string `json:"type"`
|
||||
// transcript:ASR 转写(Final=false 为实时部分结果,true 为最终)
|
||||
// reply:Agent 回答的增量文本(打字机效果,逐 token 下发,早于音频)
|
||||
Text string `json:"text,omitempty"`
|
||||
Final bool `json:"final,omitempty"`
|
||||
// task:转写完成、任务已提交,带 task_id 供客户端切运行视图
|
||||
@@ -41,6 +42,7 @@ const (
|
||||
ServerReady = "ready" // 会话就绪,可以开始说话
|
||||
ServerTranscript = "transcript" // ASR 转写结果(部分/最终)
|
||||
ServerTask = "task" // 任务已提交(带 task_id)
|
||||
ServerReply = "reply" // Agent 回答增量文本(打字机;逐 token,早于音频)
|
||||
ServerSpeaking = "speaking" // Agent 开始出声(首段 TTS 音频将至)
|
||||
ServerTTSEnd = "tts_end" // 本轮 TTS 播放完毕
|
||||
ServerError = "error" // 出错
|
||||
|
||||
Reference in New Issue
Block a user