fix(voice): 未配 TTS 时也回 tts_end(别让客户端永远卡在"思考中")

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 <noreply@anthropic.com>
This commit is contained in:
Blizzard
2026-07-25 15:27:02 +08:00
parent c66d178efe
commit 149c4dc89a
@@ -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()