Skip to main content
Crate: aic-sdk = "=0.24.0". Core SDK: 0.24.0. Source: released crate. Signatures are declarations; import the named types from aic_sdk. See the Rust guide for a complete runnable program.

Vad

Stateful dedicated VAD. Feed original mono audio, independently of enhancement; processing leaves input unchanged. Use one instance per stream and read predictions from its context. Implements Drop, Send and Sync; borrowed model bytes must outlive the detector. Mutable access serializes processing and initialization.

Vad::new

Creates an uninitialized detector. The model must be a dedicated VAD model; an enhancement model returns ModelTypeUnsupported. Credentials are an SDK key or JWT.

Vad::with_otel_config

Creates an uninitialized detector with explicit copied telemetry settings. Invalid credentials return license errors; a NUL-containing session ID returns Internal.

Vad::with_config

Consumes the detector, initializes it and returns it on success. A failure drops the consumed detector.

Vad::initialize

Copies and validates the audio configuration. Unsupported settings return AudioConfigUnsupported. This allocates; run it outside the audio callback. Reinitialize successfully after any failed reconfiguration.

Vad::process

Reads normalized mono samples and updates detector state; returns no audio. Use exactly the configured block length, or a slice up to that length when variable blocks are enabled. Errors include NotInitialized, AudioConfigMismatch and ProcessingNotAllowed. Read predictions after successful processing.

Vad::context

Creates a shared prediction/control handle. Multiple handles refer to the same detector. Native failure is asserted and can panic.

Vad::terminate_session

Requests permanent session termination for this detector. Stop processing first and use a new object for another session. This may block and is unsuitable for the audio callback. Native work becomes disallowed when the lifecycle task handles the signal; with other sessions alive that can occur after return.

VadContext

Created by Vad::context or awaited VadAsync::context. Implements Drop, Send and Sync; no public constructor. It permits cross-thread prediction reads and parameter control while the detector processes elsewhere. Predictions stop updating when audio is no longer processed.

VadContext::is_speech_detected

Returns the latest post-processed decision. It lags the input by prediction_delay() samples; do not treat a stale decision as a new inference.

VadContext::raw_vad_probability

Returns the latest model probability without SDK hold/threshold post-processing. It has the same input alignment delay.

VadContext::set_parameter

Stores a parameter for the detector. Out-of-range or NaN values return ParameterOutOfRange. Effective transitions are quantized to model frames.

VadContext::parameter

Returns the stored parameter value. Duration readback is the requested value; it is not a promise of exact transition timing. Defaults are model-specific.

VadContext::prediction_delay

Returns prediction lag in samples at the configured input rate, including reblocking and model buffering. This delay is not applied to the input audio and is independent of enhancement audio delay. Value-returning native queries assert success and can panic on internal failures.

VadContext::reset

Immediately clears the published decision to false and raw probability to 0.0, and requests processing-state reset on the next block. Audio configuration remains initialized. A terminated session is not reopened.

VadContext::update_bearer_token

Updates a JWT only when the original and new credentials are JWTs; otherwise returns TokenUpdateUnsupported. Embedded NUL returns LicenseFormatInvalid. Local success does not prove backend acceptance; keep handling processing errors.

VadParameter

Named parameter selectors. Implements Debug, Clone, Copy, PartialEq, Eq and Hash, plus native parameter conversion. Read defaults from the active context.

VadParameter::SpeechHoldDuration

Duration in seconds controlling the speech-to-silence transition. Range: 0.0 through 300 times the model frame duration. The effective duration is rounded to model frames. When the current probability is at or below threshold, speech remains detected while at least half the approximately 2 * duration history was above threshold.

VadParameter::Sensitivity

Probability threshold, 0.0 through 1.0. A probability strictly greater than this value contributes a positive frame. A lower threshold is more permissive.

VadParameter::MinimumSpeechDuration

Duration in seconds required for consecutive above-threshold frames to turn speech detection on. Range: 0.0 through 1.0. Effective timing is rounded to model frames; the stored value can differ from the effective duration.

VadAsync

Requires feature: async. Uses the same shared worker pool and per-instance mutex as async enhancement. Constructors are synchronous, model data must be static, and async operations should be awaited in stream order. The type is Send and Sync; share through Arc when needed.

VadAsync::new

Creates an uninitialized dedicated detector. Model and credential errors match Vad::new.

VadAsync::with_otel_config

Creates an uninitialized detector with copied telemetry settings.

VadAsync::with_config

Consumes the detector and awaits initialization. Failure drops the consumed object.

VadAsync::initialize

Copies settings and initializes on the shared worker pool. Errors match Vad::initialize.

VadAsync::process

Consumes the vector, reads it on the processing pool and returns it unchanged on success. Updates the prediction. On failure the vector is dropped. This Rust return value differs from Python VAD’s None result; input length and errors match Vad::process.

VadAsync::terminate_session

Waits for exclusive access and requests termination. Stop submitting audio first; use a new object for another session. Await the method, but do not treat completion as proof that native signal handling or remote usage acknowledgment has finished when other sessions remain alive.

VadAsync::context

Waits for exclusive access and returns a context. Internal native context creation failure can panic. See configuration, errors and the symbol index.

Read a prediction

The caller supplies an initialized dedicated detector and a normalized mono block. Prediction is read only after successful processing: