Table of Contents

Class VoiceActivityDetector

Namespace
NAudio.Dsp
Assembly
NAudio.Core.dll

Energy-based voice activity detector with an adaptive noise floor and hangover. Operates on a mono sample stream in fixed analysis frames: a frame counts as speech when its level rises a configurable margin above the tracked noise floor, and the decision is held for a short hangover so word-final sounds are not clipped. Used to gate noise-estimate updates (noise suppression), freeze AGC during silence, or drive a transmit gate.

public sealed class VoiceActivityDetector
Inheritance
VoiceActivityDetector
Inherited Members

Constructors

VoiceActivityDetector(int, float)

Creates a detector.

public VoiceActivityDetector(int sampleRate, float frameMilliseconds = 20)

Parameters

sampleRate int

Sample rate in Hz. Must be positive.

frameMilliseconds float

Analysis frame length in ms. Default 20 ms.

Properties

HangoverMs

Hangover time in milliseconds (decision held after speech ends). Default 200 ms.

public float HangoverMs { get; set; }

Property Value

float

IsVoiceActive

True if the most recent frame (including hangover) is classed as speech.

public bool IsVoiceActive { get; }

Property Value

bool

NoiseFloorDb

The current adaptive noise floor estimate in dBFS.

public float NoiseFloorDb { get; }

Property Value

float

ThresholdDb

Margin in dB above the noise floor that counts as speech. Default 9 dB.

public float ThresholdDb { get; set; }

Property Value

float

Methods

Process(float)

Feeds one mono sample and returns the current voice-activity decision.

public bool Process(float sample)

Parameters

sample float

Returns

bool

Reset()

Resets the detector to its initial (un-adapted) state.

public void Reset()