Skip to content

feat: dynamic pre-roll based on silence threshold crossing - #43

Merged
tai2 merged 1 commit into
mainfrom
improve-preroll
Apr 17, 2026
Merged

tai2 merged 1 commit into
mainfrom
improve-preroll

Conversation

@tai2

@tai2 tai2 commented Apr 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Replaced the fixed 100ms pre-roll with a dynamic backward scan through buffered audio chunks to find where the signal first rises above silenceThresholdDb, then adds a 100ms safety margin beyond that point
  • This captures the full speech attack envelope regardless of duration, eliminating start-of-speech clipping for gradual onsets
  • Added findPreRollStartFrame() helper function and corresponding unit tests

Test plan

  • All 114 existing unit tests pass
  • pnpm typecheck passes with no errors
  • pnpm lint passes with no new errors
  • Manual testing: verify speech playback no longer clips on gradual voice onsets

🤖 Generated with Claude Code

…nce threshold

The fixed 100ms pre-roll was insufficient for gradual speech attacks,
causing clipped playback starts. Now scans backward through buffered
chunks to find where audio first rises above the silence threshold,
then adds a 100ms safety margin beyond that point.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tai2
tai2 merged commit 950030c into main Apr 17, 2026
1 check passed
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