Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PortAudioError from sounddevice #41

Open
ileben opened this issue Dec 3, 2020 · 6 comments
Open

PortAudioError from sounddevice #41

ileben opened this issue Dec 3, 2020 · 6 comments

Comments

@ileben
Copy link

ileben commented Dec 3, 2020

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]
@LexiconCode
Copy link

LexiconCode commented Dec 3, 2020

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.

@ileben
Copy link
Author

ileben commented Dec 4, 2020

audio_self_threaded=False did not resolve the issue.

@ileben
Copy link
Author

ileben commented Dec 4, 2020

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

@ileben
Copy link
Author

ileben commented Dec 4, 2020

Here is my solution - I've also posted this in spatialaudio/python-sounddevice#233
image

@ileben
Copy link
Author

ileben commented Dec 4, 2020

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
spatialaudio/python-sounddevice#293

@daanzu
Copy link
Owner

daanzu commented Dec 4, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants