Skip to main content
Version: @ai-coustics/aic-sdk 0.24.0, Core SDK 0.24.0. API index · Node.js quickstart.

Analyzer

A mono audio collector and analysis engine combined in one JavaScript object. Use an analysis model such as Tyto. Initialize, buffer original audio and analyze the retained window. Only the model’s maximum window is retained; new audio replaces older audio. Short histories are zero-padded.

Analyzer.constructor

model must be a live analysis model, not an enhancement or VAD model. licenseKey is an SDK credential. Construction synchronously creates the collector/analyzer pair and can throw for credentials, model type or disposal errors. There is no per-instance OtelConfig constructor argument. Call initialize before buffer.

Analyzer.dispose

Synchronously releases the collector and analyzer; repeated calls are harmless. It waits for the analyzer lock if analysis is running, so it can block the event loop. Queued analysis that obtains the lock afterward rejects. Later operations throw Analyzer has been disposed. Await outstanding analysis first.

Analyzer.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. Configures the collector synchronously. For Tyto, use its native 16 kHz input and the block size returned by the model query. A failed reinitialization leaves the collector uninitialized; correct the configuration before buffering again.

Analyzer.buffer

Reads a mono Float32Array without modifying it and collects samples for later analysis. Returns void; it does not run the analysis model. Requires successful initialization and the configured block length. It can continue while analyzeAsync runs because collection does not take the analyzer lock. Older audio is discarded as the model window fills.

Analyzer.analyze

Synchronously analyzes the latest buffered window and returns AnalysisResult. Blocks the calling thread and can wait for an earlier async analysis. Short or empty histories are zero-padded; the SDK does not provide a readiness check here. Track the amount of real buffered audio yourself. Throws for disallowed processing or native analysis failure.

Analyzer.analyzeAsync

Queues analysis on the libuv pool and resolves to AnalysisResult. The worker reads the available buffered snapshot when it executes; submission does not freeze the collector. Collection can continue in parallel. Await before assuming completion or disposing. Native analysis failures reject the promise. This is expensive analysis, not an audio-callback operation.

Analyzer.reset

Synchronously requests clearing of the collector state while retaining audio settings. Until the next buffer applies that reset, analysis uses a zero-filled snapshot instead of stale audio. Waits for the analyzer lock and can block during async analysis.

Analyzer.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. This synchronous method also waits for any active analysis holding the analyzer lock.

Analyzer.terminateSession

Requests termination of the associated session. Once termination is handled, further analysis is disallowed. This does not release the native object; still call dispose(). Completion may involve asynchronous session handling when another session remains active. Do not use it as a flush operation. Synchronous; can block on the analyzer lock and session handling.

AnalysisResult

A returned object with seven number fields, not a class to construct. Values are normalized scores from 0 to 1. Lower values indicate less problematic audio except for speakerLoudness, where loudness itself is measured. These are model estimates, not a guarantee of transcription quality. See Tyto for interpretation.

AnalysisResult.riskScore

Estimate of risk to downstream speech-model performance. Evaluate against observed failures; it is not a word error rate or a probability guarantee for an individual request.

AnalysisResult.speakerReverb

Speaker distance/reverberation score. Lower values indicate less problematic reverberation.

AnalysisResult.speakerLoudness

Speaker loudness score. Interpret it separately from the other risk dimensions; lower is not universally better.

AnalysisResult.interferingSpeech

Score for speech from sources other than the main speaker.

AnalysisResult.noise

Ambient or environmental noise score.

AnalysisResult.codecDegradation

Score for lossy speech-codec artifacts, including narrowband or low-bitrate degradation.

AnalysisResult.packetLoss

Score for dropouts and discontinuities, such as packet loss, frame erasure, jitter or CPU overload. It is not a network packet counter.

Example

With the pinned package installed, set AIC_SDK_LICENSE and run node analyze-window.cjs path/to/tyto.aicmodel. It collects at least 5 s of silence and prints seven score fields. For call-quality evaluation, use representative audio and follow real-time analysis for window interpretation.
analyze-window.cjs
Node.js API index · Errors and recovery · Stream lifecycle.