Skip to main content
Package: aic-sdk==3.2.0. Core SDK: 0.24.0. Source: Python wrapper 3.2.0. The fragments below use these imports. Supply license_key from your approved secret source and use the loaded model and initialized objects described in each section. For a complete file-processing example and tuning guidance, follow the ai-coustics VAD guide.
audio denotes a one-dimensional NumPy float32 array. Async fragments run inside an async function.

Vad

class

Stateful voice activity detector (VAD) backed by a dedicated VAD model. Use one instance per independent stream and serialize initialization and processing on each instance. Native resources are released when Python releases the object. Feed mono audio to process() and read predictions through get_context(). The audio is not modified; processing only updates the detector’s prediction. When enhancement and VAD run together, feed the VAD the original input audio, not the enhanced output of Processor.process(). Run both on the same block instead of chaining them:
Example

Vad() constructor

Creates a voice activity detector. The model must be a dedicated VAD model, such as vad-ms-2.1-xxs-16khz. Enhancement models raise ModelTypeUnsupportedError. If config is provided, the VAD is initialized immediately. Otherwise, call initialize() before processing audio. Parameters
Model
required
A loaded dedicated VAD model. See Model.
str
required
SDK key or JWT for the ai-coustics SDK.
ProcessorConfig | None
default:"None"
Optional audio configuration. See ProcessorConfig.
OtelConfig | None
default:"None"
Optional per-instance OpenTelemetry configuration. See OtelConfig.

Vad.initialize()

Configures the VAD for a sample rate and block size. Unsupported configurations raise AudioConfigUnsupportedError. For the most frequent prediction updates, use ProcessorConfig.optimal(model). Parameters
ProcessorConfig
required
Audio configuration. See ProcessorConfig.
This method allocates memory and is not real-time safe.

Vad.process()

Accepts a one-dimensional NumPy float32 array of normalized mono samples. Its length must equal config.block_size, or be 1 through config.block_size when variable blocks are enabled. Native work releases the GIL. A contiguous array is read directly; a strided view is copied. Do not mutate a shared input while the call runs. Wrong dtype or dimensionality raises TypeError. Returns None: VAD processing does not modify the audio. Read the updated prediction through get_context(). When enhancement and VAD run together, pass the original input audio here, not the enhanced output of Processor.process(). Raises

Vad.get_context()

Returns a VadContext for reading predictions and controlling the VAD.

Vad.terminate_session()

Terminates the VAD’s telemetry session. Stop submitting audio and treat this session as closed once you request termination. Processing becomes disallowed when the native lifecycle task handles the signal. The call can return before that handling completes when other sessions remain alive; it is not proof of remote usage acknowledgment. The session is also stopped when the object is destroyed.
This method may block and is not real-time safe.

VadAsync

class

Async voice activity detector backed by a dedicated VAD model. Awaitable processing runs on the shared SDK processing pool. The constructor and get_context() are synchronous; both can block. Omit config at construction and await initialize_async(config) to initialize asynchronously. Await blocks in stream order and bound pending work. See async enhancement for pool settings and concurrency. When enhancement and VAD run together, feed the VAD the original input audio, not the enhanced output of ProcessorAsync.process_async().

VadAsync() constructor

Creates an async voice activity detector. The model must be a dedicated VAD model, such as vad-ms-2.1-xxs-16khz. Enhancement models raise ModelTypeUnsupportedError. Parameters
Model
required
A loaded dedicated VAD model. See Model.
str
required
SDK key or JWT for the ai-coustics SDK.
ProcessorConfig | None
default:"None"
Optional audio configuration. See ProcessorConfig.
OtelConfig | None
default:"None"
Optional per-instance OpenTelemetry configuration. See OtelConfig.

VadAsync.initialize_async()

async

Returns an awaitable resolving to None after initialization. Unsupported configurations raise AudioConfigUnsupportedError when awaited. The configuration is copied into the operation.

VadAsync.process_async()

async

Copies the one-dimensional NumPy float32 input before dispatch, then updates the VAD prediction in the background. Await it to obtain None. Input remains unchanged; the length, dtype and SDK error rules of Vad.process() apply. After awaiting, read the updated prediction through get_context(). When enhancement and VAD run together, pass the original input audio here, not the enhanced output of ProcessorAsync.process_async().

