diff --git a/apps/auracast.py b/apps/auracast.py index 37e19b6d..e4d35937 100644 --- a/apps/auracast.py +++ b/apps/auracast.py @@ -675,7 +675,7 @@ async def run_receive( try: if not audio_io.check_audio_output(output): return - except ValueError as error: + except (ValueError, ImportError, OSError) as error: print(error) return @@ -820,7 +820,7 @@ async def run_transmit( try: if not audio_io.check_audio_input(input): return - except ValueError as error: + except (ValueError, ImportError, OSError) as error: print(error) return diff --git a/bumble/audio/io.py b/bumble/audio/io.py index 7bc2b40a..f6566a2d 100644 --- a/bumble/audio/io.py +++ b/bumble/audio/io.py @@ -82,10 +82,13 @@ def check_audio_output(output: str) -> bool: if output == 'device' or output.startswith('device:'): try: import sounddevice - except (ImportError, OSError) as exc: + except ImportError as exc: raise ValueError( - 'audio output not available ' - '(sounddevice python module not installed or failed to load)' + 'audio output not available (sounddevice python module not installed)' + ) from exc + except OSError as exc: + raise ValueError( + 'audio output not available (sounddevice python module failed to load)' ) from exc if output == 'device': @@ -294,10 +297,13 @@ def check_audio_input(input: str) -> bool: if input == 'device' or input.startswith('device:'): try: import sounddevice - except (ImportError, OSError) as exc: + except ImportError as exc: raise ValueError( - 'audio input not available ' - '(sounddevice python module not installed or failed to load)' + 'audio input not available (sounddevice python module not installed)' + ) from exc + except OSError as exc: + raise ValueError( + 'audio input not available (sounddevice python module failed to load)' ) from exc if input == 'device':