Development

Development

Build Prerequisites

Requires Rust (via rustup), a C toolchain, cmake, pkg-config, clang, libclang, and ALSA development headers:

# Debian/Ubuntu:
sudo apt install build-essential cmake pkg-config clang libclang-dev libasound2-dev

# Fedora:
sudo dnf install gcc gcc-c++ cmake pkg-config clang clang-devel alsa-lib-devel

# Arch:
sudo pacman -S base-devel cmake pkgconf clang alsa-lib

Why clang (the binary)? GPU builds use bindgen to generate FFI bindings. bindgen loads libclang as a library, but needs the clang binary in PATH to locate its resource directory (containing stdbool.h, stddef.h, etc.). Without it, bindgen silently falls back to pre-built bindings that lack GPU symbols. Some distros install only a versioned binary (e.g. clang-20) via libclang-dev — bindgen only looks for the unversioned clang.

For the authoritative list of system dependencies, see test-containers/Dockerfile.vulkan .

Runtime Dependencies

Text injection requires wl-clipboard plus either wtype (wlroots) or ydotool (fallback):

# Debian/Ubuntu:
sudo apt install wl-clipboard wtype

# Fedora:
sudo dnf install wl-clipboard wtype

# Arch:
sudo pacman -S wl-clipboard wtype

GPU Backend Dependencies

GPU backends are optional. Add their system packages before building with --features <backend>.

Backend Feature flag System packages (Debian/Ubuntu)
Vulkan vulkan libvulkan-dev mesa-vulkan-drivers vulkan-tools glslc
CUDA cuda NVIDIA driver + CUDA Toolkit (nvcc)
HipBLAS hipblas ROCm (rocminfo)
OpenBLAS openblas libopenblas-dev
Parakeet on CUDA parakeet-cuda NVIDIA driver + cuDNN 9 for CUDA 13 at runtime (see below)

These backends accelerate whisper.cpp, except parakeet-cuda, which runs Parakeet’s full-precision models on an NVIDIA GPU through ONNX Runtime’s CUDA provider. It is opt-in and needs neither nvcc nor the cuda feature:

  • cuDNN 9 for CUDA 13: libcudnn.so.9 must be on the loader path (system package, or LD_LIBRARY_PATH).
  • Provider libraries beside the binary: ONNX Runtime loads libonnxruntime_providers_shared.so and libonnxruntime_providers_cuda.so from the directory of the voicsh executable only; LD_LIBRARY_PATH does not find them. cargo build --features parakeet-cuda links them into target/<profile>/ (symlinks into ~/.cache/ort.pyke.io). cargo install does not install them: copy them next to ~/.cargo/bin/voicsh yourself, e.g. cp -L target/release/libonnxruntime_providers_{shared,cuda}.so ~/.cargo/bin/.
  • GPU memory: parakeet-tdt-0.6b-v3 takes about 3.5 GB.
  • Which models: int8 models (parakeet-ultra-0.6b-int8) stay on the CPU; the GPU does not speed them up. The speedup is measured for fp32 parakeet-tdt-0.6b-v3: several times faster than the CPU.
  • Fallback: if the provider or cuDNN cannot load, voicsh prints the cause on stderr once and runs Parakeet on the CPU. On success it prints Parakeet runs on the GPU once at load.
# Vulkan (Intel/AMD/NVIDIA — Debian/Ubuntu):
sudo apt install libvulkan-dev mesa-vulkan-drivers vulkan-tools glslc

# CUDA (NVIDIA only — see link above for toolkit install):
# Requires: nvidia-smi, nvcc

# OpenBLAS (CPU-only BLAS optimization):
sudo apt install libopenblas-dev

GPU build troubleshooting: If you see unresolved import ggml_backend_vk_* errors, bindgen failed to generate GPU bindings and fell back to incomplete pre-built ones. Common causes and fixes:

Symptom Cause Fix
stdbool.h not found clang binary not in PATH sudo apt install clang
Versioned clang exists (e.g. clang-20) but clang doesn’t Distro only installed versioned binary sudo apt install clang or export CLANG_PATH=$(which clang-20)
No clang at all libclang-dev not installed sudo apt install clang libclang-dev

The build script runs preflight checks and will panic with specific guidance before compilation starts. If you need to bypass the check: export CLANG_PATH=/usr/bin/clang-20.

Feature policy

