Skip to main content

Usage guide

Setup, environment variables, and Python/JavaScript/Go usage examples.

SileroVAD

Abstract base class for voice activity detection providers. Implementations analyze audio to detect speech and silence boundaries and may emit 'error' and 'info' events.

Constructor

threshold
float
default:"0.4"
Speech probability threshold above which audio is treated as speech.
start_threshold
Optional[float]
end_threshold
Optional[float]
stop_threshold
float
default:"0.25"
min_speech_duration
float
default:"0.3"
Minimum duration, in seconds, required to confirm a speech segment.
min_silence_duration
float
default:"0.4"
Minimum duration, in seconds, required to confirm a silence segment.
padding_duration
float
default:"0.5"
max_buffered_speech
float
default:"60.0"
sample_rate
int
default:"16000"
Sample rate of the input audio, in Hz.
input_sample_rate
Optional[int]
model_sample_rate
Optional[int]
smoothing_factor
float
default:"0.35"

aclose

Release any resources held by the provider.

emit

Emit an event, invoking all registered handlers with the given arguments. Handlers are called in registration order. Coroutine handlers are scheduled on the running event loop. If the emitter is closed, the call is a no-op.
event
T
required
The event to emit.

flush

Flush any buffered audio and finalize pending detection state.

off

Remove a previously registered handler for an event. If the handler is not registered for the event, the call is a no-op.
event
T
required
The event the handler was registered for.
callback
Callable[..., Any]
required
The handler to remove.

on

Register a handler for an event. Can be used directly by passing a callback, or as a decorator when callback is omitted.
event
T
required
The event to listen for.
callback
Callable[..., Any] | None
The handler to invoke when the event is emitted. If None, a decorator is returned that registers the decorated function.
returns
Callable[..., Any]
The registered callback when callback is provided, otherwise a decorator that registers and returns the function it wraps.

on_vad_event

Register the coroutine invoked when a voice activity event occurs.
callback
Callable[[VADResponse], Awaitable[None]]
required
An async callable that receives each VADResponse.

process_audio

Analyze a chunk of audio for voice activity. Implementations should detect speech and silence transitions and emit results through the registered voice activity callback.
audio_frames
bytes
required
Raw audio bytes to analyze.