VadAsync.get_context()

Returns a VadContext for reading predictions and controlling the VAD.

VadAsync.terminate_session_async()

async

Terminates the VAD’s telemetry session asynchronously. Await the returned awaitable and stop submitting audio. Treat the session as closed immediately; native processing becomes disallowed when the lifecycle task handles the signal. Other live sessions can allow termination handling to continue after the awaitable resolves. Await completion does not prove remote usage acknowledgment.

VadContext

class

Shared control handle for a Vad. There is no public VadContext() constructor. Contexts created by the same Vad reference the same detector. They can be used from any thread while audio is being processed elsewhere.

VadContext.is_speech_detected()

Returns the post-processed VAD prediction. The prediction lags its input by get_prediction_delay() samples. If the backing Vad stops being processed, the prediction does not update.

VadContext.raw_vad_probability()

Returns the VAD model’s raw speech probability without SDK post-processing. The prediction lags its input by get_prediction_delay() samples.

VadContext.set_parameter()

Modifies a VAD parameter. Out-of-range values, including NaN, raise ParameterOutOfRangeError. Query get_parameter() for the value used by the current model. Parameters
VadParameter
required
Parameter to modify. See VadParameter.
float
required
New parameter value.

VadContext.get_parameter()

Retrieves the current value of a VAD parameter.

VadContext.parameter()

deprecated

Deprecated. Use get_parameter() instead.

VadContext.get_prediction_delay()

Returns the total VAD prediction delay in samples. This includes input reblocking, model processing and buffering overhead for the current configuration. Use it to align speech decisions with the input timeline. This delay is not applied to the audio: Vad.process() leaves its input untouched. The value only describes how far behind its input the published prediction is, and it is independent of ProcessorContext.get_audio_delay().

VadContext.reset()

Clears the VAD’s internal state and published predictions. The VAD remains initialized. Reset clears the published predictions immediately and requests internal processing state reset for the next block. Immediately after reset(), is_speech_detected() is False and raw_vad_probability() is 0.0.

VadContext.update_bearer_token()

Replaces the bearer token on the running VAD. Both the original key and new token must be JWTs. Otherwise TokenUnsupportedError is raised. Embedded NUL characters raise LicenseFormatInvalidError. A successful update is not proof of backend acceptance; continue handling processing errors.

VadParameter

enum

Parameter constants for voice activity detection. Use named constants directly; the runtime exposes PyO3 enum-like objects rather than promising standard-library enum.Enum iteration or .value behavior.

VadParameter members

VadParameter.SpeechHoldDuration

Controls how long the VAD continues to detect speech after the audio signal no longer contains speech. This affects the stability of speech detected -> not detected transitions. When the current probability is at or below the threshold, speech remains detected while at least half of the retained history was above threshold. The history spans approximately speech_hold_duration * 2 seconds. When the current probability is above threshold, the consecutive-frame test uses MinimumSpeechDuration. For example, a speech_hold_duration of 0.5 s sustains detection for 0.5 s after speech stops. Additional speech blocks during that period can extend detection until the 50% history threshold is no longer met.
Timing is rounded to the nearest model window: for a 10 ms window, to the nearest multiple of 10 ms. get_parameter() returns the stored requested value, not the effective transition timing.
Range: 0.0 to 300x model window length (seconds) Default: model-specific

VadParameter.Sensitivity

Probability threshold used to decide whether speech is detected. Dedicated VAD models output a speech probability for each processed audio block. A value above this threshold triggers a speech-detected decision. Range: 0.0–1.0 Default: model-specific

VadParameter.MinimumSpeechDuration

Controls how long speech needs to be present in the audio signal before the VAD considers it speech. This affects the stability of speech not detected -> detected transitions.
Timing is rounded to the nearest model window: for a 10 ms window, to the nearest multiple of 10 ms. get_parameter() returns the stored requested value, not the effective transition timing.
Range: 0.0–1.0 (seconds) Default: model-specific See the Python API index, Python guide and troubleshooting.