Main Content

Deploy Smart Speaker Model on Qualcomm Hexagon eNPU using LPAI SDK Add-on

This example shows you how to deploy a Simulink® model designed as smart speaker system on Qualcomm® Hexagon® eNPU using Embedded Coder® Support Package for Qualcomm Hexagon Processors. This example is based on the Simulink model available in Apply Speech Command Recognition Network in Smart Speaker Simulink Model (Audio Toolbox) example. In the updated model this example, the eNPU Predict block replaces the DL predict block from the original example as this block uses a precompiled eAI model for deploying the DL network to Hexagon eNPU.

This Simulink model consists of two main parts:

  1. Audio Input Path, which represents microphone processing. This path includes preprocessing followed by a speech command recognizer, which extracts an auditory (Bark) spectrogram used by the precompiled eAI model to predict speech commands.

  2. Audio Output Path, which represents loudspeaker output processing. This path includes preprocessing for the audio playback stream and takes the speech command from the microphone path to perform actions on the playback. You can make the smart speaker play audio with the command "Go." You can stop the audio by saying "Stop." You can increase or decrease the audio volume with the commands "Up" and "Down," respectively.

This example uses the From Workspace Simulink blocks to obtain the inputs.

Open the model by executing this command.

open_system('SmartSpeakerHexagonENPU');

The eNPU Predict block is set to work only for Qualcomm Hexagon hardware implementations (like Qualcomm Hexagon Simulator).

set_param('SmartSpeakerHexagonENPU','HardwareBoard','Qualcomm Hexagon Simulator');

Configure the eNPU Predict block with the eAI model, and also provide the quantization information (because the input to this block in this example is floating-point).

block = 'SmartSpeakerHexagonENPU/Speech Command Recognizer/eNPU';

% Set the EAINetworkFile
% Update the path to the file appropriately if the current workspace is changed
set_param(block,'EAINetworkFile','speechCommandRecognitionNetwork.eai');

% Set the input layer Quantization [min max]
set_param(block,'InputQuantizationRange','[-6 6]');

% Set the DequantizeOutput parameter to enable output data for dequantization
set_param(block,'DequantizeOutput','on');

% Set the output layer Quantization [min max]
set_param(block,'OutputQuantizationRange','[-1 1]');

Note: If the absolute of minimum and maximum values specified for InputQuantizationRange and OutputQuantizationRange are equal, the block uses symmetric quantization; else, it uses asymmetric quantization.

Simulate the model in Normal mode.

set_param('SmartSpeakerHexagonENPU','SimulationMode','Normal');

hostReference = sim('SmartSpeakerHexagonENPU');

The input is a monotone sine wave. Based on the "Go" command at the first second and "Stop" command at fifth second, you can see the output waveform transitions that slowly fades-in and fades-out respectively.

For deploying this on the Hexagon Simulator, update the model settings as below based on the intended target for deployment.

eNPU comes with different hardware version variants, and therefore, the eNPU version of the eAI model must match the target's eNPU version. Additionally, eNPU is currently available only for aDSP with v73 processor version, and therefore, the model settings must be set appropriately. In this example, we use eNPU version v3 for the Qualcomm Hexagon Simulator hardware implementation.

targetInfo = get_param('SmartSpeakerHexagonENPU','CoderTargetData');
% First set the aDSP processor version
targetInfo.Device.ProcessorVersion = 'V73';
% Disable HVX as v73 aDSP doesn't has HVX
targetInfo.Device.EnableHVX = 0;
% Set the eNPU version
targetInfo.Device.ENPUVersion = 'V3';

set_param('SmartSpeakerHexagonENPU','CoderTargetData',targetInfo);

If you want to to run the example for Qualcomm Hexagon Android Board instead, then set the below parameters (assuming that the board details are updated under Hardware Implementation > Hardware board settings from Model Settings)

  • set_param('SmartSpeakerHexagonENPU','HardwareBoard','Qualcomm Hexagon Android Board');

  • targetInfo = get_param('SmartSpeakerHexagonENPU','CoderTargetData');

  • targetInfo.Device.ProcessingUnit = 'adsp';

  • targetInfo.Device.ENPUVersion = 'V3';

  • set_param('SmartSpeakerHexagonENPU','CoderTargetData',targetInfo);

Configure other optimization parameters (optional).

set_param('SmartSpeakerHexagonENPU','BuildConfiguration','Faster Runs');
set_param('SmartSpeakerHexagonENPU','CodeReplacementLibrary','Qualcomm Hexagon QHL');

Perform PIL verification by the running these commands:

set_param('SmartSpeakerHexagonENPU','SimulationMode','processor-in-the-loop (pil)');

% Enable the below command for PIL

% pilOutput = sim('SmartSpeakerHexagonENPU');

You can verify the numerical accuracy using the Simulation Data Inspector. For more information, refer to Getting Started with Embedded Coder Support Package for Qualcomm Hexagon Processorsexample.