Relay: log upstream events + forward error envelopes to device for diagnostics
Plan 3 smoke surfaced 'session_ended reason=error' on every wake with no context. The relay now logs every upstream event type at INFO and forwards any upstream 'error' event to the device as 'error code=upstream_<code>' so it appears in the Pi's journal alongside the wake/session_ended pair. Also extends the client's wakeword.predict with per-frame RMS + score diagnostics and the bridge loop with a 5 s heartbeat for triage.
This commit is contained in:
@@ -43,11 +43,28 @@ def _build_bridge_thread(
|
||||
stop_event: threading.Event,
|
||||
) -> threading.Thread:
|
||||
def run():
|
||||
frame_counter = 0
|
||||
recent_rms_max = 0.0
|
||||
while not stop_event.is_set():
|
||||
try:
|
||||
pcm16_bytes = mic_queue.get(timeout=0.25)
|
||||
except queue.Empty:
|
||||
continue
|
||||
frame_counter += 1
|
||||
raw = np.frombuffer(pcm16_bytes, dtype=np.int16)
|
||||
rms = float(np.sqrt(np.mean(raw.astype(np.float32) ** 2)))
|
||||
if rms > recent_rms_max:
|
||||
recent_rms_max = rms
|
||||
# Every ~5 s emit a heartbeat so we can see if the InputStream is
|
||||
# actually producing frames and what state we're routing to.
|
||||
if frame_counter % 62 == 0:
|
||||
_log.info(
|
||||
"bridge frames=%d state=%s wake_en=%s up_en=%s qsize=%d rms_max_5s=%.0f",
|
||||
frame_counter, sm.state.name,
|
||||
sm.wakeword_enabled, sm.uplink_enabled, mic_queue.qsize(),
|
||||
recent_rms_max,
|
||||
)
|
||||
recent_rms_max = 0.0
|
||||
if sm.wakeword_enabled:
|
||||
frame = np.frombuffer(pcm16_bytes, dtype=np.int16)
|
||||
if frame.size != FRAME_SAMPLES:
|
||||
|
||||
Reference in New Issue
Block a user