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:
parent
a53db44d40
commit
e80489135b
1 changed files with 8 additions and 1 deletions
|
|
@ -81,8 +81,15 @@ def detect_audio_environment() -> dict:
|
||||||
warnings.append("No audio input/output devices detected")
|
warnings.append("No audio input/output devices detected")
|
||||||
except Exception:
|
except Exception:
|
||||||
warnings.append("Audio subsystem error (PortAudio cannot query devices)")
|
warnings.append("Audio subsystem error (PortAudio cannot query devices)")
|
||||||
except (ImportError, OSError):
|
except ImportError:
|
||||||
warnings.append("Audio libraries not installed (pip install sounddevice numpy)")
|
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 {
|
return {
|
||||||
"available": len(warnings) == 0,
|
"available": len(warnings) == 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue