fix: send system idle instead of tts stop to avoid Speaking→Listening race
Root cause: tts stop triggers Speaking→Listening, which calls SendStartListening in HandleStateChangedEvent. idle arrives too late and gets overridden. Fix: skip tts stop when idle is needed, go Speaking→Idle directly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
16d8a744ac
commit
eda88f83f3
|
|
@ -44,15 +44,18 @@ async def sendAudioMessage(conn: "ConnectionHandler", sentenceType, audios, text
|
|||
|
||||
# 发送结束消息(如果是最后一个文本)
|
||||
if sentenceType == SentenceType.LAST:
|
||||
await send_tts_message(conn, "stop", None)
|
||||
conn.client_is_speaking = False
|
||||
# Send system idle command if LLM requested it (e.g. antaf bridge unavailable)
|
||||
if getattr(conn, 'send_idle_after_tts', False):
|
||||
# Send system idle instead of tts stop — goes Speaking→Idle directly,
|
||||
# avoids Speaking→Listening which triggers SendStartListening
|
||||
conn.send_idle_after_tts = False
|
||||
conn.client_is_speaking = False
|
||||
await conn.websocket.send(
|
||||
json.dumps({"type": "system", "command": "idle"})
|
||||
)
|
||||
conn.logger.bind(tag=TAG).info("Sent system idle to device")
|
||||
conn.logger.bind(tag=TAG).info("Sent system idle to device (skip tts stop)")
|
||||
else:
|
||||
await send_tts_message(conn, "stop", None)
|
||||
conn.client_is_speaking = False
|
||||
if conn.close_after_chat:
|
||||
await conn.close()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue