/* tslint:disable */ /* eslint-disable */ /** * Detection score mode. */ export enum ScoreMode { /** * Use max value of the scores. */ max = 0, /** * Use average value of the scores. */ avg = 1, /** * Use median value of the scores. */ median = 2, /** * Use percentile 25 of the scores. */ p25 = 3, /** * Use percentile 50 of the scores. */ p50 = 4, /** * Use percentile 75 of the scores. */ p75 = 5, /** * Use percentile 80 of the scores. */ p80 = 6, /** * Use percentile 90 of the scores. */ p90 = 7, /** * Use percentile 95 of the scores. */ p95 = 8, } /** */ export enum VADMode { easy = 0, medium = 1, hard = 2, } /** */ export enum SampleFormat { i8 = 0, i16 = 1, i32 = 2, f32 = 3, } /** */ export class Rustpotter { free(): void; /** * Creates a rustpotter instance. * @param {RustpotterConfig} config * @returns {Rustpotter} */ static new(config: RustpotterConfig): Rustpotter; /** * Process int 32 bit audio chunks. * * The buffer length should match the return of the getSamplesPerFrame method. * @param {Int32Array} buffer * @returns {RustpotterDetection | undefined} */ processI32(buffer: Int32Array): RustpotterDetection | undefined; /** * Process int 16 bit audio chunks. * * The buffer length should match the return of the getSamplesPerFrame method. * @param {Int16Array} buffer * @returns {RustpotterDetection | undefined} */ processI16(buffer: Int16Array): RustpotterDetection | undefined; /** * Process float 32 bit audio chunks. * * The buffer length should match the return of the getSamplesPerFrame method. * @param {Float32Array} buffer * @returns {RustpotterDetection | undefined} */ processF32(buffer: Float32Array): RustpotterDetection | undefined; /** * Process byte buffer. * * The buffer length should match the return of the getByteFrameSize method. * @param {Uint8Array} buffer * @returns {RustpotterDetection | undefined} */ processBytes(buffer: Uint8Array): RustpotterDetection | undefined; /** * Loads a wakeword from its model bytes. * @param {string} key * @param {Uint8Array} bytes */ addWakeword(key: string, bytes: Uint8Array): void; /** * Removes a wakeword by key. * @param {string} key * @returns {boolean} */ removeWakeword(key: string): boolean; /** * Removes all wakewords. * @returns {boolean} */ removeWakewords(): boolean; /** * Returns the required number of samples. * @returns {number} */ getSamplesPerFrame(): number; /** * Returns the required number of bytes. * @returns {number} */ getBytesPerFrame(): number; /** * Updates detector and audio filter options * @param {RustpotterConfig} config */ updateConfig(config: RustpotterConfig): void; /** * Reset internal state. */ reset(): void; } /** */ export class RustpotterConfig { free(): void; /** * Creates a rustpotter config instance. * @returns {RustpotterConfig} */ static new(): RustpotterConfig; /** * Configures the detector threshold, * is the min score (in range 0. to 1.) that some of * the wakeword templates should obtain to trigger a detection. * * Defaults to 0.5, wakeword defined value takes prevalence if present. * @param {number} value */ setThreshold(value: number): void; /** * Configures the detector averaged threshold, * * If set to 0. this functionality is disabled. * * Wakeword defined value takes prevalence if present. * @param {number} value */ setAveragedThreshold(value: number): void; /** * Configures the required number of partial detections * to consider a partial detection as a real detection. * * Defaults to 5 * @param {number} value */ setMinScores(value: number): void; /** * Configures a basic vad detector to avoid some execution. * * Disabled by default * @param {number | undefined} value */ setVADMode(value?: number): void; /** * Configures the operation used to unify the score against each record when using wakeword references. * Doesn't apply to trained wakewords. * * Defaults to max * @param {number} value */ setScoreMode(value: number): void; /** * Configures the comparator the band size. * Doesn't apply to trained wakewords. * * Defaults to 5 * @param {number} value */ setBandSize(value: number): void; /** * Value used to express the score as a percent in range 0 - 1. * * Defaults to 0.22 * @param {number} value */ setScoreRef(value: number): void; /** * Emit detection on min scores. * * Defaults to false * @param {boolean} value */ setEager(value: boolean): void; /** * Use a gain-normalization filter to dynamically change the input volume level. * * Defaults to false * @param {boolean} value */ setGainNormalizerEnabled(value: boolean): void; /** * Set the rms level reference used by the gain-normalizer filter. * If null the approximated wakewords rms level is used. * * Defaults to null * @param {number | undefined} value */ setGainRef(value?: number): void; /** * Sets the min gain applied by the gain-normalizer filter. * * Defaults to 0.1 * @param {number} value */ setMinGain(value: number): void; /** * Sets the max gain applied by the gain-normalizer filter. * * Defaults to 1.0 * @param {number} value */ setMaxGain(value: number): void; /** * Use a band-pass filter to attenuate frequencies * out of the configured range. * * Defaults to false * @param {boolean} value */ setBandPassEnabled(value: boolean): void; /** * Configures the low-cutoff frequency for the band-pass * filter. * * Defaults to 80.0 * @param {number} value */ setBandPassLowCutoff(value: number): void; /** * Configures the high-cutoff frequency for the band-pass * filter. * * Defaults to 400.0 * @param {number} value */ setBandPassHighCutoff(value: number): void; /** * Configures the detector expected sample rate for the audio chunks to process. * * Defaults to 16000 * @param {number} value */ setSampleRate(value: number): void; /** * Configures the detector expected sample format for the audio chunks to process. * * Defaults to F32 * @param {number} value */ setSampleFormat(value: number): void; /** * Configures the detector expected number of channels for the audio chunks to process. * Rustpotter will only use data from the first channel. * * Defaults to 1 * @param {number} value */ setChannels(value: number): void; } /** */ export class RustpotterDetection { free(): void; /** * Get detection name * @returns {string} */ getName(): string; /** * Get detection score * @returns {number} */ getScore(): number; /** * Get detection avg score * @returns {number} */ getAvgScore(): number; /** * Get detection score by file name * @param {string} name * @returns {number | undefined} */ getScoreByName(name: string): number | undefined; /** * Get score file names as a || separated string * @returns {string} */ getScoreNames(): string; /** * Get detection scores * @returns {Float32Array} */ getScores(): Float32Array; /** * Get partial detections counter * @returns {number} */ getCounter(): number; /** * Get gain applied * @returns {number} */ getGain(): number; } export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; export interface InitOutput { readonly memory: WebAssembly.Memory; readonly __wbg_rustpotter_free: (a: number) => void; readonly rustpotter_new: (a: number, b: number) => void; readonly rustpotter_processI32: (a: number, b: number, c: number) => number; readonly rustpotter_processI16: (a: number, b: number, c: number) => number; readonly rustpotter_processF32: (a: number, b: number, c: number) => number; readonly rustpotter_processBytes: (a: number, b: number, c: number) => number; readonly rustpotter_addWakeword: (a: number, b: number, c: number, d: number, e: number, f: number) => void; readonly rustpotter_removeWakeword: (a: number, b: number, c: number) => number; readonly rustpotter_removeWakewords: (a: number) => number; readonly rustpotter_getSamplesPerFrame: (a: number) => number; readonly rustpotter_getBytesPerFrame: (a: number) => number; readonly rustpotter_updateConfig: (a: number, b: number) => void; readonly rustpotter_reset: (a: number) => void; readonly __wbg_rustpotterdetection_free: (a: number) => void; readonly rustpotterdetection_getName: (a: number, b: number) => void; readonly rustpotterdetection_getScore: (a: number) => number; readonly rustpotterdetection_getAvgScore: (a: number) => number; readonly rustpotterdetection_getScoreByName: (a: number, b: number, c: number, d: number) => void; readonly rustpotterdetection_getScoreNames: (a: number, b: number) => void; readonly rustpotterdetection_getScores: (a: number, b: number) => void; readonly rustpotterdetection_getCounter: (a: number) => number; readonly rustpotterdetection_getGain: (a: number) => number; readonly __wbg_rustpotterconfig_free: (a: number) => void; readonly rustpotterconfig_new: () => number; readonly rustpotterconfig_setThreshold: (a: number, b: number) => void; readonly rustpotterconfig_setAveragedThreshold: (a: number, b: number) => void; readonly rustpotterconfig_setMinScores: (a: number, b: number) => void; readonly rustpotterconfig_setVADMode: (a: number, b: number) => void; readonly rustpotterconfig_setScoreMode: (a: number, b: number) => void; readonly rustpotterconfig_setBandSize: (a: number, b: number) => void; readonly rustpotterconfig_setScoreRef: (a: number, b: number) => void; readonly rustpotterconfig_setEager: (a: number, b: number) => void; readonly rustpotterconfig_setGainNormalizerEnabled: (a: number, b: number) => void; readonly rustpotterconfig_setGainRef: (a: number, b: number, c: number) => void; readonly rustpotterconfig_setMinGain: (a: number, b: number) => void; readonly rustpotterconfig_setMaxGain: (a: number, b: number) => void; readonly rustpotterconfig_setBandPassEnabled: (a: number, b: number) => void; readonly rustpotterconfig_setBandPassLowCutoff: (a: number, b: number) => void; readonly rustpotterconfig_setBandPassHighCutoff: (a: number, b: number) => void; readonly rustpotterconfig_setSampleRate: (a: number, b: number) => void; readonly rustpotterconfig_setSampleFormat: (a: number, b: number) => void; readonly rustpotterconfig_setChannels: (a: number, b: number) => void; readonly __wbindgen_add_to_stack_pointer: (a: number) => number; readonly __wbindgen_malloc: (a: number, b: number) => number; readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; readonly __wbindgen_free: (a: number, b: number, c: number) => void; readonly __wbindgen_exn_store: (a: number) => void; } export type SyncInitInput = BufferSource | WebAssembly.Module; /** * Instantiates the given `module`, which can either be bytes or * a precompiled `WebAssembly.Module`. * * @param {SyncInitInput} module * * @returns {InitOutput} */ export function initSync(module: SyncInitInput): InitOutput; /** * If `module_or_path` is {RequestInfo} or {URL}, makes a request and * for everything else, calls `WebAssembly.instantiate` directly. * * @param {InitInput | Promise} module_or_path * * @returns {Promise} */ export default function __wbg_init (module_or_path?: InitInput | Promise): Promise;