xiaozhi-sdk 0.2.2__tar.gz → 0.2.4__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.

Files changed (36) hide show
  1. {xiaozhi_sdk-0.2.2/xiaozhi_sdk.egg-info → xiaozhi_sdk-0.2.4}/PKG-INFO +1 -1
  2. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/tests/test_wake_word.py +3 -1
  3. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/__init__.py +1 -1
  4. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/core.py +19 -7
  5. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4/xiaozhi_sdk.egg-info}/PKG-INFO +1 -1
  6. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/LICENSE +0 -0
  7. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/MANIFEST.in +0 -0
  8. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/README.md +0 -0
  9. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/file/audio/greet.wav +0 -0
  10. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/file/audio/play_music.wav +0 -0
  11. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/file/audio/say_hello.wav +0 -0
  12. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/file/audio/take_photo.wav +0 -0
  13. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/file/image/leijun.jpg +0 -0
  14. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/file/opus/linux-arm64-libopus.so +0 -0
  15. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/file/opus/linux-x64-libopus.so +0 -0
  16. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/file/opus/macos-arm64-libopus.dylib +0 -0
  17. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/file/opus/macos-x64-libopus.dylib +0 -0
  18. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/file/opus/windows-opus.dll +0 -0
  19. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/pyproject.toml +0 -0
  20. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/setup.cfg +0 -0
  21. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/tests/test_iot.py +0 -0
  22. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/tests/test_pic.py +0 -0
  23. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/tests/test_xiaozhi.py +0 -0
  24. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/__main__.py +0 -0
  25. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/cli.py +0 -0
  26. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/config.py +0 -0
  27. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/iot.py +0 -0
  28. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/mcp.py +0 -0
  29. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/opus.py +0 -0
  30. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/utils/__init__.py +0 -0
  31. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/utils/mcp_tool.py +0 -0
  32. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/utils/tool_func.py +0 -0
  33. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk.egg-info/SOURCES.txt +0 -0
  34. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk.egg-info/dependency_links.txt +0 -0
  35. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk.egg-info/requires.txt +0 -0
  36. {xiaozhi_sdk-0.2.2 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xiaozhi-sdk
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: 一个用于连接和控制小智智能设备的Python SDK,支持实时音频通信、MCP工具集成和设备管理功能。
5
5
  Author-email: dairoot <623815825@qq.com>
6
6
  License-Expression: MIT
@@ -25,7 +25,9 @@ async def test_main():
25
25
  xiaozhi = XiaoZhiWebsocket(message_handler_callback, url=URL, ota_url=ota_url)
26
26
  await xiaozhi.init_connection(MAC_ADDR)
27
27
 
28
- await xiaozhi.send_wake_word("你是")
28
+ await xiaozhi.send_wake_word("退下,拜拜不聊了")
29
+ await asyncio.wait_for(is_end.wait(), timeout=20.0)
30
+ await xiaozhi.send_wake_word("你好")
29
31
 
30
32
  await asyncio.wait_for(is_end.wait(), timeout=20.0)
31
33
  await xiaozhi.close()
@@ -1,3 +1,3 @@
1
- __version__ = "0.2.2"
1
+ __version__ = "0.2.4"
2
2
 
3
3
  from xiaozhi_sdk.core import XiaoZhiWebsocket # noqa
@@ -120,11 +120,20 @@ class XiaoZhiWebsocket(McpTool):
120
120
  await self.websocket.send(opus_data)
121
121
  await self.send_silence_audio()
122
122
 
123
- async def send_wake_word(self, wake_word: str) -> None:
123
+ async def send_wake_word(self, wake_word: str) -> bool:
124
124
  """发送唤醒词"""
125
- await self.websocket.send(
126
- json.dumps({"session_id": self.session_id, "type": "listen", "state": "detect", "text": wake_word})
127
- )
125
+ try:
126
+ await self.websocket.send(
127
+ json.dumps({"session_id": self.session_id, "type": "listen", "state": "detect", "text": wake_word})
128
+ )
129
+ return True
130
+ except websockets.ConnectionClosed:
131
+ if self.message_handler_callback:
132
+ await self.message_handler_callback(
133
+ {"type": "websocket", "state": "close", "source": "sdk.send_wake_word"}
134
+ )
135
+ logger.debug("[websocket] close")
136
+ return False
128
137
 
129
138
  async def send_silence_audio(self, duration_seconds: float = 1.2) -> None:
130
139
  """发送静音音频"""
@@ -186,7 +195,7 @@ class XiaoZhiWebsocket(McpTool):
186
195
  await self.message_handler_callback(
187
196
  {"type": "websocket", "state": "close", "source": "sdk.message_handler"}
188
197
  )
189
- logger.info("[websocket] close")
198
+ logger.debug("[websocket] close")
190
199
 
191
200
  async def set_mcp_tool(self, mcp_tool_list) -> None:
192
201
  """设置MCP工具"""
@@ -246,15 +255,16 @@ class XiaoZhiWebsocket(McpTool):
246
255
  if self.wake_word:
247
256
  await self.send_wake_word(self.wake_word)
248
257
 
249
- async def send_audio(self, pcm: bytes) -> None:
258
+ async def send_audio(self, pcm: bytes) -> bool:
250
259
  """发送音频数据"""
251
260
  if not self.websocket:
252
- return
261
+ return False
253
262
 
254
263
  state = self.websocket.state
255
264
  if state == websockets.protocol.State.OPEN:
256
265
  opus_data = await self.audio_opus.pcm_to_opus(pcm)
257
266
  await self.websocket.send(opus_data)
267
+ return True
258
268
  elif state in [websockets.protocol.State.CLOSED, websockets.protocol.State.CLOSING]:
259
269
  if self.wait_device_activated:
260
270
  logger.debug("[websocket] Server actively disconnected, reconnecting...")
@@ -265,8 +275,10 @@ class XiaoZhiWebsocket(McpTool):
265
275
  logger.debug("[websocket] Server actively disconnected")
266
276
 
267
277
  await asyncio.sleep(0.5)
278
+ return False
268
279
  else:
269
280
  await asyncio.sleep(0.1)
281
+ return False
270
282
 
271
283
  async def close(self) -> None:
272
284
  """关闭连接"""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xiaozhi-sdk
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: 一个用于连接和控制小智智能设备的Python SDK,支持实时音频通信、MCP工具集成和设备管理功能。
5
5
  Author-email: dairoot <623815825@qq.com>
6
6
  License-Expression: MIT
File without changes
File without changes
File without changes
File without changes
File without changes