diff --git a/main/xiaozhi-server/core/handle/sendAudioHandle.py b/main/xiaozhi-server/core/handle/sendAudioHandle.py index 3d60d253..d2b24f28 100644 --- a/main/xiaozhi-server/core/handle/sendAudioHandle.py +++ b/main/xiaozhi-server/core/handle/sendAudioHandle.py @@ -280,8 +280,9 @@ async def send_tts_message(conn: "ConnectionHandler", state, text=None): await sendAudio(conn, audios) # 等待所有音频包发送完成 await _wait_for_audio_completion(conn) - # 停止音频发送循环 - conn.audio_rate_controller.stop_sending() + # 停止音频发送循环(仅在流控器已初始化时调用) + if hasattr(conn, "audio_rate_controller") and conn.audio_rate_controller: + conn.audio_rate_controller.stop_sending() # 清除服务端讲话状态 conn.clearSpeakStatus()