| | |
| | | message = {"type": "tts", "state": state, "session_id": conn.session_id} |
| | | if text is not None: |
| | | message["text"] = textUtils.check_emoji(text) |
| | | # 再见/超时结束:设备收到 stop 后应直接 idle 等唤醒,不要先回 listening。 |
| | | if state == "stop" and getattr(conn, "close_after_chat", False): |
| | | message["session_end"] = True |
| | | |
| | | # TTS播放结束 |
| | | if state == "stop": |
| | |
| | | |
| | | # 发送消息到客户端 |
| | | await conn.websocket.send(json.dumps(message)) |
| | | if state == "stop": |
| | | from core.app_runtime.runtime import maybe_flush_pending_play_after_tts |
| | | |
| | | await maybe_flush_pending_play_after_tts(conn) |
| | | |
| | | |
| | | async def send_stt_message(conn: "ConnectionHandler", text): |