2025-02-04 12:20:10 +08:00
|
|
|
import json
|
2026-01-25 17:43:52 +08:00
|
|
|
from typing import TYPE_CHECKING
|
2025-02-04 12:20:10 +08:00
|
|
|
|
2026-01-25 17:43:52 +08:00
|
|
|
if TYPE_CHECKING:
|
|
|
|
|
from core.connection import ConnectionHandler
|
2025-02-18 00:07:19 +08:00
|
|
|
TAG = __name__
|
2025-02-04 12:20:10 +08:00
|
|
|
|
|
|
|
|
|
2026-01-25 17:43:52 +08:00
|
|
|
async def handleAbortMessage(conn: "ConnectionHandler"):
|
2025-05-07 18:06:13 +08:00
|
|
|
conn.logger.bind(tag=TAG).info("Abort message received")
|
2025-02-04 12:20:10 +08:00
|
|
|
# 设置成打断状态,会自动打断llm、tts任务
|
|
|
|
|
conn.client_abort = True
|
2025-04-25 09:34:22 +08:00
|
|
|
conn.clear_queues()
|
2025-02-04 12:20:10 +08:00
|
|
|
# 打断客户端说话状态
|
2025-05-07 18:06:13 +08:00
|
|
|
await conn.websocket.send(
|
|
|
|
|
json.dumps({"type": "tts", "state": "stop", "session_id": conn.session_id})
|
|
|
|
|
)
|
2025-02-04 12:20:10 +08:00
|
|
|
conn.clearSpeakStatus()
|
2025-05-07 18:06:13 +08:00
|
|
|
conn.logger.bind(tag=TAG).info("Abort message received-end")
|