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

Processor

A synchronous mono enhancement stream. Each instance has its own signal state and retains the model weights. Use one instance per stream and process blocks in order.

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

Processor.Symbol.dispose

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

Processor.getProcessorContext

Returns a newly owned handle to this processor’s shared control state. Repeated calls produce separate handles to the same state. Free each returned context when finished.

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

Processor.constructor

Creates an enhancement stream using a live model and the credential in license_key. For browser applications, pass a short-lived JWT supplied by your backend. Enhancement and bypass model types are accepted; dedicated VAD and analysis models are rejected. The constructor can throw for model creation, model type or credential errors. It does not initialize the audio format. No OpenTelemetry configuration argument is exposed.

Processor.process

Processes one block of normalized mono floating-point samples and writes the enhanced samples back into the same Float32Array. Returns void. The generated binding copies input into WebAssembly memory and copies processed values back; this is not zero-copy processing. Requires successful initialization and the configured block length. Throws for mismatched audio, disallowed processing or runtime failures. Do not rely on the input remaining unchanged if processing throws.

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

ProcessorContext

A shared control handle returned by Processor.getProcessorContext. Its constructor is private. Each returned context is separately owned and must be freed. Freeing a context does not free the processor. A context can retain control state after the processor is freed, but it does not keep an active processing stream alive.

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

ProcessorContext.Symbol.dispose

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

ProcessorContext.getAudioDelay

Returns end-to-end processing delay in samples at the initialized host sample rate, including block adaptation and model delay. Query after initialization or reinitialization. Divide by the host sample rate to convert to seconds.

ProcessorContext.getParameter

Returns the stored value for a ProcessorParameter. Bypass reads as 0 or 1; enhancement level is a normalized floating-point value.

ProcessorContext.reset

Requests clearing of signal history on the next processing pass, retaining the initialized audio configuration and parameter values. Use when beginning a new unrelated stream. It does not allocate a new processor or terminate its session.

ProcessorContext.setParameter

Sets the selected parameter. Both parameters accept finite values from 0 through 1; out-of-range values and NaN throw RangeError. Changes affect subsequent processing. See ProcessorParameter below for defaults and interpretation.

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

ProcessorParameter

Parameters accepted by ProcessorContext.getParameter and setParameter.

ProcessorParameter.Bypass

0 disables bypass; any accepted value greater than 0 enables bypass and reads back as 1. Default: 0. Bypass preserves the configured processing delay.

ProcessorParameter.EnhancementLevel

Normalized enhancement amount from 0 through 1. 0 is dry output and 1 uses the model’s maximum enhancement. The initial value is the model’s default, falling back to 1 when absent.

Process one block

This helper assumes module initialization has completed, model is a live enhancement model, token is a backend-issued JWT and audio contains exactly one optimal block of mono samples. It copies the caller’s block before enhancement, then returns the enhanced block and delay. For a stream, retain the processor across blocks instead of creating it for each call.