xr_ai_vad#
Shared Silero-VAD utterance detector for xr-ai agent workers.
Consumes int16 LE PCM bytes and emits int16 PCM utterance bytes via an async callback when speech ends.
Attributes#
Async callback fired once when an utterance crosses the speech threshold. |
|
Async callback receiving completed int16 PCM bytes and their sample rate. |
Classes#
Per-participant Silero VAD + utterance accumulator. |
Package Contents#
- xr_ai_vad.OnSpeechStartCb#
Async callback fired once when an utterance crosses the speech threshold.
- xr_ai_vad.OnUtteranceCb#
Async callback receiving completed int16 PCM bytes and their sample rate.
- class xr_ai_vad.VadDetector(
- on_utterance: OnUtteranceCb,
- *,
- on_speech_start: OnSpeechStartCb | None = None,
- silence_duration: float = 0.8,
- min_speech: float = 0.15,
- silero_threshold: float = 0.5,
Per-participant Silero VAD + utterance accumulator.
feed()accepts raw int16 LE PCM bytes. When a complete utterance is detected (silence aftermin_speech) theon_utterancecallback is awaited with int16 PCM bytes and the sample rate.When
on_speech_startis provided, it fires once per utterance at the momentspeech_sfirst crossesmin_speech— a “leading edge” hook for speculative work (e.g. warming up a downstream resource before STT completes).- reset() None#
Drop any in-progress utterance without emitting it.
- async feed(pcm_int16: bytes, sample_rate: int) None#
Process one chunk of int16 LE PCM audio.
pcm_int16— raw int16 little-endian PCM bytes (mono).sample_rate— sample rate in Hz.