aic_quail_vad
Standalone VAD analyzer for Pipecat backed by the ai-coustics SDK.
Runs a dedicated ai-coustics VAD model as its own detector. The analyzer owns
its aic_sdk.Vad instance and can be placed anywhere in the pipeline.
- Classes:
AICQuailVADAnalyzer: Standalone ai-coustics VAD analyzer.
- class pipecat.audio.vad.aic_quail_vad.AICQuailVADAnalyzer(*, license_key: str, model_id: str | None = 'vad-ms-2.1-xxs-16khz', model_path: Path | None = None, model_download_dir: Path | None = None, speech_hold_duration: float | None = None, minimum_speech_duration: float | None = None, sensitivity: float | None = None, sample_rate: int | None = None, params: VADParams | None = None)[source]
Bases:
VADAnalyzerStandalone VAD analyzer powered by the ai-coustics SDK.
The analyzer owns a dedicated
aic_sdk.Vadinitialized with a VAD-only model. Eachvoice_confidence()call processes one audio window and returns the model’s raw speech probability in[0.0, 1.0](aic_sdk.VadContext.raw_vad_probability()). The baseVADAnalyzerstate machine then gates speech start/stop using its ownVADParams(confidencethreshold,start_secs,stop_secs), so the SDK’s own VAD post-processing (sensitivity thresholding, speech-hold) is bypassed — Pipecat owns the thresholding.The analyzer reads whatever audio the pipeline feeds it. When
pipecat.audio.filters.aic_filter.AICFilteris installed as the transport’saudio_in_filter, that audio has already been enhanced, while the AIC SDK expects a VAD to run on the original signal. Detection still works, but the model is judging audio it was not trained on and the filter’s own delay is added to the VAD’s prediction delay. Pipecat offers no hook for tapping pre-enhancement audio further down the pipeline, so this is a limitation of pairing the two rather than something the analyzer can correct.Example:
analyzer = AICQuailVADAnalyzer(license_key=os.environ["AIC_SDK_LICENSE"]) # ``set_sample_rate`` is invoked by the pipeline once the transport # sample rate is known.
- __init__(*, license_key: str, model_id: str | None = 'vad-ms-2.1-xxs-16khz', model_path: Path | None = None, model_download_dir: Path | None = None, speech_hold_duration: float | None = None, minimum_speech_duration: float | None = None, sensitivity: float | None = None, sample_rate: int | None = None, params: VADParams | None = None) None[source]
Initialize the VAD analyzer.
Loads the model eagerly so the cold-start CDN download happens at construction time (typically before the event loop starts), rather than on the first
set_sample_rate()call from a running pipeline.- Parameters:
license_key – ai-coustics SDK license key.
model_id – Dedicated VAD model identifier. Defaults to
"vad-ms-2.1-xxs-16khz". See https://artifacts.ai-coustics.io/ for the catalogue. Ignored ifmodel_pathis provided. Enhancement models are rejected by the SDK.model_path – Optional path to a local
.aicmodelfile. Overridesmodel_idwhen set.model_download_dir – Directory for downloaded models. Defaults to
~/.cache/pipecat/aic-models.speech_hold_duration –
Deprecated; no longer used. Speech timing is governed by Pipecat’s
VADParams.Deprecated since version 1.5.0: Use
VADParams(start_secs/stop_secs) instead.speech_hold_durationis ignored and will be removed in 2.0.0.minimum_speech_duration –
Deprecated; no longer used. Speech timing is governed by Pipecat’s
VADParams.Deprecated since version 1.5.0: Use
VADParams(start_secs/stop_secs) instead.minimum_speech_durationis ignored and will be removed in 2.0.0.sensitivity –
Deprecated; no longer used. The speech-probability threshold is now governed by Pipecat’s
VADParams.confidence.Deprecated since version 1.5.0: Use
VADParams(confidence) instead.sensitivityis ignored and will be removed in 2.0.0.sample_rate – Initial sample rate; the pipeline will set this via
set_sample_rate()once the transport rate is known.params – Optional
VADParamsfor the base state machine.
- Raises:
ValueError – If neither
model_idnormodel_pathis provided.
- set_sample_rate(sample_rate: int) None[source]
Set the sample rate. Recreates the SDK VAD if the rate changed.
Initializes the VAD before delegating to the base class so the base’s internal sizing uses the correct
num_frames_required()(driven by the model’s optimal block size) instead of the pre-init fallback. If VAD initialization fails, the previous VAD/state is restored so the analyzer stays usable at its old sample rate rather than half-initialized.- Parameters:
sample_rate – Audio sample rate in Hz.
- voice_confidence(buffer: bytes) float[source]
Run the VAD model on one audio window.
- Parameters:
buffer – int16 little-endian audio samples for one window of
num_frames_required()samples.- Returns:
The model’s raw speech probability in
[0.0, 1.0]. The baseVADAnalyzercompares this againstVADParams.confidenceto decide speech. Returns0.0if the VAD is not yet initialized (i.e.set_sample_rate()has not run), if the buffer size does not match the expected window, or if an SDK inference error occurs.
- async cleanup() None[source]
Terminate the VAD session and release the model handle.
Concurrency contract: callers must ensure no
voice_confidence()call is in flight whencleanupruns. The pipeline always orderscleanupafter the source-stream stop, so in normal pipeline use this is guaranteed. If you invokecleanupfrom outside that ordering, drain or cancel any in-flightanalyze_audio()work first.