I'm trying to select a device to use when I go to record using the PyAudio library in Python but I don't know how to do so. I found this code online that shows all the available input devices:
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))
This works however, how do I select a device to use from this list? I can't seem to find anywhere online about selecting a device to use so if anyone could help me out that would be great, thanks.