python-sounddevice
python-sounddevice copied to clipboard
Error from PortAudio unless permission for microphone access given in Windows settings
I am running Microsoft Windows 10 Enterprise 10.0.18363 Build 18363. If I don't manually give microphone permission in Windows settings, sounddevice crashes with an error from PortAudio with a confusing error (below). I was attempting to run Caster voice recognition using kaldi-active-grammar 1.8.1. It seems like one of these (perhaps sounddevice?) should ask or at least check for microphone permissions and provide a better error message to the user with instructions on what to do.
Traceback (most recent call last):
File "C:\Python27-64bit\lib\runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27-64bit\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27-64bit\lib\site-packages\dragonfly\__main__.py", line 408, in <module>
main()
File "C:\Python27-64bit\lib\site-packages\dragonfly\__main__.py", line 403, in main
return_code = func(args)
File "C:\Python27-64bit\lib\site-packages\dragonfly\__main__.py", line 174, in cli_cmd_load
with engine.connection():
File "C:\Python27-64bit\lib\site-packages\dragonfly\engines\base\engine.py", line 50, in __enter__
self._engine.connect()
File "C:\Python27-64bit\lib\site-packages\dragonfly\engines\backend_kaldi\engine.py", line 197, in connect
reconnect_callback=self._options['audio_reconnect_callback'],
File "C:\Python27-64bit\lib\site-packages\dragonfly\engines\backend_kaldi\audio.py", line 228, in __init__
super(VADAudio, self).__init__(**kwargs)
File "C:\Python27-64bit\lib\site-packages\dragonfly\engines\backend_kaldi\audio.py", line 75, in __init__
self._connect(start=start)
File "C:\Python27-64bit\lib\site-packages\dragonfly\engines\backend_kaldi\audio.py", line 89, in _connect
callback=proxy_callback if not self.self_threaded else None,
File "C:\Python27-64bit\lib\site-packages\sounddevice.py", line 1153, in __init__
**_remove_self(locals()))
File "C:\Python27-64bit\lib\site-packages\sounddevice.py", line 861, in __init__
'Error opening {0}'.format(self.__class__.__name__))
File "C:\Python27-64bit\lib\site-packages\sounddevice.py", line 2651, in _check
raise PortAudioError(errormsg, err, hosterror_info)
sounddevice.PortAudioError: Error opening RawInputStream: Unanticipated host error [PaErrorCode -9999]: 'Undefined external error.' [MME error 1]
Thanks for the report.
The confusing error (Undefined external error
) comes from PortAudio.
I think it would be best to report the issue to their issue tracker: https://github.com/PortAudio/portaudio
Once they produce a better error, it will automatically be used in the sounddevice
module as well.