UNPKG

@juspay/neurolink

Version:

The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002

44 lines (43 loc) • 2.09 kB
/** * Silero VAD as the chunked stream's speech detector. * * A 2.3 MB ONNX model (MIT, trained on 6000+ languages) scores 32 ms frames * of 16 kHz audio: the probability that the frame is a human voice, which an * energy gate cannot tell from a chair, a keyboard or a far-away TV. It runs * through `onnxruntime-node`, an optional dependency with prebuilt CPU * binaries for Linux, macOS and Windows on x64 and arm64; measured at about * 0.1 ms per frame on one thread, so a stream costs well under one percent * of a core. One inference session per model file is shared by every stream * in the process; each detector keeps only its own LSTM state and the 64 * samples of context the model wants in front of every frame. * * Nothing here is imported statically by the rest of the package: the * adapter loads this module only when a stream needs it, and the runtime * itself is imported through a variable specifier so a typecheck or a bundle * does not need the native module present. * * @module voice/vad/sileroVad */ import type { STTSpeechDetector, STTVadEngine, STTVadOptions } from "../../types/index.js"; /** Samples per frame at 16 kHz (32 ms). */ export declare const SILERO_FRAME_SAMPLES = 512; /** Thresholds of `STTVadOptions` when the caller sets none. */ export declare const VAD_DEFAULTS: { readonly onset: 0.6; readonly sustain: 0.35; readonly startMs: 120; }; /** `options.engine`, else `NEUROLINK_STT_VAD`, else `"auto"`. */ export declare function resolveVadEngine(options?: STTVadOptions): STTVadEngine; /** The three thresholds with the defaults applied and nonsense clamped. */ export declare function resolveVadThresholds(options?: STTVadOptions): { onset: number; sustain: number; startMs: number; }; /** * A detector for one stream: the model file located (and fetched when * allowed), the runtime loaded, the shared session created on first use. * Throws an `STTError` saying exactly what is missing when it cannot. */ export declare function loadSileroDetector(options?: STTVadOptions): Promise<STTSpeechDetector>;