Skip to main content
Version: @ai-coustics/aic-sdk-wasm 0.23.0, Core SDK 0.23.0. API index · WebAssembly quickstart. Initialize the module once before loading models or constructing SDK objects. Processing, VAD and analysis calls are synchronous; the asynchronous initializer loads the module but does not turn processing into background work. A long loop can block the browser event loop and delay session requests. For background processing, initialize and own SDK objects inside a worker, then pass ordinary audio buffers through your application. Do not transfer SDK handles between workers or WebAssembly instances.

__wbg_init

The default export, conventionally imported as init, asynchronously instantiates the module. With no argument, it resolves aic_sdk_wasm_bg.wasm relative to the JavaScript module URL and fetches it. Serve both package files through your bundler or web server. Prefer the object form, for example await init({ module_or_path: wasmUrl }). The older bare input form remains accepted but logs a deprecation warning. A directly supplied Request, URL or string is fetched. A Response, byte buffer or compiled module can be supplied directly or through a promise. Although the declaration permits Promise<InitInput>, this release checks whether to fetch before awaiting the input. Resolve promises of URLs, strings or requests yourself before passing their value to the initializer; a promise of a URL is not fetched automatically. HTTP, fetch and WebAssembly compilation/instantiation failures reject the promise. Correct application/wasm MIME enables streaming instantiation; the loader can fall back to buffering for an unsuitable MIME type. After successful initialization, later calls return the already initialized instance. Complete one initialization before using the SDK; do not rely on simultaneous first calls sharing an in-flight promise.

initSync

Synchronously instantiates already available bytes or a compiled WebAssembly.Module. Prefer initSync({ module: bytes }); the bare form is deprecated. It performs no download and throws if compilation or instantiation fails. It returns the already initialized instance if initialization has completed. Use the asynchronous initializer when bytes still need to be fetched.

InitInput

Accepted input forms for the asynchronous initializer. A string URL is included through RequestInfo.

SyncInitInput

Accepted input forms for initSync. Fetch or read the bytes before calling it.

InitOutput

The initializer returns the generated raw WebAssembly export object. Application code normally ignores it and uses the exported JavaScript classes. Its memory field is a WebAssembly.Memory; its remaining fields contain raw pointer-level calls, allocation helpers, tables and binding internals. These generated ABI members are excluded from the application API documented here. Do not call their raw constructors or destructors, mix pointers with JavaScript handles or rely on their names across builds. The installed package’s .d.ts contains the complete ABI declaration.

__aic_sdk_wasm_init

Generated startup hook invoked by module initialization. It sets up panic reporting and SDK wrapper identification. It is exported for binding startup, not for application initialization; use the default export or initSync instead.

Ownership and cleanup

Model, Processor, ProcessorContext, Vad, VadContext, Analyzer and AnalysisResult all own WebAssembly allocations. Every returned handle needs its own free() call, including repeated context queries and each analysis result. Methods and properties require a live handle. Do not call free() twice, use a freed handle or pass a handle from a different module instance. When the runtime supports Symbol.dispose, the package aliases it to free() on all seven classes. Otherwise, use explicit finally cleanup. Finalization support does not guarantee when memory will be reclaimed. Terminate a processing or analysis session when finished and free the corresponding handle separately. The termination method returns void; it does not wait for the request to reach the server. Keep persistent SDK keys on your backend and pass short-lived JWTs to browser constructors. See authentication for the token flow.