From 358973686f0afcd2c0b7d0ddc5cceb5609b06590 Mon Sep 17 00:00:00 2001 From: b84330808 Date: Fri, 13 Nov 2026 01:09:43 +0900 Subject: [PATCH 1/3] fix(omnivoice-gguf): find the bundled runtime from a staged app environment (#4051) An installed app runs a copy of backend/ staged in its runtime folder (/project). That copy has no bin/, while the installer keeps the GGUF runtime in resources/bin, so the engine's `/bin` lookup reported the runtime as missing. The desktop app now passes resources/bin to the backend as OMNIVOICE_GGUF_BIN_DIR, the same way it already hands over the web UI (OMNIVOICE_FRONTEND_DIST). The backend reads the binary and checksums.sha256 from that folder and keeps `/bin` for source checkouts and builds that run from resources/. --- backend/engines/omnivoice_gguf/backend.py | 22 ++++++++- docs/engines/omnivoice-gguf.md | 4 ++ electron/src/main/backend-setup.test.ts | 19 ++++++++ electron/src/main/backend.ts | 11 +++++ tests/backend/engines/test_omnivoice_gguf.py | 48 ++++++++++++++++++++ tests/test_gguf_desktop_bundle.py | 12 +++-- 6 files changed, 111 insertions(+), 5 deletions(-) diff --git a/backend/engines/omnivoice_gguf/backend.py b/backend/engines/omnivoice_gguf/backend.py index f03eed9932..eca250976b 100644 --- a/backend/engines/omnivoice_gguf/backend.py +++ b/backend/engines/omnivoice_gguf/backend.py @@ -84,6 +84,12 @@ #: ``bin/checksums.sha256``. backend/engines/omnivoice_gguf/ → root. _REPO_ROOT = _PKG_DIR.parent.parent.parent +#: Absolute directory that holds the bundled runtime, set by the desktop app. +#: An installed app runs a copy of ``backend/`` staged in its runtime folder +#: (``/project``), which has no ``bin/``; the installer keeps +#: the runtime in ``resources/bin`` (#4051). +BIN_DIR_ENV = "OMNIVOICE_GGUF_BIN_DIR" + #: HuggingFace repo ID for the quants. Pinned by SHA via ``quant_map.json``. _HF_REPO_ID = "Serveurperso/OmniVoice-GGUF" @@ -133,13 +139,25 @@ def _platform_slug() -> str: return "linux-x86_64" +def _bin_dir() -> Path: + """Directory of the bundled runtime and its ``checksums.sha256``. + + ``OMNIVOICE_GGUF_BIN_DIR`` when it is an absolute path, else ``bin/`` at + the repo root (source checkouts and builds that run from ``resources/``). + """ + raw = os.environ.get(BIN_DIR_ENV, "").strip() + if raw and os.path.isabs(raw): + return Path(raw) + return _REPO_ROOT / "bin" + + def _binary_path(slug: Optional[str] = None) -> Path: """Resolve the on-disk path for the platform binary.""" s = slug or _platform_slug() name = "omnivoice-tts-" + s if s.startswith("windows"): name += ".exe" - return _REPO_ROOT / "bin" / name + return _bin_dir() / name def _generate_timeout_s() -> float: @@ -747,7 +765,7 @@ def _load_checksum_manifest() -> dict[str, str]: :class:`ChecksumManifestError`: an entry that may have declared a checksum must never be skipped silently. """ - manifest = _REPO_ROOT / "bin" / "checksums.sha256" + manifest = _bin_dir() / "checksums.sha256" out: dict[str, str] = {} if not manifest.is_file(): return out diff --git a/docs/engines/omnivoice-gguf.md b/docs/engines/omnivoice-gguf.md index 7eae83a3ce..0602ee0a05 100644 --- a/docs/engines/omnivoice-gguf.md +++ b/docs/engines/omnivoice-gguf.md @@ -146,6 +146,9 @@ The desktop installers ship this native binary under `resources/bin/` Windows on ARM (the x64 binary, run under emulation like the rest of the local backend), macOS Apple Silicon and the Linux AppImage/deb. The Windows binary carries its own Visual C++ runtime, so no redistributable install is needed. +The app passes that folder to the backend as `OMNIVOICE_GGUF_BIN_DIR`, so the +engine finds it wherever the app environment lives +([#4051](https://github.com/debpalash/VoiceStudio/issues/4051)). The Intel Mac download has no binary because Intel Macs cannot run the local backend at all ([macOS install](../install/macos.md)). Store builds (Microsoft Store, Mac App Store, Snap Store) and the Docker image do not include it yet; @@ -394,6 +397,7 @@ log says why once. | Variable | Default | Meaning | | --- | --- | --- | +| `OMNIVOICE_GGUF_BIN_DIR` | `bin/` at the repo root | Absolute folder holding `omnivoice-tts-` and `checksums.sha256`; the desktop app sets it to its `resources/bin/` | | `OMNIVOICE_GGUF_GENERATE_TIMEOUT_S` | (generous built-in) | Per-generation timeout for the spawned binary | | `OMNIVOICE_GGUF_QUANT` | `auto` | Pin a quant (`Q4_K_M`, `Q8_0`, `BF16`, `F32`); overrides Settings | | `OMNIVOICE_GGUF_RESIDENT` | `0` | `1` keeps a bundled `tts-server` loaded between requests (opt-in, see Resident server); overrides Settings | diff --git a/electron/src/main/backend-setup.test.ts b/electron/src/main/backend-setup.test.ts index 572af65c28..261b084ecb 100644 --- a/electron/src/main/backend-setup.test.ts +++ b/electron/src/main/backend-setup.test.ts @@ -118,6 +118,7 @@ vi.mock('./setup-downloads', async (importOriginal) => ({ })); import { BackendSupervisor, + bundledGgufBinPath, bundledUvPath, bundledWebUiPath, isExpectedPipeClose, @@ -1042,6 +1043,24 @@ it('keeps a web UI directory the user pinned themselves', () => { expect(managedBackendSpawnOptions(3900).env.OMNIVOICE_FRONTEND_DIST).toBe('/custom/web'); }); +it('points the GGUF engine at the runtime packaged with this app version', () => { + // #4051: the backend runs from a staged copy of backend/ that has no bin/. + vi.stubEnv('OMNIVOICE_GGUF_BIN_DIR', ''); + stubResourcesPath(join('/opt', 'VoiceStudio', 'resources')); + + const { env } = managedBackendSpawnOptions(3900); + + expect(env.OMNIVOICE_GGUF_BIN_DIR).toBe(join('/opt', 'VoiceStudio', 'resources', 'bin')); + expect(bundledGgufBinPath()).toBe(env.OMNIVOICE_GGUF_BIN_DIR); +}); + +it('keeps a GGUF runtime directory the user pinned themselves', () => { + vi.stubEnv('OMNIVOICE_GGUF_BIN_DIR', '/custom/bin'); + stubResourcesPath(join('/opt', 'VoiceStudio', 'resources')); + + expect(managedBackendSpawnOptions(3900).env.OMNIVOICE_GGUF_BIN_DIR).toBe('/custom/bin'); +}); + it('exposes the current process signal separately from the durable crash journal', async () => { vi.useFakeTimers(); vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('offline'))); diff --git a/electron/src/main/backend.ts b/electron/src/main/backend.ts index 65ee9dbcb6..4b06b7ae62 100644 --- a/electron/src/main/backend.ts +++ b/electron/src/main/backend.ts @@ -540,6 +540,11 @@ export function bundledWebUiPath(): string { return join(backendRoot(), 'frontend', 'dist'); } +/** The OmniVoice GGUF runtime packaged with this app version (omnivoice-tts-bundle.mjs). */ +export function bundledGgufBinPath(): string { + return join(backendRoot(), 'bin'); +} + function samePath(left: string, right: string): boolean { const normalizedLeft = resolve(left); const normalizedRight = resolve(right); @@ -744,6 +749,12 @@ function childEnv( if (app.isPackaged && process.resourcesPath && !env.OMNIVOICE_FRONTEND_DIST?.trim()) { env.OMNIVOICE_FRONTEND_DIST = bundledWebUiPath(); } + // #4051: the managed runtime runs a copy of backend/ staged in the runtime + // folder, which has no bin/, so the GGUF engine's `/bin` lookup found + // no runtime there. Point it at the one shipped in this version's resources. + if (app.isPackaged && process.resourcesPath && !env.OMNIVOICE_GGUF_BIN_DIR?.trim()) { + env.OMNIVOICE_GGUF_BIN_DIR = bundledGgufBinPath(); + } // Region defaults must leave HF_ENDPOINT unset so the backend can probe and // fail over. Only an explicit user endpoint may disable automatic selection. if (platform === 'win32') { diff --git a/tests/backend/engines/test_omnivoice_gguf.py b/tests/backend/engines/test_omnivoice_gguf.py index 40951e8ec7..a2d3bc9929 100644 --- a/tests/backend/engines/test_omnivoice_gguf.py +++ b/tests/backend/engines/test_omnivoice_gguf.py @@ -178,6 +178,54 @@ def test_is_available_passes_when_manifest_absent(monkeypatch, tmp_path, cached_ assert ok is True, reason +def test_installed_app_finds_the_runtime_outside_the_staged_backend( + monkeypatch, tmp_path, cached_weights +): + """#4051 — an installed app runs a copy of backend/ staged in its runtime + folder (``/project``), which has no bin/. The runtime and + its manifest stay in the installer's resources/bin, which the desktop app + passes as OMNIVOICE_GGUF_BIN_DIR.""" + import hashlib + + from engines.omnivoice_gguf import backend as gguf_backend + + project = tmp_path / "project" + project.mkdir() + resources_bin = tmp_path / "resources" / "bin" + resources_bin.mkdir(parents=True) + exe = resources_bin / "omnivoice-tts-linux-x86_64" + exe.write_bytes(b"\x7fELF-real-enough") + exe.chmod(0o755) + digest = hashlib.sha256(exe.read_bytes()).hexdigest() + (resources_bin / "checksums.sha256").write_text( + f"{digest} {exe.name}\n", encoding="utf-8" + ) + monkeypatch.setattr(gguf_backend, "_REPO_ROOT", project) + monkeypatch.setattr(gguf_backend, "_platform_slug", lambda: "linux-x86_64") + monkeypatch.setattr(gguf_backend, "_is_macos_quarantined", lambda p: False) + monkeypatch.setenv("OMNIVOICE_GGUF_BIN_DIR", str(resources_bin)) + + ok, reason = gguf_backend._make_backend_class().is_available() + assert ok is True, reason + assert gguf_backend._binary_path() == exe + assert gguf_backend._load_checksum_manifest() == {exe.name: digest} + + +def test_runtime_dir_defaults_to_the_repo_bin(monkeypatch): + """Source checkouts (no OMNIVOICE_GGUF_BIN_DIR) keep using /bin, and a + relative value is ignored rather than resolved against the working directory.""" + from engines.omnivoice_gguf import backend as gguf_backend + + monkeypatch.delenv("OMNIVOICE_GGUF_BIN_DIR", raising=False) + assert gguf_backend._binary_path("linux-x86_64") == ( + gguf_backend._REPO_ROOT / "bin" / "omnivoice-tts-linux-x86_64" + ) + monkeypatch.setenv("OMNIVOICE_GGUF_BIN_DIR", "bin") + assert gguf_backend._binary_path("linux-x86_64") == ( + gguf_backend._REPO_ROOT / "bin" / "omnivoice-tts-linux-x86_64" + ) + + def test_probe_load_timeout(monkeypatch, tmp_path): """T-04-06 — a hung binary surfaces as subprocess.TimeoutExpired.""" from engines.omnivoice_gguf import backend as gguf_backend diff --git a/tests/test_gguf_desktop_bundle.py b/tests/test_gguf_desktop_bundle.py index fc742a8835..08979f79f8 100644 --- a/tests/test_gguf_desktop_bundle.py +++ b/tests/test_gguf_desktop_bundle.py @@ -81,11 +81,12 @@ def test_release_builds_the_runtime_from_the_release_ref(): assert "release_tag" in build["with"]["ref"] -def test_packaged_layout_matches_the_backend_lookup(): - # The packaged backend runs from resources/, so `/bin` is - # resources/bin — exactly where the installer puts the runtime. +def test_packaged_layout_matches_the_backend_lookup(monkeypatch): + # Without OMNIVOICE_GGUF_BIN_DIR the lookup is `/bin`: resources/bin + # for a backend that runs from resources/ (store builds, a selected Python). from engines.omnivoice_gguf import backend + monkeypatch.delenv(backend.BIN_DIR_ENV, raising=False) assert (backend._REPO_ROOT / "backend" / "engines" / "omnivoice_gguf").resolve() == \ backend._PKG_DIR assert backend._binary_path("windows-x86_64") == backend._REPO_ROOT / "bin" / \ @@ -94,6 +95,11 @@ def test_packaged_layout_matches_the_backend_lookup(): assert "from: '../backend',\n to: 'backend'" in config bundle = (REPO / "electron" / "omnivoice-tts-bundle.mjs").read_text(encoding="utf-8") assert "OMNIVOICE_TTS_RESOURCE_DIR = 'bin'" in bundle + # The managed runtime runs a copy of backend/ staged outside resources/, + # with no bin/ beside it, so the app names resources/bin explicitly (#4051). + main = (REPO / "electron" / "src" / "main" / "backend.ts").read_text(encoding="utf-8") + assert f"env.{backend.BIN_DIR_ENV} = bundledGgufBinPath()" in main + assert "return join(backendRoot(), 'bin');" in main def _run_windows_build(tmp_path: Path, runtime: dict[str, str]): From 5a019da05c853a137a61da25f7080faffc8b9fde Mon Sep 17 00:00:00 2001 From: b84330808 Date: Fri, 13 Nov 2026 01:38:16 +0900 Subject: [PATCH 2/3] Add changelog fragment for #4053 --- changelog.d/4053.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/4053.fixed.md diff --git a/changelog.d/4053.fixed.md b/changelog.d/4053.fixed.md new file mode 100644 index 0000000000..8793a17740 --- /dev/null +++ b/changelog.d/4053.fixed.md @@ -0,0 +1 @@ +The OmniVoice GGUF engine finds its bundled runtime again in installed apps instead of reporting it missing (#4053) From ffae01c3c180b63870de0c9ecd2cd8024ad93789 Mon Sep 17 00:00:00 2001 From: debpalash <4178343+debpalash@users.noreply.github.com> Date: Fri, 13 Nov 2026 18:26:13 +0530 Subject: [PATCH 3/3] changelog: credit #4053 --- changelog.d/4053.fixed.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/4053.fixed.md b/changelog.d/4053.fixed.md index 8793a17740..a6216c0f5b 100644 --- a/changelog.d/4053.fixed.md +++ b/changelog.d/4053.fixed.md @@ -1 +1 @@ -The OmniVoice GGUF engine finds its bundled runtime again in installed apps instead of reporting it missing (#4053) +The OmniVoice GGUF engine finds its bundled runtime again in installed apps instead of reporting it missing — thanks @b84330808! (#4053)