import { TokenWithExpiry } from './useGetSTTToken'; import { SpeechRecognitionCanceledEventArgs, SpeechRecognitionEventArgs } from 'microsoft-cognitiveservices-speech-sdk'; export declare const DEFAULT_SPEECH_RECOGNITION_LANGUAGE = "en-US"; export interface SttEvents { onstart?: () => void; onend?: () => void; onresult: (event: SpeechRecognitionEventArgs) => void; onerror?: (event: SpeechRecognitionCanceledEventArgs) => void; onrecognizing?: (event: SpeechRecognitionEventArgs) => void; } export interface SpeechRecognizerProps { events: SttEvents; getSTTToken: () => Promise; } export declare class SpeechRecognizer { events: SttEvents; getSTTToken: () => Promise; private recognizer?; private intervalId?; private isCancelled; private isDestroyed; private status; constructor({ events, getSTTToken }: SpeechRecognizerProps); private initEvents; private refreshToken; private initTokenRefreshInterval; init: (language: string, inputDeviceId: string) => Promise; /** * Update event handlers after initialization */ updateEvents: (newEvents: SttEvents) => void; start: () => Promise; private stopRecognition; abort: () => Promise; /** * Private method to wrap the recognizer.close() in a Promise */ private closeRecognizer; /** * Destroy the recognizer. This is needed to avoid memory leaks. * If you need to use the recognizer again, you need to create a new instance. */ destroy: () => Promise; }