Skip to content

End-to-end echo path: a fixed room, a warning filter, evidence that tells where the echo moved - #14

Merged
thervier merged 4 commits into
mainfrom
e2e-echo-path
Nov 13, 2026
Merged

thervier merged 4 commits into
mainfrom
e2e-echo-path

Conversation

@thervier

Copy link
Copy Markdown
Contributor

The computer's end-to-end tier records ~1.4–3.6 s of the app's own voice leaking through the echo canceller per conversation (step 8 records it, does not fail on it). Measuring it across eight manual CI runs showed that part of it was the test setup moving the echo path, not the canceller. This PR removes both causes and keeps the evidence that found them.

What changes

  • Tests: sounddevice's NumPy 2.5 deprecation is filtered (pyproject.toml). sounddevice 0.5.6 raises it in every audio callback. A plain run ignores it, but pytest recorded ~17k per conversation and processed them at the end of each test, freezing the process ~300 ms while the app's audio ran. The app's mic stream then stayed ~87 ms behind for the rest of the run (input latency 87 → 174 ms, no overflow), the echo arrived later against its reference, and AEC3 leaked for ~3 s while it relearned. It happened in 3 of 5 runs, always after step 6's request, and failed one run (the agent answered a fragment of its own story). The filter matches that message and module only. Fixed upstream (Remove deprecated assignment to .shape spatialaudio/python-sounddevice#641) but not released; the comment says to drop the filter once a release after 0.5.6 is locked.
  • e2e: the room holds its echo's delay (tests-e2e/room.py, specs/e2e.md "The echo's delay holds", plan 202611101900_room-holds-echo-delay.md). The room's two streams ran 250–400 ppm apart, so its echo crept 20–30 ms per conversation, which a laptop's does not. It now holds the time from recording to playback (PortAudio's ADC and DAC times): one resampled sample per 10 ms block against the drift, the whole excess cut after a late block. Offline, at 0, ±400 and +1000 ppm with a 90 ms late burst, it holds within 0.1 ms; the old room went 50 → 103 ms over 40 s. In CI the delay the app sees stays flat (188–189 ms for 60 s).
  • e2e: the evidence tells where the echo moved. room.npz logs the room's echo path, and audio.npz now also logs each callback of the app's own two audio streams (latency, underflow and overflow flags). The echo recorder is entered before the build, so the voice's output stream is logged too.
  • CI: the computer's evidence is uploaded on every run, kept 30 days (specs/ci.md), since the echo check no longer fails.
  • Docs: stream_delay_ms is no longer presented as a tuning knob. AEC3 estimates the delay itself and all but ignores the hint (replaying the same audio at 0–500 ms changes the residual by 0.1 dB). specs/audio-processing.md, the computer guide, troubleshooting and the configuration reference are corrected; the field stays, harmless.

What it does not change

The leaks that remain are the canceller's own: while and just after the person talks over a story, and after some short replies (2.2 s in the last run, within the 1.4–2.0 s spread of earlier runs without a jump). A better canceller is still specs/audio-processing.md open question 3. No app code changes.

Verification

  • uv run ruff check ., uv run ruff format --check ., uv run pyright, uv run pytest (301 passed).
  • Manual CI runs of the same changes (on the working branch): the last two all green, both end-to-end jobs included; the run with the room's hold shows no hard correction and a flat echo delay.

🤖 Generated with Claude Code

thervier and others added 4 commits November 10, 2026 19:00
…e it

AEC3 estimates the echo's delay itself and uses an external one only with
delay.use_external_delay_estimator (off, and not exposed by the binding): replaying the same audio
with the hint at 0 to 500 ms changes the residual by 0.1 dB. The spec no longer says the estimator
is "seeded" by it, and the guides no longer say to raise it when the agent hears itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dio callback

sounddevice 0.5.6 assigns `data.shape` in each callback. A plain run ignores the warning, but
pytest records each one, ~17k per end-to-end conversation, and processes them at the end of each
test: the process froze ~300 ms while the app's audio ran, its mic stream then stayed ~85 ms
behind for the rest of the run, and the echo canceller leaked while it relearned (found with a
stall probe in CI). Filtered for that message and module only; fixed upstream
(spatialaudio/python-sounddevice#641), to drop once a release after 0.5.6 is locked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its audio.npz recordings are what the echo canceller is measured on, and the echo check no longer
fails, so a failure-only upload left nothing to measure. Kept 30 days.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The room recorded the app's speaker on one stream and played it into the cable on another; with
their clocks 250-400 ppm apart its echo crept 20-30 ms per conversation, which a laptop's does not
and the canceller pays for. It now holds the delay from recording to playback (PortAudio's ADC and
DAC times): one resampled sample per block against the drift, the whole excess cut after a late
block. Offline, at 0, +-400 and +1000 ppm with a 90 ms late burst, it holds within 0.1 ms (the old
room: 50 -> 103 ms over 40 s); in CI the delay seen by the app stays flat.

The evidence now also tells where a change in the echo's delay comes from: the room's log of its
echo path (room.npz) and each callback of the app's own two audio streams (in audio.npz: latency,
underflow and overflow flags). The echo recorder is entered before the build, which opens the
voice's output stream.

specs/e2e.md: Implemented -> Updated -> Implemented, with its plan Done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thervier
thervier merged commit 03af776 into main Nov 13, 2026
6 checks passed
@thervier
thervier deleted the e2e-echo-path branch November 13, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant