How ginijhnc/speedy-stt works
What this project is (type + purpose)
Speedy-STT is a Windows-only, native Rust desktop utility (not a web service). It’s a systray/background dictation app that:
• Listens for a global hotkey (hold to record)
• Captures microphone audio
• Optionally performs volume boost and audio ducking (reduce other system audio during recording)
• Runs Whisper transcription locally via whisper.cpp (CPU-optimized)
• On completion, auto-pastes the transcribed text into the active window
• Has lazy model loading (load on demand, unload after idle cooldown)
How the file structure maps to architecture (what to extract into components)
Everything is in src/ and is strongly suggestive of “one process / many modules”:
• src/main.rs — process entrypoint; wires modules together.
• src/app.rs — likely top-level orchestrator/state machine (recording/transcribing lifecycle).
• src/hotkey.rs — global hotkey registration + key events.
• src/input.rs — audio capture (mic stream) / device handling.
• src/audio.rs — audio processing utilities (buffering, format conversions, etc.).
• src/volume.rs — volume boost and/or system volume interactions.
• src/feedback.rs — “start/finish” sounds (assets).
• src/whisper.rs — whisper.cpp binding/runner; lazy load/unload model, run transcription.
• src/config.rs — reads .env configuration (hotkey, model path, cooldown, etc.).
• src/volume.rs + src/audio.rs + src/input.rs together form the “audio pipeline”.
• assets/models/ — model files downloaded by assets/scripts/download-model.ps1.
• assets/sounds/ — start/finish mp3s used by feedback.
• build.ps1 — build pipeline; implies native dependencies (LLVM/Clang, VS C++).
• Hold hotkey → record → release → transcribe → auto-paste
• Audio ducking: fade background audio to silence during recording, restore after
• Lazy model loading: load whisper model on demand, then free after configurable idle cooldown
Context / Container view (C4 Level 1–2)
Shows: user, Windows OS services, the Speedy-STT process, local filesystem (model/assets), and whisper.cpp.
Runtime sequence / activity flow (the dictation pipeline)
Shows the hotkey press lifecycle, ducking, audio capture, transcription, paste, and feedback sounds.
Component view (module-level) mapping directly to src/*.rs
Shows internal module boundaries, who calls whom, and what each module owns.
This repo is small enough that a “component view” can be very faithful without becoming noise.
External / Environment
• User
• Windows OS
• Global hotkey API
• Audio capture APIs
• System audio session / ducking controls
• Clipboard / SendInput / active window automation (for auto-paste)
• System tray APIs
• Filesystem
• .env config
• assets/models/<model>.bin (or similar)
• assets/sounds/start.mp3, finish.mp3
In-process: Speedy-STT (single executable)
• App Orchestrator (app.rs)
• Config (config.rs)
• Tray Controller (tray.rs)
• Hotkey Listener (hotkey.rs)
• Audio Input/Capture (input.rs)
• Audio Processing (audio.rs)
• Volume Boost / Ducking (volume.rs)
• Audio Feedback (feedback.rs)
• Transcription Engine Wrapper (whisper.rs → whisper.cpp)
Embedded / Native dependency
• whisper.cpp (C/C++ library invoked from Rust; model loaded from disk)
Data flow (audio buffers and text)
• User → Windows Hotkey API → hotkey.rs → app.rs
• app.rs → volume.rs (start ducking / restore ducking)
• app.rs → feedback.rs (play start/finish sound)
• app.rs → input.rs (start/stop capture)
• input.rs → audio.rs (PCM frames/buffers)
• audio.rs → whisper.rs (final audio buffer / WAV-like input)
• whisper.rs ↔ Filesystem(models) (load/unload model files)
• whisper.rs → whisper.cpp (FFI call)
• whisper.rs → app.rs (transcribed text)
• app.rs → Windows Automation (clipboard/keystrokes) (auto-paste into active window)
• tray.rs ↔ app.rs (status, enable/disable, exit)
• config.rs → everyone (hotkey config, cooldown timers, model selection, volume boost)
A timer/cooldown loop:
• app.rs → whisper.rs (unload model after idle cooldown)
app → feedback: play finish.mp3
• main.rs (composition root)
• app.rs (state machine/orchestrator)
• config.rs (configuration provider)
• tray.rs (tray UI boundary)
• hotkey.rs (hotkey boundary)
• input.rs (mic boundary)
• audio.rs (DSP/format boundary)
• volume.rs (ducking/boost boundary)
• feedback.rs (sound boundary)
• whisper.rs (inference boundary)
Diagramming conventions to make it “principal-grade”
Of the following:
• Clear labels: use runtime nouns (“Audio Capture”, “Model Loader”, “Hotkey Listener”) and annotate with file names (input.rs, whisper.rs) in smaller text.
• Blue: in-process Rust modules
• Gray: Windows OS APIs
• Green: local filesystem assets/config
• Orange: native dependency (whisper.cpp)
• Threading / async note: add small callouts like “background thread for capture” and “transcription worker thread” if that’s how it’s implemented (verify in code, but it’s typical).
• Resource lifecycle annotations:
• “Lazy load model on first transcription”
• “Unload after idle cooldown (configurable)”
• “Ducking active only during Recording”
Don’t overthink it: maximize components, minimize ambiguity
• Mirrors the src/*.rs modules as components
• Treats Windows integrations as first-class dependencies
• Captures the dictation lifecycle + model lifecycle explicitly