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.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user