I am using PyAudio in a Python script on a Raspberry Pi B. It (successfully) runs a recording loop every 10 seconds, listening for a keyword. But there is a substantial pause in between each loop which I am trying to eliminate. I have narrowed it down to where the script instantiates the stream object (see snippet below). This particular operation takes 10-11 seconds to execute, whereas everything else is instantaneous. Nothing else is running on the Pi.
I dont know if this is natural, or whether some other underlying issue (eg. alsa config?) might be the cause. Should this take a full 10 seconds to execute?
stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK)