From 149c4dc89ab7157c7450375e0e1236c6f6ec438f Mon Sep 17 00:00:00 2001 From: Blizzard Date: Sat, 25 Jul 2026 15:27:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(voice):=20=E6=9C=AA=E9=85=8D=20TTS=20?= =?UTF-8?q?=E6=97=B6=E4=B9=9F=E5=9B=9E=20tts=5Fend(=E5=88=AB=E8=AE=A9?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E6=B0=B8=E8=BF=9C=E5=8D=A1=E5=9C=A8?= =?UTF-8?q?"=E6=80=9D=E8=80=83=E4=B8=AD")?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TTSEnabled 要 api_key + tts_resource_id + tts_voice_type 三项齐全,而 ASREnabled 只要两项。线上只配齐 ASR 时:转写成功→进思考中→agent 出结果→ speak() 静默 return,连 tts_end 都不发 → 客户端永远停在"思考中"。 用户看到的是"提问后彻底没反应",完全看不出是配置缺失——两个症状 (一直思考不回答 / 结果不语音回复)其实是这同一个静默 return。 改:未配 TTS 时明确回 error 文案 + tts_end,让客户端回到待命并告知原因; 服务端日志也点明缺哪三项。 Co-Authored-By: Claude Opus 5 --- sundynix-gateway/internal/handler/voice_tts.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sundynix-gateway/internal/handler/voice_tts.go b/sundynix-gateway/internal/handler/voice_tts.go index 78e0231..1d09ea5 100644 --- a/sundynix-gateway/internal/handler/voice_tts.go +++ b/sundynix-gateway/internal/handler/voice_tts.go @@ -18,7 +18,13 @@ import ( // TTS 就绪后补吐,保证第一句不丢。 func (s *voiceSession) speak(taskID string) { if !s.cfg.TTSEnabled() { - return // 没配 TTS:只回转写 + 任务,无语音朗读 + // 没配 TTS(缺 resource-id 或音色):不朗读,但**必须**回 tts_end—— + // 否则客户端永远停在"思考中",用户看到的是"提问后彻底没反应", + // 完全看不出是配置问题(这里此前是静默 return,坑了整整一天)。 + log.Printf("[voice] TTS 未配置(需 api_key + tts_resource_id + tts_voice_type 三项齐全),本轮只回文字 uid=%s", s.uid) + s.send(voice.ServerMsg{Type: voice.ServerError, Msg: "未配置语音合成(缺 TTS resource-id 或音色),本次只有文字回答"}) + s.send(voice.ServerMsg{Type: voice.ServerTTSEnd}) + return } sb := voice.NewSentenceBuffer()