Hi,
I try the ei-keyword-spotting tutorial from @ShawnHymel with NUCLEO L476RG and SPH0645 mic, but I have some problems (ERROR: audio buffer overrun).
I measure the inference time execution and it’s about 480 ms, which I think is too much if the sampling rate is 32K and the buffer size is 6400 samples.(but probably I didn’t get exactly the flow)
I think 32 kHz is too fast. The example I use is 16 kHz, which is what Edge Impulse uses by default. Even though my I2S mic samples at 32 kHz, I drop every other sample to make it 16 kHz. I know, I should be using a low-pass filter to avoid aliasing if I’m down-sampling, but that would take what little resources I have, so I just have to assume that I won’t encounter frequencies above 8 kHz (as my application is for vocal range anyway).
If you look for audio_buffer_inference_callback() function in my main.cpp of the L476 example, you can see where I drop samples and convert the 24-bit audio to 16-bit audio.
6400 is the size of my I2S buffer. Every time half of that is filled up, it calls the audio_buffer_inference_callback() function. Here, the audio samples are converted to 16-bit PCM and 16 kHz and stored in one of the inference.buffers (it’s a double buffer). The size of that buffer is EI_CLASSIFIER_SLICE_SIZE.
One of these inference.buffers is sent to run_classifier_continuous() each time it’s filled up. That function should take no more than 250 ms to perform feature extraction (MFCCs) and inference, as it needs to meet the goal of performing inference 4 times per second.
I did some debug with the oscilloscope, and I found a strange behavior.
The inference algorithm seems to work properly for the first 3 times and then, it takes too much time.
I put a toggle pin UP-DOWN across “run_classifier_continuous” function The YELLOW
and a toggle pin UP-DOWN across half callback and complete callback --> the BLUE signal
What is the “timing optimization” option? It’s been a couple of months since I made that project, so I may not remember. Is there a particular checkbox in preferences or flag you set that’s different from my example project?
@Fede99 so a full frame of inference costs 480ms. when doing only half that this will be even further reduced, so I’m surprised about that. I’d follow Shawn’s suggestion and downsample to 16KHz on the device.
Hello Edge Team,
I had followed the instructions to include *.pack library into STM32CubeIDE but after compiling the c++ project i got below compiler error:
./Middlewares/Third_Party/EdgeImpulse_AudioPCBM_MachineLearning/edgeimpulse/edge-impulse-sdk/dsp/spectral/processing.hpp:26:10: fatal error: vector: No such file or directory
26 | | #include
same for #include
looks like below two include file are not able to fine into below include path from g++ include settings
…/Middlewares/Third_Party/EdgeImpulse_AudioPCBM_MachineLearning/edgeimpulse/
Kindly help me to resolve the compiler error related to header file not able locate in above path.
I could able to compile the code by creating new cubeMx C++ project but now I’m getting the RAM memory overflow error by 3KiB but i look at deployment result as shown below it far less than the memory on STMF401VC i.e it has 256KiB Flash and 64KiB RAM.
So why there is huge difference that will overflow RAM usage with edge impulse Library?