Runs the voice recognition model of TFL for a microcontroller on Ameba D RTL8722DM/RTL8722DM-MINI

Ameba is an easy-to-program platform for developing all kinds of AIoT applications.

Introduction to Google TensorFlow

TensorFlow (TF) is an end-to-end open-source platform for machine learning. It has a comprehensive, flexible ecosystem of tools, libraries, and community resources that lets researchers push the state-of-the-art in ML, and developers easily build and deploy ML-powered applications.

TensorFlow Lite for Microcontrollers

Picture1.png

While TensorFlow Lite (TFL) for Microcontrollers is designed to run machine learning models on microcontrollers and other devices with only a few kilobytes of memory. The core runtime just fits in 16 KB on an Arm Cortex M3 and can run many basic models. It doesn't require operating system support, any standard C or C++ libraries, or dynamic memory allocation.

Ameba and TFL for Microcontrollers

Ameba is an easy-to-program platform for developing all kinds of IoT applications. AmebaD is equipped with various peripheral interfaces, including WiFi, GPIO INT, I2C, UART, SPI, PWM, ADC. Through these interfaces, AmebaD can connect with electronic components such as LED, switches, manometer, hygrometer, PM2.5 dust sensors, …etc.

download (3).jpg

“Micro Speech” Example

Materials

  • Ameba D [RTL8722 CSM/DM] x 1 or Ameba D- MINI
  • Adafruit PDM MEMS microphone
  • LED x 4

In this example, we will use Ameba D as an example, however, the microcontroller EVB using in the video link above is Ameba D-mini.

Procedure

Connect the microphone and LEDs to the RTL8722 board following the diagram.

1-1.jpg

How to get the code?

  1. Download the Ameba customized version of TensorFlow Lite for Microcontrollers library at: https://github.com/ambiot/ambd_arduino/tree/master/Arduino_zip_libraries.
  2. Follow the instructions at https://www.arduino.cc/en/guide/libraries to install it.
  3. Ensure that the patch files found at https://github.com/ambiot/ambd_arduino/tree/master/Ameba_misc/ are also installed.
  4. Open the example, “Files” -> “Examples” -> “TensorFlowLite_Ameba” -> “micro_speech”.
  5. Upload the code and press the reset button on Ameba once the upload is finished.
1-2.jpg

Expected Behavior

Once it is running, you should see one of the LEDs flashing, indicating that it is processing audio. Saying the word “yes” will cause the green LED to light up. Saying the word “no” will cause the red LED to light up. If the word is not recognized, the blue LED will to light up.

The inference results are also output to the Arduino serial monitor, which appear as follows:

1-3.jpg

If you are having trouble getting the words recognized, here are some tips:

  • Ensure that your surroundings are quiet with minimal noise.
  • Experiment with varying the distance of the microphone, starting with it at an arm’s length.
  • Experiment with different tones and volumes when saying the words.
  • Depending on how you pronounce the words, the characteristics of the microphone used, getting one keyword recognized may be easier than the other.

Reference and Q&A

1. More information on TensorFlow Lite for Microcontrollers can be found at: https://www.tensorflow.org/lite/microcontrollers

2. For more examples, please visit our official website: bit.ly/ambiot1

3. Please join our FB Forum (English version) to further discuss with us: https://bit.ly/2Tzgxkv 

4. Or join our forum to bring up any questions: https://bit.ly/ambiotforum

Qi Zhu