import { WAKE_DETECTOR_DEFAULTS, type WakeFrameOutcome } from './detector.js'; import type { WakeDetection, WakeDetectorTuning, WakeInferenceSession, WakeModelHandle } from './types.js'; /** * The speech gate `voice.wake.vadThreshold` turns on. * * The head runs over the SAME embedding the classifiers consume, so gating costs * one tiny inference per frame and no extra front-end pass. A host supplies the * session exactly as it supplies the classifiers'. */ export interface WakeVadGate { readonly session: WakeInferenceSession; /** * Speech probability a frame must reach to be scored, from * `voice.wake.vadThreshold`. See `WAKE_VAD_MODEL.thresholds` for what a value * does; `recommendedThreshold` is the measured operating point. */ readonly threshold: number; } /** What the speech gate did with one frame. */ export interface WakeVadOutcome { /** Speech probability for this frame, or null when the gate could not run. */ readonly probability: number | null; /** True when the frame was withheld from the classifiers. */ readonly gated: boolean; /** * True when the gate itself failed on this frame. The frame is then passed * THROUGH to the classifiers and the failure is reported: a gate that cannot * run must not turn the wake word off, because gating everything is * indistinguishable to a user from a microphone that stopped working. */ readonly failed: boolean; } export interface WakeEngineOptions { /** The speech-embedding backbone, shared by every model. */ readonly embedding: WakeInferenceSession; /** Classifiers to run. An empty list means the engine scores nothing. */ readonly models: readonly WakeModelHandle[]; /** * The speech gate. Omitted means every frame reaches the classifiers, which is * what `voice.wake.vadThreshold: 0`, the shipped default, asks for. */ readonly vad?: WakeVadGate | undefined; /** Detector tuning; per-model thresholds still win. */ readonly tuning?: Partial | undefined; /** Milliseconds of audio a detection carries from before it fired. */ readonly preRollMs?: number | undefined; /** Injected clock, so cooldown behaviour is deterministic under test. */ readonly now?: (() => number) | undefined; /** Samples per frame. Defaults to 1280 (80 ms at 16 kHz). */ readonly chunkSamples?: number | undefined; /** * Where a model that misbehaves is reported. A classifier that fails to run is * skipped rather than taking the detector down, and this is the only trace of * that decision, so a host that wants to know supplies a sink. */ readonly warn?: ((message: string, meta?: Readonly>) => void) | undefined; } /** Everything one frame produced. */ export interface WakeFrameResult { /** Per-model score for this frame; empty until the pipeline has filled. */ readonly scores: ReadonlyMap; /** Per-model outcome after patience and cooldown were applied. */ readonly outcomes: ReadonlyMap; /** Models that confirmed a wake on this frame, in configuration order. */ readonly detections: readonly WakeDetection[]; /** * What the speech gate did, or null when no gate is running. A gated frame has * empty scores and outcomes, it was never handed to a classifier. */ readonly vad: WakeVadOutcome | null; } /** Frame-driven wake-word detector over a shared front end. */ export declare class WakeWordEngine { #private; constructor(options: WakeEngineOptions); /** Samples the engine expects per {@link pushFrame} call. */ get chunkSamples(): number; /** Ids of the models being scored, in configuration order. */ get modelIds(): readonly string[]; /** Frames pushed since the last reset. */ get framesSeen(): number; /** * Clear every buffer and every detector run. Called when the stream restarts: * a restarted detector must not inherit half a phrase, nor a cooldown, from * the run that died. */ reset(): void; /** * Score one frame of 16 kHz mono audio (raw int16 magnitudes as floats). * * Returns empty results while the front end is still filling its 16-frame * feature window, about 1.3 seconds of audio, rather than emitting scores * computed against openWakeWord's synthetic buffer priming. */ pushFrame(samples: Float32Array): Promise; } export { WAKE_DETECTOR_DEFAULTS }; //# sourceMappingURL=engine.d.ts.map