UNPKG

microsoft-cognitiveservices-speech-sdk

Version:
1 lines 2.49 kB
{"version":3,"sources":["src/sdk/PhraseListGrammar.ts"],"names":[],"mappings":"AAOA,OAAO,EACH,uBAAuB,EACvB,kBAAkB,EAClB,UAAU,EACb,MAAM,cAAc,CAAC;AAEtB;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,kBAAkB,CAAwB;IAElD,OAAO;IAIP;;;OAGG;WACW,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,uBAAuB,GAAG,kBAAkB,GAAG,iBAAiB;IAKtH;;;OAGG;IACI,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAItC;;;OAGG;IACI,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAI1C;;OAEG;IACI,KAAK,IAAI,IAAI;CAGvB","file":"PhraseListGrammar.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n DynamicGrammarBuilder,\r\n ServiceRecognizerBase,\r\n} from \"../common.speech/Exports.js\";\r\nimport {\r\n ConversationTranscriber,\r\n MeetingTranscriber,\r\n Recognizer\r\n} from \"./Exports.js\";\r\n\r\n/**\r\n * Allows additions of new phrases to improve speech recognition.\r\n *\r\n * Phrases added to the recognizer are effective at the start of the next recognition, or the next time the SpeechSDK must reconnect\r\n * to the speech service.\r\n */\r\nexport class PhraseListGrammar {\r\n private privGrammerBuilder: DynamicGrammarBuilder;\r\n\r\n private constructor(recogBase: ServiceRecognizerBase) {\r\n this.privGrammerBuilder = recogBase.dynamicGrammar;\r\n }\r\n\r\n /**\r\n * Creates a PhraseListGrammar from a given speech recognizer. Will accept any recognizer that derives from @class Recognizer.\r\n * @param recognizer The recognizer to add phrase lists to.\r\n */\r\n public static fromRecognizer(recognizer: Recognizer | ConversationTranscriber | MeetingTranscriber): PhraseListGrammar {\r\n const recoBase = recognizer.internalData as ServiceRecognizerBase;\r\n return new PhraseListGrammar(recoBase);\r\n }\r\n\r\n /**\r\n * Adds a single phrase to the current recognizer.\r\n * @param phrase Phrase to add.\r\n */\r\n public addPhrase(phrase: string): void {\r\n this.privGrammerBuilder.addPhrase(phrase);\r\n }\r\n\r\n /**\r\n * Adds multiple phrases to the current recognizer.\r\n * @param phrases Array of phrases to add.\r\n */\r\n public addPhrases(phrases: string[]): void {\r\n this.privGrammerBuilder.addPhrase(phrases);\r\n }\r\n\r\n /**\r\n * Clears all phrases added to the current recognizer.\r\n */\r\n public clear(): void {\r\n this.privGrammerBuilder.clearPhrases();\r\n }\r\n}\r\n"]}