Skip to content

The agent that grows with you

refactor(stt): look up whisper.cpp through pm directly

ethernet683e845357d3
diff --git a/hermes_platform/resolver/whisper.py b/hermes_platform/resolver/whisper.py
deleted file mode 100644
index 72daa37cc58..00000000000
--- a/hermes_platform/resolver/whisper.py
+++ /dev/null
@@ -1,10 +0,0 @@
-"""Passive lookup of the managed whisper.cpp executable; never provisions it."""
-
-from pathlib import Path
-
-
-def whisper_cpp_binary() -> Path | None:
- from pm import installed_package
-
- installed = installed_package("whispercpp-cpu")
- return installed.binary if installed else None
diff --git a/tests/tools/test_transcription_whisper_cpp.py b/tests/tools/test_transcription_whisper_cpp.py
index 9c7039e3c4c..076c2c33a64 100644
--- a/tests/tools/test_transcription_whisper_cpp.py
+++ b/tests/tools/test_transcription_whisper_cpp.py
@@ -5,6 +5,7 @@ import threading
from functools import partial
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
from pathlib import Path
+from types import SimpleNamespace
import pytest
@@ -64,6 +65,7 @@ def test_local_resolution_is_passive_and_command_override_wins(tmp_path, monkeyp
from tools import transcription_local as local
from tools import transcription_tools as stt
from tools import transcription_whisper_cpp as cpp
+ import pm
from pm.packages import WhisperCppCpu
from pm.store import ALL_TARGETS
@@ -71,7 +73,9 @@ def test_local_resolution_is_passive_and_command_override_wins(tmp_path, monkeyp
assert [t for t in ALL_TARGETS if package.missing_reason(t) is None] == ["win32-arm64"]
monkeypatch.delenv("HERMES_LOCAL_STT_COMMAND", raising=False)
monkeypatch.setenv("HERMES_HOME", str(tmp_path / "profile with spaces"))
- monkeypatch.setattr(cpp, "whisper_cpp_binary", lambda: tmp_path / "program files" / "whisper-cli.exe")
+ binary = tmp_path / "program files" / "whisper-cli.exe"
+ monkeypatch.setattr(pm, "installed_package",
+ lambda name: SimpleNamespace(binary=binary) if name == "whispercpp-cpu" else None)
monkeypatch.setattr(stt, "_HAS_FASTER_WHISPER", False)
calls = []
monkeypatch.setattr(cpp, "ensure_whisper_cpp_models", lambda model: calls.append(model))
diff --git a/tools/transcription_whisper_cpp.py b/tools/transcription_whisper_cpp.py
index 0ab9616b61d..5c588891fd7 100644
--- a/tools/transcription_whisper_cpp.py
+++ b/tools/transcription_whisper_cpp.py
@@ -7,7 +7,6 @@ import shlex
from pathlib import Path
from hermes_constants import get_hermes_home
-from hermes_platform.resolver.whisper import whisper_cpp_binary
logger = logging.getLogger("tools.transcription_tools")
@@ -40,9 +39,13 @@ def _file_signature(path: Path, digest: str) -> tuple | None:
def whisper_cpp_command() -> str | None:
- binary = whisper_cpp_binary()
- if binary is None:
+ import pm
+
+ # Passive: an engine the install does not carry is absent, never fetched here.
+ installed = pm.installed_package("whispercpp-cpu")
+ if installed is None:
return None
+ binary = installed.binary
models = _model_dir()
# The existing command adapter tokenizes with shlex, including on Windows.
quote = lambda path: shlex.quote(path.as_posix())