update:双麦实时打断

This commit is contained in:
hrz
2025-05-30 15:47:32 +08:00
parent 80b89a85ee
commit b1bfaf5a5c
9 changed files with 519 additions and 186 deletions
@@ -62,6 +62,7 @@ async def sendAudioMessage(conn, sentenceType, audios, text):
# 发送结束消息(如果是最后一个文本)
if conn.llm_finish_task and sentenceType == SentenceType.LAST:
await send_tts_message(conn, "stop", None)
conn.client_is_speaking = False
if conn.close_after_chat:
await conn.close()
@@ -88,6 +89,7 @@ async def sendAudio(conn, audios, pre_buffer=True):
# 播放剩余音频帧
for opus_packet in remaining_audios:
if conn.client_abort:
conn.client_abort = False
return
# 每分钟重置一次计时器
@@ -141,4 +143,5 @@ async def send_stt_message(conn, text):
await conn.websocket.send(
json.dumps({"type": "stt", "text": stt_text, "session_id": conn.session_id})
)
conn.client_is_speaking = True
await send_tts_message(conn, "start")