Repository navigation
fix(desktop): measure an on-device pause against the room's own noise - #13995
Conversation
Pause endpointing (BasedHardware#12181) closes an on-device window once the last 0.6 s is at or below a fixed 0.004 RMS. That only works where the room is quieter than 0.004. Measured live on a MacBook Air microphone with people talking nearby, 219 readings over two minutes: the quietest 100 ms slice never dropped below 0.0041 (median 0.0047), the trailing 0.6 s had a median of 0.0084, and 0 of 219 readings were at or below 0.004. So no pause ever registered: every microphone window ran the full 10 s, a wake-word command waited up to 10 s before anything happened, and window boundaries split Omi's own spoken answer into fragments that read as the user speaking. The pause floor is now relative to the room: twice the 10th percentile of the last 30 s of capture-frame levels, never below the old 0.004 and never above 0.02. A low percentile rather than a mean, so speech in the history does not lift it. The same floor drives the voiced-audio count and the leading-silence trim, so the one-second-of-speech guard against hallucinated words still holds. A quiet room and the system-audio lane (digital silence between sounds) resolve to exactly the old 0.004. The whole-window silence skip keeps its fixed floor. Verification: - Xcode 26.6 (17F113): LocalTranscriptionEndpointTests 23 (10 new, built from the measured levels), LocalTranscriptionDuplicatePolicyTests 11, STTSessionStateTests all pass. - Mutation: quietFloor forced to the fixed floor fails exactly the four tests that depend on it (noisy-room pause, noise lead-in trim, percentile ignores speech, loud-room cap). - swift-format lint clean; check_desktop_test_quality.py at baseline. - Live, same room, named bundle built from main + this commit: 15 of 15 microphone windows closed on a pause (2.3-6.4 s) over two minutes, starting off the 10 s grid. Before the change, 15 of 15 ran exactly 10.0 s on 10 s boundaries. Also with a real voice on a build carrying the BasedHardware#11801 branch: 16 of 18 closed on a pause, commands in 2.5-2.9 s. Failure-Class: none Co-Authored-By: Claude Opus 5 <[email protected]>
Git-on-my-level
left a comment
There was a problem hiding this comment.
Reviewed all three changed files - this is a clean, well-evidenced fix.
LocalTranscriptionService.swift
quietFloor(recentFrameRMS:)-roomNoiseMarginx the 10th-percentile frame RMS over the ~30 s history, clamped to [speechFloor,maximumQuietFloor] - is the right shape. A low percentile rather than a mean means a stretch of the user's own speech in the history can't lift the floor (testQuietFloorIgnoresSpeechInTheHistorypins this), and the 0.02 ceiling keeps a loud room from treating ordinary speech as quiet (testLoudRoomCannotMakeSpeechCountAsQuiet).- Lock discipline checks out:
recentFrameRMSis appended inside the samelock.withLockblock asbufferinappendAudio, and read inside the locked snapshot closure indrain- no new race on this@unchecked Sendableclass. - Passing one
quietfloor consistently toisEndpointed's tail check,voicedSamples, andleadingSilenceSampleskeeps the >=1 s voiced-audio hallucination guard coherent relative to the room rather than only the tail check -testBlipInANoisyRoomDoesNotCloseconfirms a 0.3 s blip still fails the utterance minimum with the floor at 0.012. - The 20-frame warm-up and the
speechFloorlower bound keep the first ~2 s and the system-audio lane on exactly the old behavior (digital silence resolves to percentile 0 ->max(0.004, 0)= 0.004, pinned bytestDigitalSilenceKeepsTheFixedFloor), and the whole-window silence skip indrainstill uses the fixed floor - all matching the PR description. - One behavior worth knowing, not a blocker: during a long continuous monologue the 30 s history can fill with speech-level frames, pushing the floor to the 0.02 ceiling, so mid-monologue pauses stop registering and windows fall back to the 10 s boundary. That's the ceiling doing its job and it degrades in the safe direction (no speech lost, just the old latency).
LocalTranscriptionEndpointTests.swift - the 9 new tests cover the live failure mode (fixed floor finds no pause at 0.006 room noise), pause-closes vs running-speech, the blip guard at the raised floor, lead-in trim against room noise, and the quietFloor boundaries (speech-in-history, quiet room, digital silence, loud-room cap, warm-up). I checked the arithmetic in the noisy-room cases (floor 2 x 0.006 = 0.012; 2 s of voiced audio at 0.05 clearing the 1 s minimum) - internally consistent.
20260915-pause-endpointing-room-noise.json - changelog entry matches the shipped behavior.
Checks: Desktop Swift Build & Tests, Static & Test Contracts, Release Compile, and Hygiene are all green on this head. The live-room measurements in the description (219 readings, quietest slice 0.0041-0.0057 RMS) are consistent with the constants chosen. No security or privacy surface touched - everything stays on-device.
Leaving for human maintainer review before merge.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
kodjima33
left a comment
There was a problem hiding this comment.
Owner-override: desktop bug fix. Pause endpointing floor is now relative to room background noise (2x 10th-percentile of last 30s, clamped [0.004, 0.02]) instead of a fixed 0.004 RMS that never triggered in a normal room. Tested live, has regression tests + changelog entry. No abuse signals.
What changed and why
Pause endpointing (#12181) closes an on-device transcription window once the last 0.6 s is at or below a fixed 0.004 RMS. That only works where the room is quieter than 0.004. With people talking nearby it never is, so every microphone window runs the full 10 s again: a spoken command waits for wherever it lands in that window, and window boundaries split speech mid-sentence.
The pause floor is now relative to the room: twice the 10th percentile of the last 30 s of capture-frame levels, never below the old 0.004 and never above 0.02. A low percentile rather than a mean, so speech in the history does not lift it. The same floor drives the voiced-audio count and the leading-silence trim, so the one-second-of-speech guard against hallucinated words still holds. A quiet room and the system-audio lane (digital silence between sounds) resolve to exactly the old 0.004. The whole-window silence skip keeps its fixed floor.
Found while testing #11801 (hands-free wake word), where this wait is most of the delay before a spoken command is acted on. This PR is independent of it.
Product invariants affected
none
How it was verified
MacBook Air microphone, on-device Parakeet lane, named dev bundle, Xcode 26.6 (17F113), in a room with people talking nearby.
The room. Temporary local logging (not part of this diff), 219 readings over two minutes: the quietest 100 ms slice stayed between 0.0041 and 0.0057 RMS (median 0.0047), the trailing 0.6 s had a median of 0.0084, and 0 of 219 readings were at or below 0.004.
Before this change, same spot, a real voice speaking commands, on a build of the #11801 branch (its
LocalTranscriptionService.swiftis byte-identical tomain's): 15 of 15 microphone windows were exactly 10.0 s and aligned to 10 s boundaries ([80.0s-90.0s]…[290.0s-300.0s]), while the system-audio lane in the same session closed on pauses at 3.4–5.3 s.After this change (
main+ this commit, same spot): over two minutes of ambient speech, 15 of 15 microphone windows closed on a pause (2.3–6.4 s), none at the 10 s cap, starting off the 10 s grid ([0.2s-3.4s],[12.5s-14.8s],[30.6s-36.5s]…).Also run on a build that adds this commit to the #11801 branch, with a real voice: 16 of 18 microphone windows closed on a pause (1.9–8.8 s), spoken commands closed in 2.5–2.9 s and started off the 10 s grid (
[61.8s-64.4s],[102.4s-104.8s]); the two 10 s windows were continuous background chatter.Tests
LocalTranscriptionEndpointTests: 10 new cases built from the measured levels. The fixed floor finds no pause at 0.006 room noise; the room floor does; running speech, a 0.3 s blip and room noise ahead of speech still behave; the percentile ignores speech in the history; a quiet room and digital silence keep 0.004; a loud room is capped at 0.02; too little history keeps 0.004.LocalTranscriptionEndpointTests23,LocalTranscriptionDuplicatePolicyTests11,STTSessionStateTests13 — 47 tests, 0 failures.quietFloorforced to the fixed floor, exactly the four tests that depend on it fail (noisy-room pause, noise lead-in trim, percentile ignores speech, loud-room cap).swift-formatlint clean,check_desktop_test_quality.pyat baseline.Not covered by a unit test: that
drainpasses the room floor to both helpers.drainneeds a loaded Parakeet model, so that wiring is what the live runs above verify.Failure class (fixes)
Failure-Class: none