pyaudio-OSError: [Errno -9999] Unanticipated host error

RahimEnt picture RahimEnt · Jan 7, 2017 · Viewed 7k times · Source

I just want to run a simple python audio code:

import pyaudio
import wave
import sys

CHUNK = 1024
wf = wave.open("4.wav", 'rb')
# instantiate PyAudio (1)
p = pyaudio.PyAudio()
# open stream (2)
stream = p.open(format=p.get_format_from_width(wf.getsampwidth()),
                channels=wf.getnchannels(),
                rate=wf.getframerate(),
                output=True)

but I got the following error:

Traceback (most recent call last):
  File "rec2.py", line 17, in <module>
    output=True)
  File "C:\Users\Surena\Anaconda3\lib\site-packages\pyaudio.py", line 750,  in open
    stream = Stream(self, *args, **kwargs)
  File "C:\Users\Surena\Anaconda3\lib\site-packages\pyaudio.py", line 441, in __init__
    self._stream = pa.open(**arguments)
OSError: [Errno -9999] Unanticipated host error

I tried another pyaudio record too, the same error came up. I also tried uninstall pyaudio and install it again using pip install pyaudio, but it did not help. I even uninstalled anaconda3 and reinstall it.nothing changed.

what is the problem?

Answer

Nair picture Nair · Jun 29, 2018

I had the same problem, and I fix it just by enable/disable the access to the microphone in Setting>Confidentiality>Microphone (on Windows 10)