Skip to main content

Voice Activity Detection (VAD)

Voice Activity Detection (VAD) identifies segments of speech in audio data. LocalAI provides a /v1/vad endpoint powered by the Silero VAD backend.

The audio.cpp backend also serves this endpoint, and ships the silero_vad and marblenet_vad assets inside its own package, so VAD works there with nothing to download (model: bundled:silero_vad plus the family:silero_vad option).

API

  • Method: POST
  • Endpoints: /v1/vad, /vad

Request

The request body is JSON with the following fields:

ParameterTypeRequiredDescription
modelstringYesModel name (e.g. silero-vad)
audiofloat32[]YesArray of audio samples (16kHz PCM float)

Response

Returns a JSON object with detected speech segments:

FieldTypeDescription
segmentsarrayList of detected speech segments
segments[].startfloatStart time in seconds
segments[].endfloatEnd time in seconds

Usage

Example request

The /v1/vad endpoint expects the audio field to be an array of raw 16kHz mono PCM samples as float32 values, so the request body is usually built from a real audio file rather than typed by hand.

First convert any audio file to 16kHz mono with ffmpeg:

ffmpeg -i input.mp3 -ar 16000 -ac 1 -f wav speech.wav

Then load the samples and POST them (this snippet needs pip install soundfile numpy requests):

import soundfile as sf
import numpy as np
import requests

audio, sample_rate = sf.read("speech.wav")
if audio.ndim > 1:
    audio = audio.mean(axis=1)  # downmix to mono
samples = audio.astype(np.float32).tolist()

response = requests.post(
    "http://localhost:8080/v1/vad",
    json={"model": "silero-vad", "audio": samples},
)
print(response.json())

Example response

{
  "segments": [
    {
      "start": 0.5,
      "end": 2.3
    },
    {
      "start": 3.1,
      "end": 5.8
    }
  ]
}

Model Configuration

Create a YAML configuration file for the VAD model:

name: silero-vad
backend: silero-vad

Detection parameters can be overridden via model options (key:value entries):

name: silero-vad
backend: silero-vad
options:
  - threshold:0.55
  - min_silence_duration_ms:50
  - speech_pad_ms:450

Supported options:

OptionTypeDefaultDescription
thresholdfloat0.5Speech probability threshold
min_silence_duration_msint100Minimum silence before ending a speech segment
speech_pad_msint30Padding added around each speech segment

Thresholds must be greater than 0 and less than 1. Durations must be nonnegative integers. Malformed values, negative durations, and NaN thresholds are ignored; the default or last valid value remains in use.

Reload the model (or restart LocalAI) after changing these options.

parakeet-cpp backend

The parakeet-cpp backend serves the same endpoint. It runs one of two detectors:

  • Silero VAD from a GGUF file (gallery entry parakeet-cpp-silero-vad-f16, 1.3 MB). One probability per 32 ms.

  • The VAD head of a full Moondream Ultra or Redux model (gallery entries parakeet-cpp-vad-moondream-ultra-q8_0 and parakeet-cpp-vad-moondream-redux-packed). One probability per 80 ms. The packed Redux file runs on CPU only.

  • A VAD-only slice of that head (gallery entries parakeet-cpp-vad-moondream-redux, 9.9 MB, and parakeet-cpp-vad-moondream-ultra, 6.0 MB). The slice is cut out of the full model without retraining, so the segments are byte-identical to the full model’s head, and the speed is the same. Compared with loading the whole model (213 MB to 1.4 GB), the file is 6 to 10 MB, loads in a few milliseconds instead of 0.1 to 0.7 s, and needs about 245 MiB of peak memory for a 33 s clip instead of 0.6 to 1.6 GiB. A slice cannot transcribe, and it needs a parakeet.cpp build with VAD-only GGUF support (pin e53a253 or newer).

  • A bundle GGUF (gallery entries parakeet-cpp-bundle-small, parakeet-cpp-bundle-standard and parakeet-cpp-bundle-moondream-redux). The bundle holds a Silero component next to the ASR model, and the backend uses it for this endpoint with no option. See Bundle GGUF files.

