Implements an energy‑based Voice Activity Detector with adaptive thresholding.
// Source: https://github.com/streamcoreai/streamcore-server | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works // Provided via justclaw.it.com; keep this notice with the code. package vad import "math" // Detector implements a simple energy-based Voice Activity Detector. // It requires consecutive frames above/below threshold to trigger state changes, // preventing spurious transitions from brief noise or pauses. // // When adaptive mode is on, the detector additionally tracks an exponential // moving average of non-speech energy (the line's noise floor) and derives // the effective threshold from it. One fixed global threshold can't serve // both a quiet caller on a clean line (speech RMS below 1200 → never // detected) and a caller next to a ... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key