Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(install): prefetch complete local voice models

Ruben Lütke428e3eb517e5
diff --git a/.github/workflows/fresh-install-smoke.yml b/.github/workflows/fresh-install-smoke.yml
index a5c65e1aaa..3d981c8e50 100644
--- a/.github/workflows/fresh-install-smoke.yml
+++ b/.github/workflows/fresh-install-smoke.yml
@@ -30,6 +30,10 @@ on:
- 'install/install.sh'
- 'pyproject.toml'
- 'requirements.txt'
+ - 'jarvis/__main__.py'
+ - 'jarvis/setup/prefetch.py'
+ - 'jarvis/setup/model_report.py'
+ - 'jarvis/speech/wake_model_fetch.py'
- '.github/workflows/fresh-install-smoke.yml'
# A new push to the same ref cancels the previous in-flight run so a burst of
@@ -71,7 +75,7 @@ jobs:
matrix:
os: ${{ fromJSON(needs.configure.outputs.os-matrix) }}
runs-on: ${{ matrix.os }}
- timeout-minutes: 20
+ timeout-minutes: 30
steps:
- name: Checkout
@@ -84,20 +88,26 @@ jobs:
with:
python-version: "3.11"
- - name: Run the REAL installer end-to-end (headless, no launch)
+ - name: Run the REAL installer end-to-end (runner-appropriate profile)
shell: bash
run: |
set -euo pipefail
# Reproduce exactly what install.sh does after the git clone: a venv,
- # the bootstrap deps, then hand off to installer.py. --no-launch keeps
- # the runner from spawning a server we don't tear down here (a dedicated
- # step below boots + probes it). The installer is non-interactive by
- # design now — no wizard flag needed.
+ # the bootstrap deps, then hand off to installer.py. Ordinary Linux
+ # pushes prove the headless/base floor. A manually-requested macOS leg
+ # proves the advertised desktop [full] profile AND its complete model
+ # prefetch; running that leg headless used to leave this exact install
+ # contract untested. --no-launch keeps the runner from spawning a server
+ # we don't tear down here (a dedicated step below boots + probes it).
python -m venv .venv
. .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install rich packaging
- python install/installer.py --headless --no-launch | tee install.log
+ if [ "${{ matrix.os }}" = "macos-latest" ]; then
+ python install/installer.py --with-desktop --no-launch | tee install.log
+ else
+ python install/installer.py --headless --no-launch | tee install.log
+ fi
# The installer must never prompt: fail if anything interactive leaked in.
if grep -Eiq "input\(|\? \[y/n\]|press enter" install.log; then
echo "installer output contains an interactive prompt marker"; exit 8
diff --git a/install/installer.py b/install/installer.py
index 73d254d652..28764ae881 100644
--- a/install/installer.py
+++ b/install/installer.py
@@ -416,11 +416,16 @@ def is_update_run() -> bool:
return (repo_root() / ".jarvis-managed-install").exists()
-def step_models(*, dry_run: bool) -> None:
+def step_models(*, full_profile: bool, dry_run: bool) -> None:
phase("5/6", "Voice models")
note("downloading everything the voice pipeline needs, so the first")
note("launch is ready immediately - nothing is fetched at startup")
cmd = [str(venv_python()), "-m", "jarvis", "--prefetch"]
+ if full_profile:
+ # Onboarding has not selected a language yet. Cache every supported
+ # wake language so English, German, and Spanish are all ready on the
+ # first launch; the internal headless/base path stays intentionally small.
+ cmd.append("--prefetch-all-wake-languages")
if dry_run:
console.print(f"[muted]│ (dry-run) {' '.join(cmd)}[/]")
return
@@ -438,10 +443,10 @@ def step_models(*, dry_run: bool) -> None:
label="downloading voice models (the long step - a few hundred MB)",
cwd=repo_root(),
)
- verify_models()
+ verify_models(full_profile=full_profile)
-def verify_models() -> None:
+def verify_models(*, full_profile: bool = False) -> None:
"""Print a per-model truth: what is on disk, what is pending, what is missing.
Runs the read-only report inside the venv's Python — the interpreter that
@@ -452,7 +457,7 @@ def verify_models() -> None:
probe = (
"from jarvis.setup.model_report import "
"voice_model_report, report_complete, format_report\n"
- "items = voice_model_report()\n"
+ f"items = voice_model_report(full_profile={full_profile!r})\n"
"print('\\n'.join(format_report(items)))\n"
"import sys; sys.exit(0 if report_complete(items) else 3)\n"
)
@@ -482,7 +487,8 @@ def verify_models() -> None:
console.print(f"[muted]│ {tail}[/]")
return
if result.returncode == 0:
- ok("everything the default voice path needs is present")
+ profile = "full voice profile" if full_profile else "default voice path"
+ ok(f"everything the {profile} needs is present")
else:
console.print("[bad]│ Some required voice models are missing - re-run "
"the installer or check your connection.[/]")
@@ -832,7 +838,7 @@ def main(argv: list[str] | None = None) -> int:
dry_run=args.dry_run,
)
- step_models(dry_run=args.dry_run)
+ step_models(full_profile=with_desktop, dry_run=args.dry_run)
phase("6/6", "Finish & launch")
step_worker_cli(dry_run=args.dry_run)
diff --git a/jarvis/__main__.py b/jarvis/__main__.py
index 26d9fe4545..c01a649911 100644
--- a/jarvis/__main__.py
+++ b/jarvis/__main__.py
@@ -88,6 +88,13 @@ def _build_parser() -> argparse.ArgumentParser:
help="Download all voice models the current config needs, then exit. "
"Used by the installer so the first launch has nothing left to fetch.",
)
+ parser.add_argument(
+ "--prefetch-all-wake-languages",
+ action="store_true",
+ dest="prefetch_all_wake_languages",
+ help="With --prefetch, cache wake models for every supported onboarding "
+ "language. Used by the full desktop installer.",
+ )
parser.add_argument(
"--verify-models",
action="store_true",
@@ -532,7 +539,9 @@ def main(argv: list[str] | None = None) -> int:
if args.prefetch:
from jarvis.setup.prefetch import prefetch_all
- return prefetch_all()
+ return prefetch_all(
+ all_wake_languages=bool(args.prefetch_all_wake_languages),
+ )
if args.verify_models:
from jarvis.setup.model_report import (
format_report,
diff --git a/jarvis/setup/model_report.py b/jarvis/setup/model_report.py
index 3bf524db8a..beb0d01e30 100644
--- a/jarvis/setup/model_report.py
+++ b/jarvis/setup/model_report.py
@@ -13,13 +13,12 @@ install):
"absent", never as a raised exception. The report can always be produced.
- **No network.** The faster-whisper cache probe uses ``local_files_only`` so it
never triggers a download while merely *checking*.
-- **Honest optionality.** ``required`` separates the models the DEFAULT voice
- path needs (bundled neural wake backbone + Silero VAD — both ship in-repo)
- from the optional ones (the per-language Vosk custom-wake model and the local
- Whisper models, which are downloaded / behind the ``[full]`` profile). A
- missing optional model is a pending download, not a failure — so
- ``report_complete`` gates only on the required set and never sabotages an
- install that legitimately runs cloud speech.
+- **Profile-aware optionality.** ``required`` separates the models the DEFAULT
+ voice path needs from optional local models. When the advertised ``[full]``
+ desktop installer asks for a full-profile report, every supported Vosk
+ language and the local Whisper wake model become required, so its completion
+ message cannot hide a partial model download. The cloud/headless report keeps
+ those artifacts optional.
Seams (module-level functions) keep the heavy imports lazy and let tests inject
fakes without a real config, network, or model cache — same style as
@@ -31,6 +30,7 @@ from __future__ import annotations
import importlib.util
from collections.abc import Callable, Sequence
from dataclasses import dataclass
+from functools import partial
from typing import Any
@@ -73,6 +73,12 @@ def _wake_language(cfg: Any) -> str | None:
return resolve_wake_language(cfg)
+def _supported_wake_languages() -> tuple[str, ...]:
+ from jarvis.speech.wake_model_fetch import VOSK_MODELS
+
+ return tuple(VOSK_MODELS)
+
+
def _vosk_present(language: str | None, data_dir: str | None) -> bool:
from jarvis.speech.wake_model_fetch import vosk_model_present
@@ -108,7 +114,7 @@ def _whisper_cached(name: str) -> bool:
network. Any failure (not cached, lib missing, odd cache layout) reads as
"not present".
"""
- from faster_whisper.utils import download_model # type: ignore[import-not-found]
+ from faster_whisper.utils import download_model # type: ignore[import-not-found,import-untyped]
download_model(name, local_files_only=True)
return True
@@ -137,7 +143,12 @@ def _safe(fn: Callable[[], Any], default: Any) -> Any:
return default
-def voice_model_report(cfg: Any | None = None, *, data_dir: str | None = None) -> list[ModelStatus]:
+def voice_model_report(
+ cfg: Any | None = None,
+ *,
+ data_dir: str | None = None,
+ full_profile: bool = False,
+) -> list[ModelStatus]:
"""Verify, read-only, which voice models are actually ready on disk.
``cfg`` defaults to the live config (loaded via the same path the runtime
@@ -188,39 +199,83 @@ def voice_model_report(cfg: Any | None = None, *, data_dir: str | None = None) -
)
items.append(ModelStatus("end-of-speech detection", vad_present, vad_detail, required=True))
- # 3. Custom-wake model (Vosk, per language) — downloaded once, optional.
- lang = _safe(lambda: _wake_language(cfg), None) if cfg is not None else None
- vosk_ok = bool(_safe(lambda: _vosk_present(lang, data_dir), False))
- items.append(
- ModelStatus(
- f"custom-wake model '{lang or 'default'}'",
- vosk_ok,
- "ready" if vosk_ok else "not downloaded yet - the app fetches it on first use",
- required=False,
+ # 3. Custom-wake model (Vosk, per language). A default/cloud report checks
+ # only the configured language and treats it as optional. The full desktop
+ # installer runs before onboarding, so it must prove every selectable
+ # language is cached instead of silently validating only the English default.
+ if full_profile:
+ supported = _safe(_supported_wake_languages, None)
+ if supported:
+ wake_languages: tuple[str | None, ...] = supported
+ else:
+ wake_languages = ()
+ items.append(
+ ModelStatus(
+ "custom-wake language catalog",
+ False,
+ "MISSING from the package - cannot verify the full voice profile",
+ required=True,
+ )
+ )
+ else:
+ lang = _safe(lambda: _wake_language(cfg), None) if cfg is not None else None
+ wake_languages = (lang,)
+ for lang in wake_languages:
+ vosk_ok = bool(_safe(partial(_vosk_present, lang, data_dir), False))
+ items.append(
+ ModelStatus(
+ f"custom-wake model '{lang or 'default'}'",
+ vosk_ok,
+ "ready"
+ if vosk_ok
+ else (
+ "not downloaded yet - re-run the installer or retry in the app"
+ if full_profile
+ else "not downloaded yet - the app fetches it on first use"
+ ),
+ required=full_profile,
+ )
)
- )
- # 4. Local speech recognition (faster-whisper) — optional; cloud is default.
+ # 4. Local speech recognition (faster-whisper). It remains optional for the
+ # cloud/headless report, but the advertised full profile promises this path.
if not bool(_safe(_faster_whisper_available, False)):
items.append(
ModelStatus(
"local speech model",
False,
- "not installed - cloud speech is the default "
- "(install the [full] profile for offline speech)",
- required=False,
+ (
+ "MISSING from the [full] profile - re-run the installer"
+ if full_profile
+ else "not installed - cloud speech is the default "
+ "(install the [full] profile for offline speech)"
+ ),
+ required=full_profile,
)
)
else:
- needed = _safe(lambda: _whisper_models_needed(cfg), []) if cfg is not None else []
+ fallback_models = ["base"] if full_profile else []
+ needed = (
+ _safe(lambda: _whisper_models_needed(cfg), fallback_models)
+ if cfg is not None
+ else fallback_models
+ )
+ if full_profile and not needed:
+ needed = fallback_models
for name in needed:
- cached = bool(_safe(lambda n=name: _whisper_cached(n), False))
+ cached = bool(_safe(partial(_whisper_cached, name), False))
items.append(
ModelStatus(
f"local speech model '{name}'",
cached,
- "ready" if cached else "not downloaded yet - the app fetches it on first use",
- required=False,
+ "ready"
+ if cached
+ else (
+ "not downloaded yet - re-run the installer or retry in the app"
+ if full_profile
+ else "not downloaded yet - the app fetches it on first use"
+ ),
+ required=full_profile,
)
)
diff --git a/jarvis/setup/prefetch.py b/jarvis/setup/prefetch.py
index a5d7be15b6..a5b73f2bc7 100644
--- a/jarvis/setup/prefetch.py
+++ b/jarvis/setup/prefetch.py
@@ -57,6 +57,13 @@ def _vosk_language() -> str | None:
return None
+def _supported_vosk_languages() -> tuple[str, ...]:
+ """Every language a user can select during first-run onboarding."""
+ from jarvis.speech.wake_model_fetch import VOSK_MODELS
+
+ return tuple(VOSK_MODELS)
+
+
def _whisper_models_needed() -> list[str]:
"""The faster-whisper model names the CURRENT config would load at runtime.
@@ -74,17 +81,23 @@ def _whisper_models_needed() -> list[str]:
def _download_whisper_model(name: str) -> None:
"""Fetch one faster-whisper model into the standard HuggingFace cache —
the exact cache ``WhisperModel(name)`` resolves at runtime."""
- from faster_whisper.utils import download_model # type: ignore[import-not-found]
+ from faster_whisper.utils import download_model # type: ignore[import-not-found,import-untyped]
download_model(name)
-def prefetch_all(echo: Callable[[str], None] = print) -> int:
+def prefetch_all(
+ echo: Callable[[str], None] = print,
+ *,
+ all_wake_languages: bool = False,
+) -> int:
"""Prefetch every artifact the default voice path needs. 0 = complete.
Returns 1 when at least one download failed — callers keep going (the
runtime lazy-download remains the safety net), the exit code just keeps
- the installer's summary honest.
+ the installer's summary honest. The advertised desktop installer passes
+ ``all_wake_languages=True`` because onboarding has not selected a language
+ yet; the headless/base path keeps only its configured language.
"""
# Tame the Hugging Face downloader BEFORE it is imported (both env vars
# are read at import time): no tqdm progress bars — they shred the
@@ -106,16 +119,34 @@ def prefetch_all(echo: Callable[[str], None] = print) -> int:
"on first use"
)
- # Any-word wake model (vosk_kws): fetch the per-language model once so a
- # custom wake word resolves to the reliable engine instead of stt_match.
- lang = _vosk_language()
- try:
- out = _ensure_vosk(lang, echo=echo)
- if out is None:
+ # Any-word wake model (vosk_kws): the full desktop installer runs BEFORE
+ # onboarding knows whether the user will choose English, German, or Spanish,
+ # so it caches every supported language. The internal headless/base path
+ # keeps its configured language to preserve the small-server floor.
+ languages: tuple[str | None, ...]
+ if all_wake_languages:
+ try:
+ languages = _supported_vosk_languages()
+ except Exception as exc: # noqa: BLE001 — keep the current-language fallback
failed = True
- except Exception as exc: # noqa: BLE001 — honest note, never fatal
- failed = True
- echo(f"wake model: could not provision ({exc}); it will retry at first run")
+ echo(
+ f"wake-language catalog could not be read ({exc}); "
+ "prefetching the configured language only"
+ )
+ languages = (_vosk_language(),)
+ else:
+ languages = (_vosk_language(),)
+ for lang in languages:
+ try:
+ out = _ensure_vosk(lang, echo=echo)
+ if out is None:
+ failed = True
+ except Exception as exc: # noqa: BLE001 — honest note, never fatal
+ failed = True
+ echo(
+ f"wake model '{lang or 'default'}': could not provision ({exc}); "
+ "it will retry at first run"
+ )
if not _faster_whisper_available():
echo(
@@ -124,7 +155,16 @@ def prefetch_all(echo: Callable[[str], None] = print) -> int:
)
return 1 if failed else 0
- for name in _whisper_models_needed():
+ try:
+ whisper_models = _whisper_models_needed()
+ except Exception as exc: # noqa: BLE001 — cache the safe packaged floor
+ failed = True
+ whisper_models = ["base"]
+ echo(
+ f"speech-model config could not be read ({exc}); "
+ "prefetching the packaged 'base' wake model"
+ )
+ for name in whisper_models:
echo(f"downloading speech model '{name}' (one-time, cached for every later start)")
try:
_download_whisper_model(name)
diff --git a/jarvis/ui/web/frontend/src/components/onboarding/steps/WakeWordStep.test.tsx b/jarvis/ui/web/frontend/src/components/onboarding/steps/WakeWordStep.test.tsx
index df1b0a1eff..250ba31c6b 100644
--- a/jarvis/ui/web/frontend/src/components/onboarding/steps/WakeWordStep.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/onboarding/steps/WakeWordStep.test.tsx
@@ -1,6 +1,10 @@
-import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
import { afterEach, expect, it, vi } from "vitest";
vi.mock("@/i18n", () => ({ useT: () => (k: string) => k }));
+const localSpeech = vi.hoisted(() => ({
+ onInstalled: undefined as (() => void) | undefined,
+ startInstall: vi.fn(),
+}));
const saveWakeWord = vi.fn().mockResolvedValue({ ok: true, degraded: false });
const setWakeActivation = vi.fn().mockResolvedValue({
ok: true,
@@ -10,10 +14,13 @@ const setWakeActivation = vi.fn().mockResolvedValue({
});
vi.mock("@/hooks/useWakeWord", () => ({
useWakeWord: () => ({ saveWakeWord, setWakeActivation }),
- useLocalSpeechInstall: () => ({
- status: { state: "idle", message: "", available: true },
- install: vi.fn(),
- }),
+ useLocalSpeechInstall: (onInstalled?: () => void) => {
+ localSpeech.onInstalled = onInstalled;
+ return {
+ status: { state: "idle", message: "", available: true },
+ install: localSpeech.startInstall,
+ };
+ },
}));
import { WakeWordStep } from "./WakeWordStep";
afterEach(() => {
@@ -21,6 +28,8 @@ afterEach(() => {
saveWakeWord.mockClear();
saveWakeWord.mockResolvedValue({ ok: true, degraded: false });
setWakeActivation.mockClear();
+ localSpeech.startInstall.mockClear();
+ localSpeech.onInstalled = undefined;
});
const onb = {
@@ -121,6 +130,41 @@ it("wake-word path: a degraded save does NOT advance and offers the local-speech
expect(goNext).toHaveBeenCalled();
});
+it("wake-word path: completed local install clears the stale degraded warning", async () => {
+ saveWakeWord
+ .mockResolvedValueOnce({ ok: true, degraded: true })
+ .mockResolvedValue({ ok: true, degraded: false });
+ const { goNext } = renderStep();
+ selectWakeMode();
+
+ fireEvent.change(screen.getByRole("textbox"), { target: { value: "Nova" } });
+ fireEvent.click(screen.getByRole("checkbox"));
+ fireEvent.click(screen.getByRole("button", { name: "onboarding.wake_word.cta" }));
+
+ await screen.findByText("settings_view.wake_word.needs_whisper_hint");
+ fireEvent.click(
+ screen.getByRole("button", {
+ name: "settings_view.wake_word.enable_local_button",
+ }),
+ );
+ expect(localSpeech.startInstall).toHaveBeenCalledOnce();
+
+ act(() => localSpeech.onInstalled?.());
+
+ await waitFor(() =>
+ expect(screen.queryByText("settings_view.wake_word.needs_whisper_hint")).toBeNull(),
+ );
+ expect(
+ screen.queryByRole("button", { name: "onboarding.wake_word.continue_anyway" }),
+ ).toBeNull();
+
+ // The normal CTA re-validates the already-persisted phrase and activates it.
+ fireEvent.click(screen.getByRole("button", { name: "onboarding.wake_word.cta" }));
+ await waitFor(() => expect(saveWakeWord).toHaveBeenCalledTimes(2));
+ await waitFor(() => expect(setWakeActivation).toHaveBeenCalledWith(true));
+ expect(goNext).toHaveBeenCalled();
+});
+
it("wake-word path: renders a mic-check control that reports a good level", async () => {
const fetchSpy = vi.fn(() =>
Promise.resolve({
diff --git a/jarvis/ui/web/frontend/src/components/onboarding/steps/WakeWordStep.tsx b/jarvis/ui/web/frontend/src/components/onboarding/steps/WakeWordStep.tsx
index 6417ecd0b1..ff07cc6da3 100644
--- a/jarvis/ui/web/frontend/src/components/onboarding/steps/WakeWordStep.tsx
+++ b/jarvis/ui/web/frontend/src/components/onboarding/steps/WakeWordStep.tsx
@@ -41,7 +41,14 @@ export function WakeWordStep({ onb, goNext }: StepProps) {
// user's own word). We DON'T advance silently in that case — we tell the
// user and offer the one-click local-speech install, or an honest opt-out.
const [degraded, setDegraded] = useState(false);
- const { status: install, install: startInstall } = useLocalSpeechInstall();
+ const { status: install, install: startInstall } = useLocalSpeechInstall(() => {
+ // The first save already persisted the phrase. Once the recovery installer
+ // has both the engine and its model, discard that stale degraded verdict and
+ // let the normal CTA re-check + activate it. This prevents the contradictory
+ // "model installed" plus "continue anyway" state from lingering on screen.
+ setDegraded(false);
+ setErr(null);
+ });
// Mic verification (Task 7): a live dBFS read from the desktop app's own
// capture path (the same one the wake-word detector listens on) — never
// blocks the save/acknowledge below, it just surfaces an honest signal so a
diff --git a/jarvis/ui/web/frontend/src/hooks/useWakeWord.ts b/jarvis/ui/web/frontend/src/hooks/useWakeWord.ts
index e6ae28536c..b2b72fb970 100644
--- a/jarvis/ui/web/frontend/src/hooks/useWakeWord.ts
+++ b/jarvis/ui/web/frontend/src/hooks/useWakeWord.ts
@@ -185,7 +185,7 @@ export function useLocalSpeechInstall(onInstalled?: () => void) {
setStatus(data);
if (data.state === "done" || data.state === "error") {
stopPoll();
- if (data.state === "done") onInstalledRef.current?.();
+ if (data.state === "done" && data.available) onInstalledRef.current?.();
}
} catch {
// Transient network blip during a long install — keep polling.
diff --git a/jarvis/ui/web/settings_routes.py b/jarvis/ui/web/settings_routes.py
index 135696d55c..c6df47f003 100644
--- a/jarvis/ui/web/settings_routes.py
+++ b/jarvis/ui/web/settings_routes.py
@@ -597,6 +597,42 @@ def _local_whisper_available() -> bool:
return importlib.util.find_spec("faster_whisper") is not None
+def _local_wake_model_name() -> str:
+ """Configured faster-whisper wake checkpoint, with the packaged default."""
+ try:
+ from jarvis.core.config import load_config
+
+ cfg = load_config()
+ name = str(getattr(getattr(cfg, "stt", None), "wake_model", "base") or "base")
+ return name.strip() or "base"
+ except Exception: # noqa: BLE001 — recovery install must keep a safe default
+ return "base"
+
+
+def _local_wake_model_cached(name: str) -> bool:
+ """Read-only cache probe; never downloads while a status route is polling."""
+ try:
+ from jarvis.setup.model_report import _whisper_cached
+
+ return bool(_whisper_cached(name))
+ except Exception: # noqa: BLE001 — an uncertain cache is not ready
+ return False
+
+
+def _download_local_wake_model(name: str) -> None:
+ """Download the same checkpoint and cache layout the main installer uses."""
+ from jarvis.setup.prefetch import _download_whisper_model
+
+ _download_whisper_model(name)
+
+
+def _local_speech_ready() -> bool:
+ """True only when both the engine package and its wake model are usable."""
+ return _local_whisper_available() and _local_wake_model_cached(
+ _local_wake_model_name()
+ )
+
+
# --- Local-speech (any-phrase wake) opt-in install --------------------------
# ``faster-whisper`` powers the ``stt_match`` wake path — the ONLY local way to
# detect an arbitrary, user-invented wake phrase. It is a torch-FREE opt-in
@@ -605,9 +641,10 @@ def _local_whisper_available() -> bool:
# every extra (2026-05-18, "Groq Whisper API is the new default"), so a fresh
# install could not use a custom wake word at all and silently degraded to the
# bundled "Hey Rhasspy" model. This endpoint pulls the package from INSIDE the
-# app so any wake word works everywhere without dropping to a shell — the §3
-# "recoverable in-app" contract. The spec is pinned to the [local-voice] extra
-# in pyproject.toml so the two never drift.
+# app and downloads its configured wake checkpoint so any wake word works
+# everywhere without dropping to a shell — the §3 "recoverable in-app"
+# contract. The spec is pinned to the [local-voice] extra in pyproject.toml so
+# the two never drift.
_LOCAL_SPEECH_PACKAGE = "faster-whisper>=1.0"
_local_speech_install_lock = threading.Lock()
@@ -616,7 +653,7 @@ _local_speech_install: dict[str, str] = {"state": "idle", "message": ""}
def _run_local_speech_install() -> None:
- """Blocking pip install, run on a daemon thread; updates shared state."""
+ """Install the engine and wake checkpoint on a daemon worker thread."""
import importlib
from jarvis.setup.dependencies import install_pip_package
@@ -625,11 +662,22 @@ def _run_local_speech_install() -> None:
# back to a source build (av needs FFmpeg dev libs, ctranslate2 a
# toolchain). No wheel for this Python/OS → fail fast with the honest
# classify_pip_failure diagnosis instead (BUG-059).
- ok, message = install_pip_package(_LOCAL_SPEECH_PACKAGE, only_binary=True)
- # Let this same process's find_spec see the freshly-installed package, so the
- # status endpoint flips to available without a restart (the wake PIPELINE
- # still needs a restart to actually use it — the UI says so).
+ if _local_whisper_available():
+ ok, message = True, "Local speech engine already installed."
+ else:
+ ok, message = install_pip_package(_LOCAL_SPEECH_PACKAGE, only_binary=True)
+ # Let this same process's find_spec see the freshly-installed package. Once
+ # its model is cached, the status endpoint reapplies the wake plan live when
+ # a desktop speech pipeline is present.
importlib.invalidate_caches()
+ if ok:
+ model_name = _local_wake_model_name()
+ try:
+ _download_local_wake_model(model_name)
+ message = f"Local speech engine and wake model '{model_name}' are ready."
+ except Exception as exc: # noqa: BLE001 — surface an honest retry state
+ ok = False
+ message = f"Could not download wake model '{model_name}': {exc}"
with _local_speech_install_lock:
_local_speech_install["state"] = "done" if ok else "error"
_local_speech_install["message"] = message
@@ -638,13 +686,13 @@ def _run_local_speech_install() -> None:
@router.post("/wake-word/enable-local-speech")
async def enable_local_speech(request: Request) -> dict[str, object]:
- """Install the local-speech pack (faster-whisper) so ANY wake word works.
+ """Install faster-whisper plus its wake model so any wake word works.
Idempotent and non-blocking: returns immediately with a ``state`` the UI
polls via the status endpoint. A second call while a run is in flight does
not start a duplicate install.
"""
- if _local_whisper_available():
+ if _local_speech_ready():
return {
"state": "done",
"already": True,
@@ -671,14 +719,19 @@ async def enable_local_speech(request: Request) -> dict[str, object]:
@router.get("/wake-word/enable-local-speech/status")
async def enable_local_speech_status(request: Request) -> dict[str, object]:
"""Report the local-speech install progress + whether the pack is present."""
- available = _local_whisper_available()
+ available = _local_speech_ready()
with _local_speech_install_lock:
state = _local_speech_install["state"]
message = _local_speech_install["message"]
- # Present but this process never ran the installer (e.g. installed manually,
- # or a prior run before a restart) → report done so the UI is truthful.
+ # Ready but this process never ran the installer (e.g. installed manually,
+ # or by a prior app run) → report done so the UI is truthful.
if available and state in ("idle", "running"):
state = "done"
+ elif state == "done" and not available:
+ # A successful downloader exit is not enough if the cache cannot be
+ # opened afterwards. Keep the UI in a retryable, honest state.
+ state = "error"
+ message = "The local speech install finished, but its wake model is not readable."
applied_live = False
if available:
try:
diff --git a/pyproject.toml b/pyproject.toml
index 6ba7668a84..0b4f2dd633 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -73,8 +73,10 @@ dependencies = [
# Vosk is Apache-2.0, torch-free, ~7 MB wheel with bundled libvosk, official
# CPU wheels for macOS and Linux x86+ARM plus Windows x86/x64. Upstream does
# not ship Windows ARM64, so that one target skips Vosk and retains the
- # ONNX/browser/cloud wake paths. The per-language model (~45 MB)
- # is fetched once at setup into data/wake_models/vosk/<lang>/, NOT bundled.
+ # ONNX/browser/cloud wake paths. Each per-language model is ~45 MB and is
+ # fetched into data/wake_models/vosk/<lang>/, NOT bundled. The advertised
+ # full installer caches every onboarding language; headless/base setup keeps
+ # only its configured language.
# Lazy-imported in vosk_kws_provider.py; base `import jarvis` stays clean.
# CAP below 0.3.45: that release ships NO macOS wheel (linux/win only), so a
# floor above 0.3.44 bricks every Mac install (AP-23; caught by the CI
diff --git a/tests/unit/install/test_installer_flow.py b/tests/unit/install/test_installer_flow.py
index 10fd9be9d9..4781b3ebe9 100644
--- a/tests/unit/install/test_installer_flow.py
+++ b/tests/unit/install/test_installer_flow.py
@@ -106,6 +106,27 @@ def test_headless_pip_plan_stays_base_floor(capsys) -> None:
assert ".[desktop]" not in out
+def test_full_profile_prefetches_every_wake_language(capsys) -> None:
+ installer.step_models(full_profile=True, dry_run=True)
+ out = capsys.readouterr().out
+ assert "--prefetch-all-wake-languages" in out
+
+
+def test_headless_prefetch_keeps_only_configured_wake_language(capsys) -> None:
+ installer.step_models(full_profile=False, dry_run=True)
+ out = capsys.readouterr().out
+ assert "--prefetch" in out
+ assert "--prefetch-all-wake-languages" not in out
+
+
+def test_macos_fresh_install_ci_exercises_advertised_full_profile() -> None:
+ workflow = (REPO / ".github" / "workflows" / "fresh-install-smoke.yml").read_text(
+ encoding="utf-8"
+ )
+ assert 'if [ "${{ matrix.os }}" = "macos-latest" ]; then' in workflow
+ assert "installer.py --with-desktop --no-launch" in workflow
+
+
def test_full_profile_failure_stops_desktop_install(monkeypatch) -> None:
results = iter([0, 0, 1])
monkeypatch.setattr(installer, "run_quiet", lambda *args, **kwargs: next(results))
diff --git a/tests/unit/setup/test_model_report.py b/tests/unit/setup/test_model_report.py
index a87568820f..f7278e59fc 100644
--- a/tests/unit/setup/test_model_report.py
+++ b/tests/unit/setup/test_model_report.py
@@ -87,6 +87,80 @@ def test_pending_vosk_download_is_optional_not_a_failure(monkeypatch) -> None:
assert mr.report_complete(items) is True # required set is still satisfied
+def test_full_profile_requires_every_onboarding_wake_model(monkeypatch) -> None:
+ _patch_bundled(monkeypatch)
+ monkeypatch.setattr(mr, "_supported_wake_languages", lambda: ("en", "de", "es"))
+ monkeypatch.setattr(mr, "_vosk_present", lambda lang, _data: lang != "es")
+ monkeypatch.setattr(mr, "_faster_whisper_available", lambda: True)
+ monkeypatch.setattr(mr, "_whisper_models_needed", lambda _cfg: ["base"])
+ monkeypatch.setattr(mr, "_whisper_cached", lambda _name: True)
+
+ items = mr.voice_model_report(_Cfg(), full_profile=True)
+
+ wake = [i for i in items if "custom-wake model" in i.label]
+ assert [i.label for i in wake] == [
+ "custom-wake model 'en'",
+ "custom-wake model 'de'",
+ "custom-wake model 'es'",
+ ]
+ assert all(i.required for i in wake)
+ assert mr.report_complete(items) is False
+
+
+def test_full_profile_requires_local_whisper_and_cached_wake_model(monkeypatch) -> None:
+ _patch_bundled(monkeypatch)
+ monkeypatch.setattr(mr, "_supported_wake_languages", lambda: ("en", "de", "es"))
+ monkeypatch.setattr(mr, "_vosk_present", lambda *_a, **_kw: True)
+ monkeypatch.setattr(mr, "_faster_whisper_available", lambda: True)
+ monkeypatch.setattr(mr, "_whisper_models_needed", lambda _cfg: ["base"])
+ monkeypatch.setattr(mr, "_whisper_cached", lambda _name: False)
+
+ items = mr.voice_model_report(_Cfg(), full_profile=True)
+
+ local = next(i for i in items if "local speech model 'base'" in i.label)
+ assert local.required is True
+ assert local.present is False
+ assert mr.report_complete(items) is False
+
+
+def test_full_profile_verifies_base_when_config_cannot_load(monkeypatch) -> None:
+ _patch_bundled(monkeypatch)
+ monkeypatch.setattr(mr, "_load_config", lambda: None)
+ monkeypatch.setattr(mr, "_supported_wake_languages", lambda: ("en", "de", "es"))
+ monkeypatch.setattr(mr, "_vosk_present", lambda *_a, **_kw: True)
+ monkeypatch.setattr(mr, "_faster_whisper_available", lambda: True)
+ checked: list[str] = []
+ monkeypatch.setattr(
+ mr,
+ "_whisper_cached",
+ lambda name: checked.append(name) or True,
+ )
+
+ items = mr.voice_model_report(full_profile=True)
+
+ assert checked == ["base"]
+ local = next(i for i in items if "local speech model 'base'" in i.label)
+ assert local.required is True and local.present is True
+
+
+def test_full_profile_fails_closed_when_language_catalog_cannot_load(monkeypatch) -> None:
+ _patch_bundled(monkeypatch)
+ monkeypatch.setattr(
+ mr,
+ "_supported_wake_languages",
+ lambda: (_ for _ in ()).throw(RuntimeError("catalog unavailable")),
+ )
+ monkeypatch.setattr(mr, "_faster_whisper_available", lambda: True)
+ monkeypatch.setattr(mr, "_whisper_models_needed", lambda _cfg: ["base"])
+ monkeypatch.setattr(mr, "_whisper_cached", lambda _name: True)
+
+ items = mr.voice_model_report(_Cfg(), full_profile=True)
+
+ catalog = next(i for i in items if "language catalog" in i.label)
+ assert catalog.required is True and catalog.present is False
+ assert mr.report_complete(items) is False
+
+
def test_installed_whisper_reports_cache_hit_per_model(monkeypatch) -> None:
_patch_bundled(monkeypatch)
monkeypatch.setattr(mr, "_vosk_present", lambda *_a, **_kw: True)
diff --git a/tests/unit/setup/test_prefetch.py b/tests/unit/setup/test_prefetch.py
index ff5cd990ba..406f04769c 100644
--- a/tests/unit/setup/test_prefetch.py
+++ b/tests/unit/setup/test_prefetch.py
@@ -41,6 +41,26 @@ def test_download_failure_is_nonfatal(monkeypatch) -> None:
assert any("first launch" in line for line in lines) # honest fallback note
+def test_broken_config_still_prefetches_packaged_wake_model(monkeypatch) -> None:
+ downloaded: list[str] = []
+ monkeypatch.setattr(prefetch, "_wakeword_bundle_present", lambda: True)
+ monkeypatch.setattr(prefetch, "_faster_whisper_available", lambda: True)
+ monkeypatch.setattr(prefetch, "_download_whisper_model", downloaded.append)
+ monkeypatch.setattr(
+ prefetch,
+ "_whisper_models_needed",
+ lambda: (_ for _ in ()).throw(RuntimeError("config unreadable")),
+ )
+ monkeypatch.setattr(prefetch, "_ensure_vosk", lambda *_a, **_kw: object())
+ lines: list[str] = []
+
+ rc = prefetch.prefetch_all(echo=lines.append)
+
+ assert rc == 1
+ assert downloaded == ["base"]
+ assert any("packaged 'base'" in line for line in lines)
+
+
def test_whisper_models_needed_includes_utterance_model_for_local_provider(
monkeypatch,
) -> None:
diff --git a/tests/unit/setup/test_prefetch_vosk.py b/tests/unit/setup/test_prefetch_vosk.py
index dca2dfb7e1..d4b9c0dc5c 100644
--- a/tests/unit/setup/test_prefetch_vosk.py
+++ b/tests/unit/setup/test_prefetch_vosk.py
@@ -22,6 +22,56 @@ def test_prefetch_calls_vosk_ensure(monkeypatch):
assert rc == 0
+def test_full_prefetch_downloads_every_onboarding_language(monkeypatch):
+ """The desktop installer runs before the user chooses a UI language."""
+ seen: list[str | None] = []
+
+ monkeypatch.setattr(
+ prefetch,
+ "_ensure_vosk",
+ lambda language, **_kw: seen.append(language) or object(),
+ raising=False,
+ )
+ monkeypatch.setattr(
+ prefetch,
+ "_supported_vosk_languages",
+ lambda: ("en", "de", "es"),
+ )
+ monkeypatch.setattr(prefetch, "_faster_whisper_available", lambda: False)
+
+ rc = prefetch.prefetch_all(
+ echo=lambda _line: None,
+ all_wake_languages=True,
+ )
+
+ assert rc == 0
+ assert seen == ["en", "de", "es"]
+
+
+def test_full_prefetch_continues_after_one_language_fails(monkeypatch):
+ seen: list[str | None] = []
+
+ def fake_ensure(language, **_kw):
+ seen.append(language)
+ return None if language == "de" else object()
+
+ monkeypatch.setattr(prefetch, "_ensure_vosk", fake_ensure, raising=False)
+ monkeypatch.setattr(
+ prefetch,
+ "_supported_vosk_languages",
+ lambda: ("en", "de", "es"),
+ )
+ monkeypatch.setattr(prefetch, "_faster_whisper_available", lambda: False)
+
+ rc = prefetch.prefetch_all(
+ echo=lambda _line: None,
+ all_wake_languages=True,
+ )
+
+ assert rc == 1
+ assert seen == ["en", "de", "es"]
+
+
def test_vosk_none_result_marks_prefetch_failed(monkeypatch):
"""A non-fatal fetch miss (offline mirror, etc.) must flip the honest rc."""
monkeypatch.setattr(prefetch, "_ensure_vosk", lambda *_a, **_kw: None, raising=False)
diff --git a/tests/unit/ui/test_wake_local_speech_install.py b/tests/unit/ui/test_wake_local_speech_install.py
index 14a4d98913..9595ff8366 100644
--- a/tests/unit/ui/test_wake_local_speech_install.py
+++ b/tests/unit/ui/test_wake_local_speech_install.py
@@ -1,7 +1,7 @@
"""POST/GET /api/settings/wake-word/enable-local-speech — the in-app installer
-that pulls faster-whisper so ANY wake phrase works on a fresh install.
+that pulls faster-whisper and its wake checkpoint for any phrase.
-The install itself (pip) is mocked; these lock the endpoint's state machine:
+The package and model downloads are mocked; these lock the endpoint state:
- already installed → done/already, no pip call
- fresh install → pip runs, status flips to done
- pip failure → status reports error with the reason
@@ -40,7 +40,7 @@ class _SyncThread:
def test_already_installed_returns_done_without_pip(monkeypatch) -> None:
_reset_state()
- monkeypatch.setattr(sr, "_local_whisper_available", lambda: True)
+ monkeypatch.setattr(sr, "_local_speech_ready", lambda: True)
called = []
monkeypatch.setattr(
"jarvis.setup.dependencies.install_pip_package",
@@ -57,28 +57,40 @@ def test_already_installed_returns_done_without_pip(monkeypatch) -> None:
def test_fresh_install_runs_pip_and_status_flips_to_done(monkeypatch) -> None:
_reset_state()
- monkeypatch.setattr(sr, "_local_whisper_available", lambda: False)
+ ready = {"engine": False, "model": False}
+ monkeypatch.setattr(sr, "_local_speech_ready", lambda: ready["model"])
+ monkeypatch.setattr(sr, "_local_whisper_available", lambda: ready["engine"])
+ monkeypatch.setattr(sr, "_local_wake_model_name", lambda: "base")
packages: list[str] = []
+ models: list[str] = []
def fake_install(pkg, **_kw):
packages.append(pkg)
+ ready["engine"] = True
return True, "install reported success"
+ def fake_download(name: str) -> None:
+ models.append(name)
+ ready["model"] = True
+
monkeypatch.setattr("jarvis.setup.dependencies.install_pip_package", fake_install)
+ monkeypatch.setattr(sr, "_download_local_wake_model", fake_download)
monkeypatch.setattr(sr.threading, "Thread", _SyncThread)
client = _client()
post = client.post("/api/settings/wake-word/enable-local-speech").json()
assert post["state"] == "running"
assert packages == [sr._LOCAL_SPEECH_PACKAGE]
+ assert models == ["base"]
status = client.get("/api/settings/wake-word/enable-local-speech/status").json()
assert status["state"] == "done"
- assert "success" in status["message"]
+ assert "wake model 'base'" in status["message"]
def test_pip_failure_is_reported_as_error(monkeypatch) -> None:
_reset_state()
+ monkeypatch.setattr(sr, "_local_speech_ready", lambda: False)
monkeypatch.setattr(sr, "_local_whisper_available", lambda: False)
def fake_install(pkg, **_kw):
@@ -96,10 +108,10 @@ def test_pip_failure_is_reported_as_error(monkeypatch) -> None:
def test_status_reports_available_when_present(monkeypatch) -> None:
- # Present but this process never ran the installer (installed manually or in a
- # prior run) → status is truthful without a restart.
+ # Present but this process never ran the installer (installed manually or in
+ # a prior run) → status is truthful without a restart.
_reset_state()
- monkeypatch.setattr(sr, "_local_whisper_available", lambda: True)
+ monkeypatch.setattr(sr, "_local_speech_ready", lambda: True)
status = _client().get(
"/api/settings/wake-word/enable-local-speech/status"
@@ -109,11 +121,26 @@ def test_status_reports_available_when_present(monkeypatch) -> None:
assert status["state"] == "done"
+def test_done_state_without_readable_model_becomes_retryable_error(monkeypatch) -> None:
+ _reset_state()
+ sr._local_speech_install["state"] = "done"
+ sr._local_speech_install["message"] = "download reported success"
+ monkeypatch.setattr(sr, "_local_speech_ready", lambda: False)
+
+ status = _client().get(
+ "/api/settings/wake-word/enable-local-speech/status"
+ ).json()
+
+ assert status["available"] is False
+ assert status["state"] == "error"
+ assert "not readable" in status["message"]
+
+
def test_available_pack_reapplies_current_wake_plan_live(monkeypatch) -> None:
from jarvis.core.config import WakeWordConfig
_reset_state()
- monkeypatch.setattr(sr, "_local_whisper_available", lambda: True)
+ monkeypatch.setattr(sr, "_local_speech_ready", lambda: True)
class _Pipeline:
plan = None
@@ -149,7 +176,9 @@ def test_install_is_wheel_only_for_end_users(monkeypatch) -> None:
# BUG-059: pip must never fall back to a source build on an end-user
# machine (av needs FFmpeg dev libs) — the route pins only_binary=True.
_reset_state()
+ monkeypatch.setattr(sr, "_local_speech_ready", lambda: False)
monkeypatch.setattr(sr, "_local_whisper_available", lambda: False)
+ monkeypatch.setattr(sr, "_download_local_wake_model", lambda _name: None)
kwargs: list[dict] = []
def fake_install(pkg, **kw):
@@ -161,3 +190,59 @@ def test_install_is_wheel_only_for_end_users(monkeypatch) -> None:
_client().post("/api/settings/wake-word/enable-local-speech")
assert kwargs and kwargs[0].get("only_binary") is True
_reset_state()
+
+
+def test_existing_engine_still_downloads_missing_wake_checkpoint(monkeypatch) -> None:
+ _reset_state()
+ ready = {"model": False}
+ monkeypatch.setattr(sr, "_local_speech_ready", lambda: ready["model"])
+ monkeypatch.setattr(sr, "_local_whisper_available", lambda: True)
+ monkeypatch.setattr(sr, "_local_wake_model_name", lambda: "base")
+ pip_calls: list[str] = []
+ models: list[str] = []
+
+ monkeypatch.setattr(
+ "jarvis.setup.dependencies.install_pip_package",
+ lambda pkg, **_kw: pip_calls.append(pkg) or (True, "unexpected"),
+ )
+
+ def fake_download(name: str) -> None:
+ models.append(name)
+ ready["model"] = True
+
+ monkeypatch.setattr(sr, "_download_local_wake_model", fake_download)
+ monkeypatch.setattr(sr.threading, "Thread", _SyncThread)
+
+ client = _client()
+ client.post("/api/settings/wake-word/enable-local-speech")
+ status = client.get(
+ "/api/settings/wake-word/enable-local-speech/status"
+ ).json()
+
+ assert pip_calls == []
+ assert models == ["base"]
+ assert status["state"] == "done"
+ assert status["available"] is True
+
+
+def test_model_download_failure_is_reported_as_error(monkeypatch) -> None:
+ _reset_state()
+ monkeypatch.setattr(sr, "_local_speech_ready", lambda: False)
+ monkeypatch.setattr(sr, "_local_whisper_available", lambda: True)
+ monkeypatch.setattr(sr, "_local_wake_model_name", lambda: "base")
+ monkeypatch.setattr(
+ sr,
+ "_download_local_wake_model",
+ lambda _name: (_ for _ in ()).throw(OSError("model mirror down")),
+ )
+ monkeypatch.setattr(sr.threading, "Thread", _SyncThread)
+
+ client = _client()
+ client.post("/api/settings/wake-word/enable-local-speech")
+ status = client.get(
+ "/api/settings/wake-word/enable-local-speech/status"
+ ).json()
+
+ assert status["state"] == "error"
+ assert status["available"] is False
+ assert "model mirror down" in status["message"]