diff --git a/cli.py b/cli.py index 5a3079b99..d16954e4b 100755 --- a/cli.py +++ b/cli.py @@ -3825,7 +3825,8 @@ class HermesCLI: tts_status = " (TTS enabled)" if self._voice_tts else "" try: from hermes_cli.config import load_config - _ptt_key = load_config().get("voice", {}).get("push_to_talk_key", "c-b") + _raw_ptt = load_config().get("voice", {}).get("record_key", "ctrl+b") + _ptt_key = _raw_ptt.lower().replace("ctrl+", "c-").replace("alt+", "a-") except Exception: _ptt_key = "c-b" _ptt_display = _ptt_key.replace("c-", "Ctrl+").upper() @@ -4818,11 +4819,13 @@ class HermesCLI: self._should_exit = True event.app.exit() - # Voice push-to-talk key: configurable via config.yaml (voice.push_to_talk_key) + # Voice push-to-talk key: configurable via config.yaml (voice.record_key) # Default: Ctrl+B (avoids conflict with Ctrl+R readline reverse-search) + # Config uses "ctrl+b" format; prompt_toolkit expects "c-b" format. try: from hermes_cli.config import load_config - _voice_key = load_config().get("voice", {}).get("push_to_talk_key", "c-b") + _raw_key = load_config().get("voice", {}).get("record_key", "ctrl+b") + _voice_key = _raw_key.lower().replace("ctrl+", "c-").replace("alt+", "a-") except Exception: _voice_key = "c-b" diff --git a/tools/voice_mode.py b/tools/voice_mode.py index 27de0fc55..2c3a168bd 100644 --- a/tools/voice_mode.py +++ b/tools/voice_mode.py @@ -291,13 +291,20 @@ class AudioRecorder: if cb: threading.Thread(target=cb, daemon=True).start() - self._stream = sd.InputStream( - samplerate=SAMPLE_RATE, - channels=CHANNELS, - dtype=DTYPE, - callback=_callback, - ) - self._stream.start() + try: + self._stream = sd.InputStream( + samplerate=SAMPLE_RATE, + channels=CHANNELS, + dtype=DTYPE, + callback=_callback, + ) + self._stream.start() + except Exception as e: + self._stream = None + raise RuntimeError( + f"Failed to open audio input stream: {e}. " + "Check that a microphone is connected and accessible." + ) from e self._recording = True logger.info("Voice recording started (rate=%d, channels=%d)", SAMPLE_RATE, CHANNELS)