The entry parakeet-cpp-vad installs Silero. The detectors differ and are not variants of one model, so install the entry of the VAD head by name if you want it (parakeet-cpp-vad-moondream-redux or parakeet-cpp-vad-moondream-ultra for the small files). The request is the same as above: audio is 16 kHz mono float32 PCM, and the response lists segments with start and end in seconds. An ASR model that has no VAD head fails the request with model has no VAD head.

name: parakeet-vad
backend: parakeet-cpp
known_usecases:
  - vad
parameters:
  model: parakeet-cpp/silero-vad-f16.gguf
options:
  - vad_threshold:0.5
  - vad_min_pause:0.1

All options are optional. An unset value keeps the default of the detector in use (the library defaults differ between Silero and the head):

OptionUnitSilero defaultHead defaultDescription
vad_threshold0 to 10.50.5Speech probability threshold
vad_min_pauseseconds0.10.2A silence this long separates two segments; shorter gaps merge
vad_min_speechseconds0.250.1Shorter speech runs are dropped
vad_speech_padseconds0.030Padding added around each segment
vad_trimseconds0.30.3Only for transcription with vad:true or vad_model: each piece shrinks to its speech plus this much. 0 keeps the whole cuts. The endpoint ignores it
vad_run_gate0 to below 1offoffOnly for the Moondream Ultra and Redux heads: a speech run is kept only if the median of its frame probabilities is at least this. 0 or unset is off; 1 or more fails the load. See Run gate

Option names differ from the Silero backend above (min_silence_duration_ms and speech_pad_ms are in milliseconds there). The same options tune transcription with vad:true or vad_model; see audio to text. Requests on one loaded model run one at a time.

Run gate for the Ultra and Redux heads

The Ultra and Redux heads often call steady noise speech. vad_run_gate is an opt-in check on that. A speech run is a stretch of consecutive frames at or above vad_threshold. With the gate set, a run is dropped when the median of its frame probabilities is below the gate. Speech frames sit near 1.0. A noise run sits on a plateau around 0.8 to 0.9 with some higher peaks, so its median is lower than its peak. Unset, or 0, the output is the same as without the option.

Start with 0.92 to 0.96 on Redux. Ultra gains less and needs a higher gate. The parakeet.cpp author measured on real recordings without speech (false-alarm seconds per hour): Redux 1685 without the gate and 269 with 0.92, Ultra 2174 and 826, Silero 48. The cost on recordings with speech was about 0.3 F1 points for Redux and 0.6 for Ultra, and no confidence interval excluded zero. Check it on your own audio before you rely on it.

This example is the Redux VAD-only entry with the gate on. The gallery entries do not set it:

name: parakeet-vad-redux-gated
backend: parakeet-cpp
known_usecases:
  - vad
parameters:
  model: parakeet-cpp/redux-vad.gguf
options:
  - vad_run_gate:0.92

What it does not do:

  • Music still triggers the head. The gate is not a noise rejector and it does not classify sounds.
  • Silero does not need it. Silero is the always-on gate: its false alarms on the same recordings are already low.
  • It is offline only. The endpoint, vad:true and vad_model use it. A streaming VAD of libparakeet refuses a non-zero gate, and this backend does not use that stream for the VAD endpoint or for transcription, so nothing is skipped silently. The option has no effect on plain transcription without vad:true.

It needs a libparakeet.so with run gate support (parakeet.cpp 9a28a3c or newer). With an older library, an unset option keeps working. A set option fails the first VAD call or transcription, because the old library rejects the unknown run_gate key. With vad:true on a library without parakeet_capi_transcribe_path_json_vad_with, it fails the load.

Detection Parameters

The Silero VAD backend uses the following internal defaults (overridable via options above):

  • Sample rate: 16kHz
  • Threshold: 0.5
  • Min silence duration: 100ms
  • Speech pad duration: 30ms

Error Responses

Status CodeDescription
400Missing or invalid model or audio field
500Backend error during VAD processing