bef96511fbf0e6dfa75a9c384b14dfbd6019c0c0b4346a9279e162451e97e51d.json 36 KB

1
  1. {"ast":null,"code":"\"use strict\";\n\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\nvar _asyncToGenerator = require(\"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/asyncToGenerator.js\").default;\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.IntentRecognizer = void 0;\nconst Exports_js_1 = require(\"../common.speech/Exports.js\");\nconst Exports_js_2 = require(\"../common/Exports.js\");\nconst Contracts_js_1 = require(\"./Contracts.js\");\nconst Exports_js_3 = require(\"./Exports.js\");\n/**\n * Intent recognizer.\n * @class\n */\nclass IntentRecognizer extends Exports_js_3.Recognizer {\n /**\n * Initializes an instance of the IntentRecognizer.\n * @constructor\n * @param {SpeechConfig} speechConfig - The set of configuration properties.\n * @param {AudioConfig} audioConfig - An optional audio input config associated with the recognizer\n */\n constructor(speechConfig, audioConfig) {\n Contracts_js_1.Contracts.throwIfNullOrUndefined(speechConfig, \"speechConfig\");\n const configImpl = speechConfig;\n Contracts_js_1.Contracts.throwIfNullOrUndefined(configImpl, \"speechConfig\");\n super(audioConfig, configImpl.properties, new Exports_js_1.IntentConnectionFactory());\n this.privAddedIntents = [];\n this.privAddedLmIntents = {};\n this.privDisposedIntentRecognizer = false;\n this.privProperties = configImpl.properties;\n Contracts_js_1.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(Exports_js_3.PropertyId.SpeechServiceConnection_RecoLanguage), Exports_js_3.PropertyId[Exports_js_3.PropertyId.SpeechServiceConnection_RecoLanguage]);\n }\n /**\n * Gets the spoken language of recognition.\n * @member IntentRecognizer.prototype.speechRecognitionLanguage\n * @function\n * @public\n * @returns {string} the spoken language of recognition.\n */\n get speechRecognitionLanguage() {\n Contracts_js_1.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer);\n return this.properties.getProperty(Exports_js_3.PropertyId.SpeechServiceConnection_RecoLanguage);\n }\n /**\n * Gets the authorization token used to communicate with the service.\n * @member IntentRecognizer.prototype.authorizationToken\n * @function\n * @public\n * @returns {string} Authorization token.\n */\n get authorizationToken() {\n return this.properties.getProperty(Exports_js_3.PropertyId.SpeechServiceAuthorization_Token);\n }\n /**\n * Gets/Sets the authorization token used to communicate with the service.\n * Note: Please use a token derived from your LanguageUnderstanding subscription key for the Intent recognizer.\n * @member IntentRecognizer.prototype.authorizationToken\n * @function\n * @public\n * @param {string} value - Authorization token.\n */\n set authorizationToken(value) {\n this.properties.setProperty(Exports_js_3.PropertyId.SpeechServiceAuthorization_Token, value);\n }\n /**\n * The collection of properties and their values defined for this IntentRecognizer.\n * @member IntentRecognizer.prototype.properties\n * @function\n * @public\n * @returns {PropertyCollection} The collection of properties and their\n * values defined for this IntentRecognizer.\n */\n get properties() {\n return this.privProperties;\n }\n /**\n * Starts intent recognition, and stops after the first utterance is recognized.\n * The task returns the recognition text and intent as result.\n * Note: RecognizeOnceAsync() returns when the first utterance has been recognized,\n * so it is suitable only for single shot recognition like command or query.\n * For long-running recognition, use StartContinuousRecognitionAsync() instead.\n * @member IntentRecognizer.prototype.recognizeOnceAsync\n * @function\n * @public\n * @param cb - Callback that received the recognition has finished with an IntentRecognitionResult.\n * @param err - Callback invoked in case of an error.\n */\n recognizeOnceAsync(cb, err) {\n Contracts_js_1.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer);\n if (Object.keys(this.privAddedLmIntents).length !== 0 || undefined !== this.privUmbrellaIntent) {\n const context = this.buildSpeechContext();\n this.privReco.speechContext.setSection(\"intent\", context.Intent);\n this.privReco.dynamicGrammar.addReferenceGrammar(context.ReferenceGrammars);\n const intentReco = this.privReco;\n intentReco.setIntents(this.privAddedLmIntents, this.privUmbrellaIntent);\n }\n Exports_js_2.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(Exports_js_1.RecognitionMode.Interactive), cb, err);\n }\n /**\n * Starts speech recognition, until stopContinuousRecognitionAsync() is called.\n * User must subscribe to events to receive recognition results.\n * @member IntentRecognizer.prototype.startContinuousRecognitionAsync\n * @function\n * @public\n * @param cb - Callback invoked once the recognition has started.\n * @param err - Callback invoked in case of an error.\n */\n startContinuousRecognitionAsync(cb, err) {\n if (Object.keys(this.privAddedLmIntents).length !== 0 || undefined !== this.privUmbrellaIntent) {\n const context = this.buildSpeechContext();\n this.privReco.speechContext.setSection(\"intent\", context.Intent);\n this.privReco.dynamicGrammar.addReferenceGrammar(context.ReferenceGrammars);\n const intentReco = this.privReco;\n intentReco.setIntents(this.privAddedLmIntents, this.privUmbrellaIntent);\n }\n Exports_js_2.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Exports_js_1.RecognitionMode.Conversation), cb, err);\n }\n /**\n * Stops continuous intent recognition.\n * @member IntentRecognizer.prototype.stopContinuousRecognitionAsync\n * @function\n * @public\n * @param cb - Callback invoked once the recognition has stopped.\n * @param err - Callback invoked in case of an error.\n */\n stopContinuousRecognitionAsync(cb, err) {\n Exports_js_2.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(), cb, err);\n }\n /**\n * Starts speech recognition with keyword spotting, until stopKeywordRecognitionAsync() is called.\n * User must subscribe to events to receive recognition results.\n * Note: Key word spotting functionality is only available on the Speech Devices SDK.\n * This functionality is currently not included in the SDK itself.\n * @member IntentRecognizer.prototype.startKeywordRecognitionAsync\n * @function\n * @public\n * @param {KeywordRecognitionModel} model - The keyword recognition model that specifies the keyword to be recognized.\n * @param cb - Callback invoked once the recognition has started.\n * @param err - Callback invoked in case of an error.\n */\n startKeywordRecognitionAsync(model, cb, err) {\n Contracts_js_1.Contracts.throwIfNull(model, \"model\");\n if (!!err) {\n err(\"Not yet implemented.\");\n }\n }\n /**\n * Stops continuous speech recognition.\n * Note: Key word spotting functionality is only available on the Speech Devices SDK.\n * This functionality is currently not included in the SDK itself.\n * @member IntentRecognizer.prototype.stopKeywordRecognitionAsync\n * @function\n * @public\n * @param cb - Callback invoked once the recognition has stopped.\n * @param err - Callback invoked in case of an error.\n */\n stopKeywordRecognitionAsync(cb, err) {\n if (!!cb) {\n try {\n cb();\n } catch (e) {\n if (!!err) {\n err(e);\n }\n }\n }\n }\n /**\n * Adds a phrase that should be recognized as intent.\n * @member IntentRecognizer.prototype.addIntent\n * @function\n * @public\n * @param {string} intentId - A String that represents the identifier of the intent to be recognized.\n * @param {string} phrase - A String that specifies the phrase representing the intent.\n */\n addIntent(simplePhrase, intentId) {\n Contracts_js_1.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer);\n Contracts_js_1.Contracts.throwIfNullOrWhitespace(intentId, \"intentId\");\n Contracts_js_1.Contracts.throwIfNullOrWhitespace(simplePhrase, \"simplePhrase\");\n this.privAddedIntents.push([intentId, simplePhrase]);\n }\n /**\n * Adds an intent from Language Understanding service for recognition.\n * @member IntentRecognizer.prototype.addIntentWithLanguageModel\n * @function\n * @public\n * @param {string} intentId - A String that represents the identifier of the intent\n * to be recognized. Ignored if intentName is empty.\n * @param {string} model - The intent model from Language Understanding service.\n * @param {string} intentName - The intent name defined in the intent model. If it\n * is empty, all intent names defined in the model will be added.\n */\n addIntentWithLanguageModel(intentId, model, intentName) {\n Contracts_js_1.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer);\n Contracts_js_1.Contracts.throwIfNullOrWhitespace(intentId, \"intentId\");\n Contracts_js_1.Contracts.throwIfNull(model, \"model\");\n const modelImpl = model;\n Contracts_js_1.Contracts.throwIfNullOrWhitespace(modelImpl.appId, \"model.appId\");\n this.privAddedLmIntents[intentId] = new Exports_js_1.AddedLmIntent(modelImpl, intentName);\n }\n /**\n * @summary Adds all intents from the specified Language Understanding Model.\n * @member IntentRecognizer.prototype.addAllIntents\n * @function\n * @public\n * @function\n * @public\n * @param {LanguageUnderstandingModel} model - The language understanding model containing the intents.\n * @param {string} intentId - A custom id String to be returned in the IntentRecognitionResult's getIntentId() method.\n */\n addAllIntents(model, intentId) {\n Contracts_js_1.Contracts.throwIfNull(model, \"model\");\n const modelImpl = model;\n Contracts_js_1.Contracts.throwIfNullOrWhitespace(modelImpl.appId, \"model.appId\");\n this.privUmbrellaIntent = new Exports_js_1.AddedLmIntent(modelImpl, intentId);\n }\n /**\n * closes all external resources held by an instance of this class.\n * @member IntentRecognizer.prototype.close\n * @function\n * @public\n */\n close(cb, errorCb) {\n Contracts_js_1.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer);\n Exports_js_2.marshalPromiseToCallbacks(this.dispose(true), cb, errorCb);\n }\n createRecognizerConfig(speechConfig) {\n return new Exports_js_1.RecognizerConfig(speechConfig, this.privProperties);\n }\n createServiceRecognizer(authentication, connectionFactory, audioConfig, recognizerConfig) {\n const audioImpl = audioConfig;\n return new Exports_js_1.IntentServiceRecognizer(authentication, connectionFactory, audioImpl, recognizerConfig, this);\n }\n dispose(disposing) {\n var _superprop_getDispose = () => super.dispose,\n _this = this;\n return _asyncToGenerator(function* () {\n if (_this.privDisposedIntentRecognizer) {\n return;\n }\n if (disposing) {\n _this.privDisposedIntentRecognizer = true;\n yield _superprop_getDispose().call(_this, disposing);\n }\n })();\n }\n buildSpeechContext() {\n let appId;\n let region;\n let subscriptionKey;\n const refGrammers = [];\n if (undefined !== this.privUmbrellaIntent) {\n appId = this.privUmbrellaIntent.modelImpl.appId;\n region = this.privUmbrellaIntent.modelImpl.region;\n subscriptionKey = this.privUmbrellaIntent.modelImpl.subscriptionKey;\n }\n // Build the reference grammer array.\n for (const intentId of Object.keys(this.privAddedLmIntents)) {\n const addedLmIntent = this.privAddedLmIntents[intentId];\n // validate all the same model, region, and key...\n if (appId === undefined) {\n appId = addedLmIntent.modelImpl.appId;\n } else {\n if (appId !== addedLmIntent.modelImpl.appId) {\n throw new Error(\"Intents must all be from the same LUIS model\");\n }\n }\n if (region === undefined) {\n region = addedLmIntent.modelImpl.region;\n } else {\n if (region !== addedLmIntent.modelImpl.region) {\n throw new Error(\"Intents must all be from the same LUIS model in a single region\");\n }\n }\n if (subscriptionKey === undefined) {\n subscriptionKey = addedLmIntent.modelImpl.subscriptionKey;\n } else {\n if (subscriptionKey !== addedLmIntent.modelImpl.subscriptionKey) {\n throw new Error(\"Intents must all use the same subscription key\");\n }\n }\n const grammer = \"luis/\" + appId + \"-PRODUCTION#\" + intentId;\n refGrammers.push(grammer);\n }\n return {\n Intent: {\n id: appId,\n key: subscriptionKey === undefined ? this.privProperties.getProperty(Exports_js_3.PropertyId[Exports_js_3.PropertyId.SpeechServiceConnection_Key]) : subscriptionKey,\n provider: \"LUIS\"\n },\n ReferenceGrammars: undefined === this.privUmbrellaIntent ? refGrammers : [\"luis/\" + appId + \"-PRODUCTION\"]\n };\n }\n}\nexports.IntentRecognizer = IntentRecognizer;","map":{"version":3,"names":["_asyncToGenerator","require","default","Object","defineProperty","exports","value","IntentRecognizer","Exports_js_1","Exports_js_2","Contracts_js_1","Exports_js_3","Recognizer","constructor","speechConfig","audioConfig","Contracts","throwIfNullOrUndefined","configImpl","properties","IntentConnectionFactory","privAddedIntents","privAddedLmIntents","privDisposedIntentRecognizer","privProperties","throwIfNullOrWhitespace","getProperty","PropertyId","SpeechServiceConnection_RecoLanguage","speechRecognitionLanguage","throwIfDisposed","authorizationToken","SpeechServiceAuthorization_Token","setProperty","recognizeOnceAsync","cb","err","keys","length","undefined","privUmbrellaIntent","context","buildSpeechContext","privReco","speechContext","setSection","Intent","dynamicGrammar","addReferenceGrammar","ReferenceGrammars","intentReco","setIntents","marshalPromiseToCallbacks","recognizeOnceAsyncImpl","RecognitionMode","Interactive","startContinuousRecognitionAsync","startContinuousRecognitionAsyncImpl","Conversation","stopContinuousRecognitionAsync","stopContinuousRecognitionAsyncImpl","startKeywordRecognitionAsync","model","throwIfNull","stopKeywordRecognitionAsync","e","addIntent","simplePhrase","intentId","push","addIntentWithLanguageModel","intentName","modelImpl","appId","AddedLmIntent","addAllIntents","close","errorCb","dispose","createRecognizerConfig","RecognizerConfig","createServiceRecognizer","authentication","connectionFactory","recognizerConfig","audioImpl","IntentServiceRecognizer","disposing","_superprop_getDispose","_this","call","region","subscriptionKey","refGrammers","addedLmIntent","Error","grammer","id","key","SpeechServiceConnection_Key","provider"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/IntentRecognizer.js"],"sourcesContent":["\"use strict\";\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.IntentRecognizer = void 0;\nconst Exports_js_1 = require(\"../common.speech/Exports.js\");\nconst Exports_js_2 = require(\"../common/Exports.js\");\nconst Contracts_js_1 = require(\"./Contracts.js\");\nconst Exports_js_3 = require(\"./Exports.js\");\n/**\n * Intent recognizer.\n * @class\n */\nclass IntentRecognizer extends Exports_js_3.Recognizer {\n /**\n * Initializes an instance of the IntentRecognizer.\n * @constructor\n * @param {SpeechConfig} speechConfig - The set of configuration properties.\n * @param {AudioConfig} audioConfig - An optional audio input config associated with the recognizer\n */\n constructor(speechConfig, audioConfig) {\n Contracts_js_1.Contracts.throwIfNullOrUndefined(speechConfig, \"speechConfig\");\n const configImpl = speechConfig;\n Contracts_js_1.Contracts.throwIfNullOrUndefined(configImpl, \"speechConfig\");\n super(audioConfig, configImpl.properties, new Exports_js_1.IntentConnectionFactory());\n this.privAddedIntents = [];\n this.privAddedLmIntents = {};\n this.privDisposedIntentRecognizer = false;\n this.privProperties = configImpl.properties;\n Contracts_js_1.Contracts.throwIfNullOrWhitespace(this.properties.getProperty(Exports_js_3.PropertyId.SpeechServiceConnection_RecoLanguage), Exports_js_3.PropertyId[Exports_js_3.PropertyId.SpeechServiceConnection_RecoLanguage]);\n }\n /**\n * Gets the spoken language of recognition.\n * @member IntentRecognizer.prototype.speechRecognitionLanguage\n * @function\n * @public\n * @returns {string} the spoken language of recognition.\n */\n get speechRecognitionLanguage() {\n Contracts_js_1.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer);\n return this.properties.getProperty(Exports_js_3.PropertyId.SpeechServiceConnection_RecoLanguage);\n }\n /**\n * Gets the authorization token used to communicate with the service.\n * @member IntentRecognizer.prototype.authorizationToken\n * @function\n * @public\n * @returns {string} Authorization token.\n */\n get authorizationToken() {\n return this.properties.getProperty(Exports_js_3.PropertyId.SpeechServiceAuthorization_Token);\n }\n /**\n * Gets/Sets the authorization token used to communicate with the service.\n * Note: Please use a token derived from your LanguageUnderstanding subscription key for the Intent recognizer.\n * @member IntentRecognizer.prototype.authorizationToken\n * @function\n * @public\n * @param {string} value - Authorization token.\n */\n set authorizationToken(value) {\n this.properties.setProperty(Exports_js_3.PropertyId.SpeechServiceAuthorization_Token, value);\n }\n /**\n * The collection of properties and their values defined for this IntentRecognizer.\n * @member IntentRecognizer.prototype.properties\n * @function\n * @public\n * @returns {PropertyCollection} The collection of properties and their\n * values defined for this IntentRecognizer.\n */\n get properties() {\n return this.privProperties;\n }\n /**\n * Starts intent recognition, and stops after the first utterance is recognized.\n * The task returns the recognition text and intent as result.\n * Note: RecognizeOnceAsync() returns when the first utterance has been recognized,\n * so it is suitable only for single shot recognition like command or query.\n * For long-running recognition, use StartContinuousRecognitionAsync() instead.\n * @member IntentRecognizer.prototype.recognizeOnceAsync\n * @function\n * @public\n * @param cb - Callback that received the recognition has finished with an IntentRecognitionResult.\n * @param err - Callback invoked in case of an error.\n */\n recognizeOnceAsync(cb, err) {\n Contracts_js_1.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer);\n if (Object.keys(this.privAddedLmIntents).length !== 0 || undefined !== this.privUmbrellaIntent) {\n const context = this.buildSpeechContext();\n this.privReco.speechContext.setSection(\"intent\", context.Intent);\n this.privReco.dynamicGrammar.addReferenceGrammar(context.ReferenceGrammars);\n const intentReco = this.privReco;\n intentReco.setIntents(this.privAddedLmIntents, this.privUmbrellaIntent);\n }\n Exports_js_2.marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(Exports_js_1.RecognitionMode.Interactive), cb, err);\n }\n /**\n * Starts speech recognition, until stopContinuousRecognitionAsync() is called.\n * User must subscribe to events to receive recognition results.\n * @member IntentRecognizer.prototype.startContinuousRecognitionAsync\n * @function\n * @public\n * @param cb - Callback invoked once the recognition has started.\n * @param err - Callback invoked in case of an error.\n */\n startContinuousRecognitionAsync(cb, err) {\n if (Object.keys(this.privAddedLmIntents).length !== 0 || undefined !== this.privUmbrellaIntent) {\n const context = this.buildSpeechContext();\n this.privReco.speechContext.setSection(\"intent\", context.Intent);\n this.privReco.dynamicGrammar.addReferenceGrammar(context.ReferenceGrammars);\n const intentReco = this.privReco;\n intentReco.setIntents(this.privAddedLmIntents, this.privUmbrellaIntent);\n }\n Exports_js_2.marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(Exports_js_1.RecognitionMode.Conversation), cb, err);\n }\n /**\n * Stops continuous intent recognition.\n * @member IntentRecognizer.prototype.stopContinuousRecognitionAsync\n * @function\n * @public\n * @param cb - Callback invoked once the recognition has stopped.\n * @param err - Callback invoked in case of an error.\n */\n stopContinuousRecognitionAsync(cb, err) {\n Exports_js_2.marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(), cb, err);\n }\n /**\n * Starts speech recognition with keyword spotting, until stopKeywordRecognitionAsync() is called.\n * User must subscribe to events to receive recognition results.\n * Note: Key word spotting functionality is only available on the Speech Devices SDK.\n * This functionality is currently not included in the SDK itself.\n * @member IntentRecognizer.prototype.startKeywordRecognitionAsync\n * @function\n * @public\n * @param {KeywordRecognitionModel} model - The keyword recognition model that specifies the keyword to be recognized.\n * @param cb - Callback invoked once the recognition has started.\n * @param err - Callback invoked in case of an error.\n */\n startKeywordRecognitionAsync(model, cb, err) {\n Contracts_js_1.Contracts.throwIfNull(model, \"model\");\n if (!!err) {\n err(\"Not yet implemented.\");\n }\n }\n /**\n * Stops continuous speech recognition.\n * Note: Key word spotting functionality is only available on the Speech Devices SDK.\n * This functionality is currently not included in the SDK itself.\n * @member IntentRecognizer.prototype.stopKeywordRecognitionAsync\n * @function\n * @public\n * @param cb - Callback invoked once the recognition has stopped.\n * @param err - Callback invoked in case of an error.\n */\n stopKeywordRecognitionAsync(cb, err) {\n if (!!cb) {\n try {\n cb();\n }\n catch (e) {\n if (!!err) {\n err(e);\n }\n }\n }\n }\n /**\n * Adds a phrase that should be recognized as intent.\n * @member IntentRecognizer.prototype.addIntent\n * @function\n * @public\n * @param {string} intentId - A String that represents the identifier of the intent to be recognized.\n * @param {string} phrase - A String that specifies the phrase representing the intent.\n */\n addIntent(simplePhrase, intentId) {\n Contracts_js_1.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer);\n Contracts_js_1.Contracts.throwIfNullOrWhitespace(intentId, \"intentId\");\n Contracts_js_1.Contracts.throwIfNullOrWhitespace(simplePhrase, \"simplePhrase\");\n this.privAddedIntents.push([intentId, simplePhrase]);\n }\n /**\n * Adds an intent from Language Understanding service for recognition.\n * @member IntentRecognizer.prototype.addIntentWithLanguageModel\n * @function\n * @public\n * @param {string} intentId - A String that represents the identifier of the intent\n * to be recognized. Ignored if intentName is empty.\n * @param {string} model - The intent model from Language Understanding service.\n * @param {string} intentName - The intent name defined in the intent model. If it\n * is empty, all intent names defined in the model will be added.\n */\n addIntentWithLanguageModel(intentId, model, intentName) {\n Contracts_js_1.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer);\n Contracts_js_1.Contracts.throwIfNullOrWhitespace(intentId, \"intentId\");\n Contracts_js_1.Contracts.throwIfNull(model, \"model\");\n const modelImpl = model;\n Contracts_js_1.Contracts.throwIfNullOrWhitespace(modelImpl.appId, \"model.appId\");\n this.privAddedLmIntents[intentId] = new Exports_js_1.AddedLmIntent(modelImpl, intentName);\n }\n /**\n * @summary Adds all intents from the specified Language Understanding Model.\n * @member IntentRecognizer.prototype.addAllIntents\n * @function\n * @public\n * @function\n * @public\n * @param {LanguageUnderstandingModel} model - The language understanding model containing the intents.\n * @param {string} intentId - A custom id String to be returned in the IntentRecognitionResult's getIntentId() method.\n */\n addAllIntents(model, intentId) {\n Contracts_js_1.Contracts.throwIfNull(model, \"model\");\n const modelImpl = model;\n Contracts_js_1.Contracts.throwIfNullOrWhitespace(modelImpl.appId, \"model.appId\");\n this.privUmbrellaIntent = new Exports_js_1.AddedLmIntent(modelImpl, intentId);\n }\n /**\n * closes all external resources held by an instance of this class.\n * @member IntentRecognizer.prototype.close\n * @function\n * @public\n */\n close(cb, errorCb) {\n Contracts_js_1.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer);\n Exports_js_2.marshalPromiseToCallbacks(this.dispose(true), cb, errorCb);\n }\n createRecognizerConfig(speechConfig) {\n return new Exports_js_1.RecognizerConfig(speechConfig, this.privProperties);\n }\n createServiceRecognizer(authentication, connectionFactory, audioConfig, recognizerConfig) {\n const audioImpl = audioConfig;\n return new Exports_js_1.IntentServiceRecognizer(authentication, connectionFactory, audioImpl, recognizerConfig, this);\n }\n async dispose(disposing) {\n if (this.privDisposedIntentRecognizer) {\n return;\n }\n if (disposing) {\n this.privDisposedIntentRecognizer = true;\n await super.dispose(disposing);\n }\n }\n buildSpeechContext() {\n let appId;\n let region;\n let subscriptionKey;\n const refGrammers = [];\n if (undefined !== this.privUmbrellaIntent) {\n appId = this.privUmbrellaIntent.modelImpl.appId;\n region = this.privUmbrellaIntent.modelImpl.region;\n subscriptionKey = this.privUmbrellaIntent.modelImpl.subscriptionKey;\n }\n // Build the reference grammer array.\n for (const intentId of Object.keys(this.privAddedLmIntents)) {\n const addedLmIntent = this.privAddedLmIntents[intentId];\n // validate all the same model, region, and key...\n if (appId === undefined) {\n appId = addedLmIntent.modelImpl.appId;\n }\n else {\n if (appId !== addedLmIntent.modelImpl.appId) {\n throw new Error(\"Intents must all be from the same LUIS model\");\n }\n }\n if (region === undefined) {\n region = addedLmIntent.modelImpl.region;\n }\n else {\n if (region !== addedLmIntent.modelImpl.region) {\n throw new Error(\"Intents must all be from the same LUIS model in a single region\");\n }\n }\n if (subscriptionKey === undefined) {\n subscriptionKey = addedLmIntent.modelImpl.subscriptionKey;\n }\n else {\n if (subscriptionKey !== addedLmIntent.modelImpl.subscriptionKey) {\n throw new Error(\"Intents must all use the same subscription key\");\n }\n }\n const grammer = \"luis/\" + appId + \"-PRODUCTION#\" + intentId;\n refGrammers.push(grammer);\n }\n return {\n Intent: {\n id: appId,\n key: (subscriptionKey === undefined) ? this.privProperties.getProperty(Exports_js_3.PropertyId[Exports_js_3.PropertyId.SpeechServiceConnection_Key]) : subscriptionKey,\n provider: \"LUIS\",\n },\n ReferenceGrammars: (undefined === this.privUmbrellaIntent) ? refGrammers : [\"luis/\" + appId + \"-PRODUCTION\"],\n };\n }\n}\nexports.IntentRecognizer = IntentRecognizer;\n\n"],"mappings":"AAAA,YAAY;;AACZ;AACA;AAAA,IAAAA,iBAAA,GAAAC,OAAA,qGAAAC,OAAA;AACAC,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,gBAAgB,GAAG,KAAK,CAAC;AACjC,MAAMC,YAAY,GAAGP,OAAO,CAAC,6BAA6B,CAAC;AAC3D,MAAMQ,YAAY,GAAGR,OAAO,CAAC,sBAAsB,CAAC;AACpD,MAAMS,cAAc,GAAGT,OAAO,CAAC,gBAAgB,CAAC;AAChD,MAAMU,YAAY,GAAGV,OAAO,CAAC,cAAc,CAAC;AAC5C;AACA;AACA;AACA;AACA,MAAMM,gBAAgB,SAASI,YAAY,CAACC,UAAU,CAAC;EACnD;AACJ;AACA;AACA;AACA;AACA;EACIC,WAAWA,CAACC,YAAY,EAAEC,WAAW,EAAE;IACnCL,cAAc,CAACM,SAAS,CAACC,sBAAsB,CAACH,YAAY,EAAE,cAAc,CAAC;IAC7E,MAAMI,UAAU,GAAGJ,YAAY;IAC/BJ,cAAc,CAACM,SAAS,CAACC,sBAAsB,CAACC,UAAU,EAAE,cAAc,CAAC;IAC3E,KAAK,CAACH,WAAW,EAAEG,UAAU,CAACC,UAAU,EAAE,IAAIX,YAAY,CAACY,uBAAuB,CAAC,CA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