Defer heavy ML imports to fix slow tray startup - #5
Merged
Merged
Conversation
Agent-Logs-Url: https://github.com/buzz39/meeting-recorder/sessions/404b24e8-0f23-4990-a998-b95d98608e1d Co-authored-by: buzz39 <16227736+buzz39@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
buzz39
April 22, 2026 04:16
View session
buzz39
marked this pull request as ready for review
April 22, 2026 06:39
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.
Launching the tray (
python recorder.py tray) was taking ~5 minutes to display the icon because torch, pyannote.audio, and faster-whisper were imported at module load even though none are needed to draw the tray UI.Root cause
recorder.pyhad module-topfrom diarizer import Diarizer, anddiarizer.pyhad module-topimport torch+from pyannote.audio import Pipeline. Importingpyannote.audiotransitively pulls in torch, torchaudio, pytorch-lightning, speechbrain, asteroid-filterbanks — minutes of cold-start cost on Windows.Changes
diarizer.py— replaced top-leveltorch/pyannote.audioimports with a lazy_ensure_pyannote_imports()helper. Only invoked when the pyannote backend is actually selected (i.e.HF_TOKENis set) or whenPyannoteDiarizer._load_pipelineruns. Backend-selection semantics in_init_backendare preserved.recorder.py— movedfrom diarizer import Diarizer/from transcriber import TranscriberintoRecorder.__init__, and reorderedmain()to dispatch thetraysubcommand before constructingRecorder. The tray app already builds theRecorderlazily inside its recording thread on first "Start Recording" click, so user-facing behavior is unchanged — the ML stack just loads on demand instead of at process start.After the change,
import recordercompletes in ~17 ms with no torch / pyannote / faster-whisper modules loaded.