UNPKG

apphouse

Version:

Component library for React that uses observable state management and theme-able components.

39 lines (38 loc) 1.36 kB
/// <reference types="dom-speech-recognition" /> export interface GrammarItemType { text: string; id: string; } export default class Speech { recognition: SpeechRecognition; gramar: { [text: string]: GrammarItemType; }; dictionaryLookupTable: { [word: string]: string[]; }; constructor(grammar?: GrammarItemType[]); start: () => void; onResult: (event: any) => void; onSpeechEnd: () => void; onNoMatch: () => void; onError: (event: any) => void; setGrammar: (grammar: GrammarItemType[]) => void; /** * Should return a string withough punctuation and all lowercase. * @param text the text with punctuation */ static cleanKey: (text: string) => string; static cleanAlphaNumeric: (text: string) => string; static findClosestMatch: (lookupTable: { [word: string]: string[]; }, spokenSentence: string) => string; /** * Find closest match for a given sentence based on a lookup table * @param lookupTable { [word: string]: string[] } a hashed key value pair where the key is a word and they value is an array of ids of the object where this word occurs * @param spokenSentence the sentence we try to match */ static createGrammerLookupTable: (grammar: GrammarItemType[]) => { [word: string]: string[]; }; }