Home

Awesome

Micro speech example for TensorFlow Lite

The program analyzes an audio input with a voice recognition model that can detect 2 keywords - yes and no. The recognized keywords are then printed into a serial interface. The voice recognition model is implemented using TensorFlow Lite for Microcontrollers.

The example project can be executed on Arm Virtual Hardware (AVH) as well as on physical hardware targets.

Structure

The repository is organized as follows:

FolderDescription
./micro_speech/Contains the voice recognition model that is used by all targets. This part is similar to the original TF-Lite for Microcontrollers example, with just minor modifications.<br>TensorFlow calculation kernel is provided separately via corresponding software packs listed in Prerequisites.
./Platform_FVP_Corstone_SSE-300_Ethos-U55/Project files specific for Corstone SSE-300 AVH target.
./Platform_IMXRT1050-EVKB/Project files specific for IMXRT1050-EVKB target.
./Platform_MIMXRT1064-EVK/Project files specific for MIMXRT1064-EVK target.
./VSI/Implementation of Audio Streaming Interface for FVP targets with Virtual Streaming Interface (VSI).

Prerequisites

Toolchain

Arm Virtual Hardware - Corstone and Cortex-M CPUs available via AWS Marketplace

Specific for HW targets

Note that CMSIS software packs used in the specific project will be requested and installed automatically when using Keil MDK or CMSIS-Build.

Micro speech for AVH (Fast Model) for Corstone SSE-300 with Ethos-U55

Project directory: ./Platform_FVP_Corstone_SSE-300_Ethos-U55/

This example executes the program on Corstone SSE-300 with Ethos-U55 Fixed Virtual Platforms (FVPs).

Example project has the following targets:

Micro speech for IMXRT1050-EVKB board

Project directory: ./Platform_IMXRT1050-EVKB/

This example executes the program on NXP IMXRT1050-EVKB development board with an Arm Cortex-M7 processor. It uses the on-board microphone for audio input and prints recognized keywords to the serial interface. One target IMXRT1050-EVK is provided in the project.

The board shall be connected to a PC via USB port J28. Jumper J1 shall connect pins 5-6 to ensure correct power supply in such setup. The project is configured to load the program to on-board Hyper Flash so the boot switch SW7 shall be set to 0110.

IMXRT1050-EVKB board

Execute the program in following steps:

Micro speech for MIMXRT1064-EVK board

Project directory: ./Platform_MIMXRT1064-EVK/

This example executes the program on NXP MIMXRT1064-EVK development board with an Arm Cortex-M7 processor. It uses the on-board microphone for audio input and prints recognized keywords to the serial interface. One target MIMXRT1064-EVK is provided in the project.

The board shall be connected to a PC via USB port J41. Jumper J1 shall connect the pins 5-6 to ensure correct power supply in such setup. The project is configured to load the program to on-board QSPI NOR flash so the boot switch SW7 shall be set to 0010.

MIMXRT1064-EVK board

Execute the program in following steps:

TensorFlow-Lite kernel variants

The micro speech example uses tensorflow-lite-micro pack that contains Machine Learning software component implementing among others the universal kernel for executing TensorFlow ML operations independent from the actual load type (audio, video, or others).

Implementation of these kernel operations is available in several variants optimized for Arm targets. When using the uVision project the variant can be selected in Manage Run-Time Environment window as shown on the picture below.

TF-Lite Kernel component variants

When using CMSIS-Build the kernel variant is specified in the .cprj project file in the line:

    <component Cclass="Machine Learning" Cgroup="TensorFlow" Csub="Kernel" Cvariant="CMSIS-NN" Cvendor="tensorflow"/>

Following kernel variants are available:

MVE configuration in uVision

Performance measurement with Event Statistics

File ./micro_speech/src/main_functions.cc in the repository example contains Event Statistics annotations that allow to measure performance of ML algorithms in different configurations. This currently works only in setup with Keil MDK. This video demonstrates program execution including the views into Event Statistics.

There are three events defined:

After executing the program with different TF-Lite kernel variants it can be observed that implementations optimized for Arm hardware extensions achieve significantly better performance for ML inference (C1 measurement), but also have shorter times for signal processing (C0 event).