fix: eliminate cold-start delay by pre-warming audio hardware#137
Open
RABJR51 wants to merge 1 commit intoStarmel:masterfrom
Open
fix: eliminate cold-start delay by pre-warming audio hardware#137RABJR51 wants to merge 1 commit intoStarmel:masterfrom
RABJR51 wants to merge 1 commit intoStarmel:masterfrom
Conversation
AVAudioRecorder is created fresh on every recording, causing a ~300-500ms hardware initialization delay that cuts off first words. Fix: keep a 'primed' AVAudioRecorder (prepareToRecord, not recording) alive at all times. This holds the audio engine in an initialized state. On record start, release the primed recorder and immediately start the real one — hardware is already hot, so .record() fires instantly. Re-prime after each stop so every subsequent recording is equally fast.
akatz-ai
added a commit
to akatz-ai/OpenSuperWhisper
that referenced
this pull request
Mar 27, 2026
From upstream PR Starmel#137 (Starmel#137). Keeps a primed AVAudioRecorder alive to avoid ~300-500ms hardware initialization delay that cuts off first words.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every recording creates a fresh
AVAudioRecorderfrom scratch:macOS audio hardware initialization takes ~300–500ms, which cuts off the first word(s) every time recording starts.
Fix
Keep a primed recorder alive at all times using
prepareToRecord(). This holds the audio engine in an initialized state without actually recording anything.How it works:
primeAudioHardware()creates anAVAudioRecorderand callsprepareToRecord(), keeping it inprimedRecorderprimedRecorder = nilreleases it just before starting the real recorder (hardware stays warm, so.record()fires instantly)primeAudioHardware()re-primes in the background so the next recording is equally fastResult: zero cold-start delay. First word captured every time.
Files changed
OpenSuperWhisper/AudioRecorder.swift— addsprimedRecorderproperty,primeAudioHardware()method, and calls at setup + stopTesting
Tested the logic against the source. Since
prepareToRecord()is a documented AVFoundation API specifically designed for pre-warming audio hardware, the fix is minimal and safe.