get_device_check.py
498 Bytes
import pyaudio
p = pyaudio.PyAudio()
# Print number of available devices
num_devices = p.get_device_count()
print("Number of devices:", num_devices)
# Print details for each device
for i in range(num_devices):
device_info = p.get_device_info_by_index(i)
print("Device", i, " - ", device_info["name"])
print(" Channels: ", device_info["maxInputChannels"], "input / ", device_info["maxOutputChannels"], "output")
print(" Default Sample Rate: ", device_info["defaultSampleRate"])