Architecture overview
Echophrase is a Tauri 2 desktop app with a Svelte 5 frontend and a Rust backend. It does GPU-accelerated speech-to-text entirely on the user’s machine. There is no server, no account and no telemetry; the only network traffic is model downloads fromhuggingface.co and update checks against cdn.crabnebula.app.
Where this section and the code disagree, the code wins. The repo’s
CLAUDE.md is the maintained source of truth for architecture notes.Tech stack
Cargo workspace
The rootCargo.toml is a workspace with three members: src-tauri (the app), cli (the terminal helper) and crates/echo-audio. Build output is pinned to src-tauri/target through .cargo/config.toml so CI paths never move.
Frontend layout
Backend layout
Frontend to backend
Tauri commands bridge JavaScript and Rust. Every command is registered in theinvoke_handler in src-tauri/src/lib.rs.
Speech-to-text pipeline
- Recording. The Rust
AudioRecorder(built onecho-audioandcpal) captures 16 kHz mono f32 chunks in memory on every platform. See Audio pipeline. - VAD (optional). Silero VAD V5 detects speech segments. See Silero VAD V5.
- Backend selection. The
TranscriptionBackendtrait dispatches to the active ML backend. - Preprocessing. Audio becomes a mel spectrogram: 80 bins for Whisper, 128 for Parakeet.
- Inference. DirectML on Windows, CoreML/Metal on macOS, CPU on Linux/WSL. See GPU and models.
- Output. The transcript goes to the clipboard or is pasted at the cursor.
Trait-based backends
Swappable systems sit behind traits, so backends can change without touching business logic.transcription::transcribe_source in src-tauri/src/transcription/mod.rs. Commands call that and never pick a backend themselves.
Backend rules: Candle models are safetensors only (no GGUF, no PyTorch .bin). Platform-specific code uses #[cfg(target_os = "...")].
Settings
Settings live insettings.yaml, modelled by AppSettings in src-tauri/src/settings/mod.rs. The per-recording cap is a plain user setting (5 to 180 seconds, default 30), enforced by getMaxRecordingTime() in useRecording.ts against a hard 180 second ceiling. ECHOPHRASE_CONFIG_DIR relocates the settings directory for tests.
System tray and lifecycle
The tray icon (src-tauri/src/setup/tray.rs, src-tauri/src/tray_status.rs) is the app’s lifecycle anchor and a status indicator.
Close to tray. The window’s close button hides the window instead of exiting. The process, the recorder and the global hotkeys keep running. Hidden-window recording is intentional: nothing in the frontend or backend stops a recording when the window hides or loses focus. The only way out is the tray menu’s Quit, which goes through shutdown::force_exit (ADR 0003).
Tray menu. Show, Start Recording / Stop Recording (the label follows state), and Quit. Double-clicking the icon restores the window.
Status overlay.
At startup
icons/32x32.png is decoded once and two RGBA copies with anti-aliased dots are composited. State changes are driven from commands/recording.rs: starting a recording sets Recording, stopping sets Idle, and stop-and-transcribe sets Transcribing and returns to Idle on every exit path through an RAII StatusGuard, so errors and panics still reset the tray. Open-mic mode stays Recording for the whole session. On Windows the icon carries a fixed GUID; see Windows tray icon.