UNPKG

web-voice-detection

Version:

A WebAssembly-powered Voice Activity Detection library for the browser.

28 lines (27 loc) 905 B
import { InferenceSession, Tensor } from "onnxruntime-web"; export type ONNXRuntimeAPI = typeof import("onnxruntime-web"); export type ModelFetcher = () => Promise<ArrayBuffer>; export type OrtOptions = { ortConfig?: (ort: ONNXRuntimeAPI) => any; }; export type SpeechProbabilities = { notSpeech: number; isSpeech: number; }; export type Model = { reset_state: () => void; process: (arr: Float32Array) => Promise<SpeechProbabilities>; }; export declare class ONNXModel { private ort; private modelFetcher; _session: InferenceSession; _h: Tensor; _c: Tensor; _sr: Tensor; constructor(ort: ONNXRuntimeAPI, modelFetcher: ModelFetcher); static new: (ort: ONNXRuntimeAPI, modelFetcher: ModelFetcher) => Promise<ONNXModel>; init: () => Promise<void>; reset_state: () => void; process: (audioFrame: Float32Array) => Promise<SpeechProbabilities>; }