Skip to main content
The WebAssembly binding runs models in the browser. This guide uses npm package 0.23.0. Use the WebAssembly API reference for initialization, classes and resource cleanup. The package includes the released aic_sdk_wasm.d.ts type declarations. Use the compatibility matrix when selecting models and upgrading. The package also exports dedicated Vad and Analyzer APIs. Feed VAD the original input; do not infer that another binding’s async or telemetry configuration API exists in WASM. See authentication and streams and state.

Installation

Use @ai-coustics/aic-sdk-wasm 0.23.0, Node.js 22 or later for the local token server and a browser with WebAssembly SIMD support. This example processes a local recording into a mono WAV; it does not use an AudioWorklet or microphone pipeline. Download the noisy speech fixture, or use a short recording you have permission to process, exported as mono PCM16 WAV at 16 kHz. The example accepts up to 60 seconds. Create an SDK key in the developer platform and put it in the server’s AIC_SDK_LICENSE environment variable. Do not put the key into HTML, browser storage or client configuration.
Set the server credential in this terminal without putting it in shell history:
Paste your SDK key at the hidden prompt and press Enter. The key remains on the server; the browser receives a short-lived JSON Web Token (JWT).

Quickstart

Create the local token server

Save the following as server.mjs. This server binds to loopback and serves only the listed files. The token endpoint checks the request origin and returns no cached credentials. It decodes the SDK key on the server using the documented token flow.
This is a local development server. Before production, replace it with an HTTPS backend that authenticates users, authorizes SDK access and enforces rate and usage limits. Never expose this demo server on a public interface.
server.mjs

Create the browser page

Save this as index.html beside server.mjs. Audio stays in browser memory. The page loads the WASM module and model, requests a token, processes complete frames, pads the tail and removes the reported delay before creating the output file. Session authorization and usage reporting still require network access.
index.html

Run and check the result

Open http://127.0.0.1:4173, select your recording and choose Enhance. On success, the page displays the number of processed samples and SDK version and exposes Download enhanced.wav. The output has the same sample count as the input, one channel and a 16 kHz sample rate. Compare both files to evaluate quality for your task. Each recording uses a fresh token with at least two minutes of remaining validity. Processing stops after one minute of wall time. These are demo bounds, not SDK limits. Stop the server with Ctrl+C, then run unset AIC_SDK_LICENSE.

Recover from an error

Adapt this example

Use one processor per independent audio stream. Processor.process() mutates its Float32Array in place and runs synchronously. Move sustained processing off the main UI thread and design buffering around the audio format and latency contracts. For a long-running stream, refresh a JWT through your authenticated backend before expiry and update the existing context:
Both the original and replacement credentials must be JWTs. A successful local update does not prove backend acceptance; handle subsequent processing errors. Keep only the current short-lived token in memory. Never log it or save it to local storage. At shutdown, free the context and model, terminate the session and free the processor as shown above.