xiaozhi-sdk 0.2.3__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.
- {xiaozhi_sdk-0.2.3/xiaozhi_sdk.egg-info → xiaozhi_sdk-0.2.4}/PKG-INFO +1 -1
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/__init__.py +1 -1
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/core.py +8 -3
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4/xiaozhi_sdk.egg-info}/PKG-INFO +1 -1
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/LICENSE +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/MANIFEST.in +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/README.md +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/file/audio/greet.wav +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/file/audio/play_music.wav +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/file/audio/say_hello.wav +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/file/audio/take_photo.wav +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/file/image/leijun.jpg +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/file/opus/linux-arm64-libopus.so +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/file/opus/linux-x64-libopus.so +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/file/opus/macos-arm64-libopus.dylib +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/file/opus/macos-x64-libopus.dylib +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/file/opus/windows-opus.dll +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/pyproject.toml +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/setup.cfg +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/tests/test_iot.py +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/tests/test_pic.py +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/tests/test_wake_word.py +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/tests/test_xiaozhi.py +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/__main__.py +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/cli.py +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/config.py +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/iot.py +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/mcp.py +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/opus.py +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/utils/__init__.py +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/utils/mcp_tool.py +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk/utils/tool_func.py +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk.egg-info/SOURCES.txt +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk.egg-info/dependency_links.txt +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk.egg-info/requires.txt +0 -0
- {xiaozhi_sdk-0.2.3 → xiaozhi_sdk-0.2.4}/xiaozhi_sdk.egg-info/top_level.txt +0 -0
|
@@ -120,18 +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) ->
|
|
123
|
+
async def send_wake_word(self, wake_word: str) -> bool:
|
|
124
124
|
"""发送唤醒词"""
|
|
125
125
|
try:
|
|
126
126
|
await self.websocket.send(
|
|
127
127
|
json.dumps({"session_id": self.session_id, "type": "listen", "state": "detect", "text": wake_word})
|
|
128
128
|
)
|
|
129
|
+
return True
|
|
129
130
|
except websockets.ConnectionClosed:
|
|
130
131
|
if self.message_handler_callback:
|
|
131
132
|
await self.message_handler_callback(
|
|
132
133
|
{"type": "websocket", "state": "close", "source": "sdk.send_wake_word"}
|
|
133
134
|
)
|
|
134
135
|
logger.debug("[websocket] close")
|
|
136
|
+
return False
|
|
135
137
|
|
|
136
138
|
async def send_silence_audio(self, duration_seconds: float = 1.2) -> None:
|
|
137
139
|
"""发送静音音频"""
|
|
@@ -253,15 +255,16 @@ class XiaoZhiWebsocket(McpTool):
|
|
|
253
255
|
if self.wake_word:
|
|
254
256
|
await self.send_wake_word(self.wake_word)
|
|
255
257
|
|
|
256
|
-
async def send_audio(self, pcm: bytes) ->
|
|
258
|
+
async def send_audio(self, pcm: bytes) -> bool:
|
|
257
259
|
"""发送音频数据"""
|
|
258
260
|
if not self.websocket:
|
|
259
|
-
return
|
|
261
|
+
return False
|
|
260
262
|
|
|
261
263
|
state = self.websocket.state
|
|
262
264
|
if state == websockets.protocol.State.OPEN:
|
|
263
265
|
opus_data = await self.audio_opus.pcm_to_opus(pcm)
|
|
264
266
|
await self.websocket.send(opus_data)
|
|
267
|
+
return True
|
|
265
268
|
elif state in [websockets.protocol.State.CLOSED, websockets.protocol.State.CLOSING]:
|
|
266
269
|
if self.wait_device_activated:
|
|
267
270
|
logger.debug("[websocket] Server actively disconnected, reconnecting...")
|
|
@@ -272,8 +275,10 @@ class XiaoZhiWebsocket(McpTool):
|
|
|
272
275
|
logger.debug("[websocket] Server actively disconnected")
|
|
273
276
|
|
|
274
277
|
await asyncio.sleep(0.5)
|
|
278
|
+
return False
|
|
275
279
|
else:
|
|
276
280
|
await asyncio.sleep(0.1)
|
|
281
|
+
return False
|
|
277
282
|
|
|
278
283
|
async def close(self) -> None:
|
|
279
284
|
"""关闭连接"""
|
|
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
|