From 96d69ec8a617f70d6f6879bf1ca62f7a9be0a765 Mon Sep 17 00:00:00 2001 From: Del Wang Date: Wed, 28 May 2025 23:35:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=9F=B3=E9=A2=91=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E6=B5=81=E9=87=87=E6=A0=B7=E7=8E=87=E9=BB=98=E8=AE=A4=E5=80=BC?= =?UTF-8?q?=2024k?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/protocols/websocket_protocol.py | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/examples/xiaozhi/xiaozhi/services/protocols/websocket_protocol.py b/examples/xiaozhi/xiaozhi/services/protocols/websocket_protocol.py index 71bb052..32acfd6 100644 --- a/examples/xiaozhi/xiaozhi/services/protocols/websocket_protocol.py +++ b/examples/xiaozhi/xiaozhi/services/protocols/websocket_protocol.py @@ -155,19 +155,22 @@ class WebsocketProtocol(Protocol): if not transport or transport != "websocket": return + # TODO 使用默认的 24k 采样率 + # xiaozhi-esp32-server 返回的参数是 16k 采样率,但实际用的是 24k 采样率 + # 获取音频参数 - audio_params = data.get("audio_params") - if audio_params: - # 获取服务器的采样率 - sample_rate = audio_params.get("sample_rate") - if sample_rate: - self.server_sample_rate = sample_rate - frame_duration = audio_params.get("frame_duration") - if frame_duration: - self.server_frame_duration = frame_duration - self.server_frame_size = int( - self.server_sample_rate * (self.server_frame_duration / 1000) - ) + # audio_params = data.get("audio_params") + # if audio_params: + # # 获取服务器的采样率 + # sample_rate = audio_params.get("sample_rate") + # if sample_rate: + # self.server_sample_rate = sample_rate + # frame_duration = audio_params.get("frame_duration") + # if frame_duration: + # self.server_frame_duration = frame_duration + # self.server_frame_size = int( + # self.server_sample_rate * (self.server_frame_duration / 1000) + # ) # 设置 hello 接收事件 self.hello_received.set()