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

Model

A loaded model and its metadata. Create it with Model.fromBytes; its constructor is private. Model storage is retained by each processor, VAD or analyzer created from it. Those instances remain valid if the original Model handle is freed.

Model.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. Dependent processors, VAD instances and analyzers retain shared model storage until they are freed.

Model.Symbol.dispose

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

Model.fromBytes

Loads an .aicmodel from bytes and returns a new model. The wrapper copies bytes into owned aligned storage; the caller may release or change the original Uint8Array after this call. Loading can throw for invalid, incompatible or unsupported data, or allocation failure. There is no Model.download or Model.fromFile in this package. Fetch the bytes asynchronously in your application, then call this synchronous factory.

Model.getId

Returns the model ID embedded in the loaded file as a JavaScript string. This is a metadata query and does not require a credential.

Model.getOptimalBlockSize

Returns the preferred mono block size, in samples, for the requested whole-number host sample rate in Hz. Query the rate you will actually initialize. The query computes a size; it is not a substitute for initialization validation.

Model.getOptimalSampleRate

Returns the model’s native sample rate in Hz. Use this as the starting point for initialization; other supported host rates require adaptation.

getVersion

Returns this WebAssembly wrapper’s package version, 0.23.0 for this release. It is not a query of a separately installed native library.

getCompatibleModelVersion

Returns the model format version supported by the compiled runtime. This is a format compatibility number, not a model ID or package release version. Model loading still validates the supplied file.

Fetch and inspect a model

After initialization, fetch a model URL supplied by your application. This helper checks the HTTP response and frees the loaded model after reading its metadata. It requires no SDK credential.