notalentgeek
notalentgeek

Reputation: 5779

I have trouble with PyAudio does not detect input device

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.

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

Answers (2)

notalentgeek
notalentgeek

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

Logic1
Logic1

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

Related Questions