@euirim/microsoft-cognitiveservices-speech-sdk
Version:
Microsoft Cognitive Services Speech SDK for JavaScript
1 lines • 2.23 kB
Source Map (JSON)
{"version":3,"sources":["src/sdk/PhraseListGrammar.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,kBAAkB,CAAwB;IAElD,OAAO;IAIP;;;OAGG;WACW,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,iBAAiB;IAMvE;;;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.\n// Licensed under the MIT license.\n\nimport {\n DynamicGrammarBuilder,\n ServiceRecognizerBase,\n} from \"../common.speech/Exports\";\nimport { Recognizer } from \"./Exports\";\n\n/**\n * Allows additions of new phrases to improve speech recognition.\n *\n * Phrases added to the recognizer are effective at the start of the next recognition, or the next time the SpeechSDK must reconnect\n * to the speech service.\n */\nexport class PhraseListGrammar {\n private privGrammerBuilder: DynamicGrammarBuilder;\n\n private constructor(recogBase: ServiceRecognizerBase) {\n this.privGrammerBuilder = recogBase.dynamicGrammar;\n }\n\n /**\n * Creates a PhraseListGrammar from a given speech recognizer. Will accept any recognizer that derives from @class Recognizer.\n * @param recognizer The recognizer to add phrase lists to.\n */\n public static fromRecognizer(recognizer: Recognizer): PhraseListGrammar {\n const recoBase: ServiceRecognizerBase = recognizer.internalData as ServiceRecognizerBase;\n\n return new PhraseListGrammar(recoBase);\n }\n\n /**\n * Adds a single phrase to the current recognizer.\n * @param phrase Phrase to add.\n */\n public addPhrase(phrase: string): void {\n this.privGrammerBuilder.addPhrase(phrase);\n }\n\n /**\n * Adds multiple phrases to the current recognizer.\n * @param phrases Array of phrases to add.\n */\n public addPhrases(phrases: string[]): void {\n this.privGrammerBuilder.addPhrase(phrases);\n }\n\n /**\n * Clears all phrases added to the current recognizer.\n */\n public clear(): void {\n this.privGrammerBuilder.clearPhrases();\n }\n}\n"]}