Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assets/contributors.csv
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,4 @@ Dave Neary,Ampere,,,,
Kwashie Andoh, Arm, Kwash45,,,
Sagar Surendran,Arm,spsagar13,sagar-surendran,,
Tirui Wu, Arm,,,,
Usamah Zaheer,Arm,usamahz,,,
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
---
title: Prepare the environment and model inputs
description: Install ExecuTorch and the Arm tools, then prepare the Silero VAD model and audio inputs.
weight: 2

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## Understand the workflow

Voice activity detection (VAD) classifies short audio frames as speech or silence. It is useful for voice assistants, transcription pipelines, and other systems that should avoid processing silent audio.

You will deploy the 16 kHz Silero VAD model with ExecuTorch. The workflow quantizes the model, lowers supported operations to the Arm Ethos-U backend, builds a bare-metal application, and runs it on a Corstone-320 Fixed Virtual Platform (FVP). You do not need a physical development board.

The application processes 512 audio samples every 32 ms. It keeps the long short-term memory (LSTM) hidden and cell state inside the ExecuTorch program between frames, then produces one speech probability for each frame.

The validation clip follows two paths. The host uses it to generate reference probabilities, while the bare-metal application processes the same clip on the FVP. The final comparison verifies that both paths produce the same speech decisions.

![Three-lane workflow showing host preparation from the Silero model and source audio to a stateful PTE, virtual target execution from the embedded PTE and validation audio to an FVP log, and host verification that compares reference probabilities with the FVP result.#center](silero-vad-deployment-lanes.svg "Silero VAD workflow separated into prepare, run, and verify lanes")

Use the FVP for functional validation. Its Ethos-U model is cycle accurate, but don't use its Cortex-M CPU model for CPU performance measurements.

## 1. Create an isolated ExecuTorch environment

The public development branch contains the Silero VAD Ethos-U example while maintainers upstream it. Use the tested commit so that the commands and generated artifacts match this Learning Path.

Clone the ExecuTorch fork and check out the tested revision:

```bash
git clone --branch codex/mletorch-2112-silero-vad-ethos-u \
--single-branch https://github.com/usamahz/executorch.git
cd executorch
git checkout 4af907b2192d89369440a1dc0488c1792781a82d
```

Confirm the checked-out revision:

```bash
git rev-parse --short=12 HEAD
```

The expected output is:

```output
4af907b2192d
```

Create and activate a Python virtual environment:

```bash
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
```

Install ExecuTorch and its Python dependencies:

```bash
./install_executorch.sh
```

The installation script initializes the Git submodules needed by the build and installs the matching PyTorch and ExecuTorch packages.

## 2. Install the Arm backend tools

The Arm setup script downloads the Arm GNU Toolchain, Ethos-U Vela compiler, Corstone FVPs, and supporting Python packages. Review the license terms presented by the script before using its EULA acceptance option.

Run the setup script from the ExecuTorch repository root:

```bash
./examples/arm/setup.sh --i-agree-to-the-contained-eula
source examples/arm/arm-scratch/setup_path.sh
```

The second command adds the downloaded cross-compiler and FVP binaries to the current shell environment. Run it again when you start a new shell.

Check that the two target tools are available:

```bash
command -v arm-none-eabi-g++
command -v FVP_Corstone_SSE-320
```

Each command prints an executable under `examples/arm/arm-scratch/`. If either command produces no path, source `examples/arm/arm-scratch/setup_path.sh` again.

## 3. Download the model and sample audio

Create one workspace for the files generated in this Learning Path:

```bash
mkdir -p silero-vad-work/{assets,export}
```

Download the model and sample audio from the tested Silero VAD revision:

```bash
curl --fail --location \
--output silero-vad-work/assets/silero_vad.jit \
https://raw.githubusercontent.com/snakers4/silero-vad/dbacf536adadf42210f37ae50fbaf75f6235b3cf/src/silero_vad/data/silero_vad.jit

curl --fail --location \
--output silero-vad-work/assets/test.wav \
https://raw.githubusercontent.com/snakers4/silero-vad/dbacf536adadf42210f37ae50fbaf75f6235b3cf/tests/data/test.wav
```

## 4. Create two audio clips

The target processes 2.5 seconds of audio. Copy this snippet once to create a calibration clip and a separate validation clip:

```bash
python3 - <<'PY'
import wave
from pathlib import Path

source_path = Path("silero-vad-work/assets/test.wav")
clips = (("calibration.wav", 0.0), ("validation.wav", 2.5))

with wave.open(str(source_path), "rb") as source:
parameters = source.getparams()
for name, start_seconds in clips:
source.setpos(int(start_seconds * parameters.framerate))
frames = source.readframes(int(2.5 * parameters.framerate))
with wave.open(str(source_path.with_name(name)), "wb") as target:
target.setparams(parameters)
target.writeframes(frames)
PY
```

Use `calibration.wav` to calibrate quantization. The FVP will process the separate `validation.wav` clip.

## What you've accomplished and what's next

You have installed the pinned ExecuTorch source, prepared the Arm tools, and created the model inputs.

Next, export the model as a quantized ExecuTorch program for Ethos-U85.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: Export Silero VAD for Ethos-U85
description: Quantize Silero VAD and export a stateful ExecuTorch program for the Ethos-U85 NPU.
weight: 3

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## Export the model

You prepared the model and two audio clips on the previous page. Now use the calibration clip to quantize Silero VAD and the validation clip to create a host reference.

From the ExecuTorch repository root, activate the environment and run the exporter:

```bash
source .venv/bin/activate
source examples/arm/arm-scratch/setup_path.sh

python3 examples/arm/silero_vad_example_ethos_u/model_export/export_silero_vad_ethos_u.py \
--jit-model silero-vad-work/assets/silero_vad.jit \
--calibration-audio silero-vad-work/assets/calibration.wav \
--validation-audio silero-vad-work/assets/validation.wav \
--output-path silero-vad-work/export/silero_vad_ethos_u.pte \
--expected-output-path silero-vad-work/export/expected_probs.bin \
--num-calibration-frames 32 \
--num-validation-frames 0
```

The final messages are similar to:

```output
Wrote expected probabilities to silero-vad-work/export/expected_probs.bin
Lowering to Ethos-U85...
Exported model saved to silero-vad-work/export/silero_vad_ethos_u.pte
```

The command creates two outputs:

| Output | Purpose |
| --- | --- |
| `silero-vad-work/export/silero_vad_ethos_u.pte` | Quantized program for Ethos-U85 |
| `silero-vad-work/export/expected_probs.bin` | Host probabilities for final validation |

## Understand the streaming model

The application supplies one 512-sample audio frame at a time. The exported program keeps the LSTM hidden and cell state between calls and produces one speech probability every 32 ms.

![Runtime diagram showing 64 context samples and a 512-sample frame entering the ExecuTorch program, model operations delegated to Ethos-U85, an internal int8 hidden and cell state reused between calls, and one speech probability emitted every 32 ms.#center](silero-vad-streaming-delegation.svg "Silero VAD streaming state and Ethos-U delegation boundary")

The LSTM calculations run in the Ethos-U graph. Only small boundary conversions and the state update remain as portable ExecuTorch operations.

## What you've accomplished and what's next

You have exported Silero VAD as a stateful ExecuTorch program and saved the host reference output.

Next, build the bare-metal application and run it on the Corstone-320 FVP.
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
title: Build and run the Corstone-320 application
description: Build the bare-metal ExecuTorch application and run Silero VAD on the Corstone-320 Fixed Virtual Platform.
weight: 4

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## Understand this stage

You already have the exported model and validation audio. This stage packages both into a bare-metal application and runs it on a virtual Cortex-M85 and Ethos-U85 system.

## 1. Build ExecuTorch for Cortex-M85

Continue from the ExecuTorch repository root. Activate the environment and build the target libraries:

```bash
source .venv/bin/activate
source examples/arm/arm-scratch/setup_path.sh

cmake --preset arm-baremetal -B cmake-out-arm
cmake --build cmake-out-arm --target install --parallel
```

The installed libraries provide the ExecuTorch runtime, portable operators, and Ethos-U backend used by the application.

## 2. Build the Silero VAD application

Configure the application with the exported model, validation audio, and a speech threshold of `0.55`. Select your host operating system:

{{< tabpane code=true >}}
{{< tab header="Linux" language="shell" >}}
cmake \
-S examples/arm/silero_vad_example_ethos_u/runtime \
-B silero-vad-work/app \
-DCMAKE_TOOLCHAIN_FILE="$PWD/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake" \
-DTARGET_CPU=cortex-m85 \
-DET_PTE_FILE_PATH="$PWD/silero-vad-work/export/silero_vad_ethos_u.pte" \
-DAUDIO_PATH="$PWD/silero-vad-work/assets/validation.wav" \
-DVAD_THRESHOLD=0.55
{{< /tab >}}
{{< tab header="macOS" language="shell" >}}
cmake \
-S examples/arm/silero_vad_example_ethos_u/runtime \
-B silero-vad-work/app \
-DCMAKE_TOOLCHAIN_FILE="$PWD/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake" \
-DTARGET_CPU=cortex-m85 \
-DET_PTE_FILE_PATH="$PWD/silero-vad-work/export/silero_vad_ethos_u.pte" \
-DAUDIO_PATH="$PWD/silero-vad-work/assets/validation.wav" \
-DVAD_THRESHOLD=0.55 \
-DUART0_BASE=0x49303000
{{< /tab >}}
{{< /tabpane >}}

Build the configured application:

```bash
cmake --build silero-vad-work/app \
--target silero_vad_ethos_u --parallel
```

The build creates `silero-vad-work/app/silero_vad_ethos_u`. This ELF image contains both the `.pte` model and the 2.5-second validation clip.

## 3. Run Silero VAD on the FVP

Run the application and save its simulated UART output to `fvp.log`:

```bash
mkdir -p silero-vad-work/fvp
bash backends/arm/scripts/run_fvp.sh \
--elf=silero-vad-work/app/silero_vad_ethos_u \
--target=ethos-u85-256 \
--timeout=300 2>&1 | tee silero-vad-work/fvp/fvp.log
```

The application prints one speech probability every 32 ms. Near the end, it reports a summary and stops the simulation:

```output
1 segments, 79 frames, 2.5s
Speech: 57/79 frames (72.2%)
Simulation complete, 0
No problems found!
```

## Check the target artifacts

Confirm that the application and its serial log exist:

```bash
ls -lh \
silero-vad-work/app/silero_vad_ethos_u \
silero-vad-work/fvp/fvp.log
```

## What you've accomplished and what's next

You have run the stateful Silero VAD model on a virtual Cortex-M85 and Ethos-U85 target.

Next, inspect the speech decisions and compare them with the host reference.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
title: Validate the FVP speech probabilities
description: Inspect Silero VAD speech decisions from the Corstone-320 FVP and compare them with the export-time reference probabilities.
weight: 5

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## 1. Inspect the streaming decisions

The application sends one `PROB` line over the simulated UART for every 512-sample frame. It also merges consecutive speech frames into `SEGMENT` lines.

Inspect the first probability records and the detected speech segments:

```bash
grep -Eo 'PROB .*$' \
silero-vad-work/fvp/fvp.log | head -n 10
grep -Eo 'SEGMENT .*$' \
silero-vad-work/fvp/fvp.log
```

The output is similar to:

```output
PROB 0.000 0.211681 silence
PROB 0.032 0.211681 silence
...
PROB 0.224 0.995684 speech
...
SEGMENT 0.224 2.048 speech
```

Each `PROB` line contains the frame timestamp in seconds, the probability of speech, and the decision produced with a threshold of `0.55`. Your probability values and speech segments depend on the validation audio.

The validation question is simple: did the host and FVP label every frame the same way? In this run, both found one speech segment from `0.224` to `2.048` seconds, with no decision mismatches.

![Two matching timelines for the same 2.5-second audio clip. The host reference and FVP output both show silence, speech from 0.224 to 2.048 seconds, then silence. All 79 frame decisions match.#center](silero-vad-validation-result.svg "Host and FVP produce the same speech decisions")

## 2. Compare the host and FVP results

Compare the saved host reference with the probabilities in the FVP serial log:

```bash
source .venv/bin/activate
python3 examples/arm/silero_vad_example_ethos_u/runtime/compare_vad_probs.py \
--expected silero-vad-work/export/expected_probs.bin \
--actual-log silero-vad-work/fvp/fvp.log \
--threshold 0.55 \
--atol 0.25 \
--mean-atol 0.02
```

The expected output is similar to:

```output
Compared 79 probability values
Max abs error: 0.156800 at frame 22
Mean abs error: 0.018459
Threshold mismatches at 0.550: 0
```

The comparison confirms that the host and FVP produced the same number of finite probabilities, the numerical differences stay within tolerance, and every frame has the same speech or silence decision.

## What you've accomplished

You have completed an end-to-end streaming audio workflow for Arm Ethos-U. You exported Silero VAD with model-owned recurrent state, built a bare-metal Cortex-M85 application, ran it on the Corstone-320 FVP, and validated its speech decisions against a host reference.

You can now replace the example audio with another 16 kHz mono, 16-bit PCM WAV file or use the runtime integration as a starting point for an Ethos-U85 device.
Loading