PyAudio IOError: [Errno Invalid input device (no d

2019-07-04 16:52发布

问题:

I am attempting to run a simple python file that uses pyaudio to record input. However whenever I run this file I end up with this error. I had it working once and I have no idea what changed. I have tried

import pyaudio
pa = pyaudio.PyAudio()
print(pa.get_device_count())
0

So I am seeing that it does not detect any valid devices. Is there anyway to specify to pyaudio/portaudio where to look for my input devices. I am running elementary os freya. Any help would be appreciated!

回答1:

Silly as it may seem, I had the same error, and I have been thinking: Drivers missing? Audio board missing? Microphone turned off by the OS?

No, I only needed to plug in the microphone (the actual, material, device).



回答2:

I got this error because I accidentally ran

# p = pyaudio.PyAudio()
# ...
p.terminate()

and then tried to open another stream.



回答3:

The code you paste works on my machine: I get 24. Try to reinstall your audio drivers, I'm assuming you are sure you have a working device connected.