import { DeepMaybeObservable, Supportable, ReadonlyObservable } from '@usels/core'; import { ConfigurableWindow } from '../../shared/configurable.mjs'; import '@legendapp/state'; interface SpeechRecognitionErrorEvent { error: string; message: string; } interface UseSpeechRecognitionOptions extends ConfigurableWindow { /** Language for recognition. Default: "en-US" */ lang?: string; /** Continuous recognition. Default: true */ continuous?: boolean; /** Return interim results. Default: true */ interimResults?: boolean; /** Maximum number of alternatives per result. Default: 1 */ maxAlternatives?: number; } interface UseSpeechRecognitionReturn extends Supportable { /** Whether currently listening */ isListening$: ReadonlyObservable; /** Whether current result is final */ isFinal$: ReadonlyObservable; /** Recognized text */ result$: ReadonlyObservable; /** Recognition error */ error$: ReadonlyObservable; /** Start recognition */ start: () => void; /** Stop recognition */ stop: () => void; /** Toggle recognition */ toggle: (value?: boolean) => void; } /** * Framework-agnostic reactive wrapper around the * [Web Speech Recognition API](https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition). * * Each `start()` call instantiates a fresh `SpeechRecognition` object using the * latest option values, so reactive option updates take effect on the next * `start()` without needing to recreate the hook. Cleanup is registered via * `onUnmount`. */ declare function createSpeechRecognition(options?: DeepMaybeObservable): UseSpeechRecognitionReturn; export { type UseSpeechRecognitionOptions, type UseSpeechRecognitionReturn, createSpeechRecognition };