xiaozhi-sdk 0.2.1__tar.gz → 0.2.2__tar.gz
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-0.2.1/xiaozhi_sdk.egg-info → xiaozhi_sdk-0.2.2}/PKG-INFO +1 -1
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/xiaozhi_sdk/__init__.py +1 -1
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/xiaozhi_sdk/core.py +24 -9
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2/xiaozhi_sdk.egg-info}/PKG-INFO +1 -1
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/LICENSE +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/MANIFEST.in +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/README.md +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/file/audio/greet.wav +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/file/audio/play_music.wav +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/file/audio/say_hello.wav +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/file/audio/take_photo.wav +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/file/image/leijun.jpg +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/file/opus/linux-arm64-libopus.so +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/file/opus/linux-x64-libopus.so +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/file/opus/macos-arm64-libopus.dylib +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/file/opus/macos-x64-libopus.dylib +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/file/opus/windows-opus.dll +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/pyproject.toml +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/setup.cfg +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/tests/test_iot.py +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/tests/test_pic.py +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/tests/test_wake_word.py +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/tests/test_xiaozhi.py +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/xiaozhi_sdk/__main__.py +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/xiaozhi_sdk/cli.py +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/xiaozhi_sdk/config.py +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/xiaozhi_sdk/iot.py +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/xiaozhi_sdk/mcp.py +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/xiaozhi_sdk/opus.py +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/xiaozhi_sdk/utils/__init__.py +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/xiaozhi_sdk/utils/mcp_tool.py +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/xiaozhi_sdk/utils/tool_func.py +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/xiaozhi_sdk.egg-info/SOURCES.txt +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/xiaozhi_sdk.egg-info/dependency_links.txt +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/xiaozhi_sdk.egg-info/requires.txt +0 -0
- {xiaozhi_sdk-0.2.1 → xiaozhi_sdk-0.2.2}/xiaozhi_sdk.egg-info/top_level.txt +0 -0
|
@@ -139,8 +139,11 @@ class XiaoZhiWebsocket(McpTool):
|
|
|
139
139
|
|
|
140
140
|
# audio data
|
|
141
141
|
if isinstance(message, bytes):
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
try:
|
|
143
|
+
pcm_array = await self.audio_opus.opus_to_pcm(message)
|
|
144
|
+
self.output_audio_queue.extend(pcm_array)
|
|
145
|
+
except Exception as e:
|
|
146
|
+
logger.error("opus_to_pcm error: %s", e)
|
|
144
147
|
return
|
|
145
148
|
|
|
146
149
|
# json message
|
|
@@ -149,29 +152,41 @@ class XiaoZhiWebsocket(McpTool):
|
|
|
149
152
|
if message_type == "hello":
|
|
150
153
|
self.hello_received.set()
|
|
151
154
|
self.session_id = data["session_id"]
|
|
155
|
+
return
|
|
152
156
|
elif message_type == "mcp":
|
|
153
157
|
await self.mcp(data)
|
|
154
|
-
|
|
155
|
-
|
|
158
|
+
return
|
|
159
|
+
|
|
160
|
+
# 转发其他 message_type
|
|
161
|
+
if self.message_handler_callback:
|
|
162
|
+
try:
|
|
163
|
+
await self.message_handler_callback(data)
|
|
164
|
+
except Exception as e:
|
|
165
|
+
logger.error("message_handler_callback error: %s", e)
|
|
166
|
+
|
|
167
|
+
if message_type == "tts":
|
|
156
168
|
if data["state"] == "sentence_start":
|
|
157
169
|
self.is_playing = True
|
|
158
|
-
# self.output_audio_queue.clear()
|
|
159
170
|
else:
|
|
160
171
|
self.is_playing = False
|
|
161
|
-
|
|
162
|
-
|
|
172
|
+
else:
|
|
173
|
+
logger.warning("未定义回调函数 %s", data)
|
|
163
174
|
|
|
164
175
|
async def _message_handler(self) -> None:
|
|
165
176
|
"""消息处理器"""
|
|
166
177
|
try:
|
|
167
178
|
async for message in self.websocket:
|
|
168
|
-
|
|
179
|
+
try:
|
|
180
|
+
await self._handle_websocket_message(message)
|
|
181
|
+
except Exception as e:
|
|
182
|
+
logger.error("message_handler error: %s", e)
|
|
183
|
+
|
|
169
184
|
except websockets.ConnectionClosed:
|
|
170
185
|
if self.message_handler_callback:
|
|
171
186
|
await self.message_handler_callback(
|
|
172
187
|
{"type": "websocket", "state": "close", "source": "sdk.message_handler"}
|
|
173
188
|
)
|
|
174
|
-
|
|
189
|
+
logger.info("[websocket] close")
|
|
175
190
|
|
|
176
191
|
async def set_mcp_tool(self, mcp_tool_list) -> None:
|
|
177
192
|
"""设置MCP工具"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|