Documentation

G.729 Voice Activity Detection for STM32 Discovery Board

This example shows how to model the ITU-T G.729 Voice Activity Detector (VAD) algorithm and run it on the ARM® Cortex-M based STMicroelectronics® STM32 Discovery boards.

Required MathWorks products:

  • MATLAB

  • Signal Processing Toolbox

  • DSP System Toolbox

  • Simulink

  • MATLAB Coder

  • Simulink Coder

  • Embedded Coder

  • Embedded Coder Support Package for STMicroelectronics Discovery Boards

  • DSP System Toolbox Support Package for ARM Cortex-M Processors

Available versions of this example:

Required Hardware

  • STMicroelectronics STM32F4-Discovery board or STM32F746G-Discovery board

  • In case A USB TTL-232 adapter for External mode simulation

Introduction

Voice Activity Detection (VAD) is a critical problem in many speech/audio applications including speech coding, speech recognition or speech enhancement. For instance, the ITU-T G.729 standard uses VAD modules to reduce the transmission rate during silence periods of speech.

This example is an extension of the G.729 Voice Activity Detection example from the DSP System Toolbox that you can use to simulate the behavior of the audio algorithm on your host computer. Also refer to the Parametric Audio Equalizer for ARM Cortex-M Processor example that explains how to take advantage of the ARM Cortex-M Code Replacement Library (CRL) for DSP functions.

In this example, you will learn how to deploy the G.729 Voice Activity Detection algorithm on the STM32 Discovery boards using Simulink.

Prerequisites

We recommend completing:

NOTE: Install DSP System Toolbox Support Package for ARM Cortex-M Processors to view examples and help for ARM Cortex-M DST Code Replacement Library.

Set ARM Cortex-M CMSIS Code Replacement Library (CRL)

The DSP System Toolbox Support Package for ARM Cortex-M Processors provides an optimized Code Replacement Library for signal processing and math operations.

Set the ARM Cortex-M Code Replacement Library for the

Use the STM32F4-Discovery Mic In block and schedule your algorithm based on the Mic In DMA interrupt.

In the G.729 Voice Activity Detection for STM32F4-Discovery Board example model, the voice activity detection algorithm uses audio data coming from the microphone available on the STM32F4-Discovery board. The model uses a 'Mic In' block from the STM32F4-Discovery library to get audio data from the microphone. This block outputs a frame of 16-bit audio samples. The 'Mic In' block is set with a sample frequency of 8000Hz. The frame size is set to 80 audio samples to get a 10 millisecond audio frame.

Set the 'Mic In' block to emit a 10 millisecond audio frame following step 2 of the example: Use STM32F4-Discovery audio peripherals and schedule your algorithm based on audio DMA interrupts.

Set the "Mic In" block DMA interrupt as the Base rate trigger for the model following steps 4 and 5 of the example: Use STM32F4-Discovery audio peripherals and schedule your algorithm based on audio DMA interrupts.

Use the STM32F746G-Discovery Audio In block

In the G.729 Voice Activity Detection for STM32F746G-Discovery Board example model, the voice activity detection algorithm uses audio data coming from the dual microphones available on the STM32F746G-Discovery board. The model uses a 'Audio In' block from the STM32F746G-Discovery library to get audio data from the microphone. This block outputs a frame of 2 channel 16-bit audio samples. The 'Audio In' block is set with a sample frequency of 8000Hz. The frame size is set to 80 audio samples to get a 10 millisecond audio frame.

The base rate trigger is automatically selected as the Audio Input in case of STM32F746G-Discovery.

Extend the G.729 Voice Activity Detection DSP example

The G.729 Voice Activity Detection example describes how to create and simulate a voice activity detection algorithm on your host computer. The algorithm for G.729 Voice Activity Detection is implemented in the following MATLAB function: vadG729.m. The G.729 Voice Activity Detection for STM32 Discovery Board examples uses vadG729.m inside the following MATLAB Function block: stm32f4discovery_vadG729/VAD_G729.

Configure the Model for External Mode Simulation

In this task, you will run the model in External mode. When you are prototyping and developing algorithms, it is useful to monitor signals and tune parameters while the model is running in real-time on the hardware. Simulink External mode enables this capability.

The External mode simulation uses a serial communication interface with the STM32 Discovery board. If you are using the STM32F4-Discovery board, you must use a serial adapter like the USB TTL-232 to exchange data between the host machine and the STM32F4-Discovery board. On the STM32F746G-Discovery board, you will use the serial over USB provided by the same USB connection needed for programming the board. So there is no need for an extra serial connection on the STM32F746G-Discovery board.

Open the VAD model appropriate to your target hardware from above. By default, the model is using serial COM port 28 on the host machine. Refer to Task 5 of the Code Verification and Validation with PIL and External Mode example to configure the model and set the proper connections between the STM32 Discovery board and the host machine.

To start the External mode simulation, switch the model simulation mode to External and click on the Play button as explained in Task 4 of the Code Verification and Validation with PIL and External Mode example.

External mode verbose mode is enabled by default in this example, which enables the display of debug messages for each External mode operation.

When voice is detected, a blue LED glows on the STM32F4-Discovery, a green LED glows on the STM32F746G-Discovery board. While running in External mode, the signal feeding the LED can be monitored on the Simulink scope indicating detection of voice.

Summary

This example showed how to deploy the G.729 Voice Activity Detection (VAD) algorithm on the STM32 Discovery boards. It demonstrated how to use the microphone available on the board to get a speech signal as well as an LED to display VAD results using External mode and Code Replacement Library (CRL) for ARM Cortex-M CMSIS DSP functions.

Was this topic helpful?