It’s sounding like an issue with getting the data correctly into preprocessing when using the MIC.
From what I am understanding, you tested with a 2 second wav file and everything is okay. When you move to using the MIC you record 2 seconds of audio, store this in a buffer and create an audioDataSlider using it. Anything in that first 2 seconds is recognized correctly (this would be 4 inferences total if none of the other settings have been changed). You then take the next 2 seconds, overwrite the old buffer, but now don’t get any detections in this next 2 seconds of audio, is that correct?
The audioDataSlider is meant for grabbing data from a baked-in array of audio data so there might be issues if trying to re-use a buffer for live audio. You would need to call Reset on the slider and point to the start of the buffer again. However, if you are creating a new audioDataSlider each time you grab enough new data from the MIC it shouldn’t be an issue I would think.
There is a caching mechanism in the preprocessing that might be causing issues, you can disable this by setting preProcess.m_audioWindowIndex = 0 just before DoPreProcess is called. It will be a bit slower to run but you can see if that is the issue. I don’t believe there is any other variables etc. that need to be changed or reset.
One other thing, are you sure that the audio data being written into the buffer from the mic is the correct recorded audio with the keywords in it? When we did this sample: (ML-examples/tflu-kws-cortex-m/kws_cortex_m at main · ARM-software/ML-examples · GitHub) that works on live audio that was one of the issues we faced then.