export type SoundDetectorOptions = { /** * Defines how often the detector should check whether a sound is present. * Defaults to 500ms. */ detectionFrequencyInMs?: number; /** * Defines the audio level threshold before a "change" is emitted. * Defaults to 150. This value should be in the range of 0-255. */ audioLevelThreshold?: number; /** * See https://developer.mozilla.org/en-US/docs/web/api/analysernode/fftsize * * Defaults to 128. */ fftSize?: number; /** * Defines whether the provided audio stream should be stopped (destroyed) * when the sound detector is stopped. * * Defaults to `true`. */ destroyStreamOnStop?: boolean; }; export type SoundDetectorState = { isSoundDetected: boolean; /** * Represented as percentage (0-100) where 100% is defined by `audioLevelThreshold` property. * Decrease time between samples (to 50-100ms) with `detectionFrequencyInMs` property. */ audioLevel: number; }; export type SoundStateChangeHandler = (state: SoundDetectorState) => void; /** * Creates a new sound detector. * * @param audioStream the audio stream to observe. Depending on the provided configuration, this stream might be destroyed when the sound detector is stopped. * @param onSoundDetectedStateChanged a callback which is called when the sound state changes. * @param options custom options for the sound detector. * @returns a clean-up function which once invoked stops the sound detector. */ export declare const createSoundDetector: (audioStream: MediaStream, onSoundDetectedStateChanged: SoundStateChangeHandler, options?: SoundDetectorOptions) => () => Promise;