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:
@@ -14,6 +14,7 @@ export interface VoiceCallbacks {
|
||||
onState?: (s: VoiceState) => void;
|
||||
onTranscript?: (text: string, final: boolean) => void;
|
||||
onTask?: (taskId: string) => void;
|
||||
onReply?: (deltaText: string) => void; // Agent 回答增量文本(打字机,逐 token)
|
||||
onError?: (msg: string) => void;
|
||||
}
|
||||
|
||||
@@ -115,6 +116,9 @@ export class VoiceClient {
|
||||
case "task":
|
||||
if (m.task_id) this.cb.onTask?.(m.task_id);
|
||||
break;
|
||||
case "reply":
|
||||
if (m.text) this.cb.onReply?.(m.text); // 打字机:回答增量文本
|
||||
break;
|
||||
case "speaking":
|
||||
this.setState("speaking");
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user