Skip to content
Free delivery, every order. Want a bulk deal or can't find what you need? Email support@pmdway.com now!
Free delivery, every order. Want a bulk deal or can't find what you need? Email support@pmdway.com now!
Sandeep Mistry Walks Through TinyML Audio Classification Using TensorFlow Lite, Raspberry Pi RP2040

Sandeep Mistry Walks Through TinyML Audio Classification Using TensorFlow Lite, Raspberry Pi RP2040

from hackster.io

Arm's Sandeep Mistry has penned a guide to turning a Raspberry Pi RP2040-based microcontroller board into a tinyML edge AI powerhouse — by deploying a TensorFlow Lite model for end-to-end audio classification.



"We will demonstrate how an Arm Cortex-M based microcontroller can be used for local on-device ML to detect audio events from its surrounding environment," Mistry explains of his tutorial, which focuses on the low-cost RP2040 found at the heart of the Raspberry Pi Pico and other microcontroller development boards. "This is a tutorial-style article, and we’ll guide you through training a TensorFlow based audio classification model to detect a fire alarm sound."

The tutorial uses Google's Colab as a development environment and, in Mistry's case, a SparkFun MicroMod RP2040 Processor in a MicroMod Machine Learning Carrier Board — the latter adding USB connectivity and microphone, along with an on-board inertial measurement unit (IMU) and camera connector which go unused in this particular project — or a Raspberry Pi Pico with external microphone breakout.

The guide walks through training based on the ESC-50 environmental sound classification dataset, plus transfer learning for improving its capabilities in detecting alarm sounds - tasks which take place on a more powerful device than the RP2040. Once trained, the model is created using TensorFlow's Keras API, tuned, and set up for feature extraction via a 16-bit fixed-point digital signal processor (DSP) — working around the lack of floating-point performance on the RP2040.

Mistry's tutorial then covers collecting specific training data using the RP2040 and connected microphone, finalizing training, and converting the model from Keras format into TensorFlow Lite — including quantization, a step that drops the model from 32-bit floats to 8-bit integers in order to improve performance on microcontrollers. Finally, the model is compiled into a firmware and deployed onto the RP2040.

"Since the ML processing was performed on the development boards RP2040 MCU," Mistry notes, "no audio data left the device at inference time" — a key privacy advantage compared to approaches which rely on uploading audio data to an external device for processing.

The full guide is now available on the TensorFlow blog. 

Finally - to keep up to date with interesting news, offers and new products - interact with us on facebookinstagram, and twitter.

Previous article TV for Cats with Raspberry Pi

Leave a comment

Comments must be approved before appearing

* Required fields