Trim only the real click, and surface mid-clip dropouts

Transcripts came back short, but the log showed the whole clip going up:
captured samples matched wall clock and upload duration matched the
recording minus exactly the fixed 150 ms head trim. So nothing was being
cut in transit — the losses had to be at the edges or inside the audio,
and neither was visible.

Trim the stream-open click by measurement instead of by the clock: cut
only the leading frames that are genuinely louder than the rest of the
clip, up to the old cap. Mics that do not click now keep their first
syllable.

Measure each frame against its own mean so a steady DC bias — or a
stream frozen on one value — reads as the silence it is, and report the
longest run of digital silence as dead=. A live mic never goes below
DEAD_AIR_DBFS, so anything there is input that never arrived, which is
what following the system default source invites. Warn on startup when
no device is pinned, log the noise floor next to the speech level, and
log how much of the clip the output limiter had to clamp.

BLURT_SAVE_CAPTURES keeps the raw and uploaded WAVs per clip, so the
next short transcript can be checked against what the API actually got.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-18 20:45:14 -04:00
co-authored by Claude Opus 5
parent e3faf32f55
commit 9d04427816
3 changed files with 115 additions and 30 deletions
+3 -1
View File
@@ -63,8 +63,10 @@ def main() -> None:
sd.wait()
audio = frames.mean(axis=1) if channels > 1 else frames[:, 0]
audio = blurt.resample_to_target(audio, rate)
click = blurt.leading_click_samples(audio)
audio = audio[click:]
print("\nCapture:")
print(f"\nCapture (trimmed {click * 1000 / blurt.SAMPLE_RATE:.0f} ms of stream-open click):")
report("raw", audio)
conditioned = blurt.condition_audio(audio)
report("after Blurt conditioning", conditioned)