Tested is always only everything (full), and the default install is everything: default = ["full"], and the gate in CLAUDE.md and the check job in .github/workflows/ci.yml build, lint and test that set. Every feature stays individually switchable; the reduced --no-default-features jobs are cheap compile guards, not a second supported configuration.

Error correction (error-correction, symspell) is experimental and not part of full. Opt in with cargo build --features error-correction,symspell; its CI job may fail without failing the build. Without the configured backend compiled in, the daemon answers list_correction_models with supported: false and the GNOME extension hides its Correction menu.

Parakeet backend

The parakeet feature (part of full) adds NVIDIA Parakeet TDT v3 and Parakeet Ultra. They run as ONNX models through parakeet-rs and ONNX Runtime (src/stt/parakeet.rs), on the CPU unless the opt-in parakeet-cuda feature puts full-precision models on an NVIDIA GPU (requirements: GPU Backend Dependencies ). The catalog’s ModelBackend decides which engine loads a model (src/stt/loader.rs). Whisper stays the default model.

voicsh models install parakeet-tdt-0.6b-v3   # or parakeet-ultra-0.6b-int8
voicsh config set stt.model parakeet-tdt-0.6b-v3
  • ONNX Runtime binaries: by default, ort-sys downloads a prebuilt static ONNX Runtime from cdn.pyke.io at build time and caches it in ~/.cache/ort.pyke.io. For offline builds, set ORT_LIB_PATH to a local ONNX Runtime build. ORT_SKIP_DOWNLOAD=1 makes a missing library fail instead of fetching it.

  • Model storage: Parakeet models are multi-file Hugging Face snapshots, stored in the standard Hugging Face hub cache ($HF_HUB_CACHE, else $HF_HOME/hub, else ~/.cache/huggingface/hub), pinned to the catalog revision. A snapshot already there (e.g. from hf download <repo> --revision <rev>) is used without downloading. Every file is checked against the catalog’s SHA-256 once per install; ~/.cache/voicsh/verified remembers what was checked. download::snapshot_dir_in (src/models/download.rs) is the one path resolver. Whisper ggml files and dictionaries stay in ~/.cache/voicsh/.

  • Models and licenses:

    Model Source License
    parakeet-tdt-0.6b-v3 istupakov/parakeet-tdt-0.6b-v3-onnx (fp32 export of nvidia/parakeet-tdt-0.6b-v3) CC-BY-4.0
    parakeet-ultra-0.6b-int8 wothers/parakeet-tdt-0.6b-ultra-onnx-int8 (int8 export of Parakeet Ultra, per-channel MatMul quantization) CC-BY-4.0

    parakeet-tdt-0.6b-v3 ships as fp32 (about 2.5 GB on disk and in RAM). The published int8 builds (istupakov/parakeet-tdt-0.6b-v3-onnx’s *.int8.onnx, smcleod/nemotron-3.5-asr-streaming-0.6b-int8) come from onnxruntime quantize_dynamic with default settings, which quantizes the encoder per-tensor. They transcribe markedly worse, drift into English on German speech, and the Nemotron build in auto mode sometimes picks the wrong language or returns nothing. parakeet-ultra-0.6b-int8 avoids this with per-channel quantization.

  • Language: Parakeet TDT detects the language itself, ignores stt.language, and reports no language and a fixed confidence of 1.0.

  • Real-model tests are #[ignore]d. Install parakeet-tdt-0.6b-v3, then run cargo test --lib stt::parakeet -- --ignored.

Local Install

cargo install --path=.                   # CPU only
cargo install --features=cuda --path=.   # NVIDIA GPU
cargo install --features=vulkan --path=. # Vulkan GPU
cargo install --features=parakeet-cuda --path=.  # Parakeet on NVIDIA GPU, plus the provider libraries (GPU Backend Dependencies)

Installs to ~/.cargo/bin/voicsh.

Testing

Commands

cargo test                                         # the gate (full)
cargo test --lib --no-default-features             # fast guard, skips whisper-rs and ONNX Runtime

Real-model whisper tests load only a fast model (FAST_WHISPER_MODELS in src/stt/test_models.rs), once per test process, and skip with a banner when none is installed. Install one to run them:

cargo run -- models install tiny.en

Mocking Pattern

All external dependencies are behind traits with test doubles:

