@euirim/microsoft-cognitiveservices-speech-sdk
Version:
Microsoft Cognitive Services Speech SDK for JavaScript
79 lines (77 loc) • 4.33 kB
JavaScript
;
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var Contracts_1 = require("./Contracts");
var DialogServiceConfig_1 = require("./DialogServiceConfig");
var Exports_1 = require("./Exports");
/**
* Class that defines configurations for the dialog service connector object for using a Bot Framework backend.
* @class BotFrameworkConfig
*/
var BotFrameworkConfig = /** @class */ (function (_super) {
__extends(BotFrameworkConfig, _super);
/**
* Creates an instance of BotFrameworkConfig.
*/
function BotFrameworkConfig() {
return _super.call(this) || this;
}
/**
* Creates an instance of the bot framework config with the specified subscription and region.
* @member BotFrameworkConfig.fromSubscription
* @function
* @public
* @param subscription Subscription key associated with the bot
* @param region The region name (see the <a href="https://aka.ms/csspeech/region">region page</a>).
* @returns {BotFrameworkConfig} A new bot framework config.
*/
BotFrameworkConfig.fromSubscription = function (subscription, region) {
Contracts_1.Contracts.throwIfNullOrWhitespace(subscription, "subscription");
Contracts_1.Contracts.throwIfNullOrWhitespace(region, "region");
var botFrameworkConfig = new DialogServiceConfig_1.DialogServiceConfigImpl();
botFrameworkConfig.setProperty(Exports_1.PropertyId.Conversation_DialogType, "bot_framework");
botFrameworkConfig.setProperty(Exports_1.PropertyId.SpeechServiceConnection_Key, subscription);
botFrameworkConfig.setProperty(Exports_1.PropertyId.SpeechServiceConnection_Region, region);
return botFrameworkConfig;
};
/**
* Creates an instance of the bot framework config with the specified authorization token and region.
* Note: The caller needs to ensure that the authorization token is valid. Before the authorization token
* expires, the caller needs to refresh it by calling this setter with a new valid token.
* As configuration values are copied when creating a new recognizer, the new token value will not apply to recognizers that have already been created.
* For recognizers that have been created before, you need to set authorization token of the corresponding recognizer
* to refresh the token. Otherwise, the recognizers will encounter errors during recognition.
* @member BotFrameworkConfig.fromAuthorizationToken
* @function
* @public
* @param authorizationToken The authorization token associated with the bot
* @param region The region name (see the <a href="https://aka.ms/csspeech/region">region page</a>).
* @returns {BotFrameworkConfig} A new bot framework config.
*/
BotFrameworkConfig.fromAuthorizationToken = function (authorizationToken, region) {
Contracts_1.Contracts.throwIfNullOrWhitespace(authorizationToken, "authorizationToken");
Contracts_1.Contracts.throwIfNullOrWhitespace(region, "region");
var botFrameworkConfig = new DialogServiceConfig_1.DialogServiceConfigImpl();
botFrameworkConfig.setProperty(Exports_1.PropertyId.Conversation_DialogType, "bot_framework");
botFrameworkConfig.setProperty(Exports_1.PropertyId.SpeechServiceAuthorization_Token, authorizationToken);
botFrameworkConfig.setProperty(Exports_1.PropertyId.SpeechServiceConnection_Region, region);
return botFrameworkConfig;
};
return BotFrameworkConfig;
}(DialogServiceConfig_1.DialogServiceConfigImpl));
exports.BotFrameworkConfig = BotFrameworkConfig;
//# sourceMappingURL=BotFrameworkConfig.js.map