mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-30 13:23:55 +08:00
根据语音包发送更新client_is_speaking状态
This commit is contained in:
@@ -145,6 +145,7 @@ async def sendAudio(conn, audios, frame_duration=60):
|
|||||||
else:
|
else:
|
||||||
# 直接发送opus数据包,不添加头部
|
# 直接发送opus数据包,不添加头部
|
||||||
await conn.websocket.send(audios)
|
await conn.websocket.send(audios)
|
||||||
|
conn.client_is_speaking = True
|
||||||
|
|
||||||
# 更新流控状态
|
# 更新流控状态
|
||||||
flow_control["packet_count"] += 1
|
flow_control["packet_count"] += 1
|
||||||
@@ -168,6 +169,7 @@ async def sendAudio(conn, audios, frame_duration=60):
|
|||||||
else:
|
else:
|
||||||
# 直接发送预缓冲包,不添加头部
|
# 直接发送预缓冲包,不添加头部
|
||||||
await conn.websocket.send(audios[i])
|
await conn.websocket.send(audios[i])
|
||||||
|
conn.client_is_speaking = True
|
||||||
remaining_audios = audios[pre_buffer_frames:]
|
remaining_audios = audios[pre_buffer_frames:]
|
||||||
|
|
||||||
# 播放剩余音频帧
|
# 播放剩余音频帧
|
||||||
@@ -201,6 +203,8 @@ async def sendAudio(conn, audios, frame_duration=60):
|
|||||||
# 直接发送opus数据包,不添加头部
|
# 直接发送opus数据包,不添加头部
|
||||||
await conn.websocket.send(opus_packet)
|
await conn.websocket.send(opus_packet)
|
||||||
|
|
||||||
|
conn.client_is_speaking = True
|
||||||
|
|
||||||
play_position += frame_duration
|
play_position += frame_duration
|
||||||
|
|
||||||
|
|
||||||
@@ -255,5 +259,4 @@ async def send_stt_message(conn, text):
|
|||||||
await conn.websocket.send(
|
await conn.websocket.send(
|
||||||
json.dumps({"type": "stt", "text": stt_text, "session_id": conn.session_id})
|
json.dumps({"type": "stt", "text": stt_text, "session_id": conn.session_id})
|
||||||
)
|
)
|
||||||
conn.client_is_speaking = True
|
|
||||||
await send_tts_message(conn, "start")
|
await send_tts_message(conn, "start")
|
||||||
|
|||||||
Reference in New Issue
Block a user