@ai-coustics/aic-sdk 0.24.0, Core SDK 0.24.0. API index · Node.js quickstart.
Processor
Synchronous mono enhancement on the calling JavaScript thread. Use an enhancement or bypass model and a separate instance for each stream. Initialize before processing. The input buffer is modified in place.
Processor.constructor
model must be a live model handle of the required type. licenseKey is the SDK credential string; see authentication. Construction is synchronous and can throw for an invalid key, a disposed model or a model-type mismatch. Omitted or null otelConfig uses environment settings; otherwise pass an OtelConfig object. There is no automatic initialization.
Processor.dispose
Processor has been disposed. A context retained separately no longer reaches a live processor.
Processor.initialize
sampleRate is a whole-number rate in Hz; blockSize is a positive whole-number mono sample count. Query model.getOptimalBlockSize(sampleRate) for the preferred size. Omitted, undefined or null variableBlockSize means false, requiring exactly blockSize samples. Variable mode allows shorter blocks, with possible buffering delay, but rejects larger blocks. Unsupported configurations throw an SDK error. Initialization allocates memory. The streaming SDK accepts supported rates from 8,000 through 192,000 Hz. Call on the setup path before process.
Processor.process
audio must be a mono Float32Array of normalized samples, nominally -1 to 1, matching initialization. Writes enhanced samples directly into the caller’s array and returns void. Throws before initialization, after disposal, for a block mismatch or when processing is disallowed. If the underlying buffer is shared with another worker, prevent all concurrent access while this call runs. Copy input yourself if you need the original.
Processor.getContext
Processor.terminateSession
dispose(). Completion may involve asynchronous session handling when another session remains active. Do not use it as a flush operation. Runs synchronously and may block.
ProcessorAsync
Mono enhancement through Node’s shared libuv worker pool. Construction and disposal remain synchronous. Await initialization, then await each block before submitting the next block on the same instance. A mutex protects native access but does not guarantee submission order for overlapping calls. Use separate instances for concurrent streams.
ProcessorAsync.constructor
model must be a live model handle of the required type. licenseKey is the SDK credential string; see authentication. Construction is synchronous and can throw for an invalid key, a disposed model or a model-type mismatch. Omitted or null otelConfig uses environment settings; otherwise pass an OtelConfig object. There is no automatic initialization.
ProcessorAsync.dispose
withConfig. Queued operations that acquire the lock after disposal reject. Await pending operations before disposing.
ProcessorAsync.withConfig
sampleRate is a whole-number rate in Hz; blockSize is a positive whole-number mono sample count. Query model.getOptimalBlockSize(sampleRate) for the preferred size. Omitted, undefined or null variableBlockSize means false, requiring exactly blockSize samples. Variable mode allows shorter blocks, with possible buffering delay, but rejects larger blocks. Unsupported configurations reject the promise with an SDK error. Initialization allocates memory. Runs initialization on a worker and resolves to another handle to the same native instance, not a cloned processor. Disposing either handle invalidates both. Retain the original handle until initialization succeeds so a rejection can still be cleaned up.
ProcessorAsync.initialize
sampleRate is a whole-number rate in Hz; blockSize is a positive whole-number mono sample count. Query model.getOptimalBlockSize(sampleRate) for the preferred size. Omitted, undefined or null variableBlockSize means false, requiring exactly blockSize samples. Variable mode allows shorter blocks, with possible buffering delay, but rejects larger blocks. Unsupported configurations reject the promise with an SDK error. Initialization allocates memory. Runs on a libuv worker and resolves to void. Await it before any processing. SDK initialization failures reject the promise.
ProcessorAsync.process
audio into worker-owned memory on the JavaScript thread before queuing work. Resolves to a new Float32Array<ArrayBuffer> of enhanced samples; the caller’s array stays unchanged. The result never uses SharedArrayBuffer. Input must meet the same mono format and block-length contract as Processor.process. Native errors reject the promise. Await each block to preserve stream order; do not queue an unbounded audio backlog.
ProcessorAsync.getContext
ProcessorContext. The worker waits for the instance lock. Context methods are synchronous after the handle resolves. Rejects if the processor was disposed before the worker acquired it.
ProcessorAsync.terminateSession
dispose(). Completion may involve asynchronous session handling when another session remains active. Do not use it as a flush operation. Runs on a libuv worker; await the returned promise before disposal.
ProcessorContext
Control handle obtained from Processor.getContext() or await ProcessorAsync.getContext(). There is no public constructor or dispose() method. Its synchronous methods use the shared control state and may be called while processing runs. A retained handle remains valid after the processor is disposed, but no longer controls a live processor. Keep lifecycle changes outside audio callbacks.
ProcessorContext.setParameter
parameter selects a ProcessorParameter; value must meet its range. Converts the JavaScript number to a 32-bit float before setting it. Invalid enum/value arguments throw. See the enum below for bypass’s boolean readback behavior.
ProcessorContext.getParameter
parameter, widened from a 32-bit float. For example, setting 0.8 can read back as Math.fround(0.8). Invalid parameter values throw.
ProcessorContext.getAudioDelay
samples * 1000 / sampleRate. It is not wall-clock inference time.
ProcessorContext.reset
ProcessorContext.updateBearerToken
token replaces a bearer token on a JWT-authenticated session. Both the original credential and replacement must be JWT-form licenses. A synchronous failure preserves the previous token. Return without error confirms local format acceptance, not backend acceptance; subsequent reporting can reject the token and eventually disable work. Obtain a valid replacement to recover. This operation allocates and takes a lock; keep it outside audio callbacks. See authentication.
ProcessorParameter
Exported numeric enum used by ProcessorContext. Parameters are stored as 32-bit floats even though JavaScript exposes number. Read back the value when exact comparison matters. Changes are observed by subsequent processing; they do not rewrite already produced audio.
ProcessorParameter.Bypass
0. The parameter accepts values from 0 to 1: 0 enables enhancement and any value greater than 0 enables bypass. Readback is exactly 0 or 1. Default is 0. Bypass preserves processing delay; it is not an undelayed raw-audio path.
ProcessorParameter.EnhancementLevel
1. Accepts 0 to 1. Defaults are taken from model metadata, falling back to 1 where no model default is supplied; read the effective value from the context. The effect depends on the model: compare Quail model suppression and Rook Multi Speaker listening quality on representative audio.
Example
With the pinned package installed, setAIC_SDK_LICENSE and run node enhance-block.cjs path/to/enhancement.aicmodel. This processes one silent block and reports its length and newBuffer: true. It demonstrates buffer ownership, not enhancement quality. Use the WAV quickstart for meaningful audio output.
enhance-block.cjs