Version: @ai-coustics/aic-sdk-wasm 0.25.0, Core SDK 0.25.0. API index · WebAssembly quickstart.
Vad
A synchronous dedicated voice activity detection stream. Supply a VAD Multi Speaker or VAD Voice Focus model. Each instance keeps separate signal state and retains the model weights.
Vad.free
Releases the owned WebAssembly allocation. Call once in finally and do not use the handle afterward. Garbage collection does not guarantee timely cleanup; free() does not acknowledge session termination.
Vad.Symbol.dispose
Aliases free() when the runtime supports Symbol.dispose; do not call both on the same handle. Otherwise, call free() in finally.
Vad.getContext
Returns a newly owned handle to shared prediction and control state. The handle does not contain a separate VAD model. Repeated calls require separate free() calls for the returned contexts.
Renamed in 0.25.0. This method was getVadContext() through 0.23.0.
Vad.initialize
All three arguments are required. sample_rate is a whole-number rate in Hz from 8,000 through 192,000; block_size is a positive whole-number count of mono samples, not bytes. Prefer the model’s optimal sample rate and block size. Unsupported block configurations throw. Pass false for fixed blocks of exactly block_size samples or true to permit shorter blocks up to that maximum. Variable blocks can add buffering delay. Initialization allocates memory and resets signal state. A failed initialization leaves processing uninitialized; correct the configuration before submitting audio again.
Vad.constructor
Creates a dedicated VAD stream using a live VAD model and the credential in license_key. Use a short-lived JWT from your backend in browser code. Enhancement and analysis models are rejected. Construction can throw for model type, model creation or credential errors. Initialize the audio format before processing. No OpenTelemetry configuration argument is exposed.
Vad.process
Processes one block of normalized mono Float32Array samples without changing the caller’s array. Samples are copied into WebAssembly memory and into the VAD’s processing buffer. Returns void; read the prediction through the context afterward. Requires successful initialization and the configured block length. Throws for uninitialized or mismatched audio, disallowed processing or runtime failures.
Vad.terminateSession
Requests termination of the telemetry session. Stop submitting audio before calling this method. Processing becomes disallowed once the telemetry task handles the signal; the void return is not an acknowledgment of server delivery or immediate completion. This method neither flushes delayed audio nor frees the object. Call free() separately when finished.
VadContext
A shared prediction and control handle returned by Vad.getContext. Its constructor is private. Each returned handle must be freed separately. Freeing it does not free its VAD. A surviving context retains state after the VAD is freed, but cannot produce new predictions.
VadContext.free
Releases the owned WebAssembly allocation. Call once in finally and do not use the handle afterward. Garbage collection does not guarantee timely cleanup; free() does not acknowledge session termination.
VadContext.Symbol.dispose
Aliases free() when the runtime supports Symbol.dispose; do not call both on the same handle. Otherwise, call free() in finally.
VadContext.getParameter
Returns the stored floating-point value for the selected VadParameter. Duration values are in seconds. Effective timing follows model frame boundaries; do not interpret the getter as a measurement of the resulting delay.
VadContext.getPredictionDelay
Returns end-to-end prediction delay in samples at the initialized host sample rate, including input block adaptation. Query after initialization. Divide by sample rate for seconds.
VadContext.getRawVadProbability
Returns the latest raw speech probability as a number from 0 through 1, before the hold and minimum-duration decision logic. A fresh or reset context reads 0 until new predictions are available.
VadContext.isSpeechDetected
Returns the latest speech decision after sensitivity and duration logic. A fresh or reset context reads false until processing provides a new decision.
VadContext.reset
Immediately clears the published speech decision and raw probability, and requests clearing of the underlying signal history on the next processing pass. Preserves the initialized format and configured parameters.
VadContext.setParameter
Sets the parameter for subsequent processing. Invalid ranges, infinities and NaN throw RangeError. Defaults come from the loaded model, so query them rather than assuming a universal preset. See VadParameter below for units and ranges.
VadContext.updateBearerToken
Replaces the bearer token for subsequent session requests without creating a new processing instance. Both the original credential and the replacement must be JWT-form credentials. A malformed or unsupported replacement throws and leaves the previous credential in place. Local format acceptance does not prove that the backend accepts the new token. Obtain fresh short-lived tokens through your backend; keep the SDK key on the server. This call returns void, not a network-completion promise.
EnergyVadContext
An energy VAD handle returned by Processor.getEnergyVadContext. Its constructor is private. Detection uses the enhanced signal before output mixing and runs no separate model, so an enhancement model yields speech decisions without loading a dedicated VAD model. Detection advances with Processor.process.
Every handle from one processor refers to the same energy VAD, and each must be freed separately. Freeing a handle does not free the processor or disable detection. A surviving handle stays usable after the processor is freed, but produces no new predictions.
Sensitivity uses the energy range, 1 through 15, not the 0 through 1 probability threshold of a dedicated VAD model. See VadParameter.Sensitivity.
EnergyVadContext.free
Releases this handle. Call it exactly once when finished; it does not free the backing processor.
EnergyVadContext.Symbol.dispose
Aliases free() when the runtime supports Symbol.dispose; do not call both on the same handle. Otherwise, call free() in finally.
EnergyVadContext.isSpeechDetected
Returns the energy VAD’s prediction. It is false before audio is processed and after a reset, and lags its input by getPredictionDelay() samples. Speech hold and minimum speech duration affect its timing further. The prediction stops updating if the backing processor stops being processed.
EnergyVadContext.setParameter
Modifies an energy VAD parameter. Sensitivity uses the energy range, 1 through 15. A value outside the valid range throws a RangeError. All parameters can be changed during processing.
EnergyVadContext.getParameter
Returns the current value of an energy VAD parameter.
EnergyVadContext.getPredictionDelay
Returns the prediction delay in samples, covering input reblocking, STFT and enhancement model processing. It equals ProcessorContext.getAudioDelay for the backing processor; energy detection does not delay the audio. Speech hold and minimum speech duration affect decision timing and are not included.
Before initialization the value uses the processor’s optimal block size at its native sample rate. After initialization it is expressed in samples at the rate given to Processor.initialize and includes input-buffering latency for the configured block size, which a nonoptimal or variable block size increases.
EnergyVadContext.reset
Clears the energy VAD state, including the published speech decision. Use it when the stream is interrupted or when seeking. Configured parameters are retained and the backing processor is not reset; ProcessorContext.reset also resets the energy VAD.
VadParameter
Parameters accepted by the getParameter and setParameter methods of VadContext and EnergyVadContext. Defaults are supplied by the model.
VadParameter.SpeechHoldDuration
Controls recent-speech hold behavior in seconds. Range: 0 through the model’s maximum supported hold duration. When the current probability is at or below the threshold, the decision uses the positive-frame count in the recent lookback window. Above the threshold, the consecutive-frame rule from MinimumSpeechDuration applies. Effective timing follows frame boundaries.
VadParameter.Sensitivity
Its meaning depends on the detector. On a VadContext, a speech-decision probability threshold from 0 through 1, where lower values classify more frames as speech. On an EnergyVadContext, the energy threshold of the enhanced signal, computed as 10 ** -sensitivity over 1 through 15, where higher values detect quieter speech.
VadParameter.MinimumSpeechDuration
Required speech duration in seconds, from 0 through 1, before speech is detected. Effective timing follows frame boundaries.
Read a block prediction
This helper assumes the module is initialized, model is a live dedicated VAD model, token is a backend-issued JWT and audio contains one optimal mono block. A single initial block can precede a usable prediction because of model delay and duration settings. Keep a VAD instance alive across the full stream in an integration.