Skip to content

The agent that grows with you

fix(voice): honor quoted beep_enabled strings + correct PortAudio OSError hint

Tekniumfe3dc2900993
diff --git a/cli.py b/cli.py
index 14cf9b29f3b..f4223f2e930 100644
--- a/cli.py
+++ b/cli.py
@@ -12154,9 +12154,12 @@ class HermesCLI(CLIAgentSetupMixin, CLICommandsMixin, CLIBillingMixin):
"""Return whether CLI voice mode should play record start/stop beeps."""
try:
from hermes_cli.config import load_config
+ from utils import is_truthy_value
voice_cfg = load_config().get("voice", {})
if isinstance(voice_cfg, dict):
- return bool(voice_cfg.get("beep_enabled", True))
+ # is_truthy_value handles quoted YAML strings like "false"
+ # which bool() would misread as True (#49883).
+ return is_truthy_value(voice_cfg.get("beep_enabled", True), default=True)
except Exception:
pass
return True
diff --git a/hermes_cli/voice.py b/hermes_cli/voice.py
index 27dd2f02ae1..33d40897fb3 100644
--- a/hermes_cli/voice.py
+++ b/hermes_cli/voice.py
@@ -250,10 +250,13 @@ def _beeps_enabled() -> bool:
"""CLI parity: voice.beep_enabled in config.yaml (default True)."""
try:
from hermes_cli.config import load_config
+ from utils import is_truthy_value
voice_cfg = load_config().get("voice", {})
if isinstance(voice_cfg, dict):
- return bool(voice_cfg.get("beep_enabled", True))
+ # is_truthy_value handles quoted YAML strings like "false"
+ # which bool() would misread as True (#49883).
+ return is_truthy_value(voice_cfg.get("beep_enabled", True), default=True)
except Exception:
pass
return True
diff --git a/tests/hermes_cli/test_voice_wrapper.py b/tests/hermes_cli/test_voice_wrapper.py
index c9aac3caf48..0c2652d8a2e 100644
--- a/tests/hermes_cli/test_voice_wrapper.py
+++ b/tests/hermes_cli/test_voice_wrapper.py
@@ -751,3 +751,36 @@ class TestContinuousLoopSimulation:
# The in-flight transcript was suppressed because we stopped mid-flight
assert transcripts == []
assert voice.is_continuous_active() is False
+
+
+class TestBeepsEnabledTruthyStrings:
+ """voice.beep_enabled quoted in YAML ("false"/"off") must disable beeps —
+ bool("false") is True, so the gate must use utils.is_truthy_value (#49883)."""
+
+ def _enabled_with(self, monkeypatch, value):
+ import hermes_cli.voice as voice
+
+ monkeypatch.setattr(
+ "hermes_cli.config.load_config",
+ lambda: {"voice": {"beep_enabled": value}},
+ )
+ return voice._beeps_enabled()
+
+ def test_quoted_false_string_disables(self, monkeypatch):
+ assert self._enabled_with(monkeypatch, "false") is False
+
+ def test_quoted_off_string_disables(self, monkeypatch):
+ assert self._enabled_with(monkeypatch, "off") is False
+
+ def test_quoted_true_string_enables(self, monkeypatch):
+ assert self._enabled_with(monkeypatch, "true") is True
+
+ def test_real_booleans_pass_through(self, monkeypatch):
+ assert self._enabled_with(monkeypatch, True) is True
+ assert self._enabled_with(monkeypatch, False) is False
+
+ def test_missing_key_defaults_true(self, monkeypatch):
+ import hermes_cli.voice as voice
+
+ monkeypatch.setattr("hermes_cli.config.load_config", lambda: {"voice": {}})
+ assert voice._beeps_enabled() is True
diff --git a/tests/tools/test_voice_mode.py b/tests/tools/test_voice_mode.py
index d902b39ef64..f1bb17b567f 100644
--- a/tests/tools/test_voice_mode.py
+++ b/tests/tools/test_voice_mode.py
@@ -706,6 +706,38 @@ class TestAudioRecorder:
with pytest.raises(RuntimeError, match="sounddevice and numpy"):
recorder.start()
+ def test_start_oserror_points_at_portaudio_not_pip(self, monkeypatch):
+ """OSError from _import_audio means PortAudio's shared library is
+ missing — pip can't fix that. The error must point at the system
+ package, not 'pip install sounddevice numpy' (#18432)."""
+ def _fail_import():
+ raise OSError("PortAudio library not found")
+ monkeypatch.setattr("tools.voice_mode._import_audio", _fail_import)
+ monkeypatch.setattr("tools.voice_mode._is_termux_environment", lambda: False)
+
+ from tools.voice_mode import AudioRecorder
+
+ recorder = AudioRecorder()
+ with pytest.raises(RuntimeError) as exc_info:
+ recorder.start()
+ msg = str(exc_info.value)
+ assert "PortAudio system library not found" in msg
+ assert "libportaudio2" in msg
+ assert "pip install" not in msg
+
+ def test_start_oserror_termux_hint(self, monkeypatch):
+ """Same OSError path on Termux points at pkg install portaudio."""
+ def _fail_import():
+ raise OSError("PortAudio library not found")
+ monkeypatch.setattr("tools.voice_mode._import_audio", _fail_import)
+ monkeypatch.setattr("tools.voice_mode._is_termux_environment", lambda: True)
+
+ from tools.voice_mode import AudioRecorder
+
+ recorder = AudioRecorder()
+ with pytest.raises(RuntimeError, match="pkg install portaudio"):
+ recorder.start()
+
def test_start_creates_and_starts_stream(self, mock_sd):
mock_stream = MagicMock()
mock_sd.InputStream.return_value = mock_stream
diff --git a/tools/voice_mode.py b/tools/voice_mode.py
index db491d26e35..4eb1c6462ed 100644
--- a/tools/voice_mode.py
+++ b/tools/voice_mode.py
@@ -891,7 +891,23 @@ class AudioRecorder:
"""
try:
sd, _ = _import_audio()
- except (ImportError, OSError) as e:
+ except OSError as e:
+ # sounddevice imports but PortAudio's shared library is missing —
+ # a pip install can't fix that; point at the system package
+ # instead of misreporting missing Python packages (#18432).
+ if _is_termux_environment():
+ portaudio_hint = " Termux: pkg install portaudio"
+ else:
+ portaudio_hint = (
+ " Linux: sudo apt-get install libportaudio2\n"
+ " macOS: brew install portaudio"
+ )
+ raise RuntimeError(
+ "PortAudio system library not found -- install it first:\n"
+ f"{portaudio_hint}\n"
+ "Then retry /voice on."
+ ) from e
+ except ImportError as e:
raise RuntimeError(
"Voice mode requires sounddevice and numpy.\n"
f"Install with: {sys.executable} -m pip install sounddevice numpy"