edge-impulse-run-impulse --continuous
.An Arduino sketch that demonstrates continuous audio sampling is part of the Arduino library deployment option. After importing the library into the Arduino IDE, look under ‘Examples’ for ‘nano_ble33_sense_audio_continuous’.run_classifier
function), and a prediction is returned. Then you empty the buffer, sample new data, and run the inferencing again. Naturally this has some caveats when deploying your model in the real world: 1) you have a delay between windows, as classifying the window takes some time and you’re not sampling then, making it possible to miss events. 2) there’s no overlap between windows, thus if an event is at the very end of the window, not the full event might be captured - leading to a wrong classification.
To mitigate this we have added several new features to the Edge Impulse SDK.
Activity diagram of running the impulse in sequential steps
Activity diagram of running the impulse using the parallel audio sampling mechanism
EI_CLASSIFIER_SLICES_PER_MODEL_WINDOW
macro is used to set the number of slices to fill the complete model window. The more slices per model, the smaller the slice size, thereby the more inference cycles on the sampled data. Leading to more accurate results. The sampling process uses this macro for the buffer size. Where following rule applies: the bigger the buffer, the longer the sampling cycle. So on targets with lower processing capabilities, we can increase this macro to meet the timing constraint.
Increasing the slice size, increases the volatile memory uses times 2 (since we use double buffering). On a target with limited volatile memory this could be a problem. In this case you want the slice size to be small.
audio_buffer_inference_callback()
function when there is data. Here the number of samples (inference.n_samples
) are stored in one of the buffers. When the buffer is full, the buffers are switched by toggling inference.buf_select
. The inference process is signaled by setting the flag inference.buf_ready
.
signal_t
structure to reference the selected buffer: