From e80489135ba8989a2c7409005fdebdae5d770c67 Mon Sep 17 00:00:00 2001 From: Ivelin Tenev Date: Sun, 22 Mar 2026 12:37:18 +0200 Subject: [PATCH] fix: improve error message when PortAudio system library is missing When sounddevice is installed but libportaudio2 is not present on the system, the OSError was caught together with ImportError and showed a generic 'pip install sounddevice' message that sent users down the wrong path. Split the except clause to give a clear, actionable message for the OSError case, including the correct apt/brew commands to install the system library. --- tools/voice_mode.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/voice_mode.py b/tools/voice_mode.py index 78358489..39e6e753 100644 --- a/tools/voice_mode.py +++ b/tools/voice_mode.py @@ -81,8 +81,15 @@ def detect_audio_environment() -> dict: warnings.append("No audio input/output devices detected") except Exception: warnings.append("Audio subsystem error (PortAudio cannot query devices)") - except (ImportError, OSError): + except ImportError: warnings.append("Audio libraries not installed (pip install sounddevice numpy)") + except OSError: + warnings.append( + "PortAudio system library not found -- install it first:\n" + " Linux: sudo apt-get install libportaudio2\n" + " macOS: brew install portaudio\n" + "Then retry /voice on." + ) return { "available": len(warnings) == 0,