kaldi-active-grammar icon indicating copy to clipboard operation
kaldi-active-grammar copied to clipboard

PortAudioError from sounddevice

Open ileben opened this issue 4 years ago • 6 comments

I'm getting the error below on startup when running Caster with Kaldi backend. I've tried kaldi-active-grammar versions 1.8.0 and 1.8.1, as well as both the latest medium and big models (kaldi_model_daanzu_20200905_1ep-mediumlm, kaldi_model_daanzu_20200905_1ep-biglm). I'm on an enterprise Dell workstation with builtin Realtek audio. I've tried a cheap USB headset as well as the Scarlett 2i2 audio interface. The crash happens in all configurations.

    If this free, open source engine is valuable to you, please consider donating
    https://github.com/daanzu/kaldi-active-grammar
    Disable message by calling `kaldi_active_grammar.disable_donation_message()`
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]

ileben avatar Dec 03 '20 12:12 ileben

Reposting some advice from chat. You might try audio_self_threaded=False

you can modify the bat python -m dragonfly load-directory . --engine kaldi --engine-options "model_dir=kaldi_model, vad_padding_end_ms=300, audio_self_threaded=False"

List of kaldi engine parameters for configuration.

LexiconCode avatar Dec 03 '20 13:12 LexiconCode

audio_self_threaded=False did not resolve the issue.

ileben avatar Dec 04 '20 03:12 ileben

I have tried Python 3.8 with the latest version of sounddevice, still getting the same crash.

ileben avatar Dec 04 '20 04:12 ileben

Here is my solution - I've also posted this in https://github.com/spatialaudio/python-sounddevice/issues/233 image

ileben avatar Dec 04 '20 05:12 ileben

It seems that somewhere along the stack at least one of the libraries involved should ask for (or if not possible at least check for) microphone permissions and provide the user with a better error message and guidance for what to do.

System info: OS Name Microsoft Windows 10 Enterprise Version 10.0.18363 Build 18363

Issue also submitted to sounddevice https://github.com/spatialaudio/python-sounddevice/issues/293

ileben avatar Dec 04 '20 05:12 ileben

@ileben Thanks for figuring this out and posting the solution! I will at least add a warning suggesting to check this upon error.

daanzu avatar Dec 04 '20 05:12 daanzu