From 6102d42592c2f53681e10f119fbf54e6d48896a3 Mon Sep 17 00:00:00 2001 From: dahanzimin <353767514@qq.com> Date: Tue, 21 Oct 2025 14:19:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0mini=E7=9A=84=E8=AE=AF?= =?UTF-8?q?=E9=A3=9E=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98=E5=8F=8A=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E5=9B=9E=E8=B0=83=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../origin/build/lib/mini_bot.py | 33 +++++++++---------- .../origin/build/lib/mini_xunfei.py | 16 ++++++--- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/boards/default_src/micropython_esp32c2/origin/build/lib/mini_bot.py b/boards/default_src/micropython_esp32c2/origin/build/lib/mini_bot.py index 500d3b13..ac873b80 100644 --- a/boards/default_src/micropython_esp32c2/origin/build/lib/mini_bot.py +++ b/boards/default_src/micropython_esp32c2/origin/build/lib/mini_bot.py @@ -383,7 +383,7 @@ class BOT035(FrameBuffer): else: self._wreg(_BOT035_STA, (self._rreg(_BOT035_STA) & 0xF7) | (power & 0x01) << 3) else: - print("Warning: Please upgrade the coprocessor firmware to use this feature") + raise OSError("This feature is only supported on version 2.0 ~") def pcm_any(self): return bool(self._rreg(_BOT035_STA) & 0x80) @@ -392,23 +392,20 @@ class BOT035(FrameBuffer): return self._rreg(_BOT035_PCM, ibuf) def pcm_record(self, path='mixly.wav', seconds=5, ibuf=1600, timeout=2000): - if self._version >= 3: - self.pcm_en(True) - _star = time.ticks_ms() - _size = int(ibuf * seconds * 10) - _header = b'RIFF' + (36 + _size).to_bytes(4, 'little') + b'WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00' + (ibuf * 5).to_bytes(4, 'little') + (ibuf * 10).to_bytes(4, 'little') + b'\x02\x00\x10\x00data' + _size.to_bytes(4, 'little') - with open(path, 'wb') as f: - f.write(_header) - while _size > 0: - if self.pcm_any(): - f.write(self.pcm_read(ibuf)) - _size -= ibuf - _star = time.ticks_ms() - if time.ticks_diff(time.ticks_ms(), _star) > timeout: - raise OSError("Timeout write error") - self.pcm_en(False) - else: - print("Warning: Please upgrade the coprocessor firmware to use this feature") + self.pcm_en(True) + _star = time.ticks_ms() + _size = int(ibuf * seconds * 10) + _header = b'RIFF' + (36 + _size).to_bytes(4, 'little') + b'WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00' + (ibuf * 5).to_bytes(4, 'little') + (ibuf * 10).to_bytes(4, 'little') + b'\x02\x00\x10\x00data' + _size.to_bytes(4, 'little') + with open(path, 'wb') as f: + f.write(_header) + while _size > 0: + if self.pcm_any(): + f.write(self.pcm_read(ibuf)) + _size -= ibuf + _star = time.ticks_ms() + if time.ticks_diff(time.ticks_ms(), _star) > timeout: + raise OSError("Timeout write error") + self.pcm_en(False) """Graph module""" HEART =b'\x00\x0c\x1e?~\xfc~?\x1e\x0c\x00\x00' diff --git a/boards/default_src/micropython_esp32c2/origin/build/lib/mini_xunfei.py b/boards/default_src/micropython_esp32c2/origin/build/lib/mini_xunfei.py index c47fcbe0..4ce416d9 100644 --- a/boards/default_src/micropython_esp32c2/origin/build/lib/mini_xunfei.py +++ b/boards/default_src/micropython_esp32c2/origin/build/lib/mini_xunfei.py @@ -117,7 +117,10 @@ class ASR_WebSocket(Ws_Param): return msg except Exception as e: onboard_bot.pcm_en(False) #PCM关闭 - print("Run error: %s" % (e)) + if "403 Forbidden" in str(e): + raise OSError("Access denied, Please try updating clock time") + else: + print("Run error: %s" % (e)) #大模型 class LLM_WebSocket(Ws_Param): @@ -166,10 +169,10 @@ class LLM_WebSocket(Ws_Param): d["payload"]["functions"] = {"text": self._function[1]} self.ws.send(json.dumps(d)) - def function_call(self, callback, name, description, *args): - """功能回调名称, 描述, (参数名, 类型, 描述) """ + def function_call(self, callback, name, description, params): + """功能回调名称, 描述, ((参数名, 类型, 描述), ...)""" properties = {"type": "object", "properties":{}, "required":[]} - for arg in args: + for arg in params: if len(arg) >= 3: properties["properties"][arg[0]] = {"type": arg[1], "description": arg[2]} if arg[0] not in properties["required"]: @@ -231,4 +234,7 @@ class LLM_WebSocket(Ws_Param): self.ws.close() return msg except Exception as e: - print("Run error: %s" % (e)) + if "403 Forbidden" in str(e): + raise OSError("Access denied, Please try updating clock time") + else: + print("Run error: %s" % (e))