January 31, 2021
Here is a simple snippet of code that allows you to list audio devices .
Before you can use it, make sure you install portaudio and pyaudio.
$ brew install portaudio
$ pip install pyaudio
import pyaudio
audio = pyaudio.PyAudio()
info = audio.get_host_api_info_by_index(0)
numdevices = info.get('deviceCount')
for i in range(0, numdevices):
if (audio.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0:
print("Input Device id ", i, " - ", audio.get_device_info_by_host_api_device_index(0, i).get('name'))