Links

On your Syntiant TinyML Board

Impulses can be deployed as an optimized Syntiant NDP 101 library. This packages all your signal processing blocks, configuration and learning blocks up into a single package. You can include this package in your own application to run the impulse locally. In this tutorial you'll export an impulse, and run the application on the Syntiant TinyML Board to control GPIO pins when the keyword 'go' or 'stop' is uttered, or if a circular motion is detected.

Prerequisites

Make sure you followed the Responding to your voice - Syntiant - RC Commands or Motion recognition - Syntiant tutorial, have a trained impulse, and can load code on your Syntiant TinyML Board.
Naming your classes
The NDP chip expects one and only negative class and it should be the last in the list. For instance, if your original dataset looks like: yes, no, unknown, noise and you only want to detect the keyword 'yes' and 'no', merge the 'unknown' and 'noise' labels in a single class such as z_openset (we prefix it with 'z' in order to get this class last in the list).

Exporting Syntiant library

Go to the Deployment page of your project and select the Syntiant library option:
Export to Syntiant NDP101 library for custom model development
Unzip the archive and copy the model-parameters content into the firmware-syntiant-tinyml/src/model-parameters/ folder.
The export also creates an ei_model.bin that we will use later on to flash the board.

Customizing and compiling the source code

After this, you can add your custom logic to the main Arduino sketch by customizing the on_classification_changed() function. By default this function contains the following code to activate LEDs based on "stop" and "go" classes:
void on_classification_changed(const char *event, float confidence, float anomaly_score) {
// here you can write application code, e.g. to toggle LEDs based on keywords
if (strcmp(event, "stop") == 0) {
// Toggle LED
digitalWrite(LED_RED, HIGH);
}
if (strcmp(event, "go") == 0) {
// Toggle LED
digitalWrite(LED_GREEN, HIGH);
}
}
You can also modify the src/ei_setup.cpp file to change/remove the default printf messages during inferencing.
Once you've added your own logic, to compile and flash the firmware run:
  • Windows
    • update_libraries_windows.bat
    • arduino-win-build.bat --build for audio support (add --with-imu flag for IMU support)
    • arduino-win-build.bat --flash
  • Linux and Mac
    • ./arduino-build.sh --build for audio support (add --with-imu flag for IMU support)
    • ./arduino-build.sh --flash

Deploying your impulse

Once you've compiled the Arduino firmware:
  • Take the .bin file output by Arduino and rename it to firmware.ino.bin.
  • Replace the firmware.ino.bin from our default firmware (our default firmware can be downloaded from here)
  • Replace the ei_model*.bin file in our default firmware by the one from the Syntiant library.
  • Launch the script for your OS to flash the board
Great work! You've captured data, trained a model, and deployed it to the Syntiant TinyML Board. You can now control LEDs, activate actuators, or send a message to the cloud whenever you say a keyword or detect some motion!