Coder Social home page Coder Social logo

embeddedaudioclassifier's Introduction

STM32 Nucleo-L476RG Keyword Spotting Demo

Hardware Connections

MCU Pin MCU Function Nucleo Pin Mic Board Pin
3.3V 3V
GND GND
PB3 SAI1_SCK_B D3 BCLK
PB5 SAI1_SD_B D4 DOUT
PA4 SAI1_FS_B A2 LRCL
- - - SEL

Run Demo with Custom Model in STM32CubeIDE

Select File > Import... Select Existing Projects into Workspace and click Next. Select your demo project folder (e.g. nucleo-l476-keyword-spotting) from the downloaded repository. Enable Copy projects into workspace. Click Finish.

STM32CubeIDE import project

In the Project Explorer, delete the model-parameters and tflite-model directories in the ei-keyword-spotting diretory of your project, as these contain a previously trained model on the "yes" and "no" keywords.

Select File > Import and General > File System. For the From directory section, select the model-parameters directory is selected from your downloaded Edge Impulse library. Select the model-parameters folder in the left pane to include the header files in the import. Select <project_name>/ei-keyword-spotting as the Into folder. Select Create top-level folder. Click Finish.

STM32CubeIDE import directory

Repeat this process for the tflite-model directory in the downloaded Edge Impulse library.

At this point, you should have replaced the model-parameters and tflite-model directories in your demo project. Open <project_name>/Core/Src/main.cpp to edit the program's main() function. Feel free to look through the code to see how STM32 sets up its peripherals and how the Edge Impulse library is initialized and used. Find the // YOUR CODE GOES HERE! section to do something with the inference results.

STM32Cube IDE copy in Edge Impulse model files

Select Project > Build Configurations > Set Active > Release. Then, select Project > Build Project. Wait while the project builds.

Select Run > Run Configurations. Select STM32 Cortex-M C/C++ Application type in the left pane and click the New Configuration button (top left) to create a new configuration profile. It should be named "<project_name> Release" and use the Release/<project_name>.elf file for the application. If not, click Search Project... and select the Release/<project_name>.elf file for your project. Leave everything else as default. Click Run.

STM32CubeIDE create run configuration for Release build

If asked to update the Nucleo's ST-LINK firmware, click Yes. Click Open in update mode and click Upgrade. On "Upgrade successful," close the pop-up window. Click Run > Run.

Use a serial terminal program (such as PuTTY) to view the output of your keyword spotting system.

Running keyword spotting demo on STM32

If you see ERROR: Audio buffer overrun, it means your code is taking too long to process things after inference. A few recommendations to speed things up:

  • Comment out the "raw scores" printing section
  • Make UART printing interrupt-based instead of blocking
  • Do less stuff in your code section (e.g. don't print anything to the serial terminal)
  • Use less keywords (e.g. identify 1 keyword instead of 2 or 3).

Licenses

See individual source code files for their respective licenses. STM32 code, Edge Impulse libraries, and TensorFlow Lite are all licensed differently.

This tutorial is licensed under Creative Commons, Attribution 4.0 International (CC BY 4.0)

License: CC BY 4.0

embeddedaudioclassifier's People

Contributors

shyamal10 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.