Skip to main content
Version: @ai-coustics/aic-sdk-wasm 0.23.0, Core SDK 0.23.0. API index · WebAssembly quickstart.

Analyzer

Collects mono audio and runs an analysis model such as Tyto over the latest retained window. The window uses the maximum length supported by the model; this binding has no window-length argument. New audio replaces older audio. Short histories include zero-filled input, so track how much real audio you have collected.

Analyzer.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.

Analyzer.Symbol.dispose

Aliases free() when the runtime supports Symbol.dispose; do not call both on the same handle. Otherwise, call free() in finally.

Analyzer.analyze

Synchronously analyzes the current retained window and returns a newly allocated AnalysisResult. It blocks the calling JavaScript thread. Short or empty histories are zero-padded; a successful result does not establish that enough real audio was collected. This method reads a snapshot and does not consume or clear the buffered history. Throws for disallowed processing or native analysis failure. Free each returned result after copying its values.

Analyzer.buffer

Synchronously collects a block of normalized mono Float32Array samples without modifying the caller’s array. The binding copies samples into WebAssembly memory. This call does not run analysis inference. Requires successful initialization and the configured block length; invalid input throws. The collector retains only the newest model window.

Analyzer.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.

Analyzer.constructor

Creates an analysis collector and engine using a live analysis model and the credential in license_key. Use a backend-issued short-lived JWT in browsers. An enhancement or VAD model cannot be analyzed through this interface. Construction can throw for model type, runtime creation or credential errors. No OpenTelemetry configuration or analysis-window argument is exposed.

Analyzer.reset

Requests clearing of collector signal history on the next buffer call while preserving the initialized audio format. Until that call applies the reset, analyze() uses a zero-filled snapshot instead of the previously buffered audio.

Analyzer.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.

Analyzer.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.

AnalysisResult

An owned WebAssembly result returned by Analyzer.analyze, with seven read-only numeric properties. Its constructor is private. Read the values into ordinary JavaScript data before freeing the result. It is not a plain JavaScript record and spreading it does not copy these prototype getters.

AnalysisResult.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.

AnalysisResult.Symbol.dispose

Aliases free() when the runtime supports Symbol.dispose; do not call both on the same handle. Otherwise, call free() in finally.

AnalysisResult.codecDegradation

Codec-degradation estimate from the analysis model.

AnalysisResult.interferingSpeech

Interfering-speech estimate, taking the larger of the model’s background-speaker and background-media outputs.

AnalysisResult.noise

Background-noise estimate from the analysis model.

AnalysisResult.packetLoss

Packet-loss estimate from the analysis model.

AnalysisResult.riskScore

Composite risk score derived from the model outputs and the loaded model’s postprocessing coefficients. It is not a measured word error rate.

AnalysisResult.speakerLoudness

Main-speaker loudness estimate from the analysis model. Do not interpret it as a calibrated sound-pressure measurement.

AnalysisResult.speakerReverb

Main-speaker reverberation estimate from the analysis model.

Copy and release a result

This helper assumes initialization has completed, model is a live analysis model and token is a backend-issued JWT. Supply mono audio at the model’s optimal sample rate with a length divisible by its optimal block size. It buffers the supplied audio and returns ordinary JavaScript numbers, freeing the WebAssembly result afterward. Supply enough real audio for the model’s window; shorter input is padded with zeros. Buffering a long recording synchronously blocks the event loop, so run that work in an appropriate worker.