Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8082

Beginners • Re: pyaudio doesnt like 16000 sampling rate

$
0
0
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.

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()
the results of this script were....

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.0
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?

Statistics: Posted by SmagicSman — Thu Mar 07, 2024 8:41 pm



Viewing all articles
Browse latest Browse all 8082

Trending Articles