Hi,
I am using the ReSpeaker 4-mic linear array with a Raspberry Pi 4.
I made a simple test to capture the data with the PyAudio python library in callback mode, as described below.
Even by doing nothing else on the Raspberry, I receive “overflow” messages.
Does someone already experienced this issue, and know how to solve it ?
Thanks
Here is my python test script
import time
import pyaudio
import numpy as np
DEVICE_NAME = 'seeed'
SAMPLE_RATE = 48000
N_CHANNELS = 8
FRAMES_PER_BUFFER = 8192
RUN_DURATION = 600 #TEst duration in seconds
def get_device_ind(pyaudio_instance, device_name):
"""Get audio input device by name"""
for ind in range(pyaudio_instance.get_device_count()):
if device_name in pyaudio_instance.get_device_info_by_index(ind)['name']:
return ind
return -1
def callback(in_data,
frame_count,
time_info,
status_flags):
if status_flags == 1:
print('*** pyaudio underflow !')
if status_flags == 2:
print('*** pyaudio overflow !')
# get data in right format
data = np.fromstring(in_data, dtype=np.int16)
return (None, 0)
def run():
pyaudio_instance = pyaudio.PyAudio()
stream = pyaudio_instance.open(
SAMPLE_RATE,
N_CHANNELS,
pyaudio.paInt16,
input=True,
input_device_index=get_device_ind(pyaudio_instance, DEVICE_NAME),
frames_per_buffer=FRAMES_PER_BUFFER,
start=False,
stream_callback=callback)
stream.start_stream()
time.sleep(RUN_DURATION)
stream.stop_stream()
stream.close()
pyaudio_instance.terminate()
if __name__ == "__main__":
run()