Reputation: 5779
I made this thread in Raspberry PI Stack Exchange and my problem was solved. Until last week I tried to run my Python application again (both in Raspbian and Ubuntu 16.04) this error appeared again.
OSError: [Errrno -9996] Invalid input device (no default output device)
What I have done so far.
pyaudio.PyAudio().get_device_count()
returns 0
.arecord --device=hw:1,0 --format S16_LE --rate 44100 -c1 test.wav
returns this error.ALSA lib pcm_hw.c:1700:(_snd_pcm_hw_open) Invalid value for card arecord: main:722: audio open error: No such file or directory
Upvotes: 1
Views: 6593
Reputation: 5779
Well the problem is definitely in the PyAudio part. However, some threads mention that the main culprit is miss-connection between PyAudio and PortAudio (although, I have already compiled proper PortAudio version 19 stable).
At this point my solution is to use pyalsaaudio
from https://github.com/larsimmisch/pyalsaaudio. For Python 2.x you can just install it with pip install pyalsaaudio
, however for Python 3.x you need to compile it from the source codes (see instruction in its GitHub page). Note to mention is that pyalsaaudio
only works for Linux. With pyalsaaudio
my Python application is working like usual.
Upvotes: 2
Reputation: 1847
This is not really intended to be an answer but it might be helpful to print a list of all the devices available to pyaudio and see if your USB soundcard is even being recognized.
(Some code from a previous project):
p = pyaudio.PyAudio()
for i in range(p.get_device_count()):#list all available audio devices
dev = p.get_device_info_by_index(i)
print((i,dev['name'],dev['maxInputChannels']))
You may also want to look into alsa and some techniques to list available devices and possibly alsamixer as well.
Upvotes: 0