Audio on the edge

Voice activity detection (VAD) and wake words: frames, model state and privacy.

Intermediate9 min read

Educational draft content that needs expert review before it is used as an academic reference. Specifications, versions and licences change; check the official source. No experimental result is shown here unless it was actually run.

Learning objectives

  • Describe a VAD-then-larger-system cascade
  • Explain why model state is passed between frames
  • Interpret the effect of the probability threshold

Audio systems at the edge often work as a cascade: a tiny always-on voice activity detector, and when it hears speech it wakes a larger system (wake-word detection or speech recognition). This saves energy and keeps raw audio on the device.

A VAD processes audio in short frames (for example 32 ms) and outputs the probability of speech. The Silero VAD model used here is recurrent and keeps a state between frames, so the state must be passed from one frame to the next and reset when a new stream starts. It runs at 16 kHz.

In the experiment the microphone is processed inside the browser only and no audio is sent. Microphone permission is requested only when you press the button.

Terminology (with Arabic equivalents)

VADكشف النشاط الصوتي
Frameإطار
Sampling rateمعدل أخذ العينات
Wake wordالكلمة المنبّهة
Recurrent stateالحالة التكرارية
Hysteresisالتخلّف (تأخير التبديل)

Worked example

A threshold of 0.5 may cut speech at light breaths; that is why systems use a higher start threshold, a lower end threshold and a short hangover period to avoid chopping.

Code snippet

PythonModel call contract (illustrative)
# Sketch of the Silero v5 call contract (16 kHz)
# frame: 512 new samples, prepend 64 samples of context -> input [1, 576]
# state: float32 [2, 1, 128], zeros at start, replaced by 'stateN'
# sr: int64 scalar 16000 ; output[0] = probability of speech
state = zeros((2, 1, 128))
for frame in frames(audio, 512):
    prob, state = model(concat(context, frame), state, 16000)
    context = frame[-64:]

An illustrative snippet that was not executed in the lab environment; check library versions in their official documentation before use.

Check yourself

  1. Why is VAD used before a larger recognition system?

    • To save power and reduce the audio processed
    • To increase noise
    • To change the language
    • To store recordings
    Answer and explanation

    To save power and reduce the audio processed — A small model runs all the time and wakes the larger one when needed.

  2. What must be passed between Silero VAD frames?

    • The model state
    • The file name
    • The interface key
    • Nothing
    Answer and explanation

    The model state — The model is recurrent and needs its state.

  3. When is microphone permission requested in the lab?

    • Automatically when the page opens
    • Only when the user clicks the button
    • At installation
    • It is not requested
    Answer and explanation

    Only when the user clicks the button — No capture starts without an explicit user action.

References

Suggested reading (links not verified yet)

  • Silero VAD (github.com/snakers4/silero-vad) Not verified

Image and audio processing in the experiments runs inside your browser. Your images and audio are never uploaded and conversations are not stored. Privacy