I was curious what device pyaudio was choosing, ran this script to tell me all of the devices pyaudio recognised and then which it was assigning as the default.
the results of this script were....so it is choosing device 5 but when i use arecord -l it only shows my USB mic. and when I disconnect the USB microphone this script still picks default 32 (now at device 4) but is incapable or recording any audio. So what is default 32?
I believe that this might be some pyaudio default configuration where it abstracts device 5 to my USB mic. Is that the case? Is there a better method to ensure it picks a certain device as default than specifying it when opening a stream?
Code:
import pyaudiop = pyaudio.PyAudio()for i in range(p.get_device_count()): info = p.get_device_info_by_index(i) print(info['index'], info['name'], info['maxInputChannels'])# Get the default input device indexdefault_device_index = p.get_default_input_device_info()['index']print(f"\nDefault Input Device ID: {default_device_index}")# Print the default device informationprint("Default Input Device Info:")default_device_info = p.get_device_info_by_index(default_device_index)for key, value in default_device_info.items(): print(f"{key}: {value}")p.terminate()Code:
0 vc4-hdmi-0: MAI PCM i2s-hifi-0 (hw:0,0) 01 USB PnP Sound Device: Audio (hw:2,0) 12 sysdefault 03 hdmi 04 pulse 325 default 32Default Input Device ID: 5Default Input Device Info:index: 5structVersion: 2name: defaulthostApi: 0maxInputChannels: 32maxOutputChannels: 32defaultLowInputLatency: 0.008684807256235827defaultLowOutputLatency: 0.008684807256235827defaultHighInputLatency: 0.034807256235827665defaultHighOutputLatency: 0.034807256235827665defaultSampleRate: 44100.0I believe that this might be some pyaudio default configuration where it abstracts device 5 to my USB mic. Is that the case? Is there a better method to ensure it picks a certain device as default than specifying it when opening a stream?
Statistics: Posted by SmagicSman — Thu Mar 07, 2024 8:41 pm