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

OSError: [Errno -9986] Internal PortAudio error #430

Closed
fabihoern opened this issue Jan 9, 2021 · 4 comments
Closed

OSError: [Errno -9986] Internal PortAudio error #430

fabihoern opened this issue Jan 9, 2021 · 4 comments
Labels
osx Affects Mac OS X src-coreaudio Apple Core Audio Host API src/hostapi/coreaudio

Comments

@fabihoern
Copy link

Hi,

I'm programming with PortAudio / PyAudio. I installed the library with homebrew. On my windows Pc I never got this error.
Desktop

  • OS: Mac OS
  • OS Version: Big Sur 11.1
  • PortAudio version: latest
  • PyCharm

Simple sr code:
import speech_recognition as sr

r = sr.Recognizer()
mic = sr.Microphone()
with mic as source:
r.adjust_for_ambient_noise(source)
audio = r.listen(source)
transcript = r.recognize_google(audio)
print(transcript)

I always got this error:

||PaMacCore (AUHAL)|| Error on line 1277: err='-66748', msg=Unknown Error
Traceback (most recent call last):
File "/Users/fabianhoernlein/Desktop/testsr/main.py", line 6, in
with mic as so
File "/Users/fabianhoernlein/Desktop/testsr/venv/lib/python3.9/site-packages/speech_recognition/init.py", line 138, in enter
self.audio.open(
File "/Users/fabianhoernlein/Desktop/testsr/venv/lib/python3.9/site-packages/pyaudio.py", line 750, in open
stream = Stream(self, *args, **kwargs)
File "/Users/fabianhoernlein/Desktop/testsr/venv/lib/python3.9/site-packages/pyaudio.py", line 441, in init
self._stream = pa.open(**arguments)
OSError: [Errno -9986] Internal PortAudio error

Process finished with exit code 1

I tryed a lot around packages, reinstall, update, ...
thx for help,
Fabi

@arkwad
Copy link

arkwad commented Jan 16, 2021

HI,
I have a similar Issue on

  • Machine: Macbook Air Early 2015
  • OS Version: Big Sur 11.1
  • PortAudio version: 19.6.0

||PaMacCore (AUHAL)|| Error on line 1277: err='-66748', msg=Unknown Error
Traceback (most recent call last):
File "/Users/arkwad/githome/dsp/./audio_sampler.py", line 7, in
myrecording = sd.rec(int(seconds * fs), samplerate=fs, channels=1)
File "/usr/local/lib/python3.9/site-packages/sounddevice.py", line 274, in rec
ctx.start_stream(InputStream, samplerate, ctx.input_channels,
File "/usr/local/lib/python3.9/site-packages/sounddevice.py", line 2573, in start_stream
self.stream = StreamClass(samplerate=samplerate,
File "/usr/local/lib/python3.9/site-packages/sounddevice.py", line 1415, in init
_StreamBase.init(self, kind='input', wrap_callback='array',
File "/usr/local/lib/python3.9/site-packages/sounddevice.py", line 892, in init
_check(_lib.Pa_OpenStream(self._ptr, iparameters, oparameters,
File "/usr/local/lib/python3.9/site-packages/sounddevice.py", line 2738, in _check
raise PortAudioError(errormsg, err)
sounddevice.PortAudioError: Error opening InputStream: Internal PortAudio error [PaErrorCode -9986]

I tried to run guest Ubuntu VM under VirtualBox with passing input audio to it and works as expected there so it is something specific for MacOS.

Please take a look as probably ppl have a similar problem

Test snippet:
import sounddevice as sd
from scipy.io.wavfile import write

fs = 44100 # Sample rate
seconds = 3 # Duration of recording
myrecording = sd.rec(int(seconds * fs), samplerate=fs, channels=2)
sd.wait() # Wait until recording is finished
write('output.wav', fs, myrecording) # Save as WAV file

//Arek

@arkwad
Copy link

arkwad commented Jan 16, 2021

I believe also this is a duplicated issue as #395 looks the same

@philburk
Copy link
Collaborator

Yes, this is a DUP of #395
A fix is pending in #356

@arkwad
Copy link

arkwad commented Jan 16, 2021

Actually based on comments from other connected issues:
brew uninstall portaudio && brew install portaudio --HEAD worked for me as WA so it looks like needed changes are already there

@RossBencina RossBencina added osx Affects Mac OS X src-coreaudio Apple Core Audio Host API src/hostapi/coreaudio labels Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
osx Affects Mac OS X src-coreaudio Apple Core Audio Host API src/hostapi/coreaudio
Projects
None yet
Development

No branches or pull requests

4 participants