aic-sdk==3.3.0. Core SDK: 0.25.0. Source: Python wrapper 3.3.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. To detect speech with an enhancement model instead of a dedicated VAD model, useEnergyVadContext.
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:
Vad() constructor
vad-ms-2.1-xxs-16khz. Enhancement models raise ModelTypeUnsupportedError; for an enhancement model, use Processor.get_energy_vad_context().
If config is provided, the VAD is initialized immediately. Otherwise, call initialize() before processing audio.
Parameters
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()
AudioConfigUnsupportedError.
For the most frequent prediction updates, use ProcessorConfig.optimal(model).
Parameters
ProcessorConfig
required
Audio configuration. See
ProcessorConfig.Vad.process()
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
NotInitializedError: If the VAD has not been initialized.AudioConfigMismatchError: If the block size does not match the configuration.ProcessingNotAllowedError: If processing is not authorized.
Vad.get_context()
VadContext for reading predictions and controlling the VAD.
Vad.terminate_session()
VadAsync
class
Async voice activity detector backed by a dedicated VAD model. Awaitable processing runs on the shared SDK processing pool. The constructor andget_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
vad-ms-2.1-xxs-16khz. Enhancement models raise ModelTypeUnsupportedError; for an enhancement model, use ProcessorAsync.get_energy_vad_context().
Parameters
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
None after initialization. Unsupported configurations raise AudioConfigUnsupportedError when awaited. The configuration is copied into the operation.
VadAsync.process_async()
async
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()
VadContext for reading predictions and controlling the VAD.
VadAsync.terminate_session_async()
async
VadContext
class
Shared control handle for aVad.
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()
get_prediction_delay() samples. If the backing Vad stops being processed, the prediction does not update.
VadContext.raw_vad_probability()
get_prediction_delay() samples.
VadContext.set_parameter()
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()
VadContext.parameter()
deprecated
VadContext.get_prediction_delay()
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()
reset(), is_speech_detected() is False and raw_vad_probability() is 0.0.
VadContext.update_bearer_token()
TokenUnsupportedError is raised. Embedded NUL characters raise LicenseFormatInvalidError. A successful update is not proof of backend acceptance; continue handling processing errors.
EnergyVadContext
class
Control handle for an enhancement processor’s energy-based voice activity detector. Detection uses the enhanced signal before output mixing and runs no separate VAD model, so an enhancement model provides speech decisions without loading a dedicated VAD model. There is no publicEnergyVadContext() constructor. Create one with Processor.get_energy_vad_context() or ProcessorAsync.get_energy_vad_context(). Contexts from the same processor share one detector and can be used from any thread.
Creating a context keeps enhancement inference active even when the processor is bypassed or its enhancement level is zero. Inference stays active for the processor’s lifetime, even after every context is released. A context remains usable after the processor is destroyed but receives no further audio, and releasing a context neither destroys the processor nor disables detection.
Sensitivity uses the energy range, 1.0 to 15.0, rather than the 0.0 to 1.0 probability threshold of a dedicated VAD model. See VadParameter.Sensitivity.
Example
EnergyVadContext.is_speech_detected()
False before processing and after reset(). It updates as the processor processes audio and lags its input by get_prediction_delay() samples.
EnergyVadContext.set_parameter()
VadParameter
required
Parameter to modify. See
VadParameter.float
required
New parameter value.
Sensitivity ranges from 1.0 to 15.0 on this context.ParameterOutOfRangeError: If the parameter value is out of range.
EnergyVadContext.get_parameter()
VadParameter
required
Parameter to query. See
VadParameter.float: The current parameter value.
EnergyVadContext.get_prediction_delay()
ProcessorContext.get_audio_delay(). Energy detection adds no audio delay. SpeechHoldDuration and MinimumSpeechDuration also affect decision timing but are not included.
Before initialization the value uses the model’s optimal block size and native sample rate. After initialization it includes input buffering for the configured block size and is expressed in samples at the configured sample rate. A nonoptimal or variable block size adds buffering delay, which is included.
Returns
int: The delay in samples.
EnergyVadContext.reset()
ProcessorContext.reset() also resets the energy VAD.
Concurrency. The underlying SDK reset is real-time safe. Python calls still involve the interpreter; this is not a hard real-time guarantee for a Python callback.
VadParameter
enum
Parameter constants for voice activity detection. Use named constants directly; the runtime exposes PyO3 enum-like objects rather than promising standard-libraryenum.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 approximatelyspeech_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.VadParameter.Sensitivity
Threshold used to decide whether speech is detected. Its meaning and range depend on the detector.Vad and VadAsync run a dedicated VAD model, which outputs a speech probability for each processed audio block. A value above this threshold triggers a speech-detected decision.
EnergyVadContext compares the energy left in the enhanced signal against 10 ** -sensitivity, so higher values detect quieter speech.
Range: 0.0–1.0 for dedicated VAD models; 1.0–15.0 for the energy VAD
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.