Trait Production Test
AudioSource CpalAudioSource, WavAudioSource MockAudioSource
Transcriber WhisperTranscriber MockTranscriber
CommandExecutor SystemCommandExecutor MockCommandExecutor / RecordingExecutor
TextSink InjectorSink, StdoutSink CollectorSink
PortalConnector AshpdConnector inline test connector
ClipLoader FleursSplit MemoryClips

Conventions

  • Unit tests live in #[cfg(test)] mod tests inside each file
  • serde_json is available as a dependency for JSON test assertions
  • tempfile is available for filesystem tests

Benchmarking models

voicsh benchmark                                    # every installed model, German FLEURS test split
voicsh benchmark --models large,parakeet-ultra-0.6b-int8 --lang de --limit 50
voicsh benchmark --audio speech.wav                 # speed only, on your own recording

voicsh benchmark transcribes the FLEURS test split of --lang (CC-BY-4.0) with each model through the production loader (open_transcriber) and prints WER, CER, the real-time factor and the load time. --limit N scores N clips spread evenly over the split. Named models that aren’t installed are installed first, unless --no-download is set. The scorer’s text normalizer and its limits are documented in src/benchmark/score.rs.

  • Dataset cache: the split is downloaded on first use, checked against the hub’s file sizes and the archive’s SHA-256, and converted to 16 kHz PCM16 WAV in <main checkout>/.bench-cache/fleurs/<config>/, which every worktree of the clone shares. Outside a source checkout it goes to ~/.cache/voicsh/bench/. VOICSH_BENCH_DIR overrides both. Delete a config’s directory to re-download it. Models stay in their usual cache.
  • Results: each run writes ~/.local/share/voicsh/benchmarks/<model>.<lang>.json (ModelResult in src/benchmark/accuracy.rs), replacing that model’s previous result.
  • Adding a model: add it to src/models/catalog.rs, then run voicsh benchmark --models <name>,<baseline>. Compare models only on the same --lang and --limit.

GNOME Extension Development

The extension lives in gnome/[email protected]/.

Nested Shell (UI and IPC iteration)

A dev script launches a nested GNOME Shell inside a window — fast iteration without restarting your session.

./gnome/dev.sh              # launch nested shell with extension enabled
./gnome/dev.sh --verbose    # same, with full GLib/Shell debug output

The script handles symlinks, schema compilation, and auto-enabling the extension. Edit code, close the nested window, rerun — ~2-3 second cycle.

Good for: icon states, menu rendering, styles, IPC (socket connect, toggle, status polling), keybindings.

Not for end-to-end text injection. The voicsh daemon runs on the host compositor. The nested shell is a separate Wayland compositor — injected text goes to the host, not into the nested window. Test text injection in your real session.

Why not disable/re-enable? GJS caches imported JS modules in memory. gnome-extensions disable && enable re-runs enable() on the cached code — it does not re-read files from disk. A fresh nested shell process has no cache.

Requirements: gnome-shell, glib-compile-schemas, and on GNOME 49+ also mutter-dev-bin (sudo apt install mutter-dev-bin). Uses --devkit on GNOME 49+, --nested on 45-48.

Indicator Scenarios (headless, automated)

test-containers/gnome/session.sh walks the indicator through its states (indicatorState in extension.js) against a fake daemon and the real voicsh uninstall-gnome-extension, inside a sandboxed headless GNOME Shell. Two runners provide that shell:

  • test-containers/gnome-test-local.sh uses this host’s gnome-shell, no Docker. Use it while changing the extension or the uninstall flow.
  • test-containers/gnome-test.sh uses a Docker GNOME image (GNOME_TEST_IMAGE). Use it without a local GNOME or to check another GNOME release; the voicsh binary must run on the image’s glibc.

Both write screenshots and logs to test-containers/gnome-output/. The script headers give usage and what the sandbox isolates.

Testing Against a Nested Session

voicsh respects an explicitly set, reachable DBUS_SESSION_BUS_ADDRESS (e.g. from dbus-run-session) and only looks up the host gnome-shell when it is unset or stale. Set XDG_CACHE_HOME to a scratch directory so the portal restore token (rewritten on every start) of your real session is untouched.

Real Session (end-to-end testing)

For testing text injection, install the extension in your real session:

voicsh install-gnome-extension   # prints whether the indicator is live or which step is left

When the shell needs a restart and why (first install, GJS code caching) is described in README.md . gnome-extensions enable alone fails with “does not exist” for an extension directory created after the shell started.

Quality Checks

See CLAUDE.md for the canonical quality gate commands to run before every commit.