xiaozhi-sdk 0.0.9__py3-none-any.whl → 0.0.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xiaozhi-sdk might be problematic. Click here for more details.
- xiaozhi_sdk/__init__.py +1 -1
- xiaozhi_sdk/cli.py +42 -3
- xiaozhi_sdk/iot.py +4 -1
- {xiaozhi_sdk-0.0.9.dist-info → xiaozhi_sdk-0.0.10.dist-info}/METADATA +1 -1
- {xiaozhi_sdk-0.0.9.dist-info → xiaozhi_sdk-0.0.10.dist-info}/RECORD +8 -8
- {xiaozhi_sdk-0.0.9.dist-info → xiaozhi_sdk-0.0.10.dist-info}/WHEEL +0 -0
- {xiaozhi_sdk-0.0.9.dist-info → xiaozhi_sdk-0.0.10.dist-info}/licenses/LICENSE +0 -0
- {xiaozhi_sdk-0.0.9.dist-info → xiaozhi_sdk-0.0.10.dist-info}/top_level.txt +0 -0
xiaozhi_sdk/__init__.py
CHANGED
xiaozhi_sdk/cli.py
CHANGED
|
@@ -12,6 +12,34 @@ import sounddevice as sd
|
|
|
12
12
|
from xiaozhi_sdk import XiaoZhiWebsocket
|
|
13
13
|
from xiaozhi_sdk.config import INPUT_SERVER_AUDIO_SAMPLE_RATE
|
|
14
14
|
|
|
15
|
+
# 定义自定义日志级别
|
|
16
|
+
INFO1 = 21
|
|
17
|
+
INFO2 = 22
|
|
18
|
+
INFO3 = 23
|
|
19
|
+
|
|
20
|
+
# 添加自定义日志级别到logging模块
|
|
21
|
+
logging.addLevelName(INFO1, "INFO1")
|
|
22
|
+
logging.addLevelName(INFO2, "INFO2")
|
|
23
|
+
logging.addLevelName(INFO3, "INFO3")
|
|
24
|
+
|
|
25
|
+
# 为logger添加自定义方法
|
|
26
|
+
def info1(self, message, *args, **kwargs):
|
|
27
|
+
if self.isEnabledFor(INFO1):
|
|
28
|
+
self._log(INFO1, message, args, **kwargs)
|
|
29
|
+
|
|
30
|
+
def info2(self, message, *args, **kwargs):
|
|
31
|
+
if self.isEnabledFor(INFO2):
|
|
32
|
+
self._log(INFO2, message, args, **kwargs)
|
|
33
|
+
|
|
34
|
+
def info3(self, message, *args, **kwargs):
|
|
35
|
+
if self.isEnabledFor(INFO3):
|
|
36
|
+
self._log(INFO3, message, args, **kwargs)
|
|
37
|
+
|
|
38
|
+
# 将自定义方法添加到Logger类
|
|
39
|
+
logging.Logger.info1 = info1
|
|
40
|
+
logging.Logger.info2 = info2
|
|
41
|
+
logging.Logger.info3 = info3
|
|
42
|
+
|
|
15
43
|
# 配置彩色logging
|
|
16
44
|
handler = colorlog.StreamHandler()
|
|
17
45
|
handler.setFormatter(
|
|
@@ -19,8 +47,11 @@ handler.setFormatter(
|
|
|
19
47
|
"%(log_color)s%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
|
20
48
|
datefmt="%Y-%m-%d %H:%M:%S",
|
|
21
49
|
log_colors={
|
|
22
|
-
"DEBUG": "
|
|
23
|
-
"INFO": "
|
|
50
|
+
"DEBUG": "white",
|
|
51
|
+
"INFO": "green",
|
|
52
|
+
"INFO1": "green",
|
|
53
|
+
"INFO2": "cyan",
|
|
54
|
+
"INFO3": "blue",
|
|
24
55
|
"WARNING": "yellow",
|
|
25
56
|
"ERROR": "red",
|
|
26
57
|
"CRITICAL": "red,bg_white",
|
|
@@ -41,7 +72,15 @@ is_end = False
|
|
|
41
72
|
async def handle_message(message):
|
|
42
73
|
"""处理接收到的消息"""
|
|
43
74
|
global is_end
|
|
44
|
-
|
|
75
|
+
if message["type"] == "stt":
|
|
76
|
+
logger.info1("message received: %s", message)
|
|
77
|
+
elif message["type"] == "tts":
|
|
78
|
+
logger.info2("message received: %s", message)
|
|
79
|
+
elif message["type"] == "llm":
|
|
80
|
+
logger.info3("message received: %s", message)
|
|
81
|
+
else:
|
|
82
|
+
logger.info("message received: %s", message)
|
|
83
|
+
|
|
45
84
|
if message["type"] == "websocket" and message["state"] == "close":
|
|
46
85
|
is_end = True
|
|
47
86
|
|
xiaozhi_sdk/iot.py
CHANGED
|
@@ -12,7 +12,7 @@ from xiaozhi_sdk.config import OTA_URL
|
|
|
12
12
|
# 常量定义
|
|
13
13
|
BOARD_TYPE = "xiaozhi-sdk-box"
|
|
14
14
|
USER_AGENT = "xiaozhi-sdk/{}".format(__version__)
|
|
15
|
-
BOARD_NAME = "xiaozhi-sdk
|
|
15
|
+
BOARD_NAME = "xiaozhi-sdk"
|
|
16
16
|
|
|
17
17
|
logger = logging.getLogger("xiaozhi_sdk")
|
|
18
18
|
|
|
@@ -60,6 +60,9 @@ class OtaDevice:
|
|
|
60
60
|
|
|
61
61
|
async with aiohttp.ClientSession() as session:
|
|
62
62
|
async with session.post(self.ota_url + "/", headers=headers, data=json.dumps(payload)) as response:
|
|
63
|
+
if response.status != 200:
|
|
64
|
+
err_text = await response.text()
|
|
65
|
+
raise Exception(err_text)
|
|
63
66
|
response.raise_for_status()
|
|
64
67
|
return await response.json()
|
|
65
68
|
|
|
@@ -8,19 +8,19 @@ file/opus/linux-x64-libopus.so,sha256=FmXJqkxLpDzNFOHYkmOzmsp1hP0eIS5b6x_XfOs-IQ
|
|
|
8
8
|
file/opus/macos-arm64-libopus.dylib,sha256=H7wXwkrGwb-hesMMZGFxWb0Ri1Y4m5GWiKsd8CfOhE8,357584
|
|
9
9
|
file/opus/macos-x64-libopus.dylib,sha256=MqyL_OjwSACF4Xs_-KrGbcScy4IEprr5Rlkk3ddZye8,550856
|
|
10
10
|
file/opus/windows-opus.dll,sha256=kLfhioMvbJhOgNMAldpWk3DCZqC5Xd70LRbHnACvAnw,463360
|
|
11
|
-
xiaozhi_sdk/__init__.py,sha256
|
|
11
|
+
xiaozhi_sdk/__init__.py,sha256=4-2cLsMk3Bq03wsMvSLb-DzFWsOqPFUKgKf4oeheg2Y,78
|
|
12
12
|
xiaozhi_sdk/__main__.py,sha256=i0ZJdHUqAKg9vwZrK_w0TJkzdotTYTK8aUeSPcJc1ks,210
|
|
13
|
-
xiaozhi_sdk/cli.py,sha256=
|
|
13
|
+
xiaozhi_sdk/cli.py,sha256=9BiFlGy_2wFES_4dpan8iFEnwuwTyg4vjxwWitLpO5U,5621
|
|
14
14
|
xiaozhi_sdk/config.py,sha256=h4mpMeBf2vT9qYAqCCbGVGmMemkgk98pcXP2Rh4TEFc,89
|
|
15
15
|
xiaozhi_sdk/core.py,sha256=564SefCBus6qNRApWqwI113aIN1p4eYpci1mLeMExIs,10007
|
|
16
|
-
xiaozhi_sdk/iot.py,sha256=
|
|
16
|
+
xiaozhi_sdk/iot.py,sha256=VVAheynp1iV4GCaoPywQWpKtlyoACDLswH8yfV_JZgI,2699
|
|
17
17
|
xiaozhi_sdk/mcp.py,sha256=Pbr3JEDqEnWsPwLHKzRdrDYZMg6krYZoz74lXUSh9iI,5544
|
|
18
18
|
xiaozhi_sdk/opus.py,sha256=r3nnYg0ZKAJTreb_3nKgfHJh06MJiMvnNMPO1SWdoMM,2224
|
|
19
19
|
xiaozhi_sdk/utils/__init__.py,sha256=XKSHWoFmuSkpwaIr308HybRzfFIXoT1Fd-eUKo_im6Y,1705
|
|
20
20
|
xiaozhi_sdk/utils/mcp_data.py,sha256=r_GLjFpvUKeV8IhlkT7Pfb4c9bDO9q4k3f4iPZBBcKI,3892
|
|
21
21
|
xiaozhi_sdk/utils/mcp_tool.py,sha256=imwehfUlENjelYmGbGYgb6C82-ijs53XCxrtCpqrJps,3152
|
|
22
|
-
xiaozhi_sdk-0.0.
|
|
23
|
-
xiaozhi_sdk-0.0.
|
|
24
|
-
xiaozhi_sdk-0.0.
|
|
25
|
-
xiaozhi_sdk-0.0.
|
|
26
|
-
xiaozhi_sdk-0.0.
|
|
22
|
+
xiaozhi_sdk-0.0.10.dist-info/licenses/LICENSE,sha256=Vwgps1iODKl43cAtME_0dawTjAzNW-O2BWiN5BHggww,1085
|
|
23
|
+
xiaozhi_sdk-0.0.10.dist-info/METADATA,sha256=uaSfv6gxD9hEvaKFWPSLasJVecL-BTk8Dhv-7lniDzk,2092
|
|
24
|
+
xiaozhi_sdk-0.0.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
25
|
+
xiaozhi_sdk-0.0.10.dist-info/top_level.txt,sha256=nBpue4hU5Ykm5CtYPsAdxSa_yqbtZsIT_gF_EkBaJPM,12
|
|
26
|
+
xiaozhi_sdk-0.0.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|