Using Edge Impulse with Apollo3

Hi,
I’m using the Apollo3 Artemis module and trying to get speech recognition working with it. They do provide micro speech examples in the repo, but training a new model seems complicated and I like Edge Impulse much better. So far, I have an Artemis module with PDM microphone and I sample audio at 16khz. I can generate a wav file directly from the samples taken from the module. I have just two classes for now, one wake word and noise. (windows size:1000ms, windows increase:250ms) I have been training my model based on these recordings. Training has been great and so has testing.
I deploy it as Arduino project (nano ble sense), but just add the library to my project.
It does not perform on the Artemis module as well as testing online. The problem is I think, the differences between the BLE sense PDM library and the PDM library used for Artemis, or how the PDM readings are collected (but not sure).
I know that the Artemis PDM library places the data in a uint16_t buffer with a buffer size of 4096 (as in pdm examples).
I thought maybe I could make it work since “inference.buffer” is a int16_t. I attached a code snippet.

In the snippet above, the PDM data is placed in “pdmData”.

Sorry for my lack of understanding , and thank you!

1 Like

Hi,

We haven’t worked with apollo3 before, but I took a quick look at your code snippet and I think there’s a chance your copy operation might not be working as expected due to your sizeof(pi16PDMData) use. That looks like it is getting the size of the pointer itself, not the array.

Also this is tangential, but if you are working within the Arduino libraries (it looks like those are provided for the Artemis boards), I think they expose a memcpy function that should see better performance when copying into the input buffer than the loop-based method.

Best,
David

2 Likes

Hi @kevwalle,

Like @daschwar mentioned, there is a chance that sizeof(pi16PDMData) returns the length of the pointer and not the complete array. But if it does return the array length, it returns the number of bytes. Since we’re copying short ints, the value has to be divided by 2 -> sizeof(pi16PDMData) / 2.

Regards,
Arjan

Thank you @daschwar and @Arjan for your help :grinning:
I ended up making some changes to Apollo’s PDM library and incorporating the “PDMDoubleBuffer” source files, and now I can run the nano ble sense Arduino sketches on Apollo3 without making any changes. The buffer library uses memcpy instead of for loops also. I’m not sure if everything is working 100%, classifier runs but almost everything is classified as noise. But I did train on a small dataset, and it may not be adequate. I know I can print out the generated features and it looks as expected, so maybe I’m getting closer.

If I figure out something else, I will post my results!

2 Likes

Hey @kevwalle, were you ever able to get this working? I’m in the same boat, the artemis module seems perfect for battery powered ML applications so I’m hopeful I can get this to work but would love to know your results.