title: How to select a specific input device with PyAudio
body: <p>When recording audio via PyAudio, how do you specify the exact input device to use?</p>
  
  <p>My computer has two microphones, one built-in and one via USB, and I want to record using the USB mic. The <a href="https://people.csail.mit.edu/hubert/pyaudio/docs/#class-stream" rel="noreferrer">Stream class</a> has an <code>input_device_index</code> for selecting the device, but it's unclear how this index correlates to the devices. For example, how do I know which device index 0 refers to? If I had to guess, I'd say 0 refers to the built-in device while 1 refers to the USB device, but I'd like to find some programmatic way of confirming this. On Linux, is there a way to get a list of these indexes and the devices they refer to?</p>