I am using the Microsoft Azure Kinect DK sensor for a university research project. I am trying to access the microphone data (in dB) heard from each channel. I need this data to further write a delay-and-sum algorithm with it.
I currently have tried many things. Here is the basics of what I have:
FORMAT = pyaudio.paInt16 # We use 16bit format per sample
CHANNELS =7
RATE =16000
CHUNK = 1024 # 1024bytes of data red from a buffer
RECORD_SECONDS = 0.1
WAVE_OUTPUT_FILENAME = "output.wav"
p = pyaudio.PyAudio()
stream = p.open(
format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True)
frames = []
for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
data = stream.read(CHUNK)
a0 = np.fromstring(data,dtype=np.int16)[0::7]
a = a0.tostring()
frames.append(a)
This would theoretically grab the data from the first channel but I keep getting the error "invalid number of channels".
Any help would be appreciated,
Thanks!
I think you are getting error because you are reading audio from default microphone which is not Microsoft Azure Kinect DK in your case. Make sure that Microsoft Azure Kinect DK is set as default. If it is not, then you can either set it to default and then try. Or you can find out the index of Azure Kinect DK at runtime using
PyAudio.get_device_count()
andPyAudio.get_device_info_by_index()
and pass it as an argument top.open()
call.I was able to record single channel (first channel out of 7 channels) audio from Azure Kinect DK using following code.