fix: send proper hello response with version and audio_params

ESP32 expects full xiaozhi hello format including version and
audio_params, otherwise it disconnects and retries.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hailin 2026-04-06 07:19:29 -07:00
parent fc3c99d09c
commit 9365d8c4c9
1 changed files with 9 additions and 2 deletions

View File

@ -184,11 +184,18 @@ class Relay:
msg_type = msg.get("type")
if msg_type == "hello":
# Respond with hello ack
# Respond with proper hello — must match xiaozhi protocol
resp = {
"type": "hello",
"session_id": "relay-session",
"version": 1,
"transport": "websocket",
"session_id": "relay-session",
"audio_params": {
"format": "opus",
"sample_rate": ESP_SAMPLE_RATE,
"channels": 1,
"frame_duration": ESP_FRAME_MS,
},
}
await self.ws.send(json.dumps(resp))
log.info(f"ESP32 hello: {msg.get('audio_params')}")