I’m sorry to report that I have very little experience with troublesome audio inputs. Mine have behaved well with the hardware I’m using.
The input_device
is an integer between 0 and the number of devices reported by port audio (pyaudio.PyAudio().get_device_count()
)
Reading up on how Speechrecognition and PyAudio uses this index, it seems you might be able to find the correct index by running this script:
import pyaudio
p = pyaudio.PyAudio()
info = p.get_host_api_info_by_index(0)
numdevices = info.get('deviceCount')
for i in range(0, numdevices):
if (p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0:
print "Input Device id ", i, " - ", p.get_device_info_by_host_api_device_index(0, i).get('name')
This should print all input device id’s and if possible the names. (if I’ve understood everything correctly)
/Åke