UNPKG

speech-to-element

Version:

Add real-time speech to text functionality into your website with no effort

64 lines (63 loc) 1.75 kB
export interface Options { element?: Element | Element[]; onStart?: () => void; onStop?: () => void; onResult?: OnResult; onPreResult?: OnPreResult; onCommandModeTrigger?: OnCommandModeTrigger; onPauseTrigger?: OnPauseTrigger; onError?: OnError; displayInterimResults?: boolean; insertInCursorLocation?: boolean; autoScroll?: boolean; textColor?: TextColor; translations?: Translations; commands?: Commands; } export type OnResult = (text: string, isFinal: boolean) => void; export type OnPreResult = (text: string, isFinal: boolean) => { stop?: boolean; restart?: boolean; removeNewText?: boolean; } | void | null | undefined; export type OnCommandModeTrigger = (isStart: boolean) => void; export type OnPauseTrigger = (isStart: boolean) => void; export type OnError = (message: string) => void; export interface TextColor { interim?: string; final?: string; } export interface Translations { [key: string]: string; } export interface AzureOptions { retrieveToken?: () => Promise<string | void>; subscriptionKey?: string; token?: string; region: string; language?: string; autoLanguage?: { languages: [string, ...string[]] & { length: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10; }; type?: 'AtStart' | 'Continuous'; }; endpointId?: string; deviceId?: string; stopAfterSilenceMs?: number; } export interface WebSpeechOptions { language?: string; } export interface Commands { stop?: string; pause?: string; resume?: string; reset?: string; removeAllText?: string; commandMode?: string; settings?: { substrings?: boolean; caseSensitive?: boolean; }; }