diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f1aedd4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,123 @@ +# Created by https://www.toptal.com/developers/gitignore/api/node,vscode +# Edit at https://www.toptal.com/developers/gitignore?templates=node,vscode + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test +.env*.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +### vscode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# End of https://www.toptal.com/developers/gitignore/api/node,vscode diff --git a/index.html b/index.html new file mode 100644 index 0000000..83d505d --- /dev/null +++ b/index.html @@ -0,0 +1,13 @@ + + + + + + Document + + + + + + + diff --git a/index.js b/index.js new file mode 100644 index 0000000..29f5890 --- /dev/null +++ b/index.js @@ -0,0 +1,43 @@ +const start_stt = this.document.getElementById('start_stt'); +start_stt.addEventListener('click', function () { + const speechConfig = SpeechSDK.SpeechConfig.fromSubscription( + 'fa50041df8f34ef3a14a9ef22b910602', + 'koreacentral', + ); + + const audioConfig = SpeechSDK.AudioConfig.fromDefaultMicrophoneInput(); + const recognizer = new SpeechSDK.SpeechRecognizer(speechConfig, audioConfig); + + // const recognizer = new SpeechSDK.SpeechRecognizer(speechConfig); + + // recognizer.recognizing = (s, e) => { + // console.log(`RECOGNIZING: Text=${e.result.text}`); + // }; + + recognizer.recognized = (s, e) => { + if (e.result.reason == SpeechSDK.ResultReason.RecognizedSpeech) { + console.log(`RECOGNIZED: Text=${e.result.text}`); + } else if (e.result.reason == SppeechSDK.ResultReason.NoMatch) { + console.log('NOMATCH: Speech could not be recognized.'); + } + }; + + recognizer.canceled = (s, e) => { + console.log(`CANCELED: Reason=${e.reason}`); + + if (e.reason == SpeechSDK.CancellationReason.Error) { + console.log(`"CANCELED: ErrorCode=${e.errorCode}`); + console.log(`"CANCELED: ErrorDetails=${e.errorDetails}`); + console.log('CANCELED: Did you update the subscription info?'); + } + + recognizer.stopContinuousRecognitionAsync(); + }; + + recognizer.sessionStopped = (s, e) => { + console.log('\n Session stopped event.'); + recognizer.stopContinuousRecognitionAsync(); + }; + + recognizer.startContinuousRecognitionAsync(); +}); diff --git a/microsoft.cognitiveservices.speech.sdk.bundle.js b/microsoft.cognitiveservices.speech.sdk.bundle.js new file mode 100644 index 0000000..f1a011f --- /dev/null +++ b/microsoft.cognitiveservices.speech.sdk.bundle.js @@ -0,0 +1,26933 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +window.SpeechSDK = __webpack_require__(1); + + + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +var Exports_1 = __webpack_require__(2); +var Exports_2 = __webpack_require__(4); +// Common.Storage.SetLocalStorage(new Common.Browser.LocalStorage()); +// Common.Storage.SetSessionStorage(new Common.Browser.SessionStorage()); +Exports_2.Events.instance.attachListener(new Exports_1.ConsoleLoggingListener()); +// Speech SDK API +__export(__webpack_require__(31)); + + + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +__export(__webpack_require__(3)); +__export(__webpack_require__(25)); +__export(__webpack_require__(181)); +__export(__webpack_require__(182)); +__export(__webpack_require__(183)); +__export(__webpack_require__(184)); +__export(__webpack_require__(200)); +__export(__webpack_require__(201)); +__export(__webpack_require__(202)); +__export(__webpack_require__(159)); + + + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(4); +var ConsoleLoggingListener = /** @class */ (function () { + function ConsoleLoggingListener(logLevelFilter) { + var _this = this; + if (logLevelFilter === void 0) { logLevelFilter = Exports_1.EventType.Warning; } + this.onEvent = function (event) { + if (event.eventType >= _this.privLogLevelFilter) { + var log = _this.toString(event); + switch (event.eventType) { + case Exports_1.EventType.Debug: + // tslint:disable-next-line:no-console + console.debug(log); + break; + case Exports_1.EventType.Info: + // tslint:disable-next-line:no-console + console.info(log); + break; + case Exports_1.EventType.Warning: + // tslint:disable-next-line:no-console + console.warn(log); + break; + case Exports_1.EventType.Error: + // tslint:disable-next-line:no-console + console.error(log); + break; + default: + // tslint:disable-next-line:no-console + console.log(log); + break; + } + } + }; + this.toString = function (event) { + var logFragments = [ + "" + event.EventTime, + "" + event.Name, + ]; + for (var prop in event) { + if (prop && event.hasOwnProperty(prop) && + prop !== "eventTime" && prop !== "eventType" && + prop !== "eventId" && prop !== "name" && + prop !== "constructor") { + var value = event[prop]; + var valueToLog = ""; + if (value !== undefined && value !== null) { + if (typeof (value) === "number" || typeof (value) === "string") { + valueToLog = value.toString(); + } + else { + valueToLog = JSON.stringify(value); + } + } + logFragments.push(prop + ": " + valueToLog); + } + } + return logFragments.join(" | "); + }; + this.privLogLevelFilter = logLevelFilter; + } + return ConsoleLoggingListener; +}()); +exports.ConsoleLoggingListener = ConsoleLoggingListener; + + + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +__export(__webpack_require__(5)); +__export(__webpack_require__(8)); +__export(__webpack_require__(9)); +__export(__webpack_require__(11)); +__export(__webpack_require__(10)); +__export(__webpack_require__(12)); +__export(__webpack_require__(13)); +__export(__webpack_require__(7)); +__export(__webpack_require__(14)); +__export(__webpack_require__(15)); +__export(__webpack_require__(6)); +__export(__webpack_require__(16)); +__export(__webpack_require__(17)); +__export(__webpack_require__(18)); +__export(__webpack_require__(19)); +__export(__webpack_require__(20)); +var TranslationStatus_1 = __webpack_require__(21); +exports.TranslationStatus = TranslationStatus_1.TranslationStatus; +__export(__webpack_require__(22)); +__export(__webpack_require__(23)); +__export(__webpack_require__(24)); + + + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 PlatformEvent_1 = __webpack_require__(6); +var AudioSourceEvent = /** @class */ (function (_super) { + __extends(AudioSourceEvent, _super); + function AudioSourceEvent(eventName, audioSourceId, eventType) { + if (eventType === void 0) { eventType = PlatformEvent_1.EventType.Info; } + var _this = _super.call(this, eventName, eventType) || this; + _this.privAudioSourceId = audioSourceId; + return _this; + } + Object.defineProperty(AudioSourceEvent.prototype, "audioSourceId", { + get: function () { + return this.privAudioSourceId; + }, + enumerable: true, + configurable: true + }); + return AudioSourceEvent; +}(PlatformEvent_1.PlatformEvent)); +exports.AudioSourceEvent = AudioSourceEvent; +// tslint:disable-next-line:max-classes-per-file +var AudioSourceInitializingEvent = /** @class */ (function (_super) { + __extends(AudioSourceInitializingEvent, _super); + function AudioSourceInitializingEvent(audioSourceId) { + return _super.call(this, "AudioSourceInitializingEvent", audioSourceId) || this; + } + return AudioSourceInitializingEvent; +}(AudioSourceEvent)); +exports.AudioSourceInitializingEvent = AudioSourceInitializingEvent; +// tslint:disable-next-line:max-classes-per-file +var AudioSourceReadyEvent = /** @class */ (function (_super) { + __extends(AudioSourceReadyEvent, _super); + function AudioSourceReadyEvent(audioSourceId) { + return _super.call(this, "AudioSourceReadyEvent", audioSourceId) || this; + } + return AudioSourceReadyEvent; +}(AudioSourceEvent)); +exports.AudioSourceReadyEvent = AudioSourceReadyEvent; +// tslint:disable-next-line:max-classes-per-file +var AudioSourceOffEvent = /** @class */ (function (_super) { + __extends(AudioSourceOffEvent, _super); + function AudioSourceOffEvent(audioSourceId) { + return _super.call(this, "AudioSourceOffEvent", audioSourceId) || this; + } + return AudioSourceOffEvent; +}(AudioSourceEvent)); +exports.AudioSourceOffEvent = AudioSourceOffEvent; +// tslint:disable-next-line:max-classes-per-file +var AudioSourceErrorEvent = /** @class */ (function (_super) { + __extends(AudioSourceErrorEvent, _super); + function AudioSourceErrorEvent(audioSourceId, error) { + var _this = _super.call(this, "AudioSourceErrorEvent", audioSourceId, PlatformEvent_1.EventType.Error) || this; + _this.privError = error; + return _this; + } + Object.defineProperty(AudioSourceErrorEvent.prototype, "error", { + get: function () { + return this.privError; + }, + enumerable: true, + configurable: true + }); + return AudioSourceErrorEvent; +}(AudioSourceEvent)); +exports.AudioSourceErrorEvent = AudioSourceErrorEvent; +// tslint:disable-next-line:max-classes-per-file +var AudioStreamNodeEvent = /** @class */ (function (_super) { + __extends(AudioStreamNodeEvent, _super); + function AudioStreamNodeEvent(eventName, audioSourceId, audioNodeId) { + var _this = _super.call(this, eventName, audioSourceId) || this; + _this.privAudioNodeId = audioNodeId; + return _this; + } + Object.defineProperty(AudioStreamNodeEvent.prototype, "audioNodeId", { + get: function () { + return this.privAudioNodeId; + }, + enumerable: true, + configurable: true + }); + return AudioStreamNodeEvent; +}(AudioSourceEvent)); +exports.AudioStreamNodeEvent = AudioStreamNodeEvent; +// tslint:disable-next-line:max-classes-per-file +var AudioStreamNodeAttachingEvent = /** @class */ (function (_super) { + __extends(AudioStreamNodeAttachingEvent, _super); + function AudioStreamNodeAttachingEvent(audioSourceId, audioNodeId) { + return _super.call(this, "AudioStreamNodeAttachingEvent", audioSourceId, audioNodeId) || this; + } + return AudioStreamNodeAttachingEvent; +}(AudioStreamNodeEvent)); +exports.AudioStreamNodeAttachingEvent = AudioStreamNodeAttachingEvent; +// tslint:disable-next-line:max-classes-per-file +var AudioStreamNodeAttachedEvent = /** @class */ (function (_super) { + __extends(AudioStreamNodeAttachedEvent, _super); + function AudioStreamNodeAttachedEvent(audioSourceId, audioNodeId) { + return _super.call(this, "AudioStreamNodeAttachedEvent", audioSourceId, audioNodeId) || this; + } + return AudioStreamNodeAttachedEvent; +}(AudioStreamNodeEvent)); +exports.AudioStreamNodeAttachedEvent = AudioStreamNodeAttachedEvent; +// tslint:disable-next-line:max-classes-per-file +var AudioStreamNodeDetachedEvent = /** @class */ (function (_super) { + __extends(AudioStreamNodeDetachedEvent, _super); + function AudioStreamNodeDetachedEvent(audioSourceId, audioNodeId) { + return _super.call(this, "AudioStreamNodeDetachedEvent", audioSourceId, audioNodeId) || this; + } + return AudioStreamNodeDetachedEvent; +}(AudioStreamNodeEvent)); +exports.AudioStreamNodeDetachedEvent = AudioStreamNodeDetachedEvent; +// tslint:disable-next-line:max-classes-per-file +var AudioStreamNodeErrorEvent = /** @class */ (function (_super) { + __extends(AudioStreamNodeErrorEvent, _super); + function AudioStreamNodeErrorEvent(audioSourceId, audioNodeId, error) { + var _this = _super.call(this, "AudioStreamNodeErrorEvent", audioSourceId, audioNodeId) || this; + _this.privError = error; + return _this; + } + Object.defineProperty(AudioStreamNodeErrorEvent.prototype, "error", { + get: function () { + return this.privError; + }, + enumerable: true, + configurable: true + }); + return AudioStreamNodeErrorEvent; +}(AudioStreamNodeEvent)); +exports.AudioStreamNodeErrorEvent = AudioStreamNodeErrorEvent; + + + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Guid_1 = __webpack_require__(7); +var EventType; +(function (EventType) { + EventType[EventType["Debug"] = 0] = "Debug"; + EventType[EventType["Info"] = 1] = "Info"; + EventType[EventType["Warning"] = 2] = "Warning"; + EventType[EventType["Error"] = 3] = "Error"; +})(EventType = exports.EventType || (exports.EventType = {})); +var PlatformEvent = /** @class */ (function () { + function PlatformEvent(eventName, eventType) { + this.privName = eventName; + this.privEventId = Guid_1.createNoDashGuid(); + this.privEventTime = new Date().toISOString(); + this.privEventType = eventType; + this.privMetadata = {}; + } + Object.defineProperty(PlatformEvent.prototype, "name", { + get: function () { + return this.privName; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(PlatformEvent.prototype, "eventId", { + get: function () { + return this.privEventId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(PlatformEvent.prototype, "eventTime", { + get: function () { + return this.privEventTime; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(PlatformEvent.prototype, "eventType", { + get: function () { + return this.privEventType; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(PlatformEvent.prototype, "metadata", { + get: function () { + return this.privMetadata; + }, + enumerable: true, + configurable: true + }); + return PlatformEvent; +}()); +exports.PlatformEvent = PlatformEvent; + + + +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var createGuid = function () { + var d = new Date().getTime(); + var guid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) { + var r = (d + Math.random() * 16) % 16 | 0; + d = Math.floor(d / 16); + return (c === "x" ? r : (r & 0x3 | 0x8)).toString(16); + }); + return guid; +}; +exports.createGuid = createGuid; +var createNoDashGuid = function () { + return createGuid().replace(new RegExp("-", "g"), "").toUpperCase(); +}; +exports.createNoDashGuid = createNoDashGuid; + + + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 PlatformEvent_1 = __webpack_require__(6); +var ServiceEvent = /** @class */ (function (_super) { + __extends(ServiceEvent, _super); + function ServiceEvent(eventName, jsonstring, eventType) { + if (eventType === void 0) { eventType = PlatformEvent_1.EventType.Info; } + var _this = _super.call(this, eventName, eventType) || this; + _this.privJsonResult = jsonstring; + return _this; + } + Object.defineProperty(ServiceEvent.prototype, "jsonString", { + get: function () { + return this.privJsonResult; + }, + enumerable: true, + configurable: true + }); + return ServiceEvent; +}(PlatformEvent_1.PlatformEvent)); +exports.ServiceEvent = ServiceEvent; +// tslint:disable-next-line:max-classes-per-file +var ConnectionEvent = /** @class */ (function (_super) { + __extends(ConnectionEvent, _super); + function ConnectionEvent(eventName, connectionId, eventType) { + if (eventType === void 0) { eventType = PlatformEvent_1.EventType.Info; } + var _this = _super.call(this, eventName, eventType) || this; + _this.privConnectionId = connectionId; + return _this; + } + Object.defineProperty(ConnectionEvent.prototype, "connectionId", { + get: function () { + return this.privConnectionId; + }, + enumerable: true, + configurable: true + }); + return ConnectionEvent; +}(PlatformEvent_1.PlatformEvent)); +exports.ConnectionEvent = ConnectionEvent; +// tslint:disable-next-line:max-classes-per-file +var ConnectionStartEvent = /** @class */ (function (_super) { + __extends(ConnectionStartEvent, _super); + function ConnectionStartEvent(connectionId, uri, headers) { + var _this = _super.call(this, "ConnectionStartEvent", connectionId) || this; + _this.privUri = uri; + _this.privHeaders = headers; + return _this; + } + Object.defineProperty(ConnectionStartEvent.prototype, "uri", { + get: function () { + return this.privUri; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConnectionStartEvent.prototype, "headers", { + get: function () { + return this.privHeaders; + }, + enumerable: true, + configurable: true + }); + return ConnectionStartEvent; +}(ConnectionEvent)); +exports.ConnectionStartEvent = ConnectionStartEvent; +// tslint:disable-next-line:max-classes-per-file +var ConnectionEstablishedEvent = /** @class */ (function (_super) { + __extends(ConnectionEstablishedEvent, _super); + function ConnectionEstablishedEvent(connectionId, metadata) { + return _super.call(this, "ConnectionEstablishedEvent", connectionId) || this; + } + return ConnectionEstablishedEvent; +}(ConnectionEvent)); +exports.ConnectionEstablishedEvent = ConnectionEstablishedEvent; +// tslint:disable-next-line:max-classes-per-file +var ConnectionClosedEvent = /** @class */ (function (_super) { + __extends(ConnectionClosedEvent, _super); + function ConnectionClosedEvent(connectionId, statusCode, reason) { + var _this = _super.call(this, "ConnectionClosedEvent", connectionId, PlatformEvent_1.EventType.Debug) || this; + _this.privRreason = reason; + _this.privStatusCode = statusCode; + return _this; + } + Object.defineProperty(ConnectionClosedEvent.prototype, "reason", { + get: function () { + return this.privRreason; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConnectionClosedEvent.prototype, "statusCode", { + get: function () { + return this.privStatusCode; + }, + enumerable: true, + configurable: true + }); + return ConnectionClosedEvent; +}(ConnectionEvent)); +exports.ConnectionClosedEvent = ConnectionClosedEvent; +// tslint:disable-next-line:max-classes-per-file +var ConnectionErrorEvent = /** @class */ (function (_super) { + __extends(ConnectionErrorEvent, _super); + function ConnectionErrorEvent(connectionId, message, type) { + var _this = _super.call(this, "ConnectionErrorEvent", connectionId, PlatformEvent_1.EventType.Debug) || this; + _this.privMessage = message; + _this.privType = type; + return _this; + } + Object.defineProperty(ConnectionErrorEvent.prototype, "message", { + get: function () { + return this.privMessage; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConnectionErrorEvent.prototype, "type", { + get: function () { + return this.privType; + }, + enumerable: true, + configurable: true + }); + return ConnectionErrorEvent; +}(ConnectionEvent)); +exports.ConnectionErrorEvent = ConnectionErrorEvent; +// tslint:disable-next-line:max-classes-per-file +var ConnectionEstablishErrorEvent = /** @class */ (function (_super) { + __extends(ConnectionEstablishErrorEvent, _super); + function ConnectionEstablishErrorEvent(connectionId, statuscode, reason) { + var _this = _super.call(this, "ConnectionEstablishErrorEvent", connectionId, PlatformEvent_1.EventType.Error) || this; + _this.privStatusCode = statuscode; + _this.privReason = reason; + return _this; + } + Object.defineProperty(ConnectionEstablishErrorEvent.prototype, "reason", { + get: function () { + return this.privReason; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConnectionEstablishErrorEvent.prototype, "statusCode", { + get: function () { + return this.privStatusCode; + }, + enumerable: true, + configurable: true + }); + return ConnectionEstablishErrorEvent; +}(ConnectionEvent)); +exports.ConnectionEstablishErrorEvent = ConnectionEstablishErrorEvent; +// tslint:disable-next-line:max-classes-per-file +var ConnectionMessageReceivedEvent = /** @class */ (function (_super) { + __extends(ConnectionMessageReceivedEvent, _super); + function ConnectionMessageReceivedEvent(connectionId, networkReceivedTimeISO, message) { + var _this = _super.call(this, "ConnectionMessageReceivedEvent", connectionId) || this; + _this.privNetworkReceivedTime = networkReceivedTimeISO; + _this.privMessage = message; + return _this; + } + Object.defineProperty(ConnectionMessageReceivedEvent.prototype, "networkReceivedTime", { + get: function () { + return this.privNetworkReceivedTime; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConnectionMessageReceivedEvent.prototype, "message", { + get: function () { + return this.privMessage; + }, + enumerable: true, + configurable: true + }); + return ConnectionMessageReceivedEvent; +}(ConnectionEvent)); +exports.ConnectionMessageReceivedEvent = ConnectionMessageReceivedEvent; +// tslint:disable-next-line:max-classes-per-file +var ConnectionMessageSentEvent = /** @class */ (function (_super) { + __extends(ConnectionMessageSentEvent, _super); + function ConnectionMessageSentEvent(connectionId, networkSentTimeISO, message) { + var _this = _super.call(this, "ConnectionMessageSentEvent", connectionId) || this; + _this.privNetworkSentTime = networkSentTimeISO; + _this.privMessage = message; + return _this; + } + Object.defineProperty(ConnectionMessageSentEvent.prototype, "networkSentTime", { + get: function () { + return this.privNetworkSentTime; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConnectionMessageSentEvent.prototype, "message", { + get: function () { + return this.privMessage; + }, + enumerable: true, + configurable: true + }); + return ConnectionMessageSentEvent; +}(ConnectionEvent)); +exports.ConnectionMessageSentEvent = ConnectionMessageSentEvent; + + + +/***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Error_1 = __webpack_require__(10); +var Guid_1 = __webpack_require__(7); +var MessageType; +(function (MessageType) { + MessageType[MessageType["Text"] = 0] = "Text"; + MessageType[MessageType["Binary"] = 1] = "Binary"; +})(MessageType = exports.MessageType || (exports.MessageType = {})); +var ConnectionMessage = /** @class */ (function () { + function ConnectionMessage(messageType, body, headers, id) { + this.privBody = null; + if (messageType === MessageType.Text && body && !(typeof (body) === "string")) { + throw new Error_1.InvalidOperationError("Payload must be a string"); + } + if (messageType === MessageType.Binary && body && !(body instanceof ArrayBuffer)) { + throw new Error_1.InvalidOperationError("Payload must be ArrayBuffer"); + } + this.privMessageType = messageType; + this.privBody = body; + this.privHeaders = headers ? headers : {}; + this.privId = id ? id : Guid_1.createNoDashGuid(); + switch (this.messageType) { + case MessageType.Binary: + this.privSize = this.binaryBody !== null ? this.binaryBody.byteLength : 0; + break; + case MessageType.Text: + this.privSize = this.textBody.length; + } + } + Object.defineProperty(ConnectionMessage.prototype, "messageType", { + get: function () { + return this.privMessageType; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConnectionMessage.prototype, "headers", { + get: function () { + return this.privHeaders; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConnectionMessage.prototype, "body", { + get: function () { + return this.privBody; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConnectionMessage.prototype, "textBody", { + get: function () { + if (this.privMessageType === MessageType.Binary) { + throw new Error_1.InvalidOperationError("Not supported for binary message"); + } + return this.privBody; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConnectionMessage.prototype, "binaryBody", { + get: function () { + if (this.privMessageType === MessageType.Text) { + throw new Error_1.InvalidOperationError("Not supported for text message"); + } + return this.privBody; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConnectionMessage.prototype, "id", { + get: function () { + return this.privId; + }, + enumerable: true, + configurable: true + }); + return ConnectionMessage; +}()); +exports.ConnectionMessage = ConnectionMessage; + + + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 }); +/** + * The error that is thrown when an argument passed in is null. + * + * @export + * @class ArgumentNullError + * @extends {Error} + */ +var ArgumentNullError = /** @class */ (function (_super) { + __extends(ArgumentNullError, _super); + /** + * Creates an instance of ArgumentNullError. + * + * @param {string} argumentName - Name of the argument that is null + * + * @memberOf ArgumentNullError + */ + function ArgumentNullError(argumentName) { + var _this = _super.call(this, argumentName) || this; + _this.name = "ArgumentNull"; + _this.message = argumentName; + return _this; + } + return ArgumentNullError; +}(Error)); +exports.ArgumentNullError = ArgumentNullError; +/** + * The error that is thrown when an invalid operation is performed in the code. + * + * @export + * @class InvalidOperationError + * @extends {Error} + */ +// tslint:disable-next-line:max-classes-per-file +var InvalidOperationError = /** @class */ (function (_super) { + __extends(InvalidOperationError, _super); + /** + * Creates an instance of InvalidOperationError. + * + * @param {string} error - The error + * + * @memberOf InvalidOperationError + */ + function InvalidOperationError(error) { + var _this = _super.call(this, error) || this; + _this.name = "InvalidOperation"; + _this.message = error; + return _this; + } + return InvalidOperationError; +}(Error)); +exports.InvalidOperationError = InvalidOperationError; +/** + * The error that is thrown when an object is disposed. + * + * @export + * @class ObjectDisposedError + * @extends {Error} + */ +// tslint:disable-next-line:max-classes-per-file +var ObjectDisposedError = /** @class */ (function (_super) { + __extends(ObjectDisposedError, _super); + /** + * Creates an instance of ObjectDisposedError. + * + * @param {string} objectName - The object that is disposed + * @param {string} error - The error + * + * @memberOf ObjectDisposedError + */ + function ObjectDisposedError(objectName, error) { + var _this = _super.call(this, error) || this; + _this.name = objectName + "ObjectDisposed"; + _this.message = error; + return _this; + } + return ObjectDisposedError; +}(Error)); +exports.ObjectDisposedError = ObjectDisposedError; + + + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var ConnectionOpenResponse = /** @class */ (function () { + function ConnectionOpenResponse(statusCode, reason) { + this.privStatusCode = statusCode; + this.privReason = reason; + } + Object.defineProperty(ConnectionOpenResponse.prototype, "statusCode", { + get: function () { + return this.privStatusCode; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConnectionOpenResponse.prototype, "reason", { + get: function () { + return this.privReason; + }, + enumerable: true, + configurable: true + }); + return ConnectionOpenResponse; +}()); +exports.ConnectionOpenResponse = ConnectionOpenResponse; + + + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Error_1 = __webpack_require__(10); +var EventSource_1 = __webpack_require__(13); +var Events = /** @class */ (function () { + function Events() { + } + Object.defineProperty(Events, "instance", { + get: function () { + return Events.privInstance; + }, + enumerable: true, + configurable: true + }); + Events.privInstance = new EventSource_1.EventSource(); + Events.setEventSource = function (eventSource) { + if (!eventSource) { + throw new Error_1.ArgumentNullError("eventSource"); + } + Events.privInstance = eventSource; + }; + return Events; +}()); +exports.Events = Events; + + + +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Error_1 = __webpack_require__(10); +var Guid_1 = __webpack_require__(7); +var EventSource = /** @class */ (function () { + function EventSource(metadata) { + var _this = this; + this.privEventListeners = {}; + this.privIsDisposed = false; + this.onEvent = function (event) { + if (_this.isDisposed()) { + throw (new Error_1.ObjectDisposedError("EventSource")); + } + if (_this.metadata) { + for (var paramName in _this.metadata) { + if (paramName) { + if (event.metadata) { + if (!event.metadata[paramName]) { + event.metadata[paramName] = _this.metadata[paramName]; + } + } + } + } + } + for (var eventId in _this.privEventListeners) { + if (eventId && _this.privEventListeners[eventId]) { + _this.privEventListeners[eventId](event); + } + } + }; + this.attach = function (onEventCallback) { + var id = Guid_1.createNoDashGuid(); + _this.privEventListeners[id] = onEventCallback; + return { + detach: function () { + delete _this.privEventListeners[id]; + }, + }; + }; + this.attachListener = function (listener) { + return _this.attach(listener.onEvent); + }; + this.isDisposed = function () { + return _this.privIsDisposed; + }; + this.dispose = function () { + _this.privEventListeners = null; + _this.privIsDisposed = true; + }; + this.privMetadata = metadata; + } + Object.defineProperty(EventSource.prototype, "metadata", { + get: function () { + return this.privMetadata; + }, + enumerable: true, + configurable: true + }); + return EventSource; +}()); +exports.EventSource = EventSource; + + + +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var ConnectionState; +(function (ConnectionState) { + ConnectionState[ConnectionState["None"] = 0] = "None"; + ConnectionState[ConnectionState["Connected"] = 1] = "Connected"; + ConnectionState[ConnectionState["Connecting"] = 2] = "Connecting"; + ConnectionState[ConnectionState["Disconnected"] = 3] = "Disconnected"; +})(ConnectionState = exports.ConnectionState || (exports.ConnectionState = {})); + + + +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Error_1 = __webpack_require__(10); +var List = /** @class */ (function () { + function List(list) { + var _this = this; + this.privSubscriptionIdCounter = 0; + this.privAddSubscriptions = {}; + this.privRemoveSubscriptions = {}; + this.privDisposedSubscriptions = {}; + this.privDisposeReason = null; + this.get = function (itemIndex) { + _this.throwIfDisposed(); + return _this.privList[itemIndex]; + }; + this.first = function () { + return _this.get(0); + }; + this.last = function () { + return _this.get(_this.length() - 1); + }; + this.add = function (item) { + _this.throwIfDisposed(); + _this.insertAt(_this.privList.length, item); + }; + this.insertAt = function (index, item) { + _this.throwIfDisposed(); + if (index === 0) { + _this.privList.unshift(item); + } + else if (index === _this.privList.length) { + _this.privList.push(item); + } + else { + _this.privList.splice(index, 0, item); + } + _this.triggerSubscriptions(_this.privAddSubscriptions); + }; + this.removeFirst = function () { + _this.throwIfDisposed(); + return _this.removeAt(0); + }; + this.removeLast = function () { + _this.throwIfDisposed(); + return _this.removeAt(_this.length() - 1); + }; + this.removeAt = function (index) { + _this.throwIfDisposed(); + return _this.remove(index, 1)[0]; + }; + this.remove = function (index, count) { + _this.throwIfDisposed(); + var removedElements = _this.privList.splice(index, count); + _this.triggerSubscriptions(_this.privRemoveSubscriptions); + return removedElements; + }; + this.clear = function () { + _this.throwIfDisposed(); + _this.remove(0, _this.length()); + }; + this.length = function () { + _this.throwIfDisposed(); + return _this.privList.length; + }; + this.onAdded = function (addedCallback) { + _this.throwIfDisposed(); + var subscriptionId = _this.privSubscriptionIdCounter++; + _this.privAddSubscriptions[subscriptionId] = addedCallback; + return { + detach: function () { + delete _this.privAddSubscriptions[subscriptionId]; + }, + }; + }; + this.onRemoved = function (removedCallback) { + _this.throwIfDisposed(); + var subscriptionId = _this.privSubscriptionIdCounter++; + _this.privRemoveSubscriptions[subscriptionId] = removedCallback; + return { + detach: function () { + delete _this.privRemoveSubscriptions[subscriptionId]; + }, + }; + }; + this.onDisposed = function (disposedCallback) { + _this.throwIfDisposed(); + var subscriptionId = _this.privSubscriptionIdCounter++; + _this.privDisposedSubscriptions[subscriptionId] = disposedCallback; + return { + detach: function () { + delete _this.privDisposedSubscriptions[subscriptionId]; + }, + }; + }; + this.join = function (seperator) { + _this.throwIfDisposed(); + return _this.privList.join(seperator); + }; + this.toArray = function () { + var cloneCopy = Array(); + _this.privList.forEach(function (val) { + cloneCopy.push(val); + }); + return cloneCopy; + }; + this.any = function (callback) { + _this.throwIfDisposed(); + if (callback) { + return _this.where(callback).length() > 0; + } + else { + return _this.length() > 0; + } + }; + this.all = function (callback) { + _this.throwIfDisposed(); + return _this.where(callback).length() === _this.length(); + }; + this.forEach = function (callback) { + _this.throwIfDisposed(); + for (var i = 0; i < _this.length(); i++) { + callback(_this.privList[i], i); + } + }; + this.select = function (callback) { + _this.throwIfDisposed(); + var selectList = []; + for (var i = 0; i < _this.privList.length; i++) { + selectList.push(callback(_this.privList[i], i)); + } + return new List(selectList); + }; + this.where = function (callback) { + _this.throwIfDisposed(); + var filteredList = new List(); + for (var i = 0; i < _this.privList.length; i++) { + if (callback(_this.privList[i], i)) { + filteredList.add(_this.privList[i]); + } + } + return filteredList; + }; + this.orderBy = function (compareFn) { + _this.throwIfDisposed(); + var clonedArray = _this.toArray(); + var orderedArray = clonedArray.sort(compareFn); + return new List(orderedArray); + }; + this.orderByDesc = function (compareFn) { + _this.throwIfDisposed(); + return _this.orderBy(function (a, b) { return compareFn(b, a); }); + }; + this.clone = function () { + _this.throwIfDisposed(); + return new List(_this.toArray()); + }; + this.concat = function (list) { + _this.throwIfDisposed(); + return new List(_this.privList.concat(list.toArray())); + }; + this.concatArray = function (array) { + _this.throwIfDisposed(); + return new List(_this.privList.concat(array)); + }; + this.isDisposed = function () { + return _this.privList == null; + }; + this.dispose = function (reason) { + if (!_this.isDisposed()) { + _this.privDisposeReason = reason; + _this.privList = null; + _this.privAddSubscriptions = null; + _this.privRemoveSubscriptions = null; + _this.triggerSubscriptions(_this.privDisposedSubscriptions); + } + }; + this.throwIfDisposed = function () { + if (_this.isDisposed()) { + throw new Error_1.ObjectDisposedError("List", _this.privDisposeReason); + } + }; + this.triggerSubscriptions = function (subscriptions) { + if (subscriptions) { + for (var subscriptionId in subscriptions) { + if (subscriptionId) { + subscriptions[subscriptionId](); + } + } + } + }; + this.privList = []; + // copy the list rather than taking as is. + if (list) { + for (var _i = 0, list_1 = list; _i < list_1.length; _i++) { + var item = list_1[_i]; + this.privList.push(item); + } + } + } + return List; +}()); +exports.List = List; + + + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Error_1 = __webpack_require__(10); +var PromiseState; +(function (PromiseState) { + PromiseState[PromiseState["None"] = 0] = "None"; + PromiseState[PromiseState["Resolved"] = 1] = "Resolved"; + PromiseState[PromiseState["Rejected"] = 2] = "Rejected"; +})(PromiseState = exports.PromiseState || (exports.PromiseState = {})); +var PromiseResult = /** @class */ (function () { + function PromiseResult(promiseResultEventSource) { + var _this = this; + this.throwIfError = function () { + if (_this.isError) { + throw _this.error; + } + }; + promiseResultEventSource.on(function (result) { + if (!_this.privIsCompleted) { + _this.privIsCompleted = true; + _this.privIsError = false; + _this.privResult = result; + } + }, function (error) { + if (!_this.privIsCompleted) { + _this.privIsCompleted = true; + _this.privIsError = true; + _this.privError = error; + } + }); + } + Object.defineProperty(PromiseResult.prototype, "isCompleted", { + get: function () { + return this.privIsCompleted; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(PromiseResult.prototype, "isError", { + get: function () { + return this.privIsError; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(PromiseResult.prototype, "error", { + get: function () { + return this.privError; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(PromiseResult.prototype, "result", { + get: function () { + return this.privResult; + }, + enumerable: true, + configurable: true + }); + return PromiseResult; +}()); +exports.PromiseResult = PromiseResult; +// tslint:disable-next-line:max-classes-per-file +var PromiseResultEventSource = /** @class */ (function () { + function PromiseResultEventSource() { + var _this = this; + this.setResult = function (result) { + _this.privOnSetResult(result); + }; + this.setError = function (error) { + _this.privOnSetError(error); + }; + this.on = function (onSetResult, onSetError) { + _this.privOnSetResult = onSetResult; + _this.privOnSetError = onSetError; + }; + } + return PromiseResultEventSource; +}()); +exports.PromiseResultEventSource = PromiseResultEventSource; +// tslint:disable-next-line:max-classes-per-file +var PromiseHelper = /** @class */ (function () { + function PromiseHelper() { + } + PromiseHelper.whenAll = function (promises) { + if (!promises || promises.length === 0) { + throw new Error_1.ArgumentNullError("promises"); + } + var deferred = new Deferred(); + var errors = []; + var completedPromises = 0; + var checkForCompletion = function () { + completedPromises++; + if (completedPromises === promises.length) { + if (errors.length === 0) { + deferred.resolve(true); + } + else { + deferred.reject(errors.join(", ")); + } + } + }; + for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) { + var promise = promises_1[_i]; + promise.on(function (r) { + checkForCompletion(); + }, function (e) { + errors.push(e); + checkForCompletion(); + }); + } + return deferred.promise(); + }; + PromiseHelper.fromResult = function (result) { + var deferred = new Deferred(); + deferred.resolve(result); + return deferred.promise(); + }; + PromiseHelper.fromError = function (error) { + var deferred = new Deferred(); + deferred.reject(error); + return deferred.promise(); + }; + return PromiseHelper; +}()); +exports.PromiseHelper = PromiseHelper; +// TODO: replace with ES6 promises +// tslint:disable-next-line:max-classes-per-file +var Promise = /** @class */ (function () { + function Promise(sink) { + var _this = this; + this.result = function () { + return _this.privSink.result; + }; + this.continueWith = function (continuationCallback) { + if (!continuationCallback) { + throw new Error_1.ArgumentNullError("continuationCallback"); + } + var continuationDeferral = new Deferred(); + _this.privSink.on(function (r) { + try { + var continuationResult = continuationCallback(_this.privSink.result); + continuationDeferral.resolve(continuationResult); + } + catch (e) { + continuationDeferral.reject(e); + } + }, function (error) { + try { + var continuationResult = continuationCallback(_this.privSink.result); + continuationDeferral.resolve(continuationResult); + } + catch (e) { + continuationDeferral.reject("'Error handler for error " + error + " threw error " + e + "'"); + } + }); + return continuationDeferral.promise(); + }; + this.onSuccessContinueWith = function (continuationCallback) { + if (!continuationCallback) { + throw new Error_1.ArgumentNullError("continuationCallback"); + } + var continuationDeferral = new Deferred(); + _this.privSink.on(function (r) { + try { + var continuationResult = continuationCallback(r); + continuationDeferral.resolve(continuationResult); + } + catch (e) { + continuationDeferral.reject(e); + } + }, function (error) { + continuationDeferral.reject(error); + }); + return continuationDeferral.promise(); + }; + this.continueWithPromise = function (continuationCallback) { + if (!continuationCallback) { + throw new Error_1.ArgumentNullError("continuationCallback"); + } + var continuationDeferral = new Deferred(); + _this.privSink.on(function (r) { + try { + var continuationPromise = continuationCallback(_this.privSink.result); + if (!continuationPromise) { + throw new Error("'Continuation callback did not return promise'"); + } + continuationPromise.on(function (continuationResult) { + continuationDeferral.resolve(continuationResult); + }, function (e) { + continuationDeferral.reject(e); + }); + } + catch (e) { + continuationDeferral.reject(e); + } + }, function (error) { + try { + var continuationPromise = continuationCallback(_this.privSink.result); + if (!continuationPromise) { + throw new Error("Continuation callback did not return promise"); + } + continuationPromise.on(function (continuationResult) { + continuationDeferral.resolve(continuationResult); + }, function (e) { + continuationDeferral.reject(e); + }); + } + catch (e) { + continuationDeferral.reject("'Error handler for error " + error + " threw error " + e + "'"); + } + }); + return continuationDeferral.promise(); + }; + this.onSuccessContinueWithPromise = function (continuationCallback) { + if (!continuationCallback) { + throw new Error_1.ArgumentNullError("continuationCallback"); + } + var continuationDeferral = new Deferred(); + _this.privSink.on(function (r) { + try { + var continuationPromise = continuationCallback(r); + if (!continuationPromise) { + throw new Error("Continuation callback did not return promise"); + } + continuationPromise.on(function (continuationResult) { + continuationDeferral.resolve(continuationResult); + }, function (e) { + continuationDeferral.reject(e); + }); + } + catch (e) { + continuationDeferral.reject(e); + } + }, function (error) { + continuationDeferral.reject(error); + }); + return continuationDeferral.promise(); + }; + this.on = function (successCallback, errorCallback) { + if (!successCallback) { + throw new Error_1.ArgumentNullError("successCallback"); + } + if (!errorCallback) { + throw new Error_1.ArgumentNullError("errorCallback"); + } + _this.privSink.on(successCallback, errorCallback); + return _this; + }; + this.finally = function (callback) { + if (!callback) { + throw new Error_1.ArgumentNullError("callback"); + } + var callbackWrapper = function (_) { + callback(); + }; + return _this.on(callbackWrapper, callbackWrapper); + }; + this.privSink = sink; + } + return Promise; +}()); +exports.Promise = Promise; +// tslint:disable-next-line:max-classes-per-file +var Deferred = /** @class */ (function () { + function Deferred() { + var _this = this; + this.state = function () { + return _this.privSink.state; + }; + this.promise = function () { + return _this.privPromise; + }; + this.resolve = function (result) { + _this.privSink.resolve(result); + return _this; + }; + this.reject = function (error) { + _this.privSink.reject(error); + return _this; + }; + this.privSink = new Sink(); + this.privPromise = new Promise(this.privSink); + } + return Deferred; +}()); +exports.Deferred = Deferred; +// tslint:disable-next-line:max-classes-per-file +var Sink = /** @class */ (function () { + function Sink() { + var _this = this; + this.privState = PromiseState.None; + this.privPromiseResult = null; + this.privPromiseResultEvents = null; + this.privSuccessHandlers = []; + this.privErrorHandlers = []; + this.resolve = function (result) { + if (_this.privState !== PromiseState.None) { + throw new Error("'Cannot resolve a completed promise'"); + } + _this.privState = PromiseState.Resolved; + _this.privPromiseResultEvents.setResult(result); + for (var i = 0; i < _this.privSuccessHandlers.length; i++) { + _this.executeSuccessCallback(result, _this.privSuccessHandlers[i], _this.privErrorHandlers[i]); + } + _this.detachHandlers(); + }; + this.reject = function (error) { + if (_this.privState !== PromiseState.None) { + throw new Error("'Cannot reject a completed promise'"); + } + _this.privState = PromiseState.Rejected; + _this.privPromiseResultEvents.setError(error); + for (var _i = 0, _a = _this.privErrorHandlers; _i < _a.length; _i++) { + var errorHandler = _a[_i]; + _this.executeErrorCallback(error, errorHandler); + } + _this.detachHandlers(); + }; + this.on = function (successCallback, errorCallback) { + if (successCallback == null) { + successCallback = function (r) { return; }; + } + if (_this.privState === PromiseState.None) { + _this.privSuccessHandlers.push(successCallback); + _this.privErrorHandlers.push(errorCallback); + } + else { + if (_this.privState === PromiseState.Resolved) { + _this.executeSuccessCallback(_this.privPromiseResult.result, successCallback, errorCallback); + } + else if (_this.privState === PromiseState.Rejected) { + _this.executeErrorCallback(_this.privPromiseResult.error, errorCallback); + } + _this.detachHandlers(); + } + }; + this.executeSuccessCallback = function (result, successCallback, errorCallback) { + try { + successCallback(result); + } + catch (e) { + _this.executeErrorCallback("'Unhandled callback error: " + e + "'", errorCallback); + } + }; + this.executeErrorCallback = function (error, errorCallback) { + if (errorCallback) { + try { + errorCallback(error); + } + catch (e) { + throw new Error("'Unhandled callback error: " + e + ". InnerError: " + error + "'"); + } + } + else { + throw new Error("'Unhandled error: " + error + "'"); + } + }; + this.detachHandlers = function () { + _this.privErrorHandlers = []; + _this.privSuccessHandlers = []; + }; + this.privPromiseResultEvents = new PromiseResultEventSource(); + this.privPromiseResult = new PromiseResult(this.privPromiseResultEvents); + } + Object.defineProperty(Sink.prototype, "state", { + get: function () { + return this.privState; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Sink.prototype, "result", { + get: function () { + return this.privPromiseResult; + }, + enumerable: true, + configurable: true + }); + return Sink; +}()); +exports.Sink = Sink; + + + +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Error_1 = __webpack_require__(10); +var List_1 = __webpack_require__(15); +var Promise_1 = __webpack_require__(16); +var SubscriberType; +(function (SubscriberType) { + SubscriberType[SubscriberType["Dequeue"] = 0] = "Dequeue"; + SubscriberType[SubscriberType["Peek"] = 1] = "Peek"; +})(SubscriberType || (SubscriberType = {})); +var Queue = /** @class */ (function () { + function Queue(list) { + var _this = this; + this.privPromiseStore = new List_1.List(); + this.privIsDrainInProgress = false; + this.privIsDisposing = false; + this.privDisposeReason = null; + this.enqueue = function (item) { + _this.throwIfDispose(); + _this.enqueueFromPromise(Promise_1.PromiseHelper.fromResult(item)); + }; + this.enqueueFromPromise = function (promise) { + _this.throwIfDispose(); + _this.privPromiseStore.add(promise); + promise.finally(function () { + while (_this.privPromiseStore.length() > 0) { + if (!_this.privPromiseStore.first().result().isCompleted) { + break; + } + else { + var p = _this.privPromiseStore.removeFirst(); + if (!p.result().isError) { + _this.privList.add(p.result().result); + } + else { + // TODO: Log as warning. + } + } + } + }); + }; + this.dequeue = function () { + _this.throwIfDispose(); + var deferredSubscriber = new Promise_1.Deferred(); + if (_this.privSubscribers) { + _this.privSubscribers.add({ deferral: deferredSubscriber, type: SubscriberType.Dequeue }); + _this.drain(); + } + return deferredSubscriber.promise(); + }; + this.peek = function () { + _this.throwIfDispose(); + var deferredSubscriber = new Promise_1.Deferred(); + var subs = _this.privSubscribers; + if (subs) { + _this.privSubscribers.add({ deferral: deferredSubscriber, type: SubscriberType.Peek }); + _this.drain(); + } + return deferredSubscriber.promise(); + }; + this.length = function () { + _this.throwIfDispose(); + return _this.privList.length(); + }; + this.isDisposed = function () { + return _this.privSubscribers == null; + }; + this.drainAndDispose = function (pendingItemProcessor, reason) { + if (!_this.isDisposed() && !_this.privIsDisposing) { + _this.privDisposeReason = reason; + _this.privIsDisposing = true; + var subs = _this.privSubscribers; + if (subs) { + while (subs.length() > 0) { + var subscriber = subs.removeFirst(); + // TODO: this needs work (Resolve(null) instead?). + subscriber.deferral.resolve(undefined); + // subscriber.deferral.reject("Disposed"); + } + // note: this block assumes cooperative multitasking, i.e., + // between the if-statement and the assignment there are no + // thread switches. + // Reason is that between the initial const = this.; and this + // point there is the derral.resolve() operation that might have + // caused recursive calls to the Queue, especially, calling + // Dispose() on the queue alredy (which would reset the var + // here to null!). + // That should generally hold true for javascript... + if (_this.privSubscribers === subs) { + _this.privSubscribers = subs; + } + } + for (var _i = 0, _a = _this.privDetachables; _i < _a.length; _i++) { + var detachable = _a[_i]; + detachable.detach(); + } + if (_this.privPromiseStore.length() > 0 && pendingItemProcessor) { + return Promise_1.PromiseHelper + .whenAll(_this.privPromiseStore.toArray()) + .continueWith(function () { + _this.privSubscribers = null; + _this.privList.forEach(function (item, index) { + pendingItemProcessor(item); + }); + _this.privList = null; + return true; + }); + } + else { + _this.privSubscribers = null; + _this.privList = null; + } + } + return Promise_1.PromiseHelper.fromResult(true); + }; + this.dispose = function (reason) { + _this.drainAndDispose(null, reason); + }; + this.drain = function () { + if (!_this.privIsDrainInProgress && !_this.privIsDisposing) { + _this.privIsDrainInProgress = true; + var subs = _this.privSubscribers; + var lists = _this.privList; + if (subs && lists) { + while (lists.length() > 0 && subs.length() > 0 && !_this.privIsDisposing) { + var subscriber = subs.removeFirst(); + if (subscriber.type === SubscriberType.Peek) { + subscriber.deferral.resolve(lists.first()); + } + else { + var dequeuedItem = lists.removeFirst(); + subscriber.deferral.resolve(dequeuedItem); + } + } + // note: this block assumes cooperative multitasking, i.e., + // between the if-statement and the assignment there are no + // thread switches. + // Reason is that between the initial const = this.; and this + // point there is the derral.resolve() operation that might have + // caused recursive calls to the Queue, especially, calling + // Dispose() on the queue alredy (which would reset the var + // here to null!). + // That should generally hold true for javascript... + if (_this.privSubscribers === subs) { + _this.privSubscribers = subs; + } + // note: this block assumes cooperative multitasking, i.e., + // between the if-statement and the assignment there are no + // thread switches. + // Reason is that between the initial const = this.; and this + // point there is the derral.resolve() operation that might have + // caused recursive calls to the Queue, especially, calling + // Dispose() on the queue alredy (which would reset the var + // here to null!). + // That should generally hold true for javascript... + if (_this.privList === lists) { + _this.privList = lists; + } + } + _this.privIsDrainInProgress = false; + } + }; + this.throwIfDispose = function () { + if (_this.isDisposed()) { + if (_this.privDisposeReason) { + throw new Error_1.InvalidOperationError(_this.privDisposeReason); + } + throw new Error_1.ObjectDisposedError("Queue"); + } + else if (_this.privIsDisposing) { + throw new Error_1.InvalidOperationError("Queue disposing"); + } + }; + this.privList = list ? list : new List_1.List(); + this.privDetachables = []; + this.privSubscribers = new List_1.List(); + this.privDetachables.push(this.privList.onAdded(this.drain)); + } + return Queue; +}()); +exports.Queue = Queue; + + + +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var ConnectionMessage_1 = __webpack_require__(9); +var Error_1 = __webpack_require__(10); +var Guid_1 = __webpack_require__(7); +var RawWebsocketMessage = /** @class */ (function () { + function RawWebsocketMessage(messageType, payload, id) { + this.privPayload = null; + if (!payload) { + throw new Error_1.ArgumentNullError("payload"); + } + if (messageType === ConnectionMessage_1.MessageType.Binary && !(payload instanceof ArrayBuffer)) { + throw new Error_1.InvalidOperationError("Payload must be ArrayBuffer"); + } + if (messageType === ConnectionMessage_1.MessageType.Text && !(typeof (payload) === "string")) { + throw new Error_1.InvalidOperationError("Payload must be a string"); + } + this.privMessageType = messageType; + this.privPayload = payload; + this.privId = id ? id : Guid_1.createNoDashGuid(); + } + Object.defineProperty(RawWebsocketMessage.prototype, "messageType", { + get: function () { + return this.privMessageType; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RawWebsocketMessage.prototype, "payload", { + get: function () { + return this.privPayload; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RawWebsocketMessage.prototype, "textContent", { + get: function () { + if (this.privMessageType === ConnectionMessage_1.MessageType.Binary) { + throw new Error_1.InvalidOperationError("Not supported for binary message"); + } + return this.privPayload; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RawWebsocketMessage.prototype, "binaryContent", { + get: function () { + if (this.privMessageType === ConnectionMessage_1.MessageType.Text) { + throw new Error_1.InvalidOperationError("Not supported for text message"); + } + return this.privPayload; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RawWebsocketMessage.prototype, "id", { + get: function () { + return this.privId; + }, + enumerable: true, + configurable: true + }); + return RawWebsocketMessage; +}()); +exports.RawWebsocketMessage = RawWebsocketMessage; + + + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var RiffPcmEncoder = /** @class */ (function () { + function RiffPcmEncoder(actualSampleRate, desiredSampleRate) { + var _this = this; + this.encode = function (actualAudioFrame) { + var audioFrame = _this.downSampleAudioFrame(actualAudioFrame, _this.privActualSampleRate, _this.privDesiredSampleRate); + if (!audioFrame) { + return null; + } + var audioLength = audioFrame.length * 2; + var buffer = new ArrayBuffer(audioLength); + var view = new DataView(buffer); + _this.floatTo16BitPCM(view, 0, audioFrame); + return buffer; + }; + this.setString = function (view, offset, str) { + for (var i = 0; i < str.length; i++) { + view.setUint8(offset + i, str.charCodeAt(i)); + } + }; + this.floatTo16BitPCM = function (view, offset, input) { + for (var i = 0; i < input.length; i++, offset += 2) { + var s = Math.max(-1, Math.min(1, input[i])); + view.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7FFF, true); + } + }; + this.downSampleAudioFrame = function (srcFrame, srcRate, dstRate) { + if (dstRate === srcRate || dstRate > srcRate) { + return srcFrame; + } + var ratio = srcRate / dstRate; + var dstLength = Math.round(srcFrame.length / ratio); + var dstFrame = new Float32Array(dstLength); + var srcOffset = 0; + var dstOffset = 0; + while (dstOffset < dstLength) { + var nextSrcOffset = Math.round((dstOffset + 1) * ratio); + var accum = 0; + var count = 0; + while (srcOffset < nextSrcOffset && srcOffset < srcFrame.length) { + accum += srcFrame[srcOffset++]; + count++; + } + dstFrame[dstOffset++] = accum / count; + } + return dstFrame; + }; + this.privActualSampleRate = actualSampleRate; + this.privDesiredSampleRate = desiredSampleRate; + } + return RiffPcmEncoder; +}()); +exports.RiffPcmEncoder = RiffPcmEncoder; + + + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Error_1 = __webpack_require__(10); +var Guid_1 = __webpack_require__(7); +var Queue_1 = __webpack_require__(17); +var Stream = /** @class */ (function () { + function Stream(streamId) { + var _this = this; + this.privIsWriteEnded = false; + this.privIsReadEnded = false; + this.read = function () { + if (_this.privIsReadEnded) { + throw new Error_1.InvalidOperationError("Stream read has already finished"); + } + return _this.privReaderQueue + .dequeue() + .onSuccessContinueWith(function (streamChunk) { + if (streamChunk === undefined || streamChunk.isEnd) { + _this.privReaderQueue.dispose("End of stream reached"); + } + return streamChunk; + }); + }; + this.readEnded = function () { + if (!_this.privIsReadEnded) { + _this.privIsReadEnded = true; + _this.privReaderQueue = new Queue_1.Queue(); + } + }; + this.throwIfClosed = function () { + if (_this.privIsWriteEnded) { + throw new Error_1.InvalidOperationError("Stream closed"); + } + }; + this.privId = streamId ? streamId : Guid_1.createNoDashGuid(); + this.privReaderQueue = new Queue_1.Queue(); + } + Object.defineProperty(Stream.prototype, "isClosed", { + get: function () { + return this.privIsWriteEnded; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Stream.prototype, "isReadEnded", { + get: function () { + return this.privIsReadEnded; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Stream.prototype, "id", { + get: function () { + return this.privId; + }, + enumerable: true, + configurable: true + }); + Stream.prototype.close = function () { + if (!this.privIsWriteEnded) { + this.writeStreamChunk({ + buffer: null, + isEnd: true, + timeReceived: Date.now(), + }); + this.privIsWriteEnded = true; + } + }; + Stream.prototype.writeStreamChunk = function (streamChunk) { + this.throwIfClosed(); + if (!this.privReaderQueue.isDisposed()) { + try { + this.privReaderQueue.enqueue(streamChunk); + } + catch (e) { + // Do nothing + } + } + }; + return Stream; +}()); +exports.Stream = Stream; + + + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Defines translation status. + * @class TranslationStatus + */ +var TranslationStatus; +(function (TranslationStatus) { + /** + * @member TranslationStatus.Success + */ + TranslationStatus[TranslationStatus["Success"] = 0] = "Success"; + /** + * @member TranslationStatus.Error + */ + TranslationStatus[TranslationStatus["Error"] = 1] = "Error"; +})(TranslationStatus = exports.TranslationStatus || (exports.TranslationStatus = {})); + + + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(4); +var ChunkedArrayBufferStream = /** @class */ (function (_super) { + __extends(ChunkedArrayBufferStream, _super); + function ChunkedArrayBufferStream(targetChunkSize, streamId) { + var _this = _super.call(this, streamId) || this; + _this.privTargetChunkSize = targetChunkSize; + _this.privNextBufferReadyBytes = 0; + return _this; + } + ChunkedArrayBufferStream.prototype.writeStreamChunk = function (chunk) { + // No pending write, and the buffer is the right size so write it. + if (chunk.isEnd || + (0 === this.privNextBufferReadyBytes && chunk.buffer.byteLength === this.privTargetChunkSize)) { + _super.prototype.writeStreamChunk.call(this, chunk); + return; + } + var bytesCopiedFromBuffer = 0; + while (bytesCopiedFromBuffer < chunk.buffer.byteLength) { + // Fill the next buffer. + if (undefined === this.privNextBufferToWrite) { + this.privNextBufferToWrite = new ArrayBuffer(this.privTargetChunkSize); + this.privNextBufferStartTime = chunk.timeReceived; + } + // Find out how many bytes we can copy into the read buffer. + var bytesToCopy = Math.min(chunk.buffer.byteLength - bytesCopiedFromBuffer, this.privTargetChunkSize - this.privNextBufferReadyBytes); + var targetView = new Uint8Array(this.privNextBufferToWrite); + var sourceView = new Uint8Array(chunk.buffer.slice(bytesCopiedFromBuffer, bytesToCopy + bytesCopiedFromBuffer)); + targetView.set(sourceView, this.privNextBufferReadyBytes); + this.privNextBufferReadyBytes += bytesToCopy; + bytesCopiedFromBuffer += bytesToCopy; + // Are we ready to write? + if (this.privNextBufferReadyBytes === this.privTargetChunkSize) { + _super.prototype.writeStreamChunk.call(this, { + buffer: this.privNextBufferToWrite, + isEnd: false, + timeReceived: this.privNextBufferStartTime, + }); + this.privNextBufferReadyBytes = 0; + this.privNextBufferToWrite = undefined; + } + } + }; + ChunkedArrayBufferStream.prototype.close = function () { + // Send whatever is pending, then close the base class. + if (0 !== this.privNextBufferReadyBytes && !this.isClosed) { + _super.prototype.writeStreamChunk.call(this, { + buffer: this.privNextBufferToWrite.slice(0, this.privNextBufferReadyBytes), + isEnd: false, + timeReceived: this.privNextBufferStartTime, + }); + } + _super.prototype.close.call(this); + }; + return ChunkedArrayBufferStream; +}(Exports_1.Stream)); +exports.ChunkedArrayBufferStream = ChunkedArrayBufferStream; + + + +/***/ }), +/* 23 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Timeout = /** @class */ (function () { + function Timeout() { + } + Timeout.workerTimers = null; + Timeout.clearTimeout = function (timerId) { return Timeout.timers().clearTimeout(timerId); }; + Timeout.setTimeout = function (func, delay) { return Timeout.timers().setTimeout(func, delay); }; + Timeout.load = function (url) { + // Prefilling the Maps with a function indexed by zero is necessary to be compliant with the specification. + var scheduledTimeoutFunctions = new Map([[0, function () { }]]); // tslint:disable-line no-empty + var unhandledRequests = new Map(); + var worker = new Worker(url); + worker.addEventListener("message", function (_a) { + var data = _a.data; + if (Timeout.isCallNotification(data)) { + var timerId = data.params.timerId; + var idOrFunc = scheduledTimeoutFunctions.get(timerId); + if (typeof idOrFunc === "number") { + var unhandledTimerId = unhandledRequests.get(idOrFunc); + if (unhandledTimerId === undefined || + unhandledTimerId !== timerId) { + throw new Error("The timer is in an undefined state."); + } + } + else if (typeof idOrFunc !== "undefined") { + idOrFunc(); + // A timeout can be safely deleted because it is only called once. + scheduledTimeoutFunctions.delete(timerId); + } + else { + throw new Error("The timer is in an undefined state."); + } + } + else if (Timeout.isClearResponse(data)) { + var id = data.id; + var unhandledTimerId = unhandledRequests.get(id); + if (unhandledTimerId === undefined) { + throw new Error("The timer is in an undefined state."); + } + unhandledRequests.delete(id); + scheduledTimeoutFunctions.delete(unhandledTimerId); + } + else { + var message = data.error.message; + throw new Error(message); + } + }); + var clearTimeout = function (timerId) { + var id = Math.random(); + unhandledRequests.set(id, timerId); + scheduledTimeoutFunctions.set(timerId, id); + worker.postMessage({ + id: id, + method: "clear", + params: { timerId: timerId } + }); + }; + var setTimeout = function (func, delay) { + var timerId = Math.random(); + scheduledTimeoutFunctions.set(timerId, func); + worker.postMessage({ + id: null, + method: "set", + params: { + delay: delay, + now: performance.now(), + timerId: timerId + } + }); + return timerId; + }; + return { + clearTimeout: clearTimeout, + setTimeout: setTimeout + }; + }; + Timeout.loadWorkerTimers = function () { + var worker = "!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&\"object\"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,\"default\",{enumerable:!0,value:e}),2&t&&\"string\"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,\"a\",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=\"\",n(n.s=14)}([function(e,t,n){\"use strict\";n.d(t,\"a\",(function(){return i})),n.d(t,\"b\",(function(){return u})),n.d(t,\"c\",(function(){return a})),n.d(t,\"d\",(function(){return d}));const r=new Map,o=new Map,i=e=>{const t=r.get(e);if(void 0===t)throw new Error('There is no interval scheduled with the given id \"'.concat(e,'\".'));clearTimeout(t),r.delete(e)},u=e=>{const t=o.get(e);if(void 0===t)throw new Error('There is no timeout scheduled with the given id \"'.concat(e,'\".'));clearTimeout(t),o.delete(e)},f=(e,t)=>{let n,r;if(\"performance\"in self){const o=performance.now();n=o,r=e-Math.max(0,o-t)}else n=Date.now(),r=e;return{expected:n+r,remainingDelay:r}},c=(e,t,n,r)=>{const o=\"performance\"in self?performance.now():Date.now();o>n?postMessage({id:null,method:\"call\",params:{timerId:t}}):e.set(t,setTimeout(c,n-o,e,t,n))},a=(e,t,n)=>{const{expected:o,remainingDelay:i}=f(e,n);r.set(t,setTimeout(c,i,r,t,o))},d=(e,t,n)=>{const{expected:r,remainingDelay:i}=f(e,n);o.set(t,setTimeout(c,i,o,t,r))}},function(e,t,n){\"use strict\";n.r(t);var r=n(2);for(var o in r)\"default\"!==o&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(3);for(var o in i)\"default\"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var u=n(4);for(var o in u)\"default\"!==o&&function(e){n.d(t,e,(function(){return u[e]}))}(o);var f=n(5);for(var o in f)\"default\"!==o&&function(e){n.d(t,e,(function(){return f[e]}))}(o);var c=n(6);for(var o in c)\"default\"!==o&&function(e){n.d(t,e,(function(){return c[e]}))}(o);var a=n(7);for(var o in a)\"default\"!==o&&function(e){n.d(t,e,(function(){return a[e]}))}(o);var d=n(8);for(var o in d)\"default\"!==o&&function(e){n.d(t,e,(function(){return d[e]}))}(o);var s=n(9);for(var o in s)\"default\"!==o&&function(e){n.d(t,e,(function(){return s[e]}))}(o)},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){\"use strict\";n.r(t);var r=n(11);for(var o in r)\"default\"!==o&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(12);for(var o in i)\"default\"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var u=n(13);for(var o in u)\"default\"!==o&&function(e){n.d(t,e,(function(){return u[e]}))}(o)},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){\"use strict\";n.r(t);var r=n(0),o=n(1);for(var i in o)\"default\"!==i&&function(e){n.d(t,e,(function(){return o[e]}))}(i);var u=n(10);for(var i in u)\"default\"!==i&&function(e){n.d(t,e,(function(){return u[e]}))}(i);addEventListener(\"message\",({data:e})=>{try{if(\"clear\"===e.method){const{id:t,params:{timerId:n}}=e;Object(r.b)(n),postMessage({error:null,id:t})}else{if(\"set\"!==e.method)throw new Error('The given method \"'.concat(e.method,'\" is not supported'));{const{params:{delay:t,now:n,timerId:o}}=e;Object(r.d)(t,o,n)}}}catch(t){postMessage({error:{message:t.message},id:e.id,result:null})}})}]);"; // tslint:disable-line:max-line-length + return function () { + if (Timeout.workerTimers !== null) { + return Timeout.workerTimers; + } + var blob = new Blob([worker], { type: "application/javascript; charset=utf-8" }); + var url = URL.createObjectURL(blob); + Timeout.workerTimers = Timeout.load(url); + // Edge doesn't like the URL to be revoked directly. + Timeout.workerTimers.setTimeout(function () { return URL.revokeObjectURL(url); }, 0); + return Timeout.workerTimers; + }; + }; + Timeout.timers = Timeout.loadWorkerTimers(); + Timeout.isCallNotification = function (message) { + return message.method !== undefined && message.method === "call"; + }; + Timeout.isClearResponse = function (message) { + return message.error === null && typeof message.id === "number"; + }; + return Timeout; +}()); +exports.Timeout = Timeout; + + + +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 PlatformEvent_1 = __webpack_require__(6); +var OCSPEvent = /** @class */ (function (_super) { + __extends(OCSPEvent, _super); + function OCSPEvent(eventName, eventType, signature) { + var _this = _super.call(this, eventName, eventType) || this; + _this.privSignature = signature; + return _this; + } + return OCSPEvent; +}(PlatformEvent_1.PlatformEvent)); +exports.OCSPEvent = OCSPEvent; +// tslint:disable-next-line:max-classes-per-file +var OCSPMemoryCacheHitEvent = /** @class */ (function (_super) { + __extends(OCSPMemoryCacheHitEvent, _super); + function OCSPMemoryCacheHitEvent(signature) { + return _super.call(this, "OCSPMemoryCacheHitEvent", PlatformEvent_1.EventType.Debug, signature) || this; + } + return OCSPMemoryCacheHitEvent; +}(OCSPEvent)); +exports.OCSPMemoryCacheHitEvent = OCSPMemoryCacheHitEvent; +// tslint:disable-next-line:max-classes-per-file +var OCSPCacheMissEvent = /** @class */ (function (_super) { + __extends(OCSPCacheMissEvent, _super); + function OCSPCacheMissEvent(signature) { + return _super.call(this, "OCSPCacheMissEvent", PlatformEvent_1.EventType.Debug, signature) || this; + } + return OCSPCacheMissEvent; +}(OCSPEvent)); +exports.OCSPCacheMissEvent = OCSPCacheMissEvent; +// tslint:disable-next-line:max-classes-per-file +var OCSPDiskCacheHitEvent = /** @class */ (function (_super) { + __extends(OCSPDiskCacheHitEvent, _super); + function OCSPDiskCacheHitEvent(signature) { + return _super.call(this, "OCSPDiskCacheHitEvent", PlatformEvent_1.EventType.Debug, signature) || this; + } + return OCSPDiskCacheHitEvent; +}(OCSPEvent)); +exports.OCSPDiskCacheHitEvent = OCSPDiskCacheHitEvent; +// tslint:disable-next-line:max-classes-per-file +var OCSPCacheUpdateNeededEvent = /** @class */ (function (_super) { + __extends(OCSPCacheUpdateNeededEvent, _super); + function OCSPCacheUpdateNeededEvent(signature) { + return _super.call(this, "OCSPCacheUpdateNeededEvent", PlatformEvent_1.EventType.Debug, signature) || this; + } + return OCSPCacheUpdateNeededEvent; +}(OCSPEvent)); +exports.OCSPCacheUpdateNeededEvent = OCSPCacheUpdateNeededEvent; +// tslint:disable-next-line:max-classes-per-file +var OCSPMemoryCacheStoreEvent = /** @class */ (function (_super) { + __extends(OCSPMemoryCacheStoreEvent, _super); + function OCSPMemoryCacheStoreEvent(signature) { + return _super.call(this, "OCSPMemoryCacheStoreEvent", PlatformEvent_1.EventType.Debug, signature) || this; + } + return OCSPMemoryCacheStoreEvent; +}(OCSPEvent)); +exports.OCSPMemoryCacheStoreEvent = OCSPMemoryCacheStoreEvent; +// tslint:disable-next-line:max-classes-per-file +var OCSPDiskCacheStoreEvent = /** @class */ (function (_super) { + __extends(OCSPDiskCacheStoreEvent, _super); + function OCSPDiskCacheStoreEvent(signature) { + return _super.call(this, "OCSPDiskCacheStoreEvent", PlatformEvent_1.EventType.Debug, signature) || this; + } + return OCSPDiskCacheStoreEvent; +}(OCSPEvent)); +exports.OCSPDiskCacheStoreEvent = OCSPDiskCacheStoreEvent; +// tslint:disable-next-line:max-classes-per-file +var OCSPCacheUpdatehCompleteEvent = /** @class */ (function (_super) { + __extends(OCSPCacheUpdatehCompleteEvent, _super); + function OCSPCacheUpdatehCompleteEvent(signature) { + return _super.call(this, "OCSPCacheUpdatehCompleteEvent", PlatformEvent_1.EventType.Debug, signature) || this; + } + return OCSPCacheUpdatehCompleteEvent; +}(OCSPEvent)); +exports.OCSPCacheUpdatehCompleteEvent = OCSPCacheUpdatehCompleteEvent; +// tslint:disable-next-line:max-classes-per-file +var OCSPStapleReceivedEvent = /** @class */ (function (_super) { + __extends(OCSPStapleReceivedEvent, _super); + function OCSPStapleReceivedEvent() { + return _super.call(this, "OCSPStapleReceivedEvent", PlatformEvent_1.EventType.Debug, "") || this; + } + return OCSPStapleReceivedEvent; +}(OCSPEvent)); +exports.OCSPStapleReceivedEvent = OCSPStapleReceivedEvent; +// tslint:disable-next-line:max-classes-per-file +var OCSPWSUpgradeStartedEvent = /** @class */ (function (_super) { + __extends(OCSPWSUpgradeStartedEvent, _super); + function OCSPWSUpgradeStartedEvent(serialNumber) { + return _super.call(this, "OCSPWSUpgradeStartedEvent", PlatformEvent_1.EventType.Debug, serialNumber) || this; + } + return OCSPWSUpgradeStartedEvent; +}(OCSPEvent)); +exports.OCSPWSUpgradeStartedEvent = OCSPWSUpgradeStartedEvent; +// tslint:disable-next-line:max-classes-per-file +var OCSPCacheEntryExpiredEvent = /** @class */ (function (_super) { + __extends(OCSPCacheEntryExpiredEvent, _super); + function OCSPCacheEntryExpiredEvent(serialNumber, expireTime) { + var _this = _super.call(this, "OCSPCacheEntryExpiredEvent", PlatformEvent_1.EventType.Debug, serialNumber) || this; + _this.privExpireTime = expireTime; + return _this; + } + return OCSPCacheEntryExpiredEvent; +}(OCSPEvent)); +exports.OCSPCacheEntryExpiredEvent = OCSPCacheEntryExpiredEvent; +// tslint:disable-next-line:max-classes-per-file +var OCSPCacheEntryNeedsRefreshEvent = /** @class */ (function (_super) { + __extends(OCSPCacheEntryNeedsRefreshEvent, _super); + function OCSPCacheEntryNeedsRefreshEvent(serialNumber, startTime, expireTime) { + var _this = _super.call(this, "OCSPCacheEntryNeedsRefreshEvent", PlatformEvent_1.EventType.Debug, serialNumber) || this; + _this.privExpireTime = expireTime; + _this.privStartTime = startTime; + return _this; + } + return OCSPCacheEntryNeedsRefreshEvent; +}(OCSPEvent)); +exports.OCSPCacheEntryNeedsRefreshEvent = OCSPCacheEntryNeedsRefreshEvent; +// tslint:disable-next-line:max-classes-per-file +var OCSPCacheHitEvent = /** @class */ (function (_super) { + __extends(OCSPCacheHitEvent, _super); + function OCSPCacheHitEvent(serialNumber, startTime, expireTime) { + var _this = _super.call(this, "OCSPCacheHitEvent", PlatformEvent_1.EventType.Debug, serialNumber) || this; + _this.privExpireTime = expireTime; + _this.privExpireTimeString = new Date(expireTime).toLocaleDateString(); + _this.privStartTime = startTime; + _this.privStartTimeString = new Date(startTime).toLocaleTimeString(); + return _this; + } + return OCSPCacheHitEvent; +}(OCSPEvent)); +exports.OCSPCacheHitEvent = OCSPCacheHitEvent; +// tslint:disable-next-line:max-classes-per-file +var OCSPVerificationFailedEvent = /** @class */ (function (_super) { + __extends(OCSPVerificationFailedEvent, _super); + function OCSPVerificationFailedEvent(serialNumber, error) { + var _this = _super.call(this, "OCSPVerificationFailedEvent", PlatformEvent_1.EventType.Debug, serialNumber) || this; + _this.privError = error; + return _this; + } + return OCSPVerificationFailedEvent; +}(OCSPEvent)); +exports.OCSPVerificationFailedEvent = OCSPVerificationFailedEvent; +// tslint:disable-next-line:max-classes-per-file +var OCSPCacheFetchErrorEvent = /** @class */ (function (_super) { + __extends(OCSPCacheFetchErrorEvent, _super); + function OCSPCacheFetchErrorEvent(serialNumber, error) { + var _this = _super.call(this, "OCSPCacheFetchErrorEvent", PlatformEvent_1.EventType.Debug, serialNumber) || this; + _this.privError = error; + return _this; + } + return OCSPCacheFetchErrorEvent; +}(OCSPEvent)); +exports.OCSPCacheFetchErrorEvent = OCSPCacheFetchErrorEvent; +// tslint:disable-next-line:max-classes-per-file +var OCSPResponseRetrievedEvent = /** @class */ (function (_super) { + __extends(OCSPResponseRetrievedEvent, _super); + function OCSPResponseRetrievedEvent(serialNumber) { + return _super.call(this, "OCSPResponseRetrievedEvent", PlatformEvent_1.EventType.Debug, serialNumber) || this; + } + return OCSPResponseRetrievedEvent; +}(OCSPEvent)); +exports.OCSPResponseRetrievedEvent = OCSPResponseRetrievedEvent; +// tslint:disable-next-line:max-classes-per-file +var OCSPCacheUpdateErrorEvent = /** @class */ (function (_super) { + __extends(OCSPCacheUpdateErrorEvent, _super); + function OCSPCacheUpdateErrorEvent(serialNumber, error) { + var _this = _super.call(this, "OCSPCacheUpdateErrorEvent", PlatformEvent_1.EventType.Debug, serialNumber) || this; + _this.privError = error; + return _this; + } + return OCSPCacheUpdateErrorEvent; +}(OCSPEvent)); +exports.OCSPCacheUpdateErrorEvent = OCSPCacheUpdateErrorEvent; + + + +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var Exports_2 = __webpack_require__(4); +var AudioStreamFormat_1 = __webpack_require__(42); +exports.AudioWorkletSourceURLPropertyName = "MICROPHONE-WorkletSourceUrl"; +var MicAudioSource = /** @class */ (function () { + function MicAudioSource(privRecorder, deviceId, audioSourceId) { + var _this = this; + this.privRecorder = privRecorder; + this.deviceId = deviceId; + this.privStreams = {}; + this.turnOn = function () { + if (_this.privInitializeDeferral) { + return _this.privInitializeDeferral.promise(); + } + _this.privInitializeDeferral = new Exports_2.Deferred(); + try { + _this.createAudioContext(); + } + catch (error) { + if (error instanceof Error) { + var typedError = error; + _this.privInitializeDeferral.reject(typedError.name + ": " + typedError.message); + } + else { + _this.privInitializeDeferral.reject(error); + } + return _this.privInitializeDeferral.promise(); + } + var nav = window.navigator; + var getUserMedia = (nav.getUserMedia || + nav.webkitGetUserMedia || + nav.mozGetUserMedia || + nav.msGetUserMedia); + if (!!nav.mediaDevices) { + getUserMedia = function (constraints, successCallback, errorCallback) { + nav.mediaDevices + .getUserMedia(constraints) + .then(successCallback) + .catch(errorCallback); + }; + } + if (!getUserMedia) { + var errorMsg = "Browser does not support getUserMedia."; + _this.privInitializeDeferral.reject(errorMsg); + _this.onEvent(new Exports_2.AudioSourceErrorEvent(errorMsg, "")); // mic initialized error - no streamid at this point + } + else { + var next = function () { + _this.onEvent(new Exports_2.AudioSourceInitializingEvent(_this.privId)); // no stream id + getUserMedia({ audio: _this.deviceId ? { deviceId: _this.deviceId } : true, video: false }, function (mediaStream) { + _this.privMediaStream = mediaStream; + _this.onEvent(new Exports_2.AudioSourceReadyEvent(_this.privId)); + _this.privInitializeDeferral.resolve(true); + }, function (error) { + var errorMsg = "Error occurred during microphone initialization: " + error; + var tmp = _this.privInitializeDeferral; + // HACK: this should be handled through onError callbacks of all promises up the stack. + // Unfortunately, the current implementation does not provide an easy way to reject promises + // without a lot of code replication. + // TODO: fix promise implementation, allow for a graceful reject chaining. + _this.privInitializeDeferral = null; + tmp.reject(errorMsg); // this will bubble up through the whole chain of promises, + // with each new level adding extra "Unhandled callback error" prefix to the error message. + // The following line is not guaranteed to be executed. + _this.onEvent(new Exports_2.AudioSourceErrorEvent(_this.privId, errorMsg)); + }); + }; + if (_this.privContext.state === "suspended") { + // NOTE: On iOS, the Web Audio API requires sounds to be triggered from an explicit user action. + // https://github.com/WebAudio/web-audio-api/issues/790 + _this.privContext.resume().then(next, function (reason) { + _this.privInitializeDeferral.reject("Failed to initialize audio context: " + reason); + }); + } + else { + next(); + } + } + return _this.privInitializeDeferral.promise(); + }; + this.id = function () { + return _this.privId; + }; + this.attach = function (audioNodeId) { + _this.onEvent(new Exports_2.AudioStreamNodeAttachingEvent(_this.privId, audioNodeId)); + return _this.listen(audioNodeId).onSuccessContinueWith(function (stream) { + _this.onEvent(new Exports_2.AudioStreamNodeAttachedEvent(_this.privId, audioNodeId)); + return { + detach: function () { + stream.readEnded(); + _this.turnOff(); + delete _this.privStreams[audioNodeId]; + _this.onEvent(new Exports_2.AudioStreamNodeDetachedEvent(_this.privId, audioNodeId)); + }, + id: function () { + return audioNodeId; + }, + read: function () { + return stream.read(); + }, + }; + }); + }; + this.detach = function (audioNodeId) { + if (audioNodeId && _this.privStreams[audioNodeId]) { + _this.privStreams[audioNodeId].close(); + delete _this.privStreams[audioNodeId]; + _this.onEvent(new Exports_2.AudioStreamNodeDetachedEvent(_this.privId, audioNodeId)); + } + }; + this.turnOff = function () { + for (var streamId in _this.privStreams) { + if (streamId) { + var stream = _this.privStreams[streamId]; + if (stream) { + stream.close(); + } + } + } + _this.onEvent(new Exports_2.AudioSourceOffEvent(_this.privId)); // no stream now + _this.privInitializeDeferral = null; + _this.destroyAudioContext(); + return Exports_2.PromiseHelper.fromResult(true); + }; + this.listen = function (audioNodeId) { + return _this.turnOn() + .onSuccessContinueWith(function (_) { + var stream = new Exports_2.ChunkedArrayBufferStream(_this.privOutputChunkSize, audioNodeId); + _this.privStreams[audioNodeId] = stream; + try { + _this.privRecorder.record(_this.privContext, _this.privMediaStream, stream); + } + catch (error) { + _this.onEvent(new Exports_2.AudioStreamNodeErrorEvent(_this.privId, audioNodeId, error)); + throw error; + } + return stream; + }); + }; + this.onEvent = function (event) { + _this.privEvents.onEvent(event); + Exports_2.Events.instance.onEvent(event); + }; + this.createAudioContext = function () { + if (!!_this.privContext) { + return; + } + // https://developer.mozilla.org/en-US/docs/Web/API/AudioContext + if (typeof (AudioContext) === "undefined") { + throw new Error("Browser does not support Web Audio API (AudioContext is not available)."); + } + // Browsers without sampleRate constraint support can't connect nodes with different sample rates + if (navigator.mediaDevices.getSupportedConstraints().sampleRate) { + _this.privContext = new AudioContext({ sampleRate: MicAudioSource.AUDIOFORMAT.samplesPerSec }); + } + else { + _this.privContext = new AudioContext(); + } + }; + this.destroyAudioContext = function () { + if (!_this.privContext) { + return; + } + _this.privRecorder.releaseMediaResources(_this.privContext); + // This pattern brought to you by a bug in the TypeScript compiler where it + // confuses the ("close" in this.privContext) with this.privContext always being null as the alternate. + // https://github.com/Microsoft/TypeScript/issues/11498 + var hasClose = false; + if ("close" in _this.privContext) { + hasClose = true; + } + if (hasClose) { + _this.privContext.close(); + _this.privContext = null; + } + else if (null !== _this.privContext && _this.privContext.state === "running") { + // Suspend actually takes a callback, but analogous to the + // resume method, it'll be only fired if suspend is called + // in a direct response to a user action. The later is not always + // the case, as TurnOff is also called, when we receive an + // end-of-speech message from the service. So, doing a best effort + // fire-and-forget here. + _this.privContext.suspend(); + } + }; + this.privOutputChunkSize = MicAudioSource.AUDIOFORMAT.avgBytesPerSec / 10; + this.privId = audioSourceId ? audioSourceId : Exports_2.createNoDashGuid(); + this.privEvents = new Exports_2.EventSource(); + } + Object.defineProperty(MicAudioSource.prototype, "format", { + get: function () { + return Exports_2.PromiseHelper.fromResult(MicAudioSource.AUDIOFORMAT); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(MicAudioSource.prototype, "blob", { + get: function () { + return Exports_2.PromiseHelper.fromError("Not implemented for Mic input"); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(MicAudioSource.prototype, "events", { + get: function () { + return this.privEvents; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(MicAudioSource.prototype, "deviceInfo", { + get: function () { + return this.getMicrophoneLabel().onSuccessContinueWith(function (label) { + return { + bitspersample: MicAudioSource.AUDIOFORMAT.bitsPerSample, + channelcount: MicAudioSource.AUDIOFORMAT.channels, + connectivity: Exports_1.connectivity.Unknown, + manufacturer: "Speech SDK", + model: label, + samplerate: MicAudioSource.AUDIOFORMAT.samplesPerSec, + type: Exports_1.type.Microphones, + }; + }); + }, + enumerable: true, + configurable: true + }); + MicAudioSource.prototype.setProperty = function (name, value) { + if (name === exports.AudioWorkletSourceURLPropertyName) { + this.privRecorder.setWorkletUrl(value); + } + else { + throw new Error("Property '" + name + "' is not supported on Microphone."); + } + }; + MicAudioSource.prototype.getMicrophoneLabel = function () { + var _this = this; + var defaultMicrophoneName = "microphone"; + // If we did this already, return the value. + if (this.privMicrophoneLabel !== undefined) { + return Exports_2.PromiseHelper.fromResult(this.privMicrophoneLabel); + } + // If the stream isn't currently running, we can't query devices because security. + if (this.privMediaStream === undefined || !this.privMediaStream.active) { + return Exports_2.PromiseHelper.fromResult(defaultMicrophoneName); + } + // Setup a default + this.privMicrophoneLabel = defaultMicrophoneName; + // Get the id of the device running the audio track. + var microphoneDeviceId = this.privMediaStream.getTracks()[0].getSettings().deviceId; + // If the browser doesn't support getting the device ID, set a default and return. + if (undefined === microphoneDeviceId) { + return Exports_2.PromiseHelper.fromResult(this.privMicrophoneLabel); + } + var deferred = new Exports_2.Deferred(); + // Enumerate the media devices. + navigator.mediaDevices.enumerateDevices().then(function (devices) { + for (var _i = 0, devices_1 = devices; _i < devices_1.length; _i++) { + var device = devices_1[_i]; + if (device.deviceId === microphoneDeviceId) { + // Found the device + _this.privMicrophoneLabel = device.label; + break; + } + } + deferred.resolve(_this.privMicrophoneLabel); + }, function () { return deferred.resolve(_this.privMicrophoneLabel); }); + return deferred.promise(); + }; + MicAudioSource.AUDIOFORMAT = AudioStreamFormat_1.AudioStreamFormat.getDefaultInputFormat(); + return MicAudioSource; +}()); +exports.MicAudioSource = MicAudioSource; + + + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +// Make sure not to export internal modules. +// +__export(__webpack_require__(27)); +__export(__webpack_require__(29)); +__export(__webpack_require__(28)); +__export(__webpack_require__(30)); +__export(__webpack_require__(126)); +__export(__webpack_require__(127)); +__export(__webpack_require__(129)); +__export(__webpack_require__(130)); +__export(__webpack_require__(71)); +__export(__webpack_require__(131)); +__export(__webpack_require__(132)); +__export(__webpack_require__(133)); +__export(__webpack_require__(134)); +__export(__webpack_require__(135)); +__export(__webpack_require__(136)); +__export(__webpack_require__(137)); +__export(__webpack_require__(138)); +__export(__webpack_require__(139)); +__export(__webpack_require__(140)); +__export(__webpack_require__(141)); +__export(__webpack_require__(142)); +__export(__webpack_require__(143)); +__export(__webpack_require__(144)); +__export(__webpack_require__(145)); +__export(__webpack_require__(146)); +__export(__webpack_require__(147)); +__export(__webpack_require__(149)); +__export(__webpack_require__(150)); +__export(__webpack_require__(151)); +__export(__webpack_require__(155)); +__export(__webpack_require__(156)); +__export(__webpack_require__(173)); +__export(__webpack_require__(174)); +__export(__webpack_require__(175)); +__export(__webpack_require__(177)); +__export(__webpack_require__(178)); +__export(__webpack_require__(179)); +__export(__webpack_require__(180)); +exports.OutputFormatPropertyName = "OutputFormat"; +exports.CancellationErrorCodePropertyName = "CancellationErrorCode"; +exports.ServicePropertiesPropertyName = "ServiceProperties"; +exports.ForceDictationPropertyName = "ForceDication"; +exports.AutoDetectSourceLanguagesOpenRangeOptionName = "OpenRange"; + + + +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(4); +var IAuthentication_1 = __webpack_require__(28); +var AuthHeader = "Ocp-Apim-Subscription-Key"; +/** + * @class + */ +var CognitiveSubscriptionKeyAuthentication = /** @class */ (function () { + /** + * Creates and initializes an instance of the CognitiveSubscriptionKeyAuthentication class. + * @constructor + * @param {string} subscriptionKey - The subscription key + */ + function CognitiveSubscriptionKeyAuthentication(subscriptionKey) { + var _this = this; + /** + * Fetches the subscription key. + * @member + * @function + * @public + * @param {string} authFetchEventId - The id to fetch. + */ + this.fetch = function (authFetchEventId) { + return Exports_1.PromiseHelper.fromResult(_this.privAuthInfo); + }; + /** + * Fetches the subscription key. + * @member + * @function + * @public + * @param {string} authFetchEventId - The id to fetch. + */ + this.fetchOnExpiry = function (authFetchEventId) { + return Exports_1.PromiseHelper.fromResult(_this.privAuthInfo); + }; + if (!subscriptionKey) { + throw new Exports_1.ArgumentNullError("subscriptionKey"); + } + this.privAuthInfo = new IAuthentication_1.AuthInfo(AuthHeader, subscriptionKey); + } + return CognitiveSubscriptionKeyAuthentication; +}()); +exports.CognitiveSubscriptionKeyAuthentication = CognitiveSubscriptionKeyAuthentication; + + + +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var AuthInfo = /** @class */ (function () { + function AuthInfo(headerName, token) { + this.privHeaderName = headerName; + this.privToken = token; + } + Object.defineProperty(AuthInfo.prototype, "headerName", { + get: function () { + return this.privHeaderName; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AuthInfo.prototype, "token", { + get: function () { + return this.privToken; + }, + enumerable: true, + configurable: true + }); + return AuthInfo; +}()); +exports.AuthInfo = AuthInfo; + + + +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(4); +var IAuthentication_1 = __webpack_require__(28); +var AuthHeader = "Authorization"; +var CognitiveTokenAuthentication = /** @class */ (function () { + function CognitiveTokenAuthentication(fetchCallback, fetchOnExpiryCallback) { + var _this = this; + this.fetch = function (authFetchEventId) { + return _this.privFetchCallback(authFetchEventId).onSuccessContinueWith(function (token) { return new IAuthentication_1.AuthInfo(AuthHeader, token); }); + }; + this.fetchOnExpiry = function (authFetchEventId) { + return _this.privFetchOnExpiryCallback(authFetchEventId).onSuccessContinueWith(function (token) { return new IAuthentication_1.AuthInfo(AuthHeader, token); }); + }; + if (!fetchCallback) { + throw new Exports_1.ArgumentNullError("fetchCallback"); + } + if (!fetchOnExpiryCallback) { + throw new Exports_1.ArgumentNullError("fetchOnExpiryCallback"); + } + this.privFetchCallback = fetchCallback; + this.privFetchOnExpiryCallback = fetchOnExpiryCallback; + } + return CognitiveTokenAuthentication; +}()); +exports.CognitiveTokenAuthentication = CognitiveTokenAuthentication; + + + +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(2); +var Exports_2 = __webpack_require__(31); +var ConnectionFactoryBase_1 = __webpack_require__(72); +var Exports_3 = __webpack_require__(26); +var TestHooksParamName = "testhooks"; +var ConnectionIdHeader = "X-ConnectionId"; +var IntentConnectionFactory = /** @class */ (function (_super) { + __extends(IntentConnectionFactory, _super); + function IntentConnectionFactory() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.create = function (config, authInfo, connectionId) { + var endpoint = config.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_Endpoint); + if (!endpoint) { + var region = config.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_IntentRegion); + var hostSuffix = (region && region.toLowerCase().startsWith("china")) ? ".azure.cn" : ".microsoft.com"; + var host = config.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_Host, "wss://" + region + ".sr.speech" + hostSuffix); + endpoint = host + "/speech/recognition/interactive/cognitiveservices/v1"; + } + var queryParams = { + format: "simple", + language: config.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage), + }; + _this.setCommonUrlParams(config, queryParams, endpoint); + var headers = {}; + if (authInfo.token !== undefined && authInfo.token !== "") { + headers[authInfo.headerName] = authInfo.token; + } + headers[ConnectionIdHeader] = connectionId; + config.parameters.setProperty(Exports_2.PropertyId.SpeechServiceConnection_Url, endpoint); + return new Exports_1.WebsocketConnection(endpoint, queryParams, headers, new Exports_3.WebsocketMessageFormatter(), Exports_1.ProxyInfo.fromRecognizerConfig(config), connectionId); + }; + return _this; + } + IntentConnectionFactory.prototype.getSpeechRegionFromIntentRegion = function (intentRegion) { + switch (intentRegion) { + case "West US": + case "US West": + case "westus": + return "uswest"; + case "West US 2": + case "US West 2": + case "westus2": + return "uswest2"; + case "South Central US": + case "US South Central": + case "southcentralus": + return "ussouthcentral"; + case "West Central US": + case "US West Central": + case "westcentralus": + return "uswestcentral"; + case "East US": + case "US East": + case "eastus": + return "useast"; + case "East US 2": + case "US East 2": + case "eastus2": + return "useast2"; + case "West Europe": + case "Europe West": + case "westeurope": + return "europewest"; + case "North Europe": + case "Europe North": + case "northeurope": + return "europenorth"; + case "Brazil South": + case "South Brazil": + case "southbrazil": + return "brazilsouth"; + case "Australia East": + case "East Australia": + case "eastaustralia": + return "australiaeast"; + case "Southeast Asia": + case "Asia Southeast": + case "southeastasia": + return "asiasoutheast"; + case "East Asia": + case "Asia East": + case "eastasia": + return "asiaeast"; + default: + return intentRegion; + } + }; + return IntentConnectionFactory; +}(ConnectionFactoryBase_1.ConnectionFactoryBase)); +exports.IntentConnectionFactory = IntentConnectionFactory; + + + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var AudioConfig_1 = __webpack_require__(32); +exports.AudioConfig = AudioConfig_1.AudioConfig; +var AudioStreamFormat_1 = __webpack_require__(42); +exports.AudioStreamFormat = AudioStreamFormat_1.AudioStreamFormat; +var AudioInputStream_1 = __webpack_require__(36); +exports.AudioInputStream = AudioInputStream_1.AudioInputStream; +exports.PullAudioInputStream = AudioInputStream_1.PullAudioInputStream; +exports.PushAudioInputStream = AudioInputStream_1.PushAudioInputStream; +var AudioOutputStream_1 = __webpack_require__(43); +exports.AudioOutputStream = AudioOutputStream_1.AudioOutputStream; +exports.PullAudioOutputStream = AudioOutputStream_1.PullAudioOutputStream; +exports.PushAudioOutputStream = AudioOutputStream_1.PushAudioOutputStream; +var CancellationReason_1 = __webpack_require__(46); +exports.CancellationReason = CancellationReason_1.CancellationReason; +var PullAudioInputStreamCallback_1 = __webpack_require__(47); +exports.PullAudioInputStreamCallback = PullAudioInputStreamCallback_1.PullAudioInputStreamCallback; +var PushAudioOutputStreamCallback_1 = __webpack_require__(48); +exports.PushAudioOutputStreamCallback = PushAudioOutputStreamCallback_1.PushAudioOutputStreamCallback; +var KeywordRecognitionModel_1 = __webpack_require__(49); +exports.KeywordRecognitionModel = KeywordRecognitionModel_1.KeywordRecognitionModel; +var SessionEventArgs_1 = __webpack_require__(50); +exports.SessionEventArgs = SessionEventArgs_1.SessionEventArgs; +var RecognitionEventArgs_1 = __webpack_require__(51); +exports.RecognitionEventArgs = RecognitionEventArgs_1.RecognitionEventArgs; +var OutputFormat_1 = __webpack_require__(52); +exports.OutputFormat = OutputFormat_1.OutputFormat; +var IntentRecognitionEventArgs_1 = __webpack_require__(53); +exports.IntentRecognitionEventArgs = IntentRecognitionEventArgs_1.IntentRecognitionEventArgs; +var RecognitionResult_1 = __webpack_require__(54); +exports.RecognitionResult = RecognitionResult_1.RecognitionResult; +var SpeechRecognitionResult_1 = __webpack_require__(55); +exports.SpeechRecognitionResult = SpeechRecognitionResult_1.SpeechRecognitionResult; +var IntentRecognitionResult_1 = __webpack_require__(56); +exports.IntentRecognitionResult = IntentRecognitionResult_1.IntentRecognitionResult; +var LanguageUnderstandingModel_1 = __webpack_require__(57); +exports.LanguageUnderstandingModel = LanguageUnderstandingModel_1.LanguageUnderstandingModel; +var SpeechRecognitionEventArgs_1 = __webpack_require__(58); +exports.SpeechRecognitionEventArgs = SpeechRecognitionEventArgs_1.SpeechRecognitionEventArgs; +var SpeechRecognitionCanceledEventArgs_1 = __webpack_require__(59); +exports.SpeechRecognitionCanceledEventArgs = SpeechRecognitionCanceledEventArgs_1.SpeechRecognitionCanceledEventArgs; +var TranslationRecognitionEventArgs_1 = __webpack_require__(60); +exports.TranslationRecognitionEventArgs = TranslationRecognitionEventArgs_1.TranslationRecognitionEventArgs; +var TranslationSynthesisEventArgs_1 = __webpack_require__(61); +exports.TranslationSynthesisEventArgs = TranslationSynthesisEventArgs_1.TranslationSynthesisEventArgs; +var TranslationRecognitionResult_1 = __webpack_require__(62); +exports.TranslationRecognitionResult = TranslationRecognitionResult_1.TranslationRecognitionResult; +var TranslationSynthesisResult_1 = __webpack_require__(63); +exports.TranslationSynthesisResult = TranslationSynthesisResult_1.TranslationSynthesisResult; +var ResultReason_1 = __webpack_require__(64); +exports.ResultReason = ResultReason_1.ResultReason; +var SpeechConfig_1 = __webpack_require__(65); +exports.SpeechConfig = SpeechConfig_1.SpeechConfig; +exports.SpeechConfigImpl = SpeechConfig_1.SpeechConfigImpl; +var SpeechTranslationConfig_1 = __webpack_require__(66); +exports.SpeechTranslationConfig = SpeechTranslationConfig_1.SpeechTranslationConfig; +var PropertyCollection_1 = __webpack_require__(67); +exports.PropertyCollection = PropertyCollection_1.PropertyCollection; +var PropertyId_1 = __webpack_require__(68); +exports.PropertyId = PropertyId_1.PropertyId; +var Recognizer_1 = __webpack_require__(69); +exports.Recognizer = Recognizer_1.Recognizer; +var SpeechRecognizer_1 = __webpack_require__(70); +exports.SpeechRecognizer = SpeechRecognizer_1.SpeechRecognizer; +var IntentRecognizer_1 = __webpack_require__(74); +exports.IntentRecognizer = IntentRecognizer_1.IntentRecognizer; +var VoiceProfileType_1 = __webpack_require__(75); +exports.VoiceProfileType = VoiceProfileType_1.VoiceProfileType; +var TranslationRecognizer_1 = __webpack_require__(76); +exports.TranslationRecognizer = TranslationRecognizer_1.TranslationRecognizer; +var Translations_1 = __webpack_require__(77); +exports.Translations = Translations_1.Translations; +var NoMatchReason_1 = __webpack_require__(78); +exports.NoMatchReason = NoMatchReason_1.NoMatchReason; +var NoMatchDetails_1 = __webpack_require__(79); +exports.NoMatchDetails = NoMatchDetails_1.NoMatchDetails; +var TranslationRecognitionCanceledEventArgs_1 = __webpack_require__(80); +exports.TranslationRecognitionCanceledEventArgs = TranslationRecognitionCanceledEventArgs_1.TranslationRecognitionCanceledEventArgs; +var IntentRecognitionCanceledEventArgs_1 = __webpack_require__(81); +exports.IntentRecognitionCanceledEventArgs = IntentRecognitionCanceledEventArgs_1.IntentRecognitionCanceledEventArgs; +var CancellationDetailsBase_1 = __webpack_require__(82); +exports.CancellationDetailsBase = CancellationDetailsBase_1.CancellationDetailsBase; +var CancellationDetails_1 = __webpack_require__(83); +exports.CancellationDetails = CancellationDetails_1.CancellationDetails; +var CancellationErrorCodes_1 = __webpack_require__(84); +exports.CancellationErrorCode = CancellationErrorCodes_1.CancellationErrorCode; +var ConnectionEventArgs_1 = __webpack_require__(85); +exports.ConnectionEventArgs = ConnectionEventArgs_1.ConnectionEventArgs; +var ServiceEventArgs_1 = __webpack_require__(86); +exports.ServiceEventArgs = ServiceEventArgs_1.ServiceEventArgs; +var Connection_1 = __webpack_require__(87); +exports.Connection = Connection_1.Connection; +var PhraseListGrammar_1 = __webpack_require__(89); +exports.PhraseListGrammar = PhraseListGrammar_1.PhraseListGrammar; +var DialogServiceConfig_1 = __webpack_require__(90); +exports.DialogServiceConfig = DialogServiceConfig_1.DialogServiceConfig; +var BotFrameworkConfig_1 = __webpack_require__(91); +exports.BotFrameworkConfig = BotFrameworkConfig_1.BotFrameworkConfig; +var CustomCommandsConfig_1 = __webpack_require__(92); +exports.CustomCommandsConfig = CustomCommandsConfig_1.CustomCommandsConfig; +var DialogServiceConnector_1 = __webpack_require__(93); +exports.DialogServiceConnector = DialogServiceConnector_1.DialogServiceConnector; +var ActivityReceivedEventArgs_1 = __webpack_require__(95); +exports.ActivityReceivedEventArgs = ActivityReceivedEventArgs_1.ActivityReceivedEventArgs; +var ServicePropertyChannel_1 = __webpack_require__(96); +exports.ServicePropertyChannel = ServicePropertyChannel_1.ServicePropertyChannel; +var ProfanityOption_1 = __webpack_require__(97); +exports.ProfanityOption = ProfanityOption_1.ProfanityOption; +var BaseAudioPlayer_1 = __webpack_require__(98); +exports.BaseAudioPlayer = BaseAudioPlayer_1.BaseAudioPlayer; +var ConnectionMessageEventArgs_1 = __webpack_require__(99); +exports.ConnectionMessageEventArgs = ConnectionMessageEventArgs_1.ConnectionMessageEventArgs; +var ConnectionMessage_1 = __webpack_require__(88); +exports.ConnectionMessage = ConnectionMessage_1.ConnectionMessage; +var VoiceProfile_1 = __webpack_require__(100); +exports.VoiceProfile = VoiceProfile_1.VoiceProfile; +var VoiceProfileEnrollmentResult_1 = __webpack_require__(101); +exports.VoiceProfileEnrollmentResult = VoiceProfileEnrollmentResult_1.VoiceProfileEnrollmentResult; +exports.VoiceProfileEnrollmentCancellationDetails = VoiceProfileEnrollmentResult_1.VoiceProfileEnrollmentCancellationDetails; +var VoiceProfileResult_1 = __webpack_require__(102); +exports.VoiceProfileResult = VoiceProfileResult_1.VoiceProfileResult; +exports.VoiceProfileCancellationDetails = VoiceProfileResult_1.VoiceProfileCancellationDetails; +var VoiceProfileClient_1 = __webpack_require__(103); +exports.VoiceProfileClient = VoiceProfileClient_1.VoiceProfileClient; +var SpeakerRecognizer_1 = __webpack_require__(104); +exports.SpeakerRecognizer = SpeakerRecognizer_1.SpeakerRecognizer; +var SpeakerIdentificationModel_1 = __webpack_require__(105); +exports.SpeakerIdentificationModel = SpeakerIdentificationModel_1.SpeakerIdentificationModel; +var SpeakerVerificationModel_1 = __webpack_require__(106); +exports.SpeakerVerificationModel = SpeakerVerificationModel_1.SpeakerVerificationModel; +var AutoDetectSourceLanguageConfig_1 = __webpack_require__(107); +exports.AutoDetectSourceLanguageConfig = AutoDetectSourceLanguageConfig_1.AutoDetectSourceLanguageConfig; +var AutoDetectSourceLanguageResult_1 = __webpack_require__(108); +exports.AutoDetectSourceLanguageResult = AutoDetectSourceLanguageResult_1.AutoDetectSourceLanguageResult; +var SourceLanguageConfig_1 = __webpack_require__(109); +exports.SourceLanguageConfig = SourceLanguageConfig_1.SourceLanguageConfig; +var SpeakerRecognitionResult_1 = __webpack_require__(110); +exports.SpeakerRecognitionResult = SpeakerRecognitionResult_1.SpeakerRecognitionResult; +exports.SpeakerRecognitionResultType = SpeakerRecognitionResult_1.SpeakerRecognitionResultType; +exports.SpeakerRecognitionCancellationDetails = SpeakerRecognitionResult_1.SpeakerRecognitionCancellationDetails; +var Exports_1 = __webpack_require__(111); +exports.Conversation = Exports_1.Conversation; +exports.ConversationExpirationEventArgs = Exports_1.ConversationExpirationEventArgs; +exports.ConversationParticipantsChangedEventArgs = Exports_1.ConversationParticipantsChangedEventArgs; +exports.ConversationTranslationCanceledEventArgs = Exports_1.ConversationTranslationCanceledEventArgs; +exports.ConversationTranslationEventArgs = Exports_1.ConversationTranslationEventArgs; +exports.ConversationTranslationResult = Exports_1.ConversationTranslationResult; +exports.ConversationTranslator = Exports_1.ConversationTranslator; +exports.Participant = Exports_1.Participant; +exports.ParticipantChangedReason = Exports_1.ParticipantChangedReason; +exports.User = Exports_1.User; +var SpeechSynthesisOutputFormat_1 = __webpack_require__(45); +exports.SpeechSynthesisOutputFormat = SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat; +var SpeechSynthesizer_1 = __webpack_require__(121); +exports.SpeechSynthesizer = SpeechSynthesizer_1.SpeechSynthesizer; +var SpeechSynthesisResult_1 = __webpack_require__(122); +exports.SpeechSynthesisResult = SpeechSynthesisResult_1.SpeechSynthesisResult; +var SpeechSynthesisEventArgs_1 = __webpack_require__(123); +exports.SpeechSynthesisEventArgs = SpeechSynthesisEventArgs_1.SpeechSynthesisEventArgs; +var SpeechSynthesisWordBoundaryEventArgs_1 = __webpack_require__(124); +exports.SpeechSynthesisWordBoundaryEventArgs = SpeechSynthesisWordBoundaryEventArgs_1.SpeechSynthesisWordBoundaryEventArgs; +var SpeakerAudioDestination_1 = __webpack_require__(125); +exports.SpeakerAudioDestination = SpeakerAudioDestination_1.SpeakerAudioDestination; + + + +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(2); +var Contracts_1 = __webpack_require__(33); +var Exports_2 = __webpack_require__(31); +var AudioFileWriter_1 = __webpack_require__(34); +var AudioInputStream_1 = __webpack_require__(36); +var AudioOutputStream_1 = __webpack_require__(43); +/** + * Represents audio input configuration used for specifying what type of input to use (microphone, file, stream). + * @class AudioConfig + * Updated in version 1.11.0 + */ +var AudioConfig = /** @class */ (function () { + function AudioConfig() { + } + /** + * Creates an AudioConfig object representing the default microphone on the system. + * @member AudioConfig.fromDefaultMicrophoneInput + * @function + * @public + * @returns {AudioConfig} The audio input configuration being created. + */ + AudioConfig.fromDefaultMicrophoneInput = function () { + var pcmRecorder = new Exports_1.PcmRecorder(); + return new AudioConfigImpl(new Exports_1.MicAudioSource(pcmRecorder)); + }; + /** + * Creates an AudioConfig object representing a microphone with the specified device ID. + * @member AudioConfig.fromMicrophoneInput + * @function + * @public + * @param {string | undefined} deviceId - Specifies the device ID of the microphone to be used. + * Default microphone is used the value is omitted. + * @returns {AudioConfig} The audio input configuration being created. + */ + AudioConfig.fromMicrophoneInput = function (deviceId) { + var pcmRecorder = new Exports_1.PcmRecorder(); + return new AudioConfigImpl(new Exports_1.MicAudioSource(pcmRecorder, deviceId)); + }; + /** + * Creates an AudioConfig object representing the specified file. + * @member AudioConfig.fromWavFileInput + * @function + * @public + * @param {File} fileName - Specifies the audio input file. Currently, only WAV / PCM is supported. + * @returns {AudioConfig} The audio input configuration being created. + */ + AudioConfig.fromWavFileInput = function (file) { + return new AudioConfigImpl(new Exports_1.FileAudioSource(file)); + }; + /** + * Creates an AudioConfig object representing the specified stream. + * @member AudioConfig.fromStreamInput + * @function + * @public + * @param {AudioInputStream | PullAudioInputStreamCallback} audioStream - Specifies the custom audio input + * stream. Currently, only WAV / PCM is supported. + * @returns {AudioConfig} The audio input configuration being created. + */ + AudioConfig.fromStreamInput = function (audioStream) { + if (audioStream instanceof Exports_2.PullAudioInputStreamCallback) { + return new AudioConfigImpl(new AudioInputStream_1.PullAudioInputStreamImpl(audioStream)); + } + if (audioStream instanceof Exports_2.AudioInputStream) { + return new AudioConfigImpl(audioStream); + } + throw new Error("Not Supported Type"); + }; + /** + * Creates an AudioConfig object representing the default speaker. + * @member AudioConfig.fromDefaultSpeakerOutput + * @function + * @public + * @returns {AudioConfig} The audio output configuration being created. + * Added in version 1.11.0 + */ + AudioConfig.fromDefaultSpeakerOutput = function () { + return new AudioOutputConfigImpl(new Exports_2.SpeakerAudioDestination()); + }; + /** + * Creates an AudioConfig object representing the custom IPlayer object. + * You can use the IPlayer object to control pause, resume, etc. + * @member AudioConfig.fromSpeakerOutput + * @function + * @public + * @param {IPlayer} player - the IPlayer object for playback. + * @returns {AudioConfig} The audio output configuration being created. + * Added in version 1.12.0 + */ + AudioConfig.fromSpeakerOutput = function (player) { + if (player === undefined) { + return AudioConfig.fromDefaultSpeakerOutput(); + } + if (player instanceof Exports_2.SpeakerAudioDestination) { + return new AudioOutputConfigImpl(player); + } + throw new Error("Not Supported Type"); + }; + /** + * Creates an AudioConfig object representing a specified output audio file + * @member AudioConfig.fromAudioFileOutput + * @function + * @public + * @param {PathLike} filename - the filename of the output audio file + * @returns {AudioConfig} The audio output configuration being created. + * Added in version 1.11.0 + */ + AudioConfig.fromAudioFileOutput = function (filename) { + return new AudioOutputConfigImpl(new AudioFileWriter_1.AudioFileWriter(filename)); + }; + /** + * Creates an AudioConfig object representing a specified audio output stream + * @member AudioConfig.fromStreamOutput + * @function + * @public + * @param {AudioOutputStream | PushAudioOutputStreamCallback} audioStream - Specifies the custom audio output + * stream. + * @returns {AudioConfig} The audio output configuration being created. + * Added in version 1.11.0 + */ + AudioConfig.fromStreamOutput = function (audioStream) { + if (audioStream instanceof Exports_2.PushAudioOutputStreamCallback) { + return new AudioOutputConfigImpl(new AudioOutputStream_1.PushAudioOutputStreamImpl(audioStream)); + } + if (audioStream instanceof Exports_2.PushAudioOutputStream) { + return new AudioOutputConfigImpl(audioStream); + } + if (audioStream instanceof Exports_2.PullAudioOutputStream) { + return new AudioOutputConfigImpl(audioStream); + } + throw new Error("Not Supported Type"); + }; + return AudioConfig; +}()); +exports.AudioConfig = AudioConfig; +/** + * Represents audio input stream used for custom audio input configurations. + * @private + * @class AudioConfigImpl + */ +// tslint:disable-next-line:max-classes-per-file +var AudioConfigImpl = /** @class */ (function (_super) { + __extends(AudioConfigImpl, _super); + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {IAudioSource} source - An audio source. + */ + function AudioConfigImpl(source) { + var _this = _super.call(this) || this; + _this.privSource = source; + return _this; + } + Object.defineProperty(AudioConfigImpl.prototype, "format", { + /** + * Format information for the audio + */ + get: function () { + return this.privSource.format; + }, + enumerable: true, + configurable: true + }); + /** + * @member AudioConfigImpl.prototype.close + * @function + * @public + */ + AudioConfigImpl.prototype.close = function () { + this.privSource.turnOff(); + }; + /** + * @member AudioConfigImpl.prototype.id + * @function + * @public + */ + AudioConfigImpl.prototype.id = function () { + return this.privSource.id(); + }; + Object.defineProperty(AudioConfigImpl.prototype, "blob", { + /** + * @member AudioConfigImpl.prototype.blob + * @function + * @public + */ + get: function () { + return this.privSource.blob; + }, + enumerable: true, + configurable: true + }); + /** + * @member AudioConfigImpl.prototype.turnOn + * @function + * @public + * @returns {Promise} A promise. + */ + AudioConfigImpl.prototype.turnOn = function () { + return this.privSource.turnOn(); + }; + /** + * @member AudioConfigImpl.prototype.attach + * @function + * @public + * @param {string} audioNodeId - The audio node id. + * @returns {Promise} A promise. + */ + AudioConfigImpl.prototype.attach = function (audioNodeId) { + return this.privSource.attach(audioNodeId); + }; + /** + * @member AudioConfigImpl.prototype.detach + * @function + * @public + * @param {string} audioNodeId - The audio node id. + */ + AudioConfigImpl.prototype.detach = function (audioNodeId) { + return this.privSource.detach(audioNodeId); + }; + /** + * @member AudioConfigImpl.prototype.turnOff + * @function + * @public + * @returns {Promise} A promise. + */ + AudioConfigImpl.prototype.turnOff = function () { + return this.privSource.turnOff(); + }; + Object.defineProperty(AudioConfigImpl.prototype, "events", { + /** + * @member AudioConfigImpl.prototype.events + * @function + * @public + * @returns {EventSource} An event source for audio events. + */ + get: function () { + return this.privSource.events; + }, + enumerable: true, + configurable: true + }); + AudioConfigImpl.prototype.setProperty = function (name, value) { + Contracts_1.Contracts.throwIfNull(value, "value"); + if (undefined !== this.privSource.setProperty) { + this.privSource.setProperty(name, value); + } + else { + throw new Error("This AudioConfig instance does not support setting properties."); + } + }; + AudioConfigImpl.prototype.getProperty = function (name, def) { + if (undefined !== this.privSource.getProperty) { + return this.privSource.getProperty(name, def); + } + else { + throw new Error("This AudioConfig instance does not support getting properties."); + } + return def; + }; + Object.defineProperty(AudioConfigImpl.prototype, "deviceInfo", { + get: function () { + return this.privSource.deviceInfo; + }, + enumerable: true, + configurable: true + }); + return AudioConfigImpl; +}(AudioConfig)); +exports.AudioConfigImpl = AudioConfigImpl; +// tslint:disable-next-line:max-classes-per-file +var AudioOutputConfigImpl = /** @class */ (function (_super) { + __extends(AudioOutputConfigImpl, _super); + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {IAudioDestination} destination - An audio destination. + */ + function AudioOutputConfigImpl(destination) { + var _this = _super.call(this) || this; + _this.privDestination = destination; + return _this; + } + Object.defineProperty(AudioOutputConfigImpl.prototype, "format", { + set: function (format) { + this.privDestination.format = format; + }, + enumerable: true, + configurable: true + }); + AudioOutputConfigImpl.prototype.write = function (buffer) { + this.privDestination.write(buffer); + }; + AudioOutputConfigImpl.prototype.close = function () { + this.privDestination.close(); + }; + AudioOutputConfigImpl.prototype.id = function () { + return this.privDestination.id(); + }; + AudioOutputConfigImpl.prototype.setProperty = function (name, value) { + throw new Error("This AudioConfig instance does not support setting properties."); + }; + AudioOutputConfigImpl.prototype.getProperty = function (name, def) { + throw new Error("This AudioConfig instance does not support getting properties."); + }; + return AudioOutputConfigImpl; +}(AudioConfig)); +exports.AudioOutputConfigImpl = AudioOutputConfigImpl; + + + +/***/ }), +/* 33 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * @class Contracts + * @private + */ +var Contracts = /** @class */ (function () { + function Contracts() { + } + Contracts.throwIfNullOrUndefined = function (param, name) { + if (param === undefined || param === null) { + throw new Error("throwIfNullOrUndefined:" + name); + } + }; + Contracts.throwIfNull = function (param, name) { + if (param === null) { + throw new Error("throwIfNull:" + name); + } + }; + Contracts.throwIfNullOrWhitespace = function (param, name) { + Contracts.throwIfNullOrUndefined(param, name); + if (("" + param).trim().length < 1) { + throw new Error("throwIfNullOrWhitespace:" + name); + } + }; + Contracts.throwIfDisposed = function (isDisposed) { + if (isDisposed) { + throw new Error("the object is already disposed"); + } + }; + Contracts.throwIfArrayEmptyOrWhitespace = function (array, name) { + Contracts.throwIfNullOrUndefined(array, name); + if (array.length === 0) { + throw new Error("throwIfArrayEmptyOrWhitespace:" + name); + } + for (var _i = 0, array_1 = array; _i < array_1.length; _i++) { + var item = array_1[_i]; + Contracts.throwIfNullOrWhitespace(item, name); + } + }; + Contracts.throwIfFileDoesNotExist = function (param, name) { + Contracts.throwIfNullOrWhitespace(param, name); + // TODO check for file existence. + }; + Contracts.throwIfNotUndefined = function (param, name) { + if (param !== undefined) { + throw new Error("throwIfNotUndefined:" + name); + } + }; + return Contracts; +}()); +exports.Contracts = Contracts; + + + +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var fs = __importStar(__webpack_require__(35)); +var Contracts_1 = __webpack_require__(33); +var AudioFileWriter = /** @class */ (function () { + function AudioFileWriter(filename) { + var _this = this; + this.id = function () { + return _this.privId; + }; + this.privFd = fs.openSync(filename, "w"); + } + Object.defineProperty(AudioFileWriter.prototype, "format", { + set: function (format) { + Contracts_1.Contracts.throwIfNotUndefined(this.privAudioFormat, "format is already set"); + this.privAudioFormat = format; + var headerOffset = 0; + if (this.privAudioFormat.hasHeader) { + headerOffset = this.privAudioFormat.header.byteLength; + } + if (this.privFd !== undefined) { + this.privWriteStream = fs.createWriteStream("", { fd: this.privFd, start: headerOffset, autoClose: false }); + } + }, + enumerable: true, + configurable: true + }); + AudioFileWriter.prototype.write = function (buffer) { + Contracts_1.Contracts.throwIfNullOrUndefined(this.privAudioFormat, "must set format before writing."); + if (this.privWriteStream !== undefined) { + this.privWriteStream.write(new Uint8Array(buffer.slice(0))); + } + }; + AudioFileWriter.prototype.close = function () { + var _this = this; + if (this.privFd !== undefined) { + this.privWriteStream.on("finish", function () { + if (_this.privAudioFormat.hasHeader) { + _this.privAudioFormat.updateHeader(_this.privWriteStream.bytesWritten); + fs.writeSync(_this.privFd, new Int8Array(_this.privAudioFormat.header), 0, _this.privAudioFormat.header.byteLength, 0); + } + fs.closeSync(_this.privFd); + _this.privFd = undefined; + }); + this.privWriteStream.end(); + } + }; + return AudioFileWriter; +}()); +exports.AudioFileWriter = AudioFileWriter; + + + +/***/ }), +/* 35 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(Buffer) { +// 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 Exports_1 = __webpack_require__(26); +var Exports_2 = __webpack_require__(4); +var Guid_1 = __webpack_require__(7); +var Exports_3 = __webpack_require__(31); +var AudioStreamFormat_1 = __webpack_require__(42); +/** + * Represents audio input stream used for custom audio input configurations. + * @class AudioInputStream + */ +var AudioInputStream = /** @class */ (function () { + /** + * Creates and initializes an instance. + * @constructor + */ + function AudioInputStream() { + } + /** + * Creates a memory backed PushAudioInputStream with the specified audio format. + * @member AudioInputStream.createPushStream + * @function + * @public + * @param {AudioStreamFormat} format - The audio data format in which audio will be + * written to the push audio stream's write() method (Required if format is not 16 kHz 16bit mono PCM). + * @returns {PushAudioInputStream} The audio input stream being created. + */ + AudioInputStream.createPushStream = function (format) { + return PushAudioInputStream.create(format); + }; + /** + * Creates a PullAudioInputStream that delegates to the specified callback interface for read() + * and close() methods. + * @member AudioInputStream.createPullStream + * @function + * @public + * @param {PullAudioInputStreamCallback} callback - The custom audio input object, derived from + * PullAudioInputStreamCallback + * @param {AudioStreamFormat} format - The audio data format in which audio will be returned from + * the callback's read() method (Required if format is not 16 kHz 16bit mono PCM). + * @returns {PullAudioInputStream} The audio input stream being created. + */ + AudioInputStream.createPullStream = function (callback, format) { + return PullAudioInputStream.create(callback, format); + // throw new Error("Oops"); + }; + return AudioInputStream; +}()); +exports.AudioInputStream = AudioInputStream; +/** + * Represents memory backed push audio input stream used for custom audio input configurations. + * @class PushAudioInputStream + */ +// tslint:disable-next-line:max-classes-per-file +var PushAudioInputStream = /** @class */ (function (_super) { + __extends(PushAudioInputStream, _super); + function PushAudioInputStream() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Creates a memory backed PushAudioInputStream with the specified audio format. + * @member PushAudioInputStream.create + * @function + * @public + * @param {AudioStreamFormat} format - The audio data format in which audio will be written to the + * push audio stream's write() method (Required if format is not 16 kHz 16bit mono PCM). + * @returns {PushAudioInputStream} The push audio input stream being created. + */ + PushAudioInputStream.create = function (format) { + return new PushAudioInputStreamImpl(format); + }; + return PushAudioInputStream; +}(AudioInputStream)); +exports.PushAudioInputStream = PushAudioInputStream; +/** + * Represents memory backed push audio input stream used for custom audio input configurations. + * @private + * @class PushAudioInputStreamImpl + */ +// tslint:disable-next-line:max-classes-per-file +var PushAudioInputStreamImpl = /** @class */ (function (_super) { + __extends(PushAudioInputStreamImpl, _super); + /** + * Creates and initalizes an instance with the given values. + * @constructor + * @param {AudioStreamFormat} format - The audio stream format. + */ + function PushAudioInputStreamImpl(format) { + var _this = _super.call(this) || this; + _this.onEvent = function (event) { + _this.privEvents.onEvent(event); + Exports_2.Events.instance.onEvent(event); + }; + if (format === undefined) { + _this.privFormat = AudioStreamFormat_1.AudioStreamFormatImpl.getDefaultInputFormat(); + } + else { + _this.privFormat = format; + } + _this.privEvents = new Exports_2.EventSource(); + _this.privId = Guid_1.createNoDashGuid(); + _this.privStream = new Exports_2.ChunkedArrayBufferStream(_this.privFormat.avgBytesPerSec / 10); + return _this; + } + Object.defineProperty(PushAudioInputStreamImpl.prototype, "format", { + /** + * Format information for the audio + */ + get: function () { + return Exports_2.PromiseHelper.fromResult(this.privFormat); + }, + enumerable: true, + configurable: true + }); + /** + * Writes the audio data specified by making an internal copy of the data. + * @member PushAudioInputStreamImpl.prototype.write + * @function + * @public + * @param {ArrayBuffer} dataBuffer - The audio buffer of which this function will make a copy. + */ + PushAudioInputStreamImpl.prototype.write = function (dataBuffer) { + this.privStream.writeStreamChunk({ + buffer: dataBuffer, + isEnd: false, + timeReceived: Date.now() + }); + }; + /** + * Closes the stream. + * @member PushAudioInputStreamImpl.prototype.close + * @function + * @public + */ + PushAudioInputStreamImpl.prototype.close = function () { + this.privStream.close(); + }; + PushAudioInputStreamImpl.prototype.id = function () { + return this.privId; + }; + Object.defineProperty(PushAudioInputStreamImpl.prototype, "blob", { + get: function () { + var _this = this; + return this.attach("id").onSuccessContinueWithPromise(function (audioNode) { + var data = []; + var bufferData = Buffer.from(""); + var readCycle = function () { + return audioNode.read().onSuccessContinueWithPromise(function (audioStreamChunk) { + if (!audioStreamChunk || audioStreamChunk.isEnd) { + if (typeof (XMLHttpRequest) !== "undefined") { + return Exports_2.PromiseHelper.fromResult(new Blob(data)); + } + else { + return Exports_2.PromiseHelper.fromResult(Buffer.from(bufferData)); + } + } + else { + if (typeof (Blob) !== "undefined") { + data.push(audioStreamChunk.buffer); + } + else { + bufferData = Buffer.concat([bufferData, _this.toBuffer(audioStreamChunk.buffer)]); + } + return readCycle(); + } + }); + }; + return readCycle(); + }); + }, + enumerable: true, + configurable: true + }); + PushAudioInputStreamImpl.prototype.turnOn = function () { + this.onEvent(new Exports_2.AudioSourceInitializingEvent(this.privId)); // no stream id + this.onEvent(new Exports_2.AudioSourceReadyEvent(this.privId)); + return Exports_2.PromiseHelper.fromResult(true); + }; + PushAudioInputStreamImpl.prototype.attach = function (audioNodeId) { + var _this = this; + this.onEvent(new Exports_2.AudioStreamNodeAttachingEvent(this.privId, audioNodeId)); + return this.turnOn() + .onSuccessContinueWith(function (_) { + // For now we support a single parallel reader of the pushed stream. + // So we can simiply hand the stream to the recognizer and let it recognize. + return _this.privStream; + }) + .onSuccessContinueWith(function (stream) { + _this.onEvent(new Exports_2.AudioStreamNodeAttachedEvent(_this.privId, audioNodeId)); + return { + detach: function () { + stream.readEnded(); + _this.onEvent(new Exports_2.AudioStreamNodeDetachedEvent(_this.privId, audioNodeId)); + _this.turnOff(); + }, + id: function () { + return audioNodeId; + }, + read: function () { + return stream.read(); + }, + }; + }); + }; + PushAudioInputStreamImpl.prototype.detach = function (audioNodeId) { + this.onEvent(new Exports_2.AudioStreamNodeDetachedEvent(this.privId, audioNodeId)); + }; + PushAudioInputStreamImpl.prototype.turnOff = function () { + return Exports_2.PromiseHelper.fromResult(false); + }; + Object.defineProperty(PushAudioInputStreamImpl.prototype, "events", { + get: function () { + return this.privEvents; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(PushAudioInputStreamImpl.prototype, "deviceInfo", { + get: function () { + return Exports_2.PromiseHelper.fromResult({ + bitspersample: this.privFormat.bitsPerSample, + channelcount: this.privFormat.channels, + connectivity: Exports_1.connectivity.Unknown, + manufacturer: "Speech SDK", + model: "PushStream", + samplerate: this.privFormat.samplesPerSec, + type: Exports_1.type.Stream, + }); + }, + enumerable: true, + configurable: true + }); + PushAudioInputStreamImpl.prototype.toBuffer = function (arrayBuffer) { + var buf = Buffer.alloc(arrayBuffer.byteLength); + var view = new Uint8Array(arrayBuffer); + for (var i = 0; i < buf.length; ++i) { + buf[i] = view[i]; + } + return buf; + }; + return PushAudioInputStreamImpl; +}(PushAudioInputStream)); +exports.PushAudioInputStreamImpl = PushAudioInputStreamImpl; +/* + * Represents audio input stream used for custom audio input configurations. + * @class PullAudioInputStream + */ +// tslint:disable-next-line:max-classes-per-file +var PullAudioInputStream = /** @class */ (function (_super) { + __extends(PullAudioInputStream, _super); + /** + * Creates and initializes and instance. + * @constructor + */ + function PullAudioInputStream() { + return _super.call(this) || this; + } + /** + * Creates a PullAudioInputStream that delegates to the specified callback interface for + * read() and close() methods, using the default format (16 kHz 16bit mono PCM). + * @member PullAudioInputStream.create + * @function + * @public + * @param {PullAudioInputStreamCallback} callback - The custom audio input object, + * derived from PullAudioInputStreamCustomCallback + * @param {AudioStreamFormat} format - The audio data format in which audio will be + * returned from the callback's read() method (Required if format is not 16 kHz 16bit mono PCM). + * @returns {PullAudioInputStream} The push audio input stream being created. + */ + PullAudioInputStream.create = function (callback, format) { + return new PullAudioInputStreamImpl(callback, format); + }; + return PullAudioInputStream; +}(AudioInputStream)); +exports.PullAudioInputStream = PullAudioInputStream; +/** + * Represents audio input stream used for custom audio input configurations. + * @private + * @class PullAudioInputStreamImpl + */ +// tslint:disable-next-line:max-classes-per-file +var PullAudioInputStreamImpl = /** @class */ (function (_super) { + __extends(PullAudioInputStreamImpl, _super); + /** + * Creates a PullAudioInputStream that delegates to the specified callback interface for + * read() and close() methods, using the default format (16 kHz 16bit mono PCM). + * @constructor + * @param {PullAudioInputStreamCallback} callback - The custom audio input object, + * derived from PullAudioInputStreamCustomCallback + * @param {AudioStreamFormat} format - The audio data format in which audio will be + * returned from the callback's read() method (Required if format is not 16 kHz 16bit mono PCM). + */ + function PullAudioInputStreamImpl(callback, format) { + var _this = _super.call(this) || this; + _this.onEvent = function (event) { + _this.privEvents.onEvent(event); + Exports_2.Events.instance.onEvent(event); + }; + if (undefined === format) { + _this.privFormat = Exports_3.AudioStreamFormat.getDefaultInputFormat(); + } + else { + _this.privFormat = format; + } + _this.privEvents = new Exports_2.EventSource(); + _this.privId = Guid_1.createNoDashGuid(); + _this.privCallback = callback; + _this.privIsClosed = false; + _this.privBufferSize = _this.privFormat.avgBytesPerSec / 10; + return _this; + } + Object.defineProperty(PullAudioInputStreamImpl.prototype, "format", { + /** + * Format information for the audio + */ + get: function () { + return Exports_2.PromiseHelper.fromResult(this.privFormat); + }, + enumerable: true, + configurable: true + }); + /** + * Closes the stream. + * @member PullAudioInputStreamImpl.prototype.close + * @function + * @public + */ + PullAudioInputStreamImpl.prototype.close = function () { + this.privIsClosed = true; + this.privCallback.close(); + }; + PullAudioInputStreamImpl.prototype.id = function () { + return this.privId; + }; + Object.defineProperty(PullAudioInputStreamImpl.prototype, "blob", { + get: function () { + return Exports_2.PromiseHelper.fromError("Not implemented"); + }, + enumerable: true, + configurable: true + }); + PullAudioInputStreamImpl.prototype.turnOn = function () { + this.onEvent(new Exports_2.AudioSourceInitializingEvent(this.privId)); // no stream id + this.onEvent(new Exports_2.AudioSourceReadyEvent(this.privId)); + return Exports_2.PromiseHelper.fromResult(true); + }; + PullAudioInputStreamImpl.prototype.attach = function (audioNodeId) { + var _this = this; + this.onEvent(new Exports_2.AudioStreamNodeAttachingEvent(this.privId, audioNodeId)); + return this.turnOn() + .onSuccessContinueWith(function (result) { + _this.onEvent(new Exports_2.AudioStreamNodeAttachedEvent(_this.privId, audioNodeId)); + return { + detach: function () { + _this.privCallback.close(); + _this.onEvent(new Exports_2.AudioStreamNodeDetachedEvent(_this.privId, audioNodeId)); + _this.turnOff(); + }, + id: function () { + return audioNodeId; + }, + read: function () { + var totalBytes = 0; + var transmitBuff; + // Until we have the minimum number of bytes to send in a transmission, keep asking for more. + while (totalBytes < _this.privBufferSize) { + // Sizing the read buffer to the delta between the perfect size and what's left means we won't ever get too much + // data back. + var readBuff = new ArrayBuffer(_this.privBufferSize - totalBytes); + var pulledBytes = _this.privCallback.read(readBuff); + // If there is no return buffer yet defined, set the return buffer to the that was just populated. + // This was, if we have enough data there's no copy penalty, but if we don't we have a buffer that's the + // preferred size allocated. + if (undefined === transmitBuff) { + transmitBuff = readBuff; + } + else { + // Not the first bite at the apple, so fill the return buffer with the data we got back. + var intView = new Int8Array(transmitBuff); + intView.set(new Int8Array(readBuff), totalBytes); + } + // If there are no bytes to read, just break out and be done. + if (0 === pulledBytes) { + break; + } + totalBytes += pulledBytes; + } + return Exports_2.PromiseHelper.fromResult({ + buffer: transmitBuff.slice(0, totalBytes), + isEnd: _this.privIsClosed || totalBytes === 0, + timeReceived: Date.now(), + }); + }, + }; + }); + }; + PullAudioInputStreamImpl.prototype.detach = function (audioNodeId) { + this.onEvent(new Exports_2.AudioStreamNodeDetachedEvent(this.privId, audioNodeId)); + }; + PullAudioInputStreamImpl.prototype.turnOff = function () { + return Exports_2.PromiseHelper.fromResult(false); + }; + Object.defineProperty(PullAudioInputStreamImpl.prototype, "events", { + get: function () { + return this.privEvents; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(PullAudioInputStreamImpl.prototype, "deviceInfo", { + get: function () { + return Exports_2.PromiseHelper.fromResult({ + bitspersample: this.privFormat.bitsPerSample, + channelcount: this.privFormat.channels, + connectivity: Exports_1.connectivity.Unknown, + manufacturer: "Speech SDK", + model: "PullStream", + samplerate: this.privFormat.samplesPerSec, + type: Exports_1.type.Stream, + }); + }, + enumerable: true, + configurable: true + }); + return PullAudioInputStreamImpl; +}(PullAudioInputStream)); +exports.PullAudioInputStreamImpl = PullAudioInputStreamImpl; + + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(37).Buffer)) + +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(global) {/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +/* eslint-disable no-proto */ + + + +var base64 = __webpack_require__(39) +var ieee754 = __webpack_require__(40) +var isArray = __webpack_require__(41) + +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Use Object implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * Due to various browser bugs, sometimes the Object implementation will be used even + * when the browser supports typed arrays. + * + * Note: + * + * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, + * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. + * + * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. + * + * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of + * incorrect length in some situations. + + * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they + * get the Object implementation, which is slower but behaves correctly. + */ +Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined + ? global.TYPED_ARRAY_SUPPORT + : typedArraySupport() + +/* + * Export kMaxLength after typed array support is determined. + */ +exports.kMaxLength = kMaxLength() + +function typedArraySupport () { + try { + var arr = new Uint8Array(1) + arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + return arr.foo() === 42 && // typed array instances can be augmented + typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` + arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` + } catch (e) { + return false + } +} + +function kMaxLength () { + return Buffer.TYPED_ARRAY_SUPPORT + ? 0x7fffffff + : 0x3fffffff +} + +function createBuffer (that, length) { + if (kMaxLength() < length) { + throw new RangeError('Invalid typed array length') + } + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = new Uint8Array(length) + that.__proto__ = Buffer.prototype + } else { + // Fallback: Return an object instance of the Buffer class + if (that === null) { + that = new Buffer(length) + } + that.length = length + } + + return that +} + +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + +function Buffer (arg, encodingOrOffset, length) { + if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { + return new Buffer(arg, encodingOrOffset, length) + } + + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new Error( + 'If encoding is specified then the first argument must be a string' + ) + } + return allocUnsafe(this, arg) + } + return from(this, arg, encodingOrOffset, length) +} + +Buffer.poolSize = 8192 // not used by this implementation + +// TODO: Legacy, not needed anymore. Remove in next major version. +Buffer._augment = function (arr) { + arr.__proto__ = Buffer.prototype + return arr +} + +function from (that, value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } + + if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { + return fromArrayBuffer(that, value, encodingOrOffset, length) + } + + if (typeof value === 'string') { + return fromString(that, value, encodingOrOffset) + } + + return fromObject(that, value) +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(null, value, encodingOrOffset, length) +} + +if (Buffer.TYPED_ARRAY_SUPPORT) { + Buffer.prototype.__proto__ = Uint8Array.prototype + Buffer.__proto__ = Uint8Array + if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer[Symbol.species] === Buffer) { + // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true + }) + } +} + +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be a number') + } else if (size < 0) { + throw new RangeError('"size" argument must not be negative') + } +} + +function alloc (that, size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(that, size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(that, size).fill(fill, encoding) + : createBuffer(that, size).fill(fill) + } + return createBuffer(that, size) +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(null, size, fill, encoding) +} + +function allocUnsafe (that, size) { + assertSize(size) + that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) { + for (var i = 0; i < size; ++i) { + that[i] = 0 + } + } + return that +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(null, size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(null, size) +} + +function fromString (that, string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('"encoding" must be a valid string encoding') + } + + var length = byteLength(string, encoding) | 0 + that = createBuffer(that, length) + + var actual = that.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + that = that.slice(0, actual) + } + + return that +} + +function fromArrayLike (that, array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + that = createBuffer(that, length) + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that +} + +function fromArrayBuffer (that, array, byteOffset, length) { + array.byteLength // this throws if `array` is not a valid ArrayBuffer + + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('\'offset\' is out of bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('\'length\' is out of bounds') + } + + if (byteOffset === undefined && length === undefined) { + array = new Uint8Array(array) + } else if (length === undefined) { + array = new Uint8Array(array, byteOffset) + } else { + array = new Uint8Array(array, byteOffset, length) + } + + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = array + that.__proto__ = Buffer.prototype + } else { + // Fallback: Return an object instance of the Buffer class + that = fromArrayLike(that, array) + } + return that +} + +function fromObject (that, obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + that = createBuffer(that, len) + + if (that.length === 0) { + return that + } + + obj.copy(that, 0, 0, len) + return that + } + + if (obj) { + if ((typeof ArrayBuffer !== 'undefined' && + obj.buffer instanceof ArrayBuffer) || 'length' in obj) { + if (typeof obj.length !== 'number' || isnan(obj.length)) { + return createBuffer(that, 0) + } + return fromArrayLike(that, obj) + } + + if (obj.type === 'Buffer' && isArray(obj.data)) { + return fromArrayLike(that, obj.data) + } + } + + throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') +} + +function checked (length) { + // Note: cannot use `length < kMaxLength()` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= kMaxLength()) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + kMaxLength().toString(16) + ' bytes') + } + return length | 0 +} + +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) +} + +Buffer.isBuffer = function isBuffer (b) { + return !!(b != null && b._isBuffer) +} + +Buffer.compare = function compare (a, b) { + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('Arguments must be Buffers') + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +} + +Buffer.concat = function concat (list, length) { + if (!isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } + + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length + } + return buffer +} + +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && + (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + string = '' + string + } + + var len = string.length + if (len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + case undefined: + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) return utf8ToBytes(string).length // assume utf8 + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} +Buffer.byteLength = byteLength + +function slowToString (encoding, start, end) { + var loweredCase = false + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} + +// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect +// Buffer instances. +Buffer.prototype._isBuffer = true + +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i +} + +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this +} + +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} + +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} + +Buffer.prototype.toString = function toString () { + var length = this.length | 0 + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +} + +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} + +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') + if (this.length > max) str += ' ... ' + } + return '' +} + +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (!Buffer.isBuffer(target)) { + throw new TypeError('Argument must be a Buffer') + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (isNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (Buffer.TYPED_ARRAY_SUPPORT && + typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 +} + +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +} + +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +} + +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +} + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + // must be an even number of digits + var strLen = string.length + if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (isNaN(parsed)) return i + buf[offset + i] = parsed + } + return i +} + +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +} + +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} + +function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} + +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} + +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} + +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset | 0 + if (isFinite(length)) { + length = length | 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + // legacy write(string, encoding, offset, length) - remove in v0.13 + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} + +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } + + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res +} + +function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret +} + +function latin1Slice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) + } + return ret +} + +function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; ++i) { + out += toHex(buf[i]) + } + return out +} + +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) + } + return res +} + +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf + if (Buffer.TYPED_ARRAY_SUPPORT) { + newBuf = this.subarray(start, end) + newBuf.__proto__ = Buffer.prototype + } else { + var sliceLen = end - start + newBuf = new Buffer(sliceLen, undefined) + for (var i = 0; i < sliceLen; ++i) { + newBuf[i] = this[i + start] + } + } + + return newBuf +} + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val +} + +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val +} + +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} + +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) +} + +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] +} + +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} + +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} + +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +} + +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +} + +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +} + +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} + +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) +} + +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} + +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} + +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} + +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + this[offset] = (value & 0xff) + return offset + 1 +} + +function objectWriteUInt16 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { + buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> + (littleEndian ? i : 1 - i) * 8 + } +} + +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 +} + +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 +} + +function objectWriteUInt32 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffffffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { + buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff + } +} + +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 +} + +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 +} + +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 +} + +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 +} + +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 +} + +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 +} + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} + +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +} + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + var len = end - start + var i + + if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] + } + } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { + // ascending copy from start + for (i = 0; i < len; ++i) { + target[i + targetStart] = this[i + start] + } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, start + len), + targetStart + ) + } + + return len +} + +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if (code < 256) { + val = code + } + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + } else if (typeof val === 'number') { + val = val & 255 + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 + + var i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val + } + } else { + var bytes = Buffer.isBuffer(val) + ? val + : utf8ToBytes(new Buffer(val, encoding).toString()) + var len = bytes.length + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] + } + } + + return this +} + +// HELPER FUNCTIONS +// ================ + +var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g + +function base64clean (str) { + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = stringtrim(str).replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str +} + +function stringtrim (str) { + if (str.trim) return str.trim() + return str.replace(/^\s+|\s+$/g, '') +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } + + // valid lead + leadSurrogate = codePoint + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray +} + +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i +} + +function isnan (val) { + return val !== val // eslint-disable-line no-self-compare +} + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(38))) + +/***/ }), +/* 38 */ +/***/ (function(module, exports) { + +var g; + +// This works in non-strict mode +g = (function() { + return this; +})(); + +try { + // This works if eval is allowed (see CSP) + g = g || new Function("return this")(); +} catch (e) { + // This works if the window reference is available + if (typeof window === "object") g = window; +} + +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} + +module.exports = g; + + +/***/ }), +/* 39 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.byteLength = byteLength +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray + +var lookup = [] +var revLookup = [] +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i +} + +// Support decoding URL-safe base64 strings, as Node.js does. +// See: https://en.wikipedia.org/wiki/Base64#URL_applications +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 + +function getLens (b64) { + var len = b64.length + + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + var validLen = b64.indexOf('=') + if (validLen === -1) validLen = len + + var placeHoldersLen = validLen === len + ? 0 + : 4 - (validLen % 4) + + return [validLen, placeHoldersLen] +} + +// base64 is 4/3 + up to two characters of the original data +function byteLength (b64) { + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function _byteLength (b64, validLen, placeHoldersLen) { + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} + +function toByteArray (b64) { + var tmp + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) + + var curByte = 0 + + // if there are placeholders, only get up to the last complete 4 chars + var len = placeHoldersLen > 0 + ? validLen - 4 + : validLen + + var i + for (i = 0; i < len; i += 4) { + tmp = + (revLookup[b64.charCodeAt(i)] << 18) | + (revLookup[b64.charCodeAt(i + 1)] << 12) | + (revLookup[b64.charCodeAt(i + 2)] << 6) | + revLookup[b64.charCodeAt(i + 3)] + arr[curByte++] = (tmp >> 16) & 0xFF + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 2) { + tmp = + (revLookup[b64.charCodeAt(i)] << 2) | + (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[curByte++] = tmp & 0xFF + } + + if (placeHoldersLen === 1) { + tmp = + (revLookup[b64.charCodeAt(i)] << 10) | + (revLookup[b64.charCodeAt(i + 1)] << 4) | + (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + + lookup[num >> 12 & 0x3F] + + lookup[num >> 6 & 0x3F] + + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = + ((uint8[i] << 16) & 0xFF0000) + + ((uint8[i + 1] << 8) & 0xFF00) + + (uint8[i + 2] & 0xFF) + output.push(tripletToBase64(tmp)) + } + return output.join('') +} + +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk( + uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) + )) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + parts.push( + lookup[tmp >> 2] + + lookup[(tmp << 4) & 0x3F] + + '==' + ) + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + uint8[len - 1] + parts.push( + lookup[tmp >> 10] + + lookup[(tmp >> 4) & 0x3F] + + lookup[(tmp << 2) & 0x3F] + + '=' + ) + } + + return parts.join('') +} + + +/***/ }), +/* 40 */ +/***/ (function(module, exports) { + +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} + +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } + + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = ((value * c) - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128 +} + + +/***/ }), +/* 41 */ +/***/ (function(module, exports) { + +var toString = {}.toString; + +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; + + +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 }); +/** + * Represents audio stream format used for custom audio input configurations. + * @class AudioStreamFormat + */ +var AudioStreamFormat = /** @class */ (function () { + function AudioStreamFormat() { + } + /** + * Creates an audio stream format object representing the default audio stream + * format (16KHz 16bit mono PCM). + * @member AudioStreamFormat.getDefaultInputFormat + * @function + * @public + * @returns {AudioStreamFormat} The audio stream format being created. + */ + AudioStreamFormat.getDefaultInputFormat = function () { + return AudioStreamFormatImpl.getDefaultInputFormat(); + }; + /** + * Creates an audio stream format object with the specified pcm waveformat characteristics. + * @member AudioStreamFormat.getWaveFormatPCM + * @function + * @public + * @param {number} samplesPerSecond - Sample rate, in samples per second (Hertz). + * @param {number} bitsPerSample - Bits per sample, typically 16. + * @param {number} channels - Number of channels in the waveform-audio data. Monaural data + * uses one channel and stereo data uses two channels. + * @returns {AudioStreamFormat} The audio stream format being created. + */ + AudioStreamFormat.getWaveFormatPCM = function (samplesPerSecond, bitsPerSample, channels) { + return new AudioStreamFormatImpl(samplesPerSecond, bitsPerSample, channels); + }; + return AudioStreamFormat; +}()); +exports.AudioStreamFormat = AudioStreamFormat; +/** + * @private + * @class AudioStreamFormatImpl + */ +// tslint:disable-next-line:max-classes-per-file +var AudioStreamFormatImpl = /** @class */ (function (_super) { + __extends(AudioStreamFormatImpl, _super); + /** + * Creates an instance with the given values. + * @constructor + * @param {number} samplesPerSec - Samples per second. + * @param {number} bitsPerSample - Bits per sample. + * @param {number} channels - Number of channels. + */ + function AudioStreamFormatImpl(samplesPerSec, bitsPerSample, channels) { + if (samplesPerSec === void 0) { samplesPerSec = 16000; } + if (bitsPerSample === void 0) { bitsPerSample = 16; } + if (channels === void 0) { channels = 1; } + var _this = _super.call(this) || this; + _this.setString = function (view, offset, str) { + for (var i = 0; i < str.length; i++) { + view.setUint8(offset + i, str.charCodeAt(i)); + } + }; + _this.formatTag = 1; + _this.bitsPerSample = bitsPerSample; + _this.samplesPerSec = samplesPerSec; + _this.channels = channels; + _this.avgBytesPerSec = _this.samplesPerSec * _this.channels * (_this.bitsPerSample / 8); + _this.blockAlign = _this.channels * Math.max(_this.bitsPerSample, 8); + _this.privHeader = new ArrayBuffer(44); + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView + var view = new DataView(_this.privHeader); + /* RIFF identifier */ + _this.setString(view, 0, "RIFF"); + /* file length */ + view.setUint32(4, 0, true); + /* RIFF type & Format */ + _this.setString(view, 8, "WAVEfmt "); + /* format chunk length */ + view.setUint32(16, 16, true); + /* sample format (raw) */ + view.setUint16(20, 1, true); + /* channel count */ + view.setUint16(22, _this.channels, true); + /* sample rate */ + view.setUint32(24, _this.samplesPerSec, true); + /* byte rate (sample rate * block align) */ + view.setUint32(28, _this.avgBytesPerSec, true); + /* block align (channel count * bytes per sample) */ + view.setUint16(32, _this.channels * (_this.bitsPerSample / 8), true); + /* bits per sample */ + view.setUint16(34, _this.bitsPerSample, true); + /* data chunk identifier */ + _this.setString(view, 36, "data"); + /* data chunk length */ + view.setUint32(40, 0, true); + return _this; + } + /** + * Retrieves the default input format. + * @member AudioStreamFormatImpl.getDefaultInputFormat + * @function + * @public + * @returns {AudioStreamFormatImpl} The default input format. + */ + AudioStreamFormatImpl.getDefaultInputFormat = function () { + return new AudioStreamFormatImpl(); + }; + /** + * Closes the configuration object. + * @member AudioStreamFormatImpl.prototype.close + * @function + * @public + */ + AudioStreamFormatImpl.prototype.close = function () { return; }; + Object.defineProperty(AudioStreamFormatImpl.prototype, "header", { + get: function () { + return this.privHeader; + }, + enumerable: true, + configurable: true + }); + return AudioStreamFormatImpl; +}(AudioStreamFormat)); +exports.AudioStreamFormatImpl = AudioStreamFormatImpl; + + + +/***/ }), +/* 43 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(4); +var Contracts_1 = __webpack_require__(33); +var AudioOutputFormat_1 = __webpack_require__(44); +/** + * Represents audio output stream used for custom audio output configurations. + * @class AudioOutputStream + */ +var AudioOutputStream = /** @class */ (function () { + /** + * Creates and initializes an instance. + * @constructor + */ + function AudioOutputStream() { + } + /** + * Creates a memory backed PullAudioOutputStream with the specified audio format. + * @member AudioOutputStream.createPullStream + * @function + * @public + * @returns {PullAudioOutputStream} The audio output stream being created. + */ + AudioOutputStream.createPullStream = function () { + return PullAudioOutputStream.create(); + }; + return AudioOutputStream; +}()); +exports.AudioOutputStream = AudioOutputStream; +/** + * Represents memory backed push audio output stream used for custom audio output configurations. + * @class PullAudioOutputStream + */ +// tslint:disable-next-line:max-classes-per-file +var PullAudioOutputStream = /** @class */ (function (_super) { + __extends(PullAudioOutputStream, _super); + function PullAudioOutputStream() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Creates a memory backed PullAudioOutputStream with the specified audio format. + * @member PullAudioOutputStream.create + * @function + * @public + * @returns {PullAudioOutputStream} The push audio output stream being created. + */ + PullAudioOutputStream.create = function () { + return new PullAudioOutputStreamImpl(); + }; + return PullAudioOutputStream; +}(AudioOutputStream)); +exports.PullAudioOutputStream = PullAudioOutputStream; +/** + * Represents memory backed push audio output stream used for custom audio output configurations. + * @private + * @class PullAudioOutputStreamImpl + */ +// tslint:disable-next-line:max-classes-per-file +var PullAudioOutputStreamImpl = /** @class */ (function (_super) { + __extends(PullAudioOutputStreamImpl, _super); + /** + * Creates and initializes an instance with the given values. + * @constructor + */ + function PullAudioOutputStreamImpl() { + var _this = _super.call(this) || this; + _this.privId = Exports_1.createNoDashGuid(); + _this.privStream = new Exports_1.Stream(); + return _this; + } + Object.defineProperty(PullAudioOutputStreamImpl.prototype, "format", { + /** + * Format information for the audio + */ + get: function () { + return this.privFormat; + }, + /** + * Sets the format information to the stream. For internal use only. + * @param {AudioStreamFormat} format - the format to be set. + */ + set: function (format) { + if (format === undefined || format === null) { + this.privFormat = AudioOutputFormat_1.AudioOutputFormatImpl.getDefaultOutputFormat(); + } + this.privFormat = format; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(PullAudioOutputStreamImpl.prototype, "isClosed", { + /** + * Checks if the stream is closed + * @member PullAudioOutputStreamImpl.prototype.isClosed + * @property + * @public + */ + get: function () { + return this.privStream.isClosed; + }, + enumerable: true, + configurable: true + }); + /** + * Gets the id of the stream + * @member PullAudioOutputStreamImpl.prototype.id + * @property + * @public + */ + PullAudioOutputStreamImpl.prototype.id = function () { + return this.privId; + }; + /** + * Reads audio data from the internal buffer. + * @member PullAudioOutputStreamImpl.prototype.read + * @function + * @public + * @param {ArrayBuffer} dataBuffer - An ArrayBuffer to store the read data. + * @returns {Promise} - Audio buffer length has been read. + */ + PullAudioOutputStreamImpl.prototype.read = function (dataBuffer) { + var _this = this; + var intView = new Int8Array(dataBuffer); + var totalBytes = 0; + if (this.privLastChunkView !== undefined) { + if (this.privLastChunkView.length > dataBuffer.byteLength) { + intView.set(this.privLastChunkView.slice(0, dataBuffer.byteLength)); + this.privLastChunkView = this.privLastChunkView.slice(dataBuffer.byteLength); + return Exports_1.PromiseHelper.fromResult(dataBuffer.byteLength); + } + intView.set(this.privLastChunkView); + totalBytes = this.privLastChunkView.length; + this.privLastChunkView = undefined; + } + var deffer = new Exports_1.Deferred(); + // Until we have the minimum number of bytes to send in a transmission, keep asking for more. + var readUntilFilled = function () { + if (totalBytes < dataBuffer.byteLength && !_this.privStream.isReadEnded) { + _this.privStream.read() + .onSuccessContinueWith(function (chunk) { + if (chunk !== undefined && !chunk.isEnd) { + var tmpBuffer = void 0; + if (chunk.buffer.byteLength > dataBuffer.byteLength - totalBytes) { + tmpBuffer = chunk.buffer.slice(0, dataBuffer.byteLength - totalBytes); + _this.privLastChunkView = new Int8Array(chunk.buffer.slice(dataBuffer.byteLength - totalBytes)); + } + else { + tmpBuffer = chunk.buffer; + } + intView.set(new Int8Array(tmpBuffer), totalBytes); + totalBytes += tmpBuffer.byteLength; + readUntilFilled(); + } + else { + _this.privStream.readEnded(); + deffer.resolve(totalBytes); + } + }); + } + else { + deffer.resolve(totalBytes); + } + }; + readUntilFilled(); + return deffer.promise(); + }; + /** + * Writes the audio data specified by making an internal copy of the data. + * @member PullAudioOutputStreamImpl.prototype.write + * @function + * @public + * @param {ArrayBuffer} dataBuffer - The audio buffer of which this function will make a copy. + */ + PullAudioOutputStreamImpl.prototype.write = function (dataBuffer) { + Contracts_1.Contracts.throwIfNullOrUndefined(this.privStream, "must set format before writing"); + this.privStream.writeStreamChunk({ + buffer: dataBuffer, + isEnd: false, + timeReceived: Date.now() + }); + }; + /** + * Closes the stream. + * @member PullAudioOutputStreamImpl.prototype.close + * @function + * @public + */ + PullAudioOutputStreamImpl.prototype.close = function () { + this.privStream.close(); + }; + return PullAudioOutputStreamImpl; +}(PullAudioOutputStream)); +exports.PullAudioOutputStreamImpl = PullAudioOutputStreamImpl; +/* + * Represents audio output stream used for custom audio output configurations. + * @class PushAudioOutputStream + */ +// tslint:disable-next-line:max-classes-per-file +var PushAudioOutputStream = /** @class */ (function (_super) { + __extends(PushAudioOutputStream, _super); + /** + * Creates and initializes and instance. + * @constructor + */ + function PushAudioOutputStream() { + return _super.call(this) || this; + } + /** + * Creates a PushAudioOutputStream that delegates to the specified callback interface for + * write() and close() methods. + * @member PushAudioOutputStream.create + * @function + * @public + * @param {PushAudioOutputStreamCallback} callback - The custom audio output object, + * derived from PushAudioOutputStreamCallback + * @returns {PushAudioOutputStream} The push audio output stream being created. + */ + PushAudioOutputStream.create = function (callback) { + return new PushAudioOutputStreamImpl(callback); + }; + return PushAudioOutputStream; +}(AudioOutputStream)); +exports.PushAudioOutputStream = PushAudioOutputStream; +/** + * Represents audio output stream used for custom audio output configurations. + * @private + * @class PushAudioOutputStreamImpl + */ +// tslint:disable-next-line:max-classes-per-file +var PushAudioOutputStreamImpl = /** @class */ (function (_super) { + __extends(PushAudioOutputStreamImpl, _super); + /** + * Creates a PushAudioOutputStream that delegates to the specified callback interface for + * read() and close() methods. + * @constructor + * @param {PushAudioOutputStreamCallback} callback - The custom audio output object, + * derived from PushAudioOutputStreamCallback + */ + function PushAudioOutputStreamImpl(callback) { + var _this = _super.call(this) || this; + _this.privId = Exports_1.createNoDashGuid(); + _this.privCallback = callback; + return _this; + } + Object.defineProperty(PushAudioOutputStreamImpl.prototype, "format", { + // tslint:disable-next-line:no-empty + set: function (format) { }, + enumerable: true, + configurable: true + }); + PushAudioOutputStreamImpl.prototype.write = function (buffer) { + if (!!this.privCallback.write) { + this.privCallback.write(buffer); + } + }; + PushAudioOutputStreamImpl.prototype.close = function () { + if (!!this.privCallback.close) { + this.privCallback.close(); + } + }; + PushAudioOutputStreamImpl.prototype.id = function () { + return this.privId; + }; + return PushAudioOutputStreamImpl; +}(PushAudioOutputStream)); +exports.PushAudioOutputStreamImpl = PushAudioOutputStreamImpl; + + + +/***/ }), +/* 44 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 __()); + }; +})(); +var _a; +Object.defineProperty(exports, "__esModule", { value: true }); +var SpeechSynthesisOutputFormat_1 = __webpack_require__(45); +var AudioStreamFormat_1 = __webpack_require__(42); +var AudioFormatTag; +(function (AudioFormatTag) { + AudioFormatTag[AudioFormatTag["PCM"] = 1] = "PCM"; + AudioFormatTag[AudioFormatTag["MuLaw"] = 2] = "MuLaw"; + AudioFormatTag[AudioFormatTag["Siren"] = 3] = "Siren"; + AudioFormatTag[AudioFormatTag["MP3"] = 4] = "MP3"; + AudioFormatTag[AudioFormatTag["SILKSkype"] = 5] = "SILKSkype"; + AudioFormatTag[AudioFormatTag["Opus"] = 6] = "Opus"; +})(AudioFormatTag = exports.AudioFormatTag || (exports.AudioFormatTag = {})); +/** + * @private + * @class AudioOutputFormatImpl + * Added in version 1.11.0 + */ +// tslint:disable-next-line:max-classes-per-file +var AudioOutputFormatImpl = /** @class */ (function (_super) { + __extends(AudioOutputFormatImpl, _super); + /** + * Creates an instance with the given values. + * @constructor + * @param formatTag + * @param {number} samplesPerSec - Samples per second. + * @param {number} bitsPerSample - Bits per sample. + * @param {number} channels - Number of channels. + * @param avgBytesPerSec + * @param blockAlign + * @param audioFormatString + * @param requestAudioFormatString + * @param hasHeader + */ + function AudioOutputFormatImpl(formatTag, channels, samplesPerSec, avgBytesPerSec, blockAlign, bitsPerSample, audioFormatString, requestAudioFormatString, hasHeader) { + var _this = _super.call(this, samplesPerSec, bitsPerSample, channels) || this; + _this.formatTag = formatTag; + _this.avgBytesPerSec = avgBytesPerSec; + _this.blockAlign = blockAlign; + _this.priAudioFormatString = audioFormatString; + _this.priRequestAudioFormatString = requestAudioFormatString; + _this.priHasHeader = hasHeader; + return _this; + } + AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat = function (speechSynthesisOutputFormat) { + if (speechSynthesisOutputFormat === undefined) { + return AudioOutputFormatImpl.getDefaultOutputFormat(); + } + return AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString(AudioOutputFormatImpl.SpeechSynthesisOutputFormatToString[speechSynthesisOutputFormat]); + }; + AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString = function (speechSynthesisOutputFormatString) { + switch (speechSynthesisOutputFormatString) { + case "raw-8khz-8bit-mono-mulaw": + return new AudioOutputFormatImpl(AudioFormatTag.PCM, 1, 8000, 8000, 1, 8, speechSynthesisOutputFormatString, speechSynthesisOutputFormatString, false); + case "riff-16khz-16kbps-mono-siren": + return new AudioOutputFormatImpl(AudioFormatTag.Siren, 1, 16000, 2000, 40, 0, speechSynthesisOutputFormatString, "audio-16khz-16kbps-mono-siren", true); + case "audio-16khz-16kbps-mono-siren": + return new AudioOutputFormatImpl(AudioFormatTag.Siren, 1, 16000, 2000, 40, 0, speechSynthesisOutputFormatString, speechSynthesisOutputFormatString, false); + case "audio-16khz-32kbitrate-mono-mp3": + return new AudioOutputFormatImpl(AudioFormatTag.MP3, 1, 16000, 32 << 7, 2, 16, speechSynthesisOutputFormatString, speechSynthesisOutputFormatString, false); + case "audio-16khz-128kbitrate-mono-mp3": + return new AudioOutputFormatImpl(AudioFormatTag.MP3, 1, 16000, 128 << 7, 2, 16, speechSynthesisOutputFormatString, speechSynthesisOutputFormatString, false); + case "audio-16khz-64kbitrate-mono-mp3": + return new AudioOutputFormatImpl(AudioFormatTag.MP3, 1, 16000, 64 << 7, 2, 16, speechSynthesisOutputFormatString, speechSynthesisOutputFormatString, false); + case "audio-24khz-48kbitrate-mono-mp3": + return new AudioOutputFormatImpl(AudioFormatTag.MP3, 1, 16000, 48 << 7, 2, 16, speechSynthesisOutputFormatString, speechSynthesisOutputFormatString, false); + case "audio-24khz-96kbitrate-mono-mp3": + return new AudioOutputFormatImpl(AudioFormatTag.MP3, 1, 16000, 96 << 7, 2, 16, speechSynthesisOutputFormatString, speechSynthesisOutputFormatString, false); + case "audio-24khz-160kbitrate-mono-mp3": + return new AudioOutputFormatImpl(AudioFormatTag.MP3, 1, 16000, 160 << 7, 2, 16, speechSynthesisOutputFormatString, speechSynthesisOutputFormatString, false); + case "raw-16khz-16bit-mono-truesilk": + return new AudioOutputFormatImpl(AudioFormatTag.SILKSkype, 1, 16000, 32000, 2, 16, speechSynthesisOutputFormatString, speechSynthesisOutputFormatString, false); + case "riff-8khz-16bit-mono-pcm": + return new AudioOutputFormatImpl(AudioFormatTag.PCM, 1, 8000, 16000, 2, 16, speechSynthesisOutputFormatString, "raw-8khz-16bit-mono-pcm", true); + case "riff-24khz-16bit-mono-pcm": + return new AudioOutputFormatImpl(AudioFormatTag.PCM, 1, 24000, 48000, 2, 16, speechSynthesisOutputFormatString, "raw-24khz-16bit-mono-pcm", true); + case "riff-8khz-8bit-mono-mulaw": + return new AudioOutputFormatImpl(AudioFormatTag.MuLaw, 1, 8000, 8000, 1, 8, speechSynthesisOutputFormatString, "raw-8khz-8bit-mono-mulaw", true); + case "raw-16khz-16bit-mono-pcm": + return new AudioOutputFormatImpl(AudioFormatTag.PCM, 1, 16000, 32000, 2, 16, speechSynthesisOutputFormatString, "raw-16khz-16bit-mono-pcm", false); + case "raw-24khz-16bit-mono-pcm": + return new AudioOutputFormatImpl(AudioFormatTag.PCM, 1, 24000, 48000, 2, 16, speechSynthesisOutputFormatString, "raw-24khz-16bit-mono-pcm", false); + case "raw-8khz-16bit-mono-pcm": + return new AudioOutputFormatImpl(AudioFormatTag.PCM, 1, 8000, 16000, 2, 16, speechSynthesisOutputFormatString, "raw-8khz-16bit-mono-pcm", false); + case "ogg-16khz-16bit-mono-opus": + return new AudioOutputFormatImpl(AudioFormatTag.Opus, 1, 16000, 8192, 2, 16, speechSynthesisOutputFormatString, "ogg-16khz-16bit-mono-opus", false); + case "ogg-24khz-16bit-mono-opus": + return new AudioOutputFormatImpl(AudioFormatTag.Opus, 1, 24000, 8192, 2, 16, speechSynthesisOutputFormatString, "ogg-24khz-16bit-mono-opus", false); + case "riff-16khz-16bit-mono-pcm": + default: + return new AudioOutputFormatImpl(AudioFormatTag.PCM, 1, 16000, 32000, 2, 16, "riff-16khz-16bit-mono-pcm", "raw-16khz-16bit-mono-pcm", true); + } + }; + AudioOutputFormatImpl.getDefaultOutputFormat = function () { + return AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString((typeof window !== "undefined") ? "audio-24khz-48kbitrate-mono-mp3" : "riff-16khz-16bit-mono-pcm"); + }; + Object.defineProperty(AudioOutputFormatImpl.prototype, "hasHeader", { + /** + * Specifies if this audio output format has a header + * @boolean AudioOutputFormatImpl.prototype.hasHeader + * @function + * @public + */ + get: function () { + return this.priHasHeader; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AudioOutputFormatImpl.prototype, "header", { + /** + * Specifies the header of this format + * @ArrayBuffer AudioOutputFormatImpl.prototype.header + * @function + * @public + */ + get: function () { + if (this.hasHeader) { + return this.privHeader; + } + return undefined; + }, + enumerable: true, + configurable: true + }); + /** + * Updates the header based on the audio length + * @member AudioOutputFormatImpl.updateHeader + * @function + * @public + * @param {number} audioLength - the audio length + */ + AudioOutputFormatImpl.prototype.updateHeader = function (audioLength) { + if (this.priHasHeader) { + var view = new DataView(this.privHeader); + view.setUint32(40, audioLength, true); + } + }; + Object.defineProperty(AudioOutputFormatImpl.prototype, "requestAudioFormatString", { + /** + * Specifies the audio format string to be sent to the service + * @string AudioOutputFormatImpl.prototype.requestAudioFormatString + * @function + * @public + */ + get: function () { + return this.priRequestAudioFormatString; + }, + enumerable: true, + configurable: true + }); + AudioOutputFormatImpl.SpeechSynthesisOutputFormatToString = (_a = {}, + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoMULaw] = "raw-8khz-8bit-mono-mulaw", + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren] = "riff-16khz-16kbps-mono-siren", + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Audio16Khz16KbpsMonoSiren] = "audio-16khz-16kbps-mono-siren", + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3] = "audio-16khz-32kbitrate-mono-mp3", + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3] = "audio-16khz-128kbitrate-mono-mp3", + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3] = "audio-16khz-64kbitrate-mono-mp3", + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3] = "audio-24khz-48kbitrate-mono-mp3", + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3] = "audio-24khz-96kbitrate-mono-mp3", + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3] = "audio-24khz-160kbitrate-mono-mp3", + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoTrueSilk] = "raw-16khz-16bit-mono-truesilk", + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm] = "riff-16khz-16bit-mono-pcm", + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm] = "riff-8khz-16bit-mono-pcm", + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm] = "riff-24khz-16bit-mono-pcm", + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoMULaw] = "riff-8khz-8bit-mono-mulaw", + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoPcm] = "raw-16khz-16bit-mono-pcm", + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoPcm] = "raw-24khz-16bit-mono-pcm", + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm] = "raw-8khz-16bit-mono-pcm", + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Ogg16Khz16BitMonoOpus] = "ogg-16khz-16bit-mono-opus", + _a[SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat.Ogg24Khz16BitMonoOpus] = "ogg-24khz-16bit-mono-opus", + _a); + return AudioOutputFormatImpl; +}(AudioStreamFormat_1.AudioStreamFormatImpl)); +exports.AudioOutputFormatImpl = AudioOutputFormatImpl; + + + +/***/ }), +/* 45 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Define speech synthesis audio output formats. + * @enum SpeechSynthesisOutputFormat + * Added in version 1.11.0 + */ +var SpeechSynthesisOutputFormat; +(function (SpeechSynthesisOutputFormat) { + /** + * raw-8khz-8bit-mono-mulaw + * @member SpeechSynthesisOutputFormat.Raw8Khz8BitMonoMULaw, + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Raw8Khz8BitMonoMULaw"] = 0] = "Raw8Khz8BitMonoMULaw"; + /** + * riff-16khz-16kbps-mono-siren + * @member SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Riff16Khz16KbpsMonoSiren"] = 1] = "Riff16Khz16KbpsMonoSiren"; + /** + * audio-16khz-16kbps-mono-siren + * @member SpeechSynthesisOutputFormat.Audio16Khz16KbpsMonoSiren + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Audio16Khz16KbpsMonoSiren"] = 2] = "Audio16Khz16KbpsMonoSiren"; + /** + * audio-16khz-32kbitrate-mono-mp3 + * @member SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3 + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Audio16Khz32KBitRateMonoMp3"] = 3] = "Audio16Khz32KBitRateMonoMp3"; + /** + * audio-16khz-128kbitrate-mono-mp3 + * @member SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3 + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Audio16Khz128KBitRateMonoMp3"] = 4] = "Audio16Khz128KBitRateMonoMp3"; + /** + * audio-16khz-64kbitrate-mono-mp3 + * @member SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3 + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Audio16Khz64KBitRateMonoMp3"] = 5] = "Audio16Khz64KBitRateMonoMp3"; + /** + * audio-24khz-48kbitrate-mono-mp3 + * @member SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3 + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Audio24Khz48KBitRateMonoMp3"] = 6] = "Audio24Khz48KBitRateMonoMp3"; + /** + * audio-24khz-96kbitrate-mono-mp3 + * @member SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3 + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Audio24Khz96KBitRateMonoMp3"] = 7] = "Audio24Khz96KBitRateMonoMp3"; + /** + * audio-24khz-160kbitrate-mono-mp3 + * @member SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3 + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Audio24Khz160KBitRateMonoMp3"] = 8] = "Audio24Khz160KBitRateMonoMp3"; + /** + * raw-16khz-16bit-mono-truesilk + * @member SpeechSynthesisOutputFormat.Raw16Khz16BitMonoTrueSilk + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Raw16Khz16BitMonoTrueSilk"] = 9] = "Raw16Khz16BitMonoTrueSilk"; + /** + * riff-16khz-16bit-mono-pcm + * @member SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Riff16Khz16BitMonoPcm"] = 10] = "Riff16Khz16BitMonoPcm"; + /** + * riff-8khz-16bit-mono-pcm + * @member SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Riff8Khz16BitMonoPcm"] = 11] = "Riff8Khz16BitMonoPcm"; + /** + * riff-24khz-16bit-mono-pcm + * @member SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Riff24Khz16BitMonoPcm"] = 12] = "Riff24Khz16BitMonoPcm"; + /** + * riff-8khz-8bit-mono-mulaw + * @member SpeechSynthesisOutputFormat.Riff8Khz8BitMonoMULaw + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Riff8Khz8BitMonoMULaw"] = 13] = "Riff8Khz8BitMonoMULaw"; + /** + * raw-16khz-16bit-mono-pcm + * @member SpeechSynthesisOutputFormat.Raw16Khz16BitMonoPcm + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Raw16Khz16BitMonoPcm"] = 14] = "Raw16Khz16BitMonoPcm"; + /** + * raw-24khz-16bit-mono-pcm + * @member SpeechSynthesisOutputFormat.Raw24Khz16BitMonoPcm + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Raw24Khz16BitMonoPcm"] = 15] = "Raw24Khz16BitMonoPcm"; + /** + * raw-8khz-16bit-mono-pcm + * @member SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Raw8Khz16BitMonoPcm"] = 16] = "Raw8Khz16BitMonoPcm"; + /** + * ogg-16khz-16bit-mono-opus + * @member SpeechSynthesisOutputFormat.Ogg16Khz16BitMonoOpus + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Ogg16Khz16BitMonoOpus"] = 17] = "Ogg16Khz16BitMonoOpus"; + /** + * ogg-24khz-16bit-mono-opus + * @member SpeechSynthesisOutputFormat.Ogg24Khz16BitMonoOpus + */ + SpeechSynthesisOutputFormat[SpeechSynthesisOutputFormat["Ogg24Khz16BitMonoOpus"] = 18] = "Ogg24Khz16BitMonoOpus"; +})(SpeechSynthesisOutputFormat = exports.SpeechSynthesisOutputFormat || (exports.SpeechSynthesisOutputFormat = {})); + + + +/***/ }), +/* 46 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Defines the possible reasons a recognition result might be canceled. + * @class CancellationReason + */ +var CancellationReason; +(function (CancellationReason) { + /** + * Indicates that an error occurred during speech recognition. + * @member CancellationReason.Error + */ + CancellationReason[CancellationReason["Error"] = 0] = "Error"; + /** + * Indicates that the end of the audio stream was reached. + * @member CancellationReason.EndOfStream + */ + CancellationReason[CancellationReason["EndOfStream"] = 1] = "EndOfStream"; +})(CancellationReason = exports.CancellationReason || (exports.CancellationReason = {})); + + + +/***/ }), +/* 47 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +/** + * An abstract base class that defines callback methods (read() and close()) for + * custom audio input streams). + * @class PullAudioInputStreamCallback + */ +var PullAudioInputStreamCallback = /** @class */ (function () { + function PullAudioInputStreamCallback() { + } + return PullAudioInputStreamCallback; +}()); +exports.PullAudioInputStreamCallback = PullAudioInputStreamCallback; + + + +/***/ }), +/* 48 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +/** + * An abstract base class that defines callback methods (write() and close()) for + * custom audio output streams). + * @class PushAudioOutputStreamCallback + */ +var PushAudioOutputStreamCallback = /** @class */ (function () { + function PushAudioOutputStreamCallback() { + } + return PushAudioOutputStreamCallback; +}()); +exports.PushAudioOutputStreamCallback = PushAudioOutputStreamCallback; + + + +/***/ }), +/* 49 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Contracts_1 = __webpack_require__(33); +/** + * Represents a keyword recognition model for recognizing when + * the user says a keyword to initiate further speech recognition. + * @class KeywordRecognitionModel + */ +var KeywordRecognitionModel = /** @class */ (function () { + /** + * Create and initializes a new instance. + * @constructor + */ + function KeywordRecognitionModel() { + this.privDisposed = false; + } + /** + * Creates a keyword recognition model using the specified filename. + * @member KeywordRecognitionModel.fromFile + * @function + * @public + * @param {string} fileName - A string that represents file name for the keyword recognition model. + * Note, the file can point to a zip file in which case the model + * will be extracted from the zip. + * @returns {KeywordRecognitionModel} The keyword recognition model being created. + */ + KeywordRecognitionModel.fromFile = function (fileName) { + Contracts_1.Contracts.throwIfFileDoesNotExist(fileName, "fileName"); + throw new Error("Not yet implemented."); + }; + /** + * Creates a keyword recognition model using the specified filename. + * @member KeywordRecognitionModel.fromStream + * @function + * @public + * @param {string} file - A File that represents file for the keyword recognition model. + * Note, the file can point to a zip file in which case the model will be extracted from the zip. + * @returns {KeywordRecognitionModel} The keyword recognition model being created. + */ + KeywordRecognitionModel.fromStream = function (file) { + Contracts_1.Contracts.throwIfNull(file, "file"); + throw new Error("Not yet implemented."); + }; + /** + * Dispose of associated resources. + * @member KeywordRecognitionModel.prototype.close + * @function + * @public + */ + KeywordRecognitionModel.prototype.close = function () { + if (this.privDisposed) { + return; + } + this.privDisposed = true; + }; + return KeywordRecognitionModel; +}()); +exports.KeywordRecognitionModel = KeywordRecognitionModel; + + + +/***/ }), +/* 50 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Defines content for session events like SessionStarted/Stopped, SoundStarted/Stopped. + * @class SessionEventArgs + */ +var SessionEventArgs = /** @class */ (function () { + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {string} sessionId - The session id. + */ + function SessionEventArgs(sessionId) { + this.privSessionId = sessionId; + } + Object.defineProperty(SessionEventArgs.prototype, "sessionId", { + /** + * Represents the session identifier. + * @member SessionEventArgs.prototype.sessionId + * @function + * @public + * @returns {string} Represents the session identifier. + */ + get: function () { + return this.privSessionId; + }, + enumerable: true, + configurable: true + }); + return SessionEventArgs; +}()); +exports.SessionEventArgs = SessionEventArgs; + + + +/***/ }), +/* 51 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(31); +/** + * Defines payload for session events like Speech Start/End Detected + * @class + */ +var RecognitionEventArgs = /** @class */ (function (_super) { + __extends(RecognitionEventArgs, _super); + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {number} offset - The offset. + * @param {string} sessionId - The session id. + */ + function RecognitionEventArgs(offset, sessionId) { + var _this = _super.call(this, sessionId) || this; + _this.privOffset = offset; + return _this; + } + Object.defineProperty(RecognitionEventArgs.prototype, "offset", { + /** + * Represents the message offset + * @member RecognitionEventArgs.prototype.offset + * @function + * @public + */ + get: function () { + return this.privOffset; + }, + enumerable: true, + configurable: true + }); + return RecognitionEventArgs; +}(Exports_1.SessionEventArgs)); +exports.RecognitionEventArgs = RecognitionEventArgs; + + + +/***/ }), +/* 52 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Define Speech Recognizer output formats. + * @class OutputFormat + */ +var OutputFormat; +(function (OutputFormat) { + /** + * @member OutputFormat.Simple + */ + OutputFormat[OutputFormat["Simple"] = 0] = "Simple"; + /** + * @member OutputFormat.Detailed + */ + OutputFormat[OutputFormat["Detailed"] = 1] = "Detailed"; +})(OutputFormat = exports.OutputFormat || (exports.OutputFormat = {})); + + + +/***/ }), +/* 53 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(31); +/** + * Intent recognition result event arguments. + * @class + */ +var IntentRecognitionEventArgs = /** @class */ (function (_super) { + __extends(IntentRecognitionEventArgs, _super); + /** + * Creates and initializes an instance of this class. + * @constructor + * @param result - The result of the intent recognition. + * @param offset - The offset. + * @param sessionId - The session id. + */ + function IntentRecognitionEventArgs(result, offset, sessionId) { + var _this = _super.call(this, offset, sessionId) || this; + _this.privResult = result; + return _this; + } + Object.defineProperty(IntentRecognitionEventArgs.prototype, "result", { + /** + * Represents the intent recognition result. + * @member IntentRecognitionEventArgs.prototype.result + * @function + * @public + * @returns {IntentRecognitionResult} Represents the intent recognition result. + */ + get: function () { + return this.privResult; + }, + enumerable: true, + configurable: true + }); + return IntentRecognitionEventArgs; +}(Exports_1.RecognitionEventArgs)); +exports.IntentRecognitionEventArgs = IntentRecognitionEventArgs; + + + +/***/ }), +/* 54 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Defines result of speech recognition. + * @class RecognitionResult + */ +var RecognitionResult = /** @class */ (function () { + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {string} resultId - The result id. + * @param {ResultReason} reason - The reason. + * @param {string} text - The recognized text. + * @param {number} duration - The duration. + * @param {number} offset - The offset into the stream. + * @param {string} language - Primary Language detected, if provided. + * @param {string} languageDetectionConfidence - Primary Language confidence ("Unknown," "Low," "Medium," "High"...), if provided. + * @param {string} errorDetails - Error details, if provided. + * @param {string} json - Additional Json, if provided. + * @param {PropertyCollection} properties - Additional properties, if provided. + */ + function RecognitionResult(resultId, reason, text, duration, offset, language, languageDetectionConfidence, errorDetails, json, properties) { + this.privResultId = resultId; + this.privReason = reason; + this.privText = text; + this.privDuration = duration; + this.privOffset = offset; + this.privLanguage = language; + this.privLanguageDetectionConfidence = languageDetectionConfidence; + this.privErrorDetails = errorDetails; + this.privJson = json; + this.privProperties = properties; + } + Object.defineProperty(RecognitionResult.prototype, "resultId", { + /** + * Specifies the result identifier. + * @member RecognitionResult.prototype.resultId + * @function + * @public + * @returns {string} Specifies the result identifier. + */ + get: function () { + return this.privResultId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognitionResult.prototype, "reason", { + /** + * Specifies status of the result. + * @member RecognitionResult.prototype.reason + * @function + * @public + * @returns {ResultReason} Specifies status of the result. + */ + get: function () { + return this.privReason; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognitionResult.prototype, "text", { + /** + * Presents the recognized text in the result. + * @member RecognitionResult.prototype.text + * @function + * @public + * @returns {string} Presents the recognized text in the result. + */ + get: function () { + return this.privText; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognitionResult.prototype, "duration", { + /** + * Duration of recognized speech in 100 nano second incements. + * @member RecognitionResult.prototype.duration + * @function + * @public + * @returns {number} Duration of recognized speech in 100 nano second incements. + */ + get: function () { + return this.privDuration; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognitionResult.prototype, "offset", { + /** + * Offset of recognized speech in 100 nano second incements. + * @member RecognitionResult.prototype.offset + * @function + * @public + * @returns {number} Offset of recognized speech in 100 nano second incements. + */ + get: function () { + return this.privOffset; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognitionResult.prototype, "language", { + /** + * Primary Language detected. + * @member RecognitionResult.prototype.language + * @function + * @public + * @returns {string} language detected. + */ + get: function () { + return this.privLanguage; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognitionResult.prototype, "languageDetectionConfidence", { + /** + * Primary Language detection confidence (Unknown, Low, Medium, High). + * @member RecognitionResult.prototype.languageDetectionConfidence + * @function + * @public + * @returns {string} detection confidence strength. + */ + get: function () { + return this.privLanguageDetectionConfidence; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognitionResult.prototype, "errorDetails", { + /** + * In case of an unsuccessful recognition, provides details of the occurred error. + * @member RecognitionResult.prototype.errorDetails + * @function + * @public + * @returns {string} a brief description of an error. + */ + get: function () { + return this.privErrorDetails; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognitionResult.prototype, "json", { + /** + * A string containing Json serialized recognition result as it was received from the service. + * @member RecognitionResult.prototype.json + * @function + * @private + * @returns {string} Json serialized representation of the result. + */ + get: function () { + return this.privJson; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognitionResult.prototype, "properties", { + /** + * The set of properties exposed in the result. + * @member RecognitionResult.prototype.properties + * @function + * @public + * @returns {PropertyCollection} The set of properties exposed in the result. + */ + get: function () { + return this.privProperties; + }, + enumerable: true, + configurable: true + }); + return RecognitionResult; +}()); +exports.RecognitionResult = RecognitionResult; + + + +/***/ }), +/* 55 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(31); +/** + * Defines result of speech recognition. + * @class SpeechRecognitionResult + */ +var SpeechRecognitionResult = /** @class */ (function (_super) { + __extends(SpeechRecognitionResult, _super); + /** + * Creates and initializes an instance of this class. + * @constructor + * @public + * @param {string} resultId - The result id. + * @param {ResultReason} reason - The reason. + * @param {string} text - The recognized text. + * @param {number} duration - The duration. + * @param {number} offset - The offset into the stream. + * @param {string} language - Primary Language detected, if provided. + * @param {string} languageDetectionConfidence - Primary Language confidence ("Unknown," "Low," "Medium," "High"...), if provided. + * @param {string} errorDetails - Error details, if provided. + * @param {string} json - Additional Json, if provided. + * @param {PropertyCollection} properties - Additional properties, if provided. + */ + function SpeechRecognitionResult(resultId, reason, text, duration, offset, language, languageDetectionConfidence, errorDetails, json, properties) { + return _super.call(this, resultId, reason, text, duration, offset, language, languageDetectionConfidence, errorDetails, json, properties) || this; + } + return SpeechRecognitionResult; +}(Exports_1.RecognitionResult)); +exports.SpeechRecognitionResult = SpeechRecognitionResult; + + + +/***/ }), +/* 56 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(31); +/** + * Intent recognition result. + * @class + */ +var IntentRecognitionResult = /** @class */ (function (_super) { + __extends(IntentRecognitionResult, _super); + /** + * Creates and initializes an instance of this class. + * @constructor + * @param intentId - The intent id. + * @param resultId - The result id. + * @param reason - The reason. + * @param text - The recognized text. + * @param duration - The duration. + * @param offset - The offset into the stream. + * @param language - Primary Language detected, if provided. + * @param languageDetectionConfidence - Primary Language confidence ("Unknown," "Low," "Medium," "High"...), if provided. + * @param errorDetails - Error details, if provided. + * @param json - Additional Json, if provided. + * @param properties - Additional properties, if provided. + */ + function IntentRecognitionResult(intentId, resultId, reason, text, duration, offset, language, languageDetectionConfidence, errorDetails, json, properties) { + var _this = _super.call(this, resultId, reason, text, duration, offset, language, languageDetectionConfidence, errorDetails, json, properties) || this; + _this.privIntentId = intentId; + return _this; + } + Object.defineProperty(IntentRecognitionResult.prototype, "intentId", { + /** + * A String that represents the intent identifier being recognized. + * @member IntentRecognitionResult.prototype.intentId + * @function + * @public + * @returns {string} A String that represents the intent identifier being recognized. + */ + get: function () { + return this.privIntentId; + }, + enumerable: true, + configurable: true + }); + return IntentRecognitionResult; +}(Exports_1.SpeechRecognitionResult)); +exports.IntentRecognitionResult = IntentRecognitionResult; + + + +/***/ }), +/* 57 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 = __webpack_require__(33); +/** + * Language understanding model + * @class LanguageUnderstandingModel + */ +var LanguageUnderstandingModel = /** @class */ (function () { + /** + * Creates and initializes a new instance + * @constructor + */ + function LanguageUnderstandingModel() { + } + /** + * Creates an language understanding model using the specified endpoint. + * @member LanguageUnderstandingModel.fromEndpoint + * @function + * @public + * @param {URL} uri - A String that represents the endpoint of the language understanding model. + * @returns {LanguageUnderstandingModel} The language understanding model being created. + */ + LanguageUnderstandingModel.fromEndpoint = function (uri) { + Contracts_1.Contracts.throwIfNull(uri, "uri"); + Contracts_1.Contracts.throwIfNullOrWhitespace(uri.hostname, "uri"); + var langModelImp = new LanguageUnderstandingModelImpl(); + // Need to extract the app ID from the URL. + // URL is in the format: https://.api.cognitive.microsoft.com/luis/v2.0/apps/?subscription-key=&timezoneOffset=-360 + // Start tearing the string apart. + // region can be extracted from the host name. + var firstDot = uri.host.indexOf("."); + if (-1 === firstDot) { + throw new Error("Could not determine region from endpoint"); + } + langModelImp.region = uri.host.substr(0, firstDot); + // Now the app ID. + var lastSegment = uri.pathname.lastIndexOf("/") + 1; + if (-1 === lastSegment) { + throw new Error("Could not determine appId from endpoint"); + } + langModelImp.appId = uri.pathname.substr(lastSegment); + // And finally the key. + langModelImp.subscriptionKey = uri.searchParams.get("subscription-key"); + if (undefined === langModelImp.subscriptionKey) { + throw new Error("Could not determine subscription key from endpoint"); + } + return langModelImp; + }; + /** + * Creates an language understanding model using the application id of Language Understanding service. + * @member LanguageUnderstandingModel.fromAppId + * @function + * @public + * @param {string} appId - A String that represents the application id of Language Understanding service. + * @returns {LanguageUnderstandingModel} The language understanding model being created. + */ + LanguageUnderstandingModel.fromAppId = function (appId) { + Contracts_1.Contracts.throwIfNullOrWhitespace(appId, "appId"); + var langModelImp = new LanguageUnderstandingModelImpl(); + langModelImp.appId = appId; + return langModelImp; + }; + /** + * Creates a language understanding model using hostname, subscription key and application + * id of Language Understanding service. + * @member LanguageUnderstandingModel.fromSubscription + * @function + * @public + * @param {string} subscriptionKey - A String that represents the subscription key of + * Language Understanding service. + * @param {string} appId - A String that represents the application id of Language + * Understanding service. + * @param {LanguageUnderstandingModel} region - A String that represents the region + * of the Language Understanding service (see the region page). + * @returns {LanguageUnderstandingModel} The language understanding model being created. + */ + LanguageUnderstandingModel.fromSubscription = function (subscriptionKey, appId, region) { + Contracts_1.Contracts.throwIfNullOrWhitespace(subscriptionKey, "subscriptionKey"); + Contracts_1.Contracts.throwIfNullOrWhitespace(appId, "appId"); + Contracts_1.Contracts.throwIfNullOrWhitespace(region, "region"); + var langModelImp = new LanguageUnderstandingModelImpl(); + langModelImp.appId = appId; + langModelImp.region = region; + langModelImp.subscriptionKey = subscriptionKey; + return langModelImp; + }; + return LanguageUnderstandingModel; +}()); +exports.LanguageUnderstandingModel = LanguageUnderstandingModel; +/** + * @private + * @class LanguageUnderstandingModelImpl + */ +// tslint:disable-next-line:max-classes-per-file +var LanguageUnderstandingModelImpl = /** @class */ (function (_super) { + __extends(LanguageUnderstandingModelImpl, _super); + function LanguageUnderstandingModelImpl() { + return _super !== null && _super.apply(this, arguments) || this; + } + return LanguageUnderstandingModelImpl; +}(LanguageUnderstandingModel)); +exports.LanguageUnderstandingModelImpl = LanguageUnderstandingModelImpl; + + + +/***/ }), +/* 58 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(31); +/** + * Defines contents of speech recognizing/recognized event. + * @class SpeechRecognitionEventArgs + */ +var SpeechRecognitionEventArgs = /** @class */ (function (_super) { + __extends(SpeechRecognitionEventArgs, _super); + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {SpeechRecognitionResult} result - The speech recognition result. + * @param {number} offset - The offset. + * @param {string} sessionId - The session id. + */ + function SpeechRecognitionEventArgs(result, offset, sessionId) { + var _this = _super.call(this, offset, sessionId) || this; + _this.privResult = result; + return _this; + } + Object.defineProperty(SpeechRecognitionEventArgs.prototype, "result", { + /** + * Specifies the recognition result. + * @member SpeechRecognitionEventArgs.prototype.result + * @function + * @public + * @returns {SpeechRecognitionResult} the recognition result. + */ + get: function () { + return this.privResult; + }, + enumerable: true, + configurable: true + }); + return SpeechRecognitionEventArgs; +}(Exports_1.RecognitionEventArgs)); +exports.SpeechRecognitionEventArgs = SpeechRecognitionEventArgs; + + + +/***/ }), +/* 59 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(31); +/** + * Defines content of a RecognitionErrorEvent. + * @class SpeechRecognitionCanceledEventArgs + */ +var SpeechRecognitionCanceledEventArgs = /** @class */ (function (_super) { + __extends(SpeechRecognitionCanceledEventArgs, _super); + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {CancellationReason} reason - The cancellation reason. + * @param {string} errorDetails - Error details, if provided. + * @param {number} offset - The offset. + * @param {string} sessionId - The session id. + */ + function SpeechRecognitionCanceledEventArgs(reason, errorDetails, errorCode, offset, sessionId) { + var _this = _super.call(this, offset, sessionId) || this; + _this.privReason = reason; + _this.privErrorDetails = errorDetails; + _this.privErrorCode = errorCode; + return _this; + } + Object.defineProperty(SpeechRecognitionCanceledEventArgs.prototype, "reason", { + /** + * The reason the recognition was canceled. + * @member SpeechRecognitionCanceledEventArgs.prototype.reason + * @function + * @public + * @returns {CancellationReason} Specifies the reason canceled. + */ + get: function () { + return this.privReason; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechRecognitionCanceledEventArgs.prototype, "errorCode", { + /** + * The error code in case of an unsuccessful recognition. + * Added in version 1.1.0. + * @return An error code that represents the error reason. + */ + get: function () { + return this.privErrorCode; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechRecognitionCanceledEventArgs.prototype, "errorDetails", { + /** + * In case of an unsuccessful recognition, provides details of the occurred error. + * @member SpeechRecognitionCanceledEventArgs.prototype.errorDetails + * @function + * @public + * @returns {string} A String that represents the error details. + */ + get: function () { + return this.privErrorDetails; + }, + enumerable: true, + configurable: true + }); + return SpeechRecognitionCanceledEventArgs; +}(Exports_1.RecognitionEventArgs)); +exports.SpeechRecognitionCanceledEventArgs = SpeechRecognitionCanceledEventArgs; + + + +/***/ }), +/* 60 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(31); +/** + * Translation text result event arguments. + * @class TranslationRecognitionEventArgs + */ +var TranslationRecognitionEventArgs = /** @class */ (function (_super) { + __extends(TranslationRecognitionEventArgs, _super); + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {TranslationRecognitionResult} result - The translation recognition result. + * @param {number} offset - The offset. + * @param {string} sessionId - The session id. + */ + function TranslationRecognitionEventArgs(result, offset, sessionId) { + var _this = _super.call(this, offset, sessionId) || this; + _this.privResult = result; + return _this; + } + Object.defineProperty(TranslationRecognitionEventArgs.prototype, "result", { + /** + * Specifies the recognition result. + * @member TranslationRecognitionEventArgs.prototype.result + * @function + * @public + * @returns {TranslationRecognitionResult} the recognition result. + */ + get: function () { + return this.privResult; + }, + enumerable: true, + configurable: true + }); + return TranslationRecognitionEventArgs; +}(Exports_1.RecognitionEventArgs)); +exports.TranslationRecognitionEventArgs = TranslationRecognitionEventArgs; + + + +/***/ }), +/* 61 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(31); +/** + * Translation Synthesis event arguments + * @class TranslationSynthesisEventArgs + */ +var TranslationSynthesisEventArgs = /** @class */ (function (_super) { + __extends(TranslationSynthesisEventArgs, _super); + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {TranslationSynthesisResult} result - The translation synthesis result. + * @param {string} sessionId - The session id. + */ + function TranslationSynthesisEventArgs(result, sessionId) { + var _this = _super.call(this, sessionId) || this; + _this.privResult = result; + return _this; + } + Object.defineProperty(TranslationSynthesisEventArgs.prototype, "result", { + /** + * Specifies the translation synthesis result. + * @member TranslationSynthesisEventArgs.prototype.result + * @function + * @public + * @returns {TranslationSynthesisResult} Specifies the translation synthesis result. + */ + get: function () { + return this.privResult; + }, + enumerable: true, + configurable: true + }); + return TranslationSynthesisEventArgs; +}(Exports_1.SessionEventArgs)); +exports.TranslationSynthesisEventArgs = TranslationSynthesisEventArgs; + + + +/***/ }), +/* 62 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(31); +/** + * Translation text result. + * @class TranslationRecognitionResult + */ +var TranslationRecognitionResult = /** @class */ (function (_super) { + __extends(TranslationRecognitionResult, _super); + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {Translations} translations - The translations. + * @param {string} resultId - The result id. + * @param {ResultReason} reason - The reason. + * @param {string} text - The recognized text. + * @param {number} duration - The duration. + * @param {number} offset - The offset into the stream. + * @param {string} errorDetails - Error details, if provided. + * @param {string} json - Additional Json, if provided. + * @param {PropertyCollection} properties - Additional properties, if provided. + */ + function TranslationRecognitionResult(translations, resultId, reason, text, duration, offset, errorDetails, json, properties) { + var _this = _super.call(this, resultId, reason, text, duration, offset, undefined, undefined, errorDetails, json, properties) || this; + _this.privTranslations = translations; + return _this; + } + Object.defineProperty(TranslationRecognitionResult.prototype, "translations", { + /** + * Presents the translation results. Each item in the dictionary represents + * a translation result in one of target languages, where the key is the name + * of the target language, in BCP-47 format, and the value is the translation + * text in the specified language. + * @member TranslationRecognitionResult.prototype.translations + * @function + * @public + * @returns {Translations} the current translation map that holds all translations requested. + */ + get: function () { + return this.privTranslations; + }, + enumerable: true, + configurable: true + }); + return TranslationRecognitionResult; +}(Exports_1.SpeechRecognitionResult)); +exports.TranslationRecognitionResult = TranslationRecognitionResult; + + + +/***/ }), +/* 63 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Defines translation synthesis result, i.e. the voice output of the translated + * text in the target language. + * @class TranslationSynthesisResult + */ +var TranslationSynthesisResult = /** @class */ (function () { + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {ResultReason} reason - The synthesis reason. + * @param {ArrayBuffer} audio - The audio data. + */ + function TranslationSynthesisResult(reason, audio) { + this.privReason = reason; + this.privAudio = audio; + } + Object.defineProperty(TranslationSynthesisResult.prototype, "audio", { + /** + * Translated text in the target language. + * @member TranslationSynthesisResult.prototype.audio + * @function + * @public + * @returns {ArrayBuffer} Translated audio in the target language. + */ + get: function () { + return this.privAudio; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TranslationSynthesisResult.prototype, "reason", { + /** + * The synthesis status. + * @member TranslationSynthesisResult.prototype.reason + * @function + * @public + * @returns {ResultReason} The synthesis status. + */ + get: function () { + return this.privReason; + }, + enumerable: true, + configurable: true + }); + return TranslationSynthesisResult; +}()); +exports.TranslationSynthesisResult = TranslationSynthesisResult; + + + +/***/ }), +/* 64 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Defines the possible reasons a recognition result might be generated. + * @class ResultReason + */ +var ResultReason; +(function (ResultReason) { + /** + * Indicates speech could not be recognized. More details + * can be found in the NoMatchDetails object. + * @member ResultReason.NoMatch + */ + ResultReason[ResultReason["NoMatch"] = 0] = "NoMatch"; + /** + * Indicates that the recognition was canceled. More details + * can be found using the CancellationDetails object. + * @member ResultReason.Canceled + */ + ResultReason[ResultReason["Canceled"] = 1] = "Canceled"; + /** + * Indicates the speech result contains hypothesis text. + * @member ResultReason.RecognizedSpeech + */ + ResultReason[ResultReason["RecognizingSpeech"] = 2] = "RecognizingSpeech"; + /** + * Indicates the speech result contains final text that has been recognized. + * Speech Recognition is now complete for this phrase. + * @member ResultReason.RecognizedSpeech + */ + ResultReason[ResultReason["RecognizedSpeech"] = 3] = "RecognizedSpeech"; + /** + * Indicates the intent result contains hypothesis text and intent. + * @member ResultReason.RecognizingIntent + */ + ResultReason[ResultReason["RecognizingIntent"] = 4] = "RecognizingIntent"; + /** + * Indicates the intent result contains final text and intent. + * Speech Recognition and Intent determination are now complete for this phrase. + * @member ResultReason.RecognizedIntent + */ + ResultReason[ResultReason["RecognizedIntent"] = 5] = "RecognizedIntent"; + /** + * Indicates the translation result contains hypothesis text and its translation(s). + * @member ResultReason.TranslatingSpeech + */ + ResultReason[ResultReason["TranslatingSpeech"] = 6] = "TranslatingSpeech"; + /** + * Indicates the translation result contains final text and corresponding translation(s). + * Speech Recognition and Translation are now complete for this phrase. + * @member ResultReason.TranslatedSpeech + */ + ResultReason[ResultReason["TranslatedSpeech"] = 7] = "TranslatedSpeech"; + /** + * Indicates the synthesized audio result contains a non-zero amount of audio data + * @member ResultReason.SynthesizingAudio + */ + ResultReason[ResultReason["SynthesizingAudio"] = 8] = "SynthesizingAudio"; + /** + * Indicates the synthesized audio is now complete for this phrase. + * @member ResultReason.SynthesizingAudioCompleted + */ + ResultReason[ResultReason["SynthesizingAudioCompleted"] = 9] = "SynthesizingAudioCompleted"; + /** + * Indicates the speech synthesis is now started + * @member ResultReason.SynthesizingAudioStarted + */ + ResultReason[ResultReason["SynthesizingAudioStarted"] = 10] = "SynthesizingAudioStarted"; + /** + * Indicates the voice profile is being enrolled and customers need to send more audio to create a voice profile. + * @member ResultReason.EnrollingVoiceProfile + */ + ResultReason[ResultReason["EnrollingVoiceProfile"] = 11] = "EnrollingVoiceProfile"; + /** + * Indicates the voice profile has been enrolled. + * @member ResultReason.EnrolledVoiceProfile + */ + ResultReason[ResultReason["EnrolledVoiceProfile"] = 12] = "EnrolledVoiceProfile"; + /** + * Indicates successful identification of some speakers. + * @member ResultReason.RecognizedSpeakers + */ + ResultReason[ResultReason["RecognizedSpeakers"] = 13] = "RecognizedSpeakers"; + /** + * Indicates successfully verified one speaker. + * @member ResultReason.RecognizedSpeaker + */ + ResultReason[ResultReason["RecognizedSpeaker"] = 14] = "RecognizedSpeaker"; + /** + * Indicates a voice profile has been reset successfully. + * @member ResultReason.ResetVoiceProfile + */ + ResultReason[ResultReason["ResetVoiceProfile"] = 15] = "ResetVoiceProfile"; + /** + * Indicates a voice profile has been deleted successfully. + * @member ResultReason.DeletedVoiceProfile + */ + ResultReason[ResultReason["DeletedVoiceProfile"] = 16] = "DeletedVoiceProfile"; +})(ResultReason = exports.ResultReason || (exports.ResultReason = {})); + + + +/***/ }), +/* 65 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(26); +var Contracts_1 = __webpack_require__(33); +var Exports_2 = __webpack_require__(31); +/** + * Speech configuration. + * @class SpeechConfig + */ +var SpeechConfig = /** @class */ (function () { + /** + * Creates and initializes an instance. + * @constructor + */ + function SpeechConfig() { + } + /** + * Static instance of SpeechConfig returned by passing subscriptionKey and service region. + * Note: Please use your LanguageUnderstanding subscription key in case you want to use the Intent recognizer. + * @member SpeechConfig.fromSubscription + * @function + * @public + * @param {string} subscriptionKey - The subscription key. + * @param {string} region - The region name (see the region page). + * @returns {SpeechConfig} The speech factory + */ + SpeechConfig.fromSubscription = function (subscriptionKey, region) { + Contracts_1.Contracts.throwIfNullOrWhitespace(subscriptionKey, "subscriptionKey"); + Contracts_1.Contracts.throwIfNullOrWhitespace(region, "region"); + var speechImpl = new SpeechConfigImpl(); + speechImpl.setProperty(Exports_2.PropertyId.SpeechServiceConnection_Region, region); + speechImpl.setProperty(Exports_2.PropertyId.SpeechServiceConnection_IntentRegion, region); + speechImpl.setProperty(Exports_2.PropertyId.SpeechServiceConnection_Key, subscriptionKey); + return speechImpl; + }; + /** + * Creates an instance of the speech config with specified endpoint and subscription key. + * This method is intended only for users who use a non-standard service endpoint or parameters. + * Note: Please use your LanguageUnderstanding subscription key in case you want to use the Intent recognizer. + * Note: The query parameters specified in the endpoint URL are not changed, even if they are set by any other APIs. + * For example, if language is defined in the uri as query parameter "language=de-DE", and also set by + * SpeechConfig.speechRecognitionLanguage = "en-US", the language setting in uri takes precedence, + * and the effective language is "de-DE". Only the parameters that are not specified in the + * endpoint URL can be set by other APIs. + * Note: To use authorization token with fromEndpoint, pass an empty string to the subscriptionKey in the + * fromEndpoint method, and then set authorizationToken="token" on the created SpeechConfig instance to + * use the authorization token. + * @member SpeechConfig.fromEndpoint + * @function + * @public + * @param {URL} endpoint - The service endpoint to connect to. + * @param {string} subscriptionKey - The subscription key. If a subscription key is not specified, an authorization token must be set. + * @returns {SpeechConfig} A speech factory instance. + */ + SpeechConfig.fromEndpoint = function (endpoint, subscriptionKey) { + Contracts_1.Contracts.throwIfNull(endpoint, "endpoint"); + var speechImpl = new SpeechConfigImpl(); + speechImpl.setProperty(Exports_2.PropertyId.SpeechServiceConnection_Endpoint, endpoint.href); + if (undefined !== subscriptionKey) { + speechImpl.setProperty(Exports_2.PropertyId.SpeechServiceConnection_Key, subscriptionKey); + } + return speechImpl; + }; + /** + * Creates an instance of the speech config with specified host and subscription key. + * This method is intended only for users who use a non-default service host. Standard resource path will be assumed. + * For services with a non-standard resource path or no path at all, use fromEndpoint instead. + * Note: Query parameters are not allowed in the host URI and must be set by other APIs. + * Note: To use an authorization token with fromHost, use fromHost(URL), + * and then set the AuthorizationToken property on the created SpeechConfig instance. + * Note: Added in version 1.9.0. + * @member SpeechConfig.fromHost + * @function + * @public + * @param {URL} host - The service endpoint to connect to. Format is "protocol://host:port" where ":port" is optional. + * @param {string} subscriptionKey - The subscription key. If a subscription key is not specified, an authorization token must be set. + * @returns {SpeechConfig} A speech factory instance. + */ + SpeechConfig.fromHost = function (hostName, subscriptionKey) { + Contracts_1.Contracts.throwIfNull(hostName, "hostName"); + var speechImpl = new SpeechConfigImpl(); + speechImpl.setProperty(Exports_2.PropertyId.SpeechServiceConnection_Host, hostName.protocol + "//" + hostName.hostname + (hostName.port === "" ? "" : ":" + hostName.port)); + if (undefined !== subscriptionKey) { + speechImpl.setProperty(Exports_2.PropertyId.SpeechServiceConnection_Key, subscriptionKey); + } + return speechImpl; + }; + /** + * Creates an instance of the speech factory with specified initial 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. + * Note: Please use a token derived from your LanguageUnderstanding subscription key in case you want + * to use the Intent recognizer. 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 SpeechConfig.fromAuthorizationToken + * @function + * @public + * @param {string} authorizationToken - The initial authorization token. + * @param {string} region - The region name (see the region page). + * @returns {SpeechConfig} A speech factory instance. + */ + SpeechConfig.fromAuthorizationToken = function (authorizationToken, region) { + Contracts_1.Contracts.throwIfNull(authorizationToken, "authorizationToken"); + Contracts_1.Contracts.throwIfNullOrWhitespace(region, "region"); + var speechImpl = new SpeechConfigImpl(); + speechImpl.setProperty(Exports_2.PropertyId.SpeechServiceConnection_Region, region); + speechImpl.setProperty(Exports_2.PropertyId.SpeechServiceConnection_IntentRegion, region); + speechImpl.authorizationToken = authorizationToken; + return speechImpl; + }; + /** + * Closes the configuration. + * @member SpeechConfig.prototype.close + * @function + * @public + */ + /* tslint:disable:no-empty */ + SpeechConfig.prototype.close = function () { }; + return SpeechConfig; +}()); +exports.SpeechConfig = SpeechConfig; +/** + * @public + * @class SpeechConfigImpl + */ +// tslint:disable-next-line:max-classes-per-file +var SpeechConfigImpl = /** @class */ (function (_super) { + __extends(SpeechConfigImpl, _super); + function SpeechConfigImpl() { + var _this = _super.call(this) || this; + _this.privProperties = new Exports_2.PropertyCollection(); + _this.speechRecognitionLanguage = "en-US"; // Should we have a default? + _this.outputFormat = Exports_2.OutputFormat.Simple; + return _this; + } + Object.defineProperty(SpeechConfigImpl.prototype, "properties", { + get: function () { + return this.privProperties; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechConfigImpl.prototype, "endPoint", { + get: function () { + return new URL(this.privProperties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_Endpoint)); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechConfigImpl.prototype, "subscriptionKey", { + get: function () { + return this.privProperties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_Key); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechConfigImpl.prototype, "region", { + get: function () { + return this.privProperties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_Region); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechConfigImpl.prototype, "authorizationToken", { + get: function () { + return this.privProperties.getProperty(Exports_2.PropertyId.SpeechServiceAuthorization_Token); + }, + set: function (value) { + this.privProperties.setProperty(Exports_2.PropertyId.SpeechServiceAuthorization_Token, value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechConfigImpl.prototype, "speechRecognitionLanguage", { + get: function () { + return this.privProperties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage); + }, + set: function (value) { + this.privProperties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage, value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechConfigImpl.prototype, "autoDetectSourceLanguages", { + get: function () { + return this.privProperties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages); + }, + set: function (value) { + this.privProperties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechConfigImpl.prototype, "outputFormat", { + get: function () { + return Exports_2.OutputFormat[this.privProperties.getProperty(Exports_1.OutputFormatPropertyName, undefined)]; + }, + set: function (value) { + this.privProperties.setProperty(Exports_1.OutputFormatPropertyName, Exports_2.OutputFormat[value]); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechConfigImpl.prototype, "endpointId", { + get: function () { + return this.privProperties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_EndpointId); + }, + set: function (value) { + this.privProperties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_EndpointId, value); + }, + enumerable: true, + configurable: true + }); + SpeechConfigImpl.prototype.setProperty = function (name, value) { + Contracts_1.Contracts.throwIfNull(value, "value"); + this.privProperties.setProperty(name, value); + }; + SpeechConfigImpl.prototype.getProperty = function (name, def) { + return this.privProperties.getProperty(name, def); + }; + SpeechConfigImpl.prototype.setProxy = function (proxyHostName, proxyPort, proxyUserName, proxyPassword) { + this.setProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_ProxyHostName], proxyHostName); + this.setProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_ProxyPort], proxyPort); + this.setProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_ProxyUserName], proxyUserName); + this.setProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_ProxyPassword], proxyPassword); + }; + SpeechConfigImpl.prototype.setServiceProperty = function (name, value, channel) { + var currentProperties = JSON.parse(this.privProperties.getProperty(Exports_1.ServicePropertiesPropertyName, "{}")); + currentProperties[name] = value; + this.privProperties.setProperty(Exports_1.ServicePropertiesPropertyName, JSON.stringify(currentProperties)); + }; + SpeechConfigImpl.prototype.setProfanity = function (profanity) { + this.privProperties.setProperty(Exports_2.PropertyId.SpeechServiceResponse_ProfanityOption, Exports_2.ProfanityOption[profanity]); + }; + SpeechConfigImpl.prototype.enableAudioLogging = function () { + this.privProperties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_EnableAudioLogging, "true"); + }; + SpeechConfigImpl.prototype.requestWordLevelTimestamps = function () { + this.privProperties.setProperty(Exports_2.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps, "true"); + }; + SpeechConfigImpl.prototype.enableDictation = function () { + this.privProperties.setProperty(Exports_1.ForceDictationPropertyName, "true"); + }; + SpeechConfigImpl.prototype.clone = function () { + var ret = new SpeechConfigImpl(); + ret.privProperties = this.privProperties.clone(); + return ret; + }; + Object.defineProperty(SpeechConfigImpl.prototype, "speechSynthesisLanguage", { + get: function () { + return this.privProperties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_SynthLanguage); + }, + set: function (language) { + this.privProperties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_SynthLanguage, language); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechConfigImpl.prototype, "speechSynthesisVoiceName", { + get: function () { + return this.privProperties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_SynthVoice); + }, + set: function (voice) { + this.privProperties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_SynthVoice, voice); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechConfigImpl.prototype, "speechSynthesisOutputFormat", { + get: function () { + return Exports_2.SpeechSynthesisOutputFormat[this.privProperties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_SynthOutputFormat, undefined)]; + }, + set: function (format) { + this.privProperties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_SynthOutputFormat, Exports_2.SpeechSynthesisOutputFormat[format]); + }, + enumerable: true, + configurable: true + }); + return SpeechConfigImpl; +}(SpeechConfig)); +exports.SpeechConfigImpl = SpeechConfigImpl; + + + +/***/ }), +/* 66 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(26); +var Contracts_1 = __webpack_require__(33); +var Exports_2 = __webpack_require__(31); +/** + * Speech translation configuration. + * @class SpeechTranslationConfig + */ +var SpeechTranslationConfig = /** @class */ (function (_super) { + __extends(SpeechTranslationConfig, _super); + /** + * Creates an instance of recognizer config. + */ + function SpeechTranslationConfig() { + return _super.call(this) || this; + } + /** + * Static instance of SpeechTranslationConfig returned by passing a subscription key and service region. + * @member SpeechTranslationConfig.fromSubscription + * @function + * @public + * @param {string} subscriptionKey - The subscription key. + * @param {string} region - The region name (see the region page). + * @returns {SpeechTranslationConfig} The speech translation config. + */ + SpeechTranslationConfig.fromSubscription = function (subscriptionKey, region) { + Contracts_1.Contracts.throwIfNullOrWhitespace(subscriptionKey, "subscriptionKey"); + Contracts_1.Contracts.throwIfNullOrWhitespace(region, "region"); + var ret = new SpeechTranslationConfigImpl(); + ret.properties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_Key, subscriptionKey); + ret.properties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_Region, region); + return ret; + }; + /** + * Static instance of SpeechTranslationConfig returned by passing authorization token and service 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 setting the property authorizationToken with a new + * valid token. Otherwise, all the recognizers created by this SpeechTranslationConfig instance + * will encounter errors during recognition. + * 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 SpeechTranslationConfig.fromAuthorizationToken + * @function + * @public + * @param {string} authorizationToken - The authorization token. + * @param {string} region - The region name (see the region page). + * @returns {SpeechTranslationConfig} The speech translation config. + */ + SpeechTranslationConfig.fromAuthorizationToken = function (authorizationToken, region) { + Contracts_1.Contracts.throwIfNullOrWhitespace(authorizationToken, "authorizationToken"); + Contracts_1.Contracts.throwIfNullOrWhitespace(region, "region"); + var ret = new SpeechTranslationConfigImpl(); + ret.properties.setProperty(Exports_2.PropertyId.SpeechServiceAuthorization_Token, authorizationToken); + ret.properties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_Region, region); + return ret; + }; + /** + * Creates an instance of the speech config with specified host and subscription key. + * This method is intended only for users who use a non-default service host. Standard resource path will be assumed. + * For services with a non-standard resource path or no path at all, use fromEndpoint instead. + * Note: Query parameters are not allowed in the host URI and must be set by other APIs. + * Note: To use an authorization token with fromHost, use fromHost(URL), + * and then set the AuthorizationToken property on the created SpeechConfig instance. + * Note: Added in version 1.9.0. + * @member SpeechConfig.fromHost + * @function + * @public + * @param {URL} host - The service endpoint to connect to. Format is "protocol://host:port" where ":port" is optional. + * @param {string} subscriptionKey - The subscription key. If a subscription key is not specified, an authorization token must be set. + * @returns {SpeechConfig} A speech factory instance. + */ + SpeechTranslationConfig.fromHost = function (hostName, subscriptionKey) { + Contracts_1.Contracts.throwIfNull(hostName, "hostName"); + var speechImpl = new SpeechTranslationConfigImpl(); + speechImpl.setProperty(Exports_2.PropertyId.SpeechServiceConnection_Host, hostName.protocol + "//" + hostName.hostname + (hostName.port === "" ? "" : ":" + hostName.port)); + if (undefined !== subscriptionKey) { + speechImpl.setProperty(Exports_2.PropertyId.SpeechServiceConnection_Key, subscriptionKey); + } + return speechImpl; + }; + /** + * Creates an instance of the speech translation config with specified endpoint and subscription key. + * This method is intended only for users who use a non-standard service endpoint or paramters. + * Note: The query properties specified in the endpoint URL are not changed, even if they are + * set by any other APIs. For example, if language is defined in the uri as query parameter + * "language=de-DE", and also set by the speechRecognitionLanguage property, the language + * setting in uri takes precedence, and the effective language is "de-DE". + * Only the properties that are not specified in the endpoint URL can be set by other APIs. + * Note: To use authorization token with fromEndpoint, pass an empty string to the subscriptionKey in the + * fromEndpoint method, and then set authorizationToken="token" on the created SpeechConfig instance to + * use the authorization token. + * @member SpeechTranslationConfig.fromEndpoint + * @function + * @public + * @param {URL} endpoint - The service endpoint to connect to. + * @param {string} subscriptionKey - The subscription key. + * @returns {SpeechTranslationConfig} A speech config instance. + */ + SpeechTranslationConfig.fromEndpoint = function (endpoint, subscriptionKey) { + Contracts_1.Contracts.throwIfNull(endpoint, "endpoint"); + Contracts_1.Contracts.throwIfNull(subscriptionKey, "subscriptionKey"); + var ret = new SpeechTranslationConfigImpl(); + ret.properties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_Endpoint, endpoint.href); + ret.properties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_Key, subscriptionKey); + return ret; + }; + return SpeechTranslationConfig; +}(Exports_2.SpeechConfig)); +exports.SpeechTranslationConfig = SpeechTranslationConfig; +/** + * @private + * @class SpeechTranslationConfigImpl + */ +// tslint:disable-next-line:max-classes-per-file +var SpeechTranslationConfigImpl = /** @class */ (function (_super) { + __extends(SpeechTranslationConfigImpl, _super); + function SpeechTranslationConfigImpl() { + var _this = _super.call(this) || this; + _this.privSpeechProperties = new Exports_2.PropertyCollection(); + _this.outputFormat = Exports_2.OutputFormat.Simple; + return _this; + } + Object.defineProperty(SpeechTranslationConfigImpl.prototype, "authorizationToken", { + /** + * Gets/Sets the authorization token. + * If this is set, subscription key is ignored. + * User needs to make sure the provided authorization token is valid and not expired. + * @member SpeechTranslationConfigImpl.prototype.authorizationToken + * @function + * @public + * @param {string} value - The authorization token. + */ + set: function (value) { + Contracts_1.Contracts.throwIfNullOrWhitespace(value, "value"); + this.privSpeechProperties.setProperty(Exports_2.PropertyId.SpeechServiceAuthorization_Token, value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechTranslationConfigImpl.prototype, "speechRecognitionLanguage", { + /** + * Gets/Sets the speech recognition language. + * @member SpeechTranslationConfigImpl.prototype.speechRecognitionLanguage + * @function + * @public + * @param {string} value - The authorization token. + */ + set: function (value) { + Contracts_1.Contracts.throwIfNullOrWhitespace(value, "value"); + this.privSpeechProperties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage, value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechTranslationConfigImpl.prototype, "subscriptionKey", { + /** + * @member SpeechTranslationConfigImpl.prototype.subscriptionKey + * @function + * @public + */ + get: function () { + return this.privSpeechProperties.getProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_Key]); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechTranslationConfigImpl.prototype, "outputFormat", { + /** + * Gets the output format + * @member SpeechTranslationConfigImpl.prototype.outputFormat + * @function + * @public + */ + get: function () { + return Exports_2.OutputFormat[this.privSpeechProperties.getProperty(Exports_1.OutputFormatPropertyName, undefined)]; + }, + /** + * Gets/Sets the output format + * @member SpeechTranslationConfigImpl.prototype.outputFormat + * @function + * @public + */ + set: function (value) { + this.privSpeechProperties.setProperty(Exports_1.OutputFormatPropertyName, Exports_2.OutputFormat[value]); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechTranslationConfigImpl.prototype, "endpointId", { + /** + * Gets the endpoint id. + * @member SpeechTranslationConfigImpl.prototype.endpointId + * @function + * @public + */ + get: function () { + return this.privSpeechProperties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_EndpointId); + }, + /** + * Gets/Sets the endpoint id. + * @member SpeechTranslationConfigImpl.prototype.endpointId + * @function + * @public + */ + set: function (value) { + this.privSpeechProperties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_EndpointId, value); + }, + enumerable: true, + configurable: true + }); + /** + * Add a (text) target language to translate into. + * @member SpeechTranslationConfigImpl.prototype.addTargetLanguage + * @function + * @public + * @param {string} value - The language such as de-DE + */ + SpeechTranslationConfigImpl.prototype.addTargetLanguage = function (value) { + Contracts_1.Contracts.throwIfNullOrWhitespace(value, "value"); + var languages = this.targetLanguages; + languages.push(value); + this.privSpeechProperties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_TranslationToLanguages, languages.join(",")); + }; + Object.defineProperty(SpeechTranslationConfigImpl.prototype, "targetLanguages", { + /** + * Gets the (text) target language to translate into. + * @member SpeechTranslationConfigImpl.prototype.targetLanguages + * @function + * @public + * @param {string} value - The language such as de-DE + */ + get: function () { + if (this.privSpeechProperties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_TranslationToLanguages, undefined) !== undefined) { + return this.privSpeechProperties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","); + } + else { + return []; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechTranslationConfigImpl.prototype, "voiceName", { + /** + * Gets the voice name. + * @member SpeechTranslationConfigImpl.prototype.voiceName + * @function + * @public + */ + get: function () { + return this.getProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_TranslationVoice]); + }, + /** + * Gets/Sets the voice of the translated language, enable voice synthesis output. + * @member SpeechTranslationConfigImpl.prototype.voiceName + * @function + * @public + * @param {string} value - The name of the voice. + */ + set: function (value) { + Contracts_1.Contracts.throwIfNullOrWhitespace(value, "value"); + this.privSpeechProperties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_TranslationVoice, value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechTranslationConfigImpl.prototype, "region", { + /** + * Provides the region. + * @member SpeechTranslationConfigImpl.prototype.region + * @function + * @public + * @returns {string} The region. + */ + get: function () { + return this.privSpeechProperties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_Region); + }, + enumerable: true, + configurable: true + }); + SpeechTranslationConfigImpl.prototype.setProxy = function (proxyHostName, proxyPort, proxyUserName, proxyPassword) { + this.setProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_ProxyHostName], proxyHostName); + this.setProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_ProxyPort], proxyPort); + this.setProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_ProxyUserName], proxyUserName); + this.setProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_ProxyPassword], proxyPassword); + }; + /** + * Gets an arbitrary property value. + * @member SpeechTranslationConfigImpl.prototype.getProperty + * @function + * @public + * @param {string} name - The name of the property. + * @param {string} def - The default value of the property in case it is not set. + * @returns {string} The value of the property. + */ + SpeechTranslationConfigImpl.prototype.getProperty = function (name, def) { + return this.privSpeechProperties.getProperty(name, def); + }; + /** + * Gets/Sets an arbitrary property value. + * @member SpeechTranslationConfigImpl.prototype.setProperty + * @function + * @public + * @param {string} name - The name of the property. + * @param {string} value - The value of the property. + */ + SpeechTranslationConfigImpl.prototype.setProperty = function (name, value) { + this.privSpeechProperties.setProperty(name, value); + }; + Object.defineProperty(SpeechTranslationConfigImpl.prototype, "properties", { + /** + * Provides access to custom properties. + * @member SpeechTranslationConfigImpl.prototype.properties + * @function + * @public + * @returns {PropertyCollection} The properties. + */ + get: function () { + return this.privSpeechProperties; + }, + enumerable: true, + configurable: true + }); + /** + * Dispose of associated resources. + * @member SpeechTranslationConfigImpl.prototype.close + * @function + * @public + */ + SpeechTranslationConfigImpl.prototype.close = function () { + return; + }; + SpeechTranslationConfigImpl.prototype.setServiceProperty = function (name, value, channel) { + var currentProperties = JSON.parse(this.privSpeechProperties.getProperty(Exports_1.ServicePropertiesPropertyName, "{}")); + currentProperties[name] = value; + this.privSpeechProperties.setProperty(Exports_1.ServicePropertiesPropertyName, JSON.stringify(currentProperties)); + }; + SpeechTranslationConfigImpl.prototype.setProfanity = function (profanity) { + this.privSpeechProperties.setProperty(Exports_2.PropertyId.SpeechServiceResponse_ProfanityOption, Exports_2.ProfanityOption[profanity]); + }; + SpeechTranslationConfigImpl.prototype.enableAudioLogging = function () { + this.privSpeechProperties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_EnableAudioLogging, "true"); + }; + SpeechTranslationConfigImpl.prototype.requestWordLevelTimestamps = function () { + this.privSpeechProperties.setProperty(Exports_2.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps, "true"); + }; + SpeechTranslationConfigImpl.prototype.enableDictation = function () { + this.privSpeechProperties.setProperty(Exports_1.ForceDictationPropertyName, "true"); + }; + Object.defineProperty(SpeechTranslationConfigImpl.prototype, "speechSynthesisLanguage", { + get: function () { + return this.privSpeechProperties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_SynthLanguage); + }, + set: function (language) { + this.privSpeechProperties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_SynthLanguage, language); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechTranslationConfigImpl.prototype, "speechSynthesisVoiceName", { + get: function () { + return this.privSpeechProperties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_SynthVoice); + }, + set: function (voice) { + this.privSpeechProperties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_SynthVoice, voice); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechTranslationConfigImpl.prototype, "speechSynthesisOutputFormat", { + get: function () { + return Exports_2.SpeechSynthesisOutputFormat[this.privSpeechProperties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_SynthOutputFormat, undefined)]; + }, + set: function (format) { + this.privSpeechProperties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_SynthOutputFormat, Exports_2.SpeechSynthesisOutputFormat[format]); + }, + enumerable: true, + configurable: true + }); + return SpeechTranslationConfigImpl; +}(SpeechTranslationConfig)); +exports.SpeechTranslationConfigImpl = SpeechTranslationConfigImpl; + + + +/***/ }), +/* 67 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(31); +/** + * Represents collection of properties and their values. + * @class PropertyCollection + */ +var PropertyCollection = /** @class */ (function () { + function PropertyCollection() { + this.privKeys = []; + this.privValues = []; + } + /** + * Returns the property value in type String. The parameter must have the same type as String. + * Currently only String, int and bool are allowed. + * If the name is not available, the specified defaultValue is returned. + * @member PropertyCollection.prototype.getProperty + * @function + * @public + * @param {string} key - The parameter name. + * @param {string} def - The default value which is returned if the parameter + * is not available in the collection. + * @returns {string} value of the parameter. + */ + PropertyCollection.prototype.getProperty = function (key, def) { + var keyToUse; + if (typeof key === "string") { + keyToUse = key; + } + else { + keyToUse = Exports_1.PropertyId[key]; + } + for (var n = 0; n < this.privKeys.length; n++) { + if (this.privKeys[n] === keyToUse) { + return this.privValues[n]; + } + } + return def; + }; + /** + * Sets the String value of the parameter specified by name. + * @member PropertyCollection.prototype.setProperty + * @function + * @public + * @param {string} key - The parameter name. + * @param {string} value - The value of the parameter. + */ + PropertyCollection.prototype.setProperty = function (key, value) { + var keyToUse; + if (typeof key === "string") { + keyToUse = key; + } + else { + keyToUse = Exports_1.PropertyId[key]; + } + for (var n = 0; n < this.privKeys.length; n++) { + if (this.privKeys[n] === keyToUse) { + this.privValues[n] = value; + return; + } + } + this.privKeys.push(keyToUse); + this.privValues.push(value); + }; + /** + * Clones the collection. + * @member PropertyCollection.prototype.clone + * @function + * @public + * @returns {PropertyCollection} A copy of the collection. + */ + PropertyCollection.prototype.clone = function () { + var clonedMap = new PropertyCollection(); + for (var n = 0; n < this.privKeys.length; n++) { + clonedMap.privKeys.push(this.privKeys[n]); + clonedMap.privValues.push(this.privValues[n]); + } + return clonedMap; + }; + /** + * Merges this set of properties into another, no overwrites. + * @member PropertyCollection.prototype.mergeTo + * @function + * @public + * @param {PropertyCollection} The collection to merge into. + */ + PropertyCollection.prototype.mergeTo = function (destinationCollection) { + var _this = this; + this.privKeys.forEach(function (key) { + if (destinationCollection.getProperty(key, undefined) === undefined) { + var value = _this.getProperty(key); + destinationCollection.setProperty(key, value); + } + }); + }; + return PropertyCollection; +}()); +exports.PropertyCollection = PropertyCollection; + + + +/***/ }), +/* 68 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Defines speech property ids. + * @class PropertyId + */ +var PropertyId; +(function (PropertyId) { + /** + * The Cognitive Services Speech Service subscription Key. If you are using an intent recognizer, you need to specify + * to specify the LUIS endpoint key for your particular LUIS app. Under normal circumstances, you shouldn't + * have to use this property directly. + * Instead, use [[SpeechConfig.fromSubscription]]. + * @member PropertyId.SpeechServiceConnection_Key + */ + PropertyId[PropertyId["SpeechServiceConnection_Key"] = 0] = "SpeechServiceConnection_Key"; + /** + * The Cognitive Services Speech Service endpoint (url). Under normal circumstances, you shouldn't + * have to use this property directly. + * Instead, use [[SpeechConfig.fromEndpoint]]. + * NOTE: This endpoint is not the same as the endpoint used to obtain an access token. + * @member PropertyId.SpeechServiceConnection_Endpoint + */ + PropertyId[PropertyId["SpeechServiceConnection_Endpoint"] = 1] = "SpeechServiceConnection_Endpoint"; + /** + * The Cognitive Services Speech Service region. Under normal circumstances, you shouldn't have to + * use this property directly. + * Instead, use [[SpeechConfig.fromSubscription]], [[SpeechConfig.fromEndpoint]], [[SpeechConfig.fromAuthorizationToken]]. + * @member PropertyId.SpeechServiceConnection_Region + */ + PropertyId[PropertyId["SpeechServiceConnection_Region"] = 2] = "SpeechServiceConnection_Region"; + /** + * The Cognitive Services Speech Service authorization token (aka access token). Under normal circumstances, + * you shouldn't have to use this property directly. + * Instead, use [[SpeechConfig.fromAuthorizationToken]], [[SpeechRecognizer.authorizationToken]], + * [[IntentRecognizer.authorizationToken]], [[TranslationRecognizer.authorizationToken]], [[SpeakerRecognizer.authorizationToken]]. + * @member PropertyId.SpeechServiceAuthorization_Token + */ + PropertyId[PropertyId["SpeechServiceAuthorization_Token"] = 3] = "SpeechServiceAuthorization_Token"; + /** + * The Cognitive Services Speech Service authorization type. Currently unused. + * @member PropertyId.SpeechServiceAuthorization_Type + */ + PropertyId[PropertyId["SpeechServiceAuthorization_Type"] = 4] = "SpeechServiceAuthorization_Type"; + /** + * The Cognitive Services Speech Service endpoint id. Under normal circumstances, you shouldn't + * have to use this property directly. + * Instead, use [[SpeechConfig.endpointId]]. + * NOTE: The endpoint id is available in the Speech Portal, listed under Endpoint Details. + * @member PropertyId.SpeechServiceConnection_EndpointId + */ + PropertyId[PropertyId["SpeechServiceConnection_EndpointId"] = 5] = "SpeechServiceConnection_EndpointId"; + /** + * The list of comma separated languages (BCP-47 format) used as target translation languages. Under normal circumstances, + * you shouldn't have to use this property directly. + * Instead use [[SpeechTranslationConfig.addTargetLanguage]], + * [[SpeechTranslationConfig.targetLanguages]], [[TranslationRecognizer.targetLanguages]]. + * @member PropertyId.SpeechServiceConnection_TranslationToLanguages + */ + PropertyId[PropertyId["SpeechServiceConnection_TranslationToLanguages"] = 6] = "SpeechServiceConnection_TranslationToLanguages"; + /** + * The name of the Cognitive Service Text to Speech Service Voice. Under normal circumstances, you shouldn't have to use this + * property directly. + * Instead, use [[SpeechTranslationConfig.voiceName]]. + * NOTE: Valid voice names can be found here. + * @member PropertyId.SpeechServiceConnection_TranslationVoice + */ + PropertyId[PropertyId["SpeechServiceConnection_TranslationVoice"] = 7] = "SpeechServiceConnection_TranslationVoice"; + /** + * Translation features. + * @member PropertyId.SpeechServiceConnection_TranslationFeatures + */ + PropertyId[PropertyId["SpeechServiceConnection_TranslationFeatures"] = 8] = "SpeechServiceConnection_TranslationFeatures"; + /** + * The Language Understanding Service Region. Under normal circumstances, you shouldn't have to use this property directly. + * Instead, use [[LanguageUnderstandingModel]]. + * @member PropertyId.SpeechServiceConnection_IntentRegion + */ + PropertyId[PropertyId["SpeechServiceConnection_IntentRegion"] = 9] = "SpeechServiceConnection_IntentRegion"; + /** + * The host name of the proxy server used to connect to the Cognitive Services Speech Service. Only relevant in Node.js environments. + * You shouldn't have to use this property directly. + * Instead use . + * Added in version 1.4.0. + */ + PropertyId[PropertyId["SpeechServiceConnection_ProxyHostName"] = 10] = "SpeechServiceConnection_ProxyHostName"; + /** + * The port of the proxy server used to connect to the Cognitive Services Speech Service. Only relevant in Node.js environments. + * You shouldn't have to use this property directly. + * Instead use . + * Added in version 1.4.0. + */ + PropertyId[PropertyId["SpeechServiceConnection_ProxyPort"] = 11] = "SpeechServiceConnection_ProxyPort"; + /** + * The user name of the proxy server used to connect to the Cognitive Services Speech Service. Only relevant in Node.js environments. + * You shouldn't have to use this property directly. + * Instead use . + * Added in version 1.4.0. + */ + PropertyId[PropertyId["SpeechServiceConnection_ProxyUserName"] = 12] = "SpeechServiceConnection_ProxyUserName"; + /** + * The password of the proxy server used to connect to the Cognitive Services Speech Service. Only relevant in Node.js environments. + * You shouldn't have to use this property directly. + * Instead use . + * Added in version 1.4.0. + */ + PropertyId[PropertyId["SpeechServiceConnection_ProxyPassword"] = 13] = "SpeechServiceConnection_ProxyPassword"; + /** + * The Cognitive Services Speech Service recognition Mode. Can be "INTERACTIVE", "CONVERSATION", "DICTATION". + * This property is intended to be read-only. The SDK is using it internally. + * @member PropertyId.SpeechServiceConnection_RecoMode + */ + PropertyId[PropertyId["SpeechServiceConnection_RecoMode"] = 14] = "SpeechServiceConnection_RecoMode"; + /** + * The spoken language to be recognized (in BCP-47 format). Under normal circumstances, you shouldn't have to use this property + * directly. + * Instead, use [[SpeechConfig.speechRecognitionLanguage]]. + * @member PropertyId.SpeechServiceConnection_RecoLanguage + */ + PropertyId[PropertyId["SpeechServiceConnection_RecoLanguage"] = 15] = "SpeechServiceConnection_RecoLanguage"; + /** + * The session id. This id is a universally unique identifier (aka UUID) representing a specific binding of an audio input stream + * and the underlying speech recognition instance to which it is bound. Under normal circumstances, you shouldn't have to use this + * property directly. + * Instead use [[SessionEventArgs.sessionId]]. + * @member PropertyId.Speech_SessionId + */ + PropertyId[PropertyId["Speech_SessionId"] = 16] = "Speech_SessionId"; + /** + * The spoken language to be synthesized (e.g. en-US) + * @member PropertyId.SpeechServiceConnection_SynthLanguage + */ + PropertyId[PropertyId["SpeechServiceConnection_SynthLanguage"] = 17] = "SpeechServiceConnection_SynthLanguage"; + /** + * The name of the TTS voice to be used for speech synthesis + * @member PropertyId.SpeechServiceConnection_SynthVoice + */ + PropertyId[PropertyId["SpeechServiceConnection_SynthVoice"] = 18] = "SpeechServiceConnection_SynthVoice"; + /** + * The string to specify TTS output audio format + * @member PropertyId.SpeechServiceConnection_SynthOutputFormat + */ + PropertyId[PropertyId["SpeechServiceConnection_SynthOutputFormat"] = 19] = "SpeechServiceConnection_SynthOutputFormat"; + /** + * The list of comma separated languages used as possible source languages + * Added in version 1.13.0 + * @member PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages + */ + PropertyId[PropertyId["SpeechServiceConnection_AutoDetectSourceLanguages"] = 20] = "SpeechServiceConnection_AutoDetectSourceLanguages"; + /** + * The requested Cognitive Services Speech Service response output format (simple or detailed). Under normal circumstances, you shouldn't have + * to use this property directly. + * Instead use [[SpeechConfig.outputFormat]]. + * @member PropertyId.SpeechServiceResponse_RequestDetailedResultTrueFalse + */ + PropertyId[PropertyId["SpeechServiceResponse_RequestDetailedResultTrueFalse"] = 21] = "SpeechServiceResponse_RequestDetailedResultTrueFalse"; + /** + * The requested Cognitive Services Speech Service response output profanity level. Currently unused. + * @member PropertyId.SpeechServiceResponse_RequestProfanityFilterTrueFalse + */ + PropertyId[PropertyId["SpeechServiceResponse_RequestProfanityFilterTrueFalse"] = 22] = "SpeechServiceResponse_RequestProfanityFilterTrueFalse"; + /** + * The Cognitive Services Speech Service response output (in JSON format). This property is available on recognition result objects only. + * @member PropertyId.SpeechServiceResponse_JsonResult + */ + PropertyId[PropertyId["SpeechServiceResponse_JsonResult"] = 23] = "SpeechServiceResponse_JsonResult"; + /** + * The Cognitive Services Speech Service error details (in JSON format). Under normal circumstances, you shouldn't have to + * use this property directly. Instead use [[CancellationDetails.errorDetails]]. + * @member PropertyId.SpeechServiceResponse_JsonErrorDetails + */ + PropertyId[PropertyId["SpeechServiceResponse_JsonErrorDetails"] = 24] = "SpeechServiceResponse_JsonErrorDetails"; + /** + * The cancellation reason. Currently unused. + * @member PropertyId.CancellationDetails_Reason + */ + PropertyId[PropertyId["CancellationDetails_Reason"] = 25] = "CancellationDetails_Reason"; + /** + * The cancellation text. Currently unused. + * @member PropertyId.CancellationDetails_ReasonText + */ + PropertyId[PropertyId["CancellationDetails_ReasonText"] = 26] = "CancellationDetails_ReasonText"; + /** + * The Cancellation detailed text. Currently unused. + * @member PropertyId.CancellationDetails_ReasonDetailedText + */ + PropertyId[PropertyId["CancellationDetails_ReasonDetailedText"] = 27] = "CancellationDetails_ReasonDetailedText"; + /** + * The Language Understanding Service response output (in JSON format). Available via [[IntentRecognitionResult]] + * @member PropertyId.LanguageUnderstandingServiceResponse_JsonResult + */ + PropertyId[PropertyId["LanguageUnderstandingServiceResponse_JsonResult"] = 28] = "LanguageUnderstandingServiceResponse_JsonResult"; + /** + * The URL string built from speech configuration. + * This property is intended to be read-only. The SDK is using it internally. + * NOTE: Added in version 1.7.0. + */ + PropertyId[PropertyId["SpeechServiceConnection_Url"] = 29] = "SpeechServiceConnection_Url"; + /** + * The initial silence timeout value (in milliseconds) used by the service. + * Added in version 1.7.0 + */ + PropertyId[PropertyId["SpeechServiceConnection_InitialSilenceTimeoutMs"] = 30] = "SpeechServiceConnection_InitialSilenceTimeoutMs"; + /** + * The end silence timeout value (in milliseconds) used by the service. + * Added in version 1.7.0 + */ + PropertyId[PropertyId["SpeechServiceConnection_EndSilenceTimeoutMs"] = 31] = "SpeechServiceConnection_EndSilenceTimeoutMs"; + /** + * A boolean value specifying whether audio logging is enabled in the service or not. + * Added in version 1.7.0 + */ + PropertyId[PropertyId["SpeechServiceConnection_EnableAudioLogging"] = 32] = "SpeechServiceConnection_EnableAudioLogging"; + /** + * The requested Cognitive Services Speech Service response output profanity setting. + * Allowed values are "masked", "removed", and "raw". + * Added in version 1.7.0. + */ + PropertyId[PropertyId["SpeechServiceResponse_ProfanityOption"] = 33] = "SpeechServiceResponse_ProfanityOption"; + /** + * A string value specifying which post processing option should be used by service. + * Allowed values are "TrueText". + * Added in version 1.7.0 + */ + PropertyId[PropertyId["SpeechServiceResponse_PostProcessingOption"] = 34] = "SpeechServiceResponse_PostProcessingOption"; + /** + * A boolean value specifying whether to include word-level timestamps in the response result. + * Added in version 1.7.0 + */ + PropertyId[PropertyId["SpeechServiceResponse_RequestWordLevelTimestamps"] = 35] = "SpeechServiceResponse_RequestWordLevelTimestamps"; + /** + * The number of times a word has to be in partial results to be returned. + * Added in version 1.7.0 + */ + PropertyId[PropertyId["SpeechServiceResponse_StablePartialResultThreshold"] = 36] = "SpeechServiceResponse_StablePartialResultThreshold"; + /** + * A string value specifying the output format option in the response result. Internal use only. + * Added in version 1.7.0. + */ + PropertyId[PropertyId["SpeechServiceResponse_OutputFormatOption"] = 37] = "SpeechServiceResponse_OutputFormatOption"; + /** + * A boolean value to request for stabilizing translation partial results by omitting words in the end. + * Added in version 1.7.0. + */ + PropertyId[PropertyId["SpeechServiceResponse_TranslationRequestStablePartialResult"] = 38] = "SpeechServiceResponse_TranslationRequestStablePartialResult"; + /** + * Identifier used to connect to the backend service. + * @member PropertyId.Conversation_ApplicationId + */ + PropertyId[PropertyId["Conversation_ApplicationId"] = 39] = "Conversation_ApplicationId"; + /** + * Type of dialog backend to connect to. + * @member PropertyId.Conversation_DialogType + */ + PropertyId[PropertyId["Conversation_DialogType"] = 40] = "Conversation_DialogType"; + /** + * Silence timeout for listening + * @member PropertyId.Conversation_Initial_Silence_Timeout + */ + PropertyId[PropertyId["Conversation_Initial_Silence_Timeout"] = 41] = "Conversation_Initial_Silence_Timeout"; + /** + * From Id to add to speech recognition activities. + * @member PropertyId.Conversation_From_Id + */ + PropertyId[PropertyId["Conversation_From_Id"] = 42] = "Conversation_From_Id"; + /** + * ConversationId for the session. + * @member PropertyId.Conversation_Conversation_Id + */ + PropertyId[PropertyId["Conversation_Conversation_Id"] = 43] = "Conversation_Conversation_Id"; + /** + * Comma separated list of custom voice deployment ids. + * @member PropertyId.Conversation_Custom_Voice_Deployment_Ids + */ + PropertyId[PropertyId["Conversation_Custom_Voice_Deployment_Ids"] = 44] = "Conversation_Custom_Voice_Deployment_Ids"; + /** + * Speech activity template, stamp properties from the template on the activity generated by the service for speech. + * @member PropertyId.Conversation_Speech_Activity_Template + * Added in version 1.10.0. + */ + PropertyId[PropertyId["Conversation_Speech_Activity_Template"] = 45] = "Conversation_Speech_Activity_Template"; + /** + * The Cognitive Services Speech Service host (url). Under normal circumstances, you shouldn't have to use this property directly. + * Instead, use [[SpeechConfig.fromHost]]. + */ + PropertyId[PropertyId["SpeechServiceConnection_Host"] = 46] = "SpeechServiceConnection_Host"; + /** + * Set the host for service calls to the Conversation Translator REST management and websocket calls. + */ + PropertyId[PropertyId["ConversationTranslator_Host"] = 47] = "ConversationTranslator_Host"; + /** + * Optionally set the the host's display name. + * Used when joining a conversation. + */ + PropertyId[PropertyId["ConversationTranslator_Name"] = 48] = "ConversationTranslator_Name"; + /** + * Optionally set a value for the X-CorrelationId request header. + * Used for troubleshooting errors in the server logs. It should be a valid guid. + */ + PropertyId[PropertyId["ConversationTranslator_CorrelationId"] = 49] = "ConversationTranslator_CorrelationId"; + /** + * Set the conversation token to be sent to the speech service. This enables the + * service to service call from the speech service to the Conversation Translator service for relaying + * recognitions. For internal use. + */ + PropertyId[PropertyId["ConversationTranslator_Token"] = 50] = "ConversationTranslator_Token"; +})(PropertyId = exports.PropertyId || (exports.PropertyId = {})); + + + +/***/ }), +/* 69 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var Exports_2 = __webpack_require__(4); +var Contracts_1 = __webpack_require__(33); +var Exports_3 = __webpack_require__(31); +/** + * Defines the base class Recognizer which mainly contains common event handlers. + * @class Recognizer + */ +var Recognizer = /** @class */ (function () { + /** + * Creates and initializes an instance of a Recognizer + * @constructor + * @param {AudioConfig} audioInput - An optional audio input stream associated with the recognizer + */ + function Recognizer(audioConfig, properties, connectionFactory) { + this.audioConfig = (audioConfig !== undefined) ? audioConfig : Exports_3.AudioConfig.fromDefaultMicrophoneInput(); + this.privDisposed = false; + this.privProperties = properties.clone(); + this.privConnectionFactory = connectionFactory; + this.implCommonRecognizerSetup(); + } + /** + * Dispose of associated resources. + * @member Recognizer.prototype.close + * @function + * @public + */ + Recognizer.prototype.close = function () { + Contracts_1.Contracts.throwIfDisposed(this.privDisposed); + this.dispose(true); + }; + Object.defineProperty(Recognizer.prototype, "internalData", { + /** + * @Internal + * Internal data member to support fromRecognizer* pattern methods on other classes. + * Do not use externally, object returned will change without warning or notice. + */ + get: function () { + return this.privReco; + }, + enumerable: true, + configurable: true + }); + /** + * This method performs cleanup of resources. + * The Boolean parameter disposing indicates whether the method is called + * from Dispose (if disposing is true) or from the finalizer (if disposing is false). + * Derived classes should override this method to dispose resource if needed. + * @member Recognizer.prototype.dispose + * @function + * @public + * @param {boolean} disposing - Flag to request disposal. + */ + Recognizer.prototype.dispose = function (disposing) { + if (this.privDisposed) { + return; + } + if (disposing) { + if (this.privReco) { + this.privReco.audioSource.turnOff(); + this.privReco.dispose(); + } + } + this.privDisposed = true; + }; + Object.defineProperty(Recognizer, "telemetryEnabled", { + /** + * This method returns the current state of the telemetry setting. + * @member Recognizer.prototype.telemetryEnabled + * @function + * @public + * @returns true if the telemetry is enabled, false otherwise. + */ + get: function () { + return Exports_1.ServiceRecognizerBase.telemetryDataEnabled; + }, + enumerable: true, + configurable: true + }); + /** + * This method globally enables or disables telemetry. + * @member Recognizer.prototype.enableTelemetry + * @function + * @public + * @param enabled - Global setting for telemetry collection. + * If set to true, telemetry information like microphone errors, + * recognition errors are collected and sent to Microsoft. + * If set to false, no telemetry is sent to Microsoft. + */ + /* tslint:disable:member-ordering */ + Recognizer.enableTelemetry = function (enabled) { + Exports_1.ServiceRecognizerBase.telemetryDataEnabled = enabled; + }; + // Does the generic recognizer setup that is common across all recognizer types. + Recognizer.prototype.implCommonRecognizerSetup = function () { + var _this = this; + var osPlatform = (typeof window !== "undefined") ? "Browser" : "Node"; + var osName = "unknown"; + var osVersion = "unknown"; + if (typeof navigator !== "undefined") { + osPlatform = osPlatform + "/" + navigator.platform; + osName = navigator.userAgent; + osVersion = navigator.appVersion; + } + var recognizerConfig = this.createRecognizerConfig(new Exports_1.SpeechServiceConfig(new Exports_1.Context(new Exports_1.OS(osPlatform, osName, osVersion)))); + var subscriptionKey = this.privProperties.getProperty(Exports_3.PropertyId.SpeechServiceConnection_Key, undefined); + var authentication = (subscriptionKey && subscriptionKey !== "") ? + new Exports_1.CognitiveSubscriptionKeyAuthentication(subscriptionKey) : + new Exports_1.CognitiveTokenAuthentication(function (authFetchEventId) { + var authorizationToken = _this.privProperties.getProperty(Exports_3.PropertyId.SpeechServiceAuthorization_Token, undefined); + return Exports_2.PromiseHelper.fromResult(authorizationToken); + }, function (authFetchEventId) { + var authorizationToken = _this.privProperties.getProperty(Exports_3.PropertyId.SpeechServiceAuthorization_Token, undefined); + return Exports_2.PromiseHelper.fromResult(authorizationToken); + }); + this.privReco = this.createServiceRecognizer(authentication, this.privConnectionFactory, this.audioConfig, recognizerConfig); + }; + Recognizer.prototype.recognizeOnceAsyncImpl = function (recognitionMode, cb, err) { + var _this = this; + try { + Contracts_1.Contracts.throwIfDisposed(this.privDisposed); + this.implRecognizerStop().on(function (_) { + try { + _this.privReco.recognize(recognitionMode, function (e) { + _this.implRecognizerStop().on(function (_) { + if (!!cb) { + cb(e); + } + }, function (error) { + if (!!err) { + err(error); + } + }); + }, function (e) { + _this.implRecognizerStop(); // We're already in an error path so best effort here. + if (!!err) { + err(e); + } + /* tslint:disable:no-empty */ + }).on(function (_) { }, function (error) { + if (!!err) { + err(error); + } + }); + } + catch (error) { + if (!!err) { + if (error instanceof Error) { + var typedError = error; + err(typedError.name + ": " + typedError.message); + } + else { + err(error); + } + } + // Destroy the recognizer. + _this.dispose(true); + } + }, function (error) { + if (!!err) { + err(error); + } + }); + } + catch (error) { + if (!!err) { + if (error instanceof Error) { + var typedError = error; + err(typedError.name + ": " + typedError.message); + } + else { + err(error); + } + } + // Destroy the recognizer. + this.dispose(true); + } + }; + Recognizer.prototype.startContinuousRecognitionAsyncImpl = function (recognitionMode, cb, err) { + var _this = this; + try { + Contracts_1.Contracts.throwIfDisposed(this.privDisposed); + this.implRecognizerStop().on(function (_) { + _this.privReco.recognize(recognitionMode, undefined, undefined).on(function (_) { + // report result to promise. + if (!!cb) { + try { + cb(); + } + catch (e) { + if (!!err) { + err(e); + } + } + cb = undefined; + } + }, function (error) { + if (!!err) { + err(error); + } + // Destroy the recognizer. + _this.dispose(true); + }); + }, function (error) { + if (!!err) { + err(error); + } + // Destroy the recognizer. + _this.dispose(true); + }); + } + catch (error) { + if (!!err) { + if (error instanceof Error) { + var typedError = error; + err(typedError.name + ": " + typedError.message); + } + else { + err(error); + } + } + // Destroy the recognizer. + this.dispose(true); + } + }; + Recognizer.prototype.stopContinuousRecognitionAsyncImpl = function (cb, err) { + try { + Contracts_1.Contracts.throwIfDisposed(this.privDisposed); + this.implRecognizerStop().on(function (_) { + if (!!cb) { + try { + cb(); + } + catch (e) { + if (!!err) { + err(e); + } + } + } + }, function (error) { + if (!!err) { + err(error); + } + }); + } + catch (error) { + if (!!err) { + if (error instanceof Error) { + var typedError = error; + err(typedError.name + ": " + typedError.message); + } + else { + err(error); + } + } + // Destroy the recognizer. + this.dispose(true); + } + }; + Recognizer.prototype.implRecognizerStop = function () { + if (this.privReco) { + return this.privReco.stopRecognizing(); + } + return Exports_2.PromiseHelper.fromResult(true); + }; + return Recognizer; +}()); +exports.Recognizer = Recognizer; + + + +/***/ }), +/* 70 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(26); +var SpeechConnectionFactory_1 = __webpack_require__(71); +var Contracts_1 = __webpack_require__(33); +var Exports_2 = __webpack_require__(31); +/** + * Performs speech recognition from microphone, file, or other audio input streams, and gets transcribed text as result. + * @class SpeechRecognizer + */ +var SpeechRecognizer = /** @class */ (function (_super) { + __extends(SpeechRecognizer, _super); + /** + * SpeechRecognizer constructor. + * @constructor + * @param {SpeechConfig} speechConfig - an set of initial properties for this recognizer + * @param {AudioConfig} audioConfig - An optional audio configuration associated with the recognizer + */ + function SpeechRecognizer(speechConfig, audioConfig) { + var _this = this; + var speechConfigImpl = speechConfig; + Contracts_1.Contracts.throwIfNull(speechConfigImpl, "speechConfig"); + Contracts_1.Contracts.throwIfNullOrWhitespace(speechConfigImpl.properties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage), Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage]); + _this = _super.call(this, audioConfig, speechConfigImpl.properties, new SpeechConnectionFactory_1.SpeechConnectionFactory()) || this; + _this.privDisposedSpeechRecognizer = false; + return _this; + } + /** + * SpeechRecognizer constructor. + * @constructor + * @param {SpeechConfig} speechConfig - an set of initial properties for this recognizer + * @param {AutoDetectSourceLanguageConfig} autoDetectSourceLanguageConfig - An source language detection configuration associated with the recognizer + * @param {AudioConfig} audioConfig - An optional audio configuration associated with the recognizer + */ + SpeechRecognizer.FromConfig = function (speechConfig, autoDetectSourceLanguageConfig, audioConfig) { + var speechConfigImpl = speechConfig; + autoDetectSourceLanguageConfig.properties.mergeTo(speechConfigImpl.properties); + var recognizer = new SpeechRecognizer(speechConfig, audioConfig); + return recognizer; + }; + Object.defineProperty(SpeechRecognizer.prototype, "endpointId", { + /** + * Gets the endpoint id of a customized speech model that is used for speech recognition. + * @member SpeechRecognizer.prototype.endpointId + * @function + * @public + * @returns {string} the endpoint id of a customized speech model that is used for speech recognition. + */ + get: function () { + Contracts_1.Contracts.throwIfDisposed(this.privDisposedSpeechRecognizer); + return this.properties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_EndpointId, "00000000-0000-0000-0000-000000000000"); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechRecognizer.prototype, "authorizationToken", { + /** + * Gets the authorization token used to communicate with the service. + * @member SpeechRecognizer.prototype.authorizationToken + * @function + * @public + * @returns {string} Authorization token. + */ + get: function () { + return this.properties.getProperty(Exports_2.PropertyId.SpeechServiceAuthorization_Token); + }, + /** + * Gets/Sets the authorization token used to communicate with the service. + * @member SpeechRecognizer.prototype.authorizationToken + * @function + * @public + * @param {string} token - Authorization token. + */ + set: function (token) { + Contracts_1.Contracts.throwIfNullOrWhitespace(token, "token"); + this.properties.setProperty(Exports_2.PropertyId.SpeechServiceAuthorization_Token, token); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechRecognizer.prototype, "speechRecognitionLanguage", { + /** + * Gets the spoken language of recognition. + * @member SpeechRecognizer.prototype.speechRecognitionLanguage + * @function + * @public + * @returns {string} The spoken language of recognition. + */ + get: function () { + Contracts_1.Contracts.throwIfDisposed(this.privDisposedSpeechRecognizer); + return this.properties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechRecognizer.prototype, "outputFormat", { + /** + * Gets the output format of recognition. + * @member SpeechRecognizer.prototype.outputFormat + * @function + * @public + * @returns {OutputFormat} The output format of recognition. + */ + get: function () { + Contracts_1.Contracts.throwIfDisposed(this.privDisposedSpeechRecognizer); + if (this.properties.getProperty(Exports_1.OutputFormatPropertyName, Exports_2.OutputFormat[Exports_2.OutputFormat.Simple]) === Exports_2.OutputFormat[Exports_2.OutputFormat.Simple]) { + return Exports_2.OutputFormat.Simple; + } + else { + return Exports_2.OutputFormat.Detailed; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechRecognizer.prototype, "properties", { + /** + * The collection of properties and their values defined for this SpeechRecognizer. + * @member SpeechRecognizer.prototype.properties + * @function + * @public + * @returns {PropertyCollection} The collection of properties and their values defined for this SpeechRecognizer. + */ + get: function () { + return this.privProperties; + }, + enumerable: true, + configurable: true + }); + /** + * Starts speech recognition, and stops after the first utterance is recognized. + * The task returns the recognition text as result. + * Note: RecognizeOnceAsync() returns when the first utterance has been recognized, + * so it is suitable only for single shot recognition + * like command or query. For long-running recognition, use StartContinuousRecognitionAsync() instead. + * @member SpeechRecognizer.prototype.recognizeOnceAsync + * @function + * @public + * @param cb - Callback that received the SpeechRecognitionResult. + * @param err - Callback invoked in case of an error. + */ + SpeechRecognizer.prototype.recognizeOnceAsync = function (cb, err) { + this.recognizeOnceAsyncImpl(Exports_1.RecognitionMode.Interactive, cb, err); + }; + /** + * Starts speech recognition, until stopContinuousRecognitionAsync() is called. + * User must subscribe to events to receive recognition results. + * @member SpeechRecognizer.prototype.startContinuousRecognitionAsync + * @function + * @public + * @param cb - Callback invoked once the recognition has started. + * @param err - Callback invoked in case of an error. + */ + SpeechRecognizer.prototype.startContinuousRecognitionAsync = function (cb, err) { + this.startContinuousRecognitionAsyncImpl(Exports_1.RecognitionMode.Conversation, cb, err); + }; + /** + * Stops continuous speech recognition. + * @member SpeechRecognizer.prototype.stopContinuousRecognitionAsync + * @function + * @public + * @param cb - Callback invoked once the recognition has stopped. + * @param err - Callback invoked in case of an error. + */ + SpeechRecognizer.prototype.stopContinuousRecognitionAsync = function (cb, err) { + this.stopContinuousRecognitionAsyncImpl(cb, err); + }; + /** + * Starts speech recognition with keyword spotting, until + * stopKeywordRecognitionAsync() is called. + * User must subscribe to events to receive recognition results. + * Note: Key word spotting functionality is only available on the + * Speech Devices SDK. This functionality is currently not included in the SDK itself. + * @member SpeechRecognizer.prototype.startKeywordRecognitionAsync + * @function + * @public + * @param {KeywordRecognitionModel} model The keyword recognition model that + * specifies the keyword to be recognized. + * @param cb - Callback invoked once the recognition has started. + * @param err - Callback invoked in case of an error. + */ + SpeechRecognizer.prototype.startKeywordRecognitionAsync = function (model, cb, err) { + Contracts_1.Contracts.throwIfNull(model, "model"); + if (!!err) { + err("Not yet implemented."); + } + }; + /** + * Stops continuous speech recognition. + * Note: Key word spotting functionality is only available on the + * Speech Devices SDK. This functionality is currently not included in the SDK itself. + * @member SpeechRecognizer.prototype.stopKeywordRecognitionAsync + * @function + * @public + * @param cb - Callback invoked once the recognition has stopped. + * @param err - Callback invoked in case of an error. + */ + SpeechRecognizer.prototype.stopKeywordRecognitionAsync = function (cb, err) { + if (!!cb) { + cb(); + } + }; + /** + * closes all external resources held by an instance of this class. + * @member SpeechRecognizer.prototype.close + * @function + * @public + */ + SpeechRecognizer.prototype.close = function () { + Contracts_1.Contracts.throwIfDisposed(this.privDisposedSpeechRecognizer); + this.dispose(true); + }; + /** + * Disposes any resources held by the object. + * @member SpeechRecognizer.prototype.dispose + * @function + * @public + * @param {boolean} disposing - true if disposing the object. + */ + SpeechRecognizer.prototype.dispose = function (disposing) { + if (this.privDisposedSpeechRecognizer) { + return; + } + if (disposing) { + this.implRecognizerStop(); // Dispose is synchronous, so just start it.... + this.privDisposedSpeechRecognizer = true; + } + _super.prototype.dispose.call(this, disposing); + }; + SpeechRecognizer.prototype.createRecognizerConfig = function (speechConfig) { + return new Exports_1.RecognizerConfig(speechConfig, this.properties); + }; + SpeechRecognizer.prototype.createServiceRecognizer = function (authentication, connectionFactory, audioConfig, recognizerConfig) { + var configImpl = audioConfig; + return new Exports_1.SpeechServiceRecognizer(authentication, connectionFactory, configImpl, recognizerConfig, this); + }; + return SpeechRecognizer; +}(Exports_2.Recognizer)); +exports.SpeechRecognizer = SpeechRecognizer; + + + +/***/ }), +/* 71 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(2); +var Exports_2 = __webpack_require__(26); +var Exports_3 = __webpack_require__(31); +var ConnectionFactoryBase_1 = __webpack_require__(72); +var Exports_4 = __webpack_require__(26); +var QueryParameterNames_1 = __webpack_require__(73); +var SpeechConnectionFactory = /** @class */ (function (_super) { + __extends(SpeechConnectionFactory, _super); + function SpeechConnectionFactory() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.interactiveRelativeUri = "/speech/recognition/interactive/cognitiveservices/v1"; + _this.conversationRelativeUri = "/speech/recognition/conversation/cognitiveservices/v1"; + _this.dictationRelativeUri = "/speech/recognition/dictation/cognitiveservices/v1"; + _this.create = function (config, authInfo, connectionId) { + var endpoint = config.parameters.getProperty(Exports_3.PropertyId.SpeechServiceConnection_Endpoint, undefined); + var region = config.parameters.getProperty(Exports_3.PropertyId.SpeechServiceConnection_Region, undefined); + var hostSuffix = (region && region.toLowerCase().startsWith("china")) ? ".azure.cn" : ".microsoft.com"; + var host = config.parameters.getProperty(Exports_3.PropertyId.SpeechServiceConnection_Host, "wss://" + region + ".stt.speech" + hostSuffix); + var queryParams = {}; + var endpointId = config.parameters.getProperty(Exports_3.PropertyId.SpeechServiceConnection_EndpointId, undefined); + var language = config.parameters.getProperty(Exports_3.PropertyId.SpeechServiceConnection_RecoLanguage, undefined); + if (endpointId) { + if (!endpoint || endpoint.search(QueryParameterNames_1.QueryParameterNames.DeploymentIdParamName) === -1) { + queryParams[QueryParameterNames_1.QueryParameterNames.DeploymentIdParamName] = endpointId; + } + } + else if (language) { + if (!endpoint || endpoint.search(QueryParameterNames_1.QueryParameterNames.LanguageParamName) === -1) { + queryParams[QueryParameterNames_1.QueryParameterNames.LanguageParamName] = language; + } + } + if (!endpoint || endpoint.search(QueryParameterNames_1.QueryParameterNames.FormatParamName) === -1) { + queryParams[QueryParameterNames_1.QueryParameterNames.FormatParamName] = config.parameters.getProperty(Exports_2.OutputFormatPropertyName, Exports_3.OutputFormat[Exports_3.OutputFormat.Simple]).toLowerCase(); + } + if (config.autoDetectSourceLanguages !== undefined) { + queryParams[QueryParameterNames_1.QueryParameterNames.EnableLanguageID] = "true"; + } + _this.setCommonUrlParams(config, queryParams, endpoint); + if (!endpoint) { + switch (config.recognitionMode) { + case Exports_4.RecognitionMode.Conversation: + if (config.parameters.getProperty(Exports_2.ForceDictationPropertyName, "false") === "true") { + endpoint = host + _this.dictationRelativeUri; + } + else { + endpoint = host + _this.conversationRelativeUri; + } + break; + case Exports_4.RecognitionMode.Dictation: + endpoint = host + _this.dictationRelativeUri; + break; + default: + endpoint = host + _this.interactiveRelativeUri; // default is interactive + break; + } + } + var headers = {}; + if (authInfo.token !== undefined && authInfo.token !== "") { + headers[authInfo.headerName] = authInfo.token; + } + headers[QueryParameterNames_1.QueryParameterNames.ConnectionIdHeader] = connectionId; + config.parameters.setProperty(Exports_3.PropertyId.SpeechServiceConnection_Url, endpoint); + return new Exports_1.WebsocketConnection(endpoint, queryParams, headers, new Exports_4.WebsocketMessageFormatter(), Exports_1.ProxyInfo.fromRecognizerConfig(config), connectionId); + }; + return _this; + } + return SpeechConnectionFactory; +}(ConnectionFactoryBase_1.ConnectionFactoryBase)); +exports.SpeechConnectionFactory = SpeechConnectionFactory; + + + +/***/ }), +/* 72 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var Exports_2 = __webpack_require__(31); +var QueryParameterNames_1 = __webpack_require__(73); +var ConnectionFactoryBase = /** @class */ (function () { + function ConnectionFactoryBase() { + } + ConnectionFactoryBase.prototype.setCommonUrlParams = function (config, queryParams, endpoint) { + this.setUrlParameter(Exports_2.PropertyId.SpeechServiceConnection_EnableAudioLogging, QueryParameterNames_1.QueryParameterNames.EnableAudioLogging, config, queryParams, endpoint); + this.setUrlParameter(Exports_2.PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps, QueryParameterNames_1.QueryParameterNames.EnableWordLevelTimestamps, config, queryParams, endpoint); + this.setUrlParameter(Exports_2.PropertyId.SpeechServiceResponse_ProfanityOption, QueryParameterNames_1.QueryParameterNames.Profanify, config, queryParams, endpoint); + this.setUrlParameter(Exports_2.PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs, QueryParameterNames_1.QueryParameterNames.InitialSilenceTimeoutMs, config, queryParams, endpoint); + this.setUrlParameter(Exports_2.PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs, QueryParameterNames_1.QueryParameterNames.EndSilenceTimeoutMs, config, queryParams, endpoint); + this.setUrlParameter(Exports_2.PropertyId.SpeechServiceResponse_StablePartialResultThreshold, QueryParameterNames_1.QueryParameterNames.StableIntermediateThreshold, config, queryParams, endpoint); + var serviceProperties = JSON.parse(config.parameters.getProperty(Exports_1.ServicePropertiesPropertyName, "{}")); + Object.keys(serviceProperties).forEach(function (value, num, array) { + queryParams[value] = serviceProperties[value]; + }); + }; + ConnectionFactoryBase.prototype.setUrlParameter = function (propId, parameterName, config, queryParams, endpoint) { + var value = config.parameters.getProperty(propId, undefined); + if (value && (!endpoint || endpoint.search(parameterName) === -1)) { + queryParams[parameterName] = value.toLocaleLowerCase(); + } + }; + return ConnectionFactoryBase; +}()); +exports.ConnectionFactoryBase = ConnectionFactoryBase; + + + +/***/ }), +/* 73 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var QueryParameterNames = /** @class */ (function () { + function QueryParameterNames() { + } + Object.defineProperty(QueryParameterNames, "TestHooksParamName", { + get: function () { + return "testhooks"; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(QueryParameterNames, "ConnectionIdHeader", { + get: function () { + return "X-ConnectionId"; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(QueryParameterNames, "DeploymentIdParamName", { + get: function () { + return "cid"; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(QueryParameterNames, "FormatParamName", { + get: function () { + return "format"; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(QueryParameterNames, "LanguageParamName", { + get: function () { + return "language"; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(QueryParameterNames, "TranslationFromParamName", { + get: function () { + return "from"; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(QueryParameterNames, "TranslationToParamName", { + get: function () { + return "to"; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(QueryParameterNames, "Profanify", { + get: function () { + return "profanity"; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(QueryParameterNames, "EnableAudioLogging", { + get: function () { + return "storeAudio"; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(QueryParameterNames, "EnableWordLevelTimestamps", { + get: function () { + return "wordLevelTimestamps"; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(QueryParameterNames, "InitialSilenceTimeoutMs", { + get: function () { + return "initialSilenceTimeoutMs"; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(QueryParameterNames, "EndSilenceTimeoutMs", { + get: function () { + return "endSilenceTimeoutMs"; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(QueryParameterNames, "StableIntermediateThreshold", { + get: function () { + return "stableIntermediateThreshold"; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(QueryParameterNames, "StableTranslation", { + get: function () { + return "stableTranslation"; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(QueryParameterNames, "EnableLanguageID", { + get: function () { + return "lidEnabled"; + }, + enumerable: true, + configurable: true + }); + return QueryParameterNames; +}()); +exports.QueryParameterNames = QueryParameterNames; + + + +/***/ }), +/* 74 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(26); +var Contracts_1 = __webpack_require__(33); +var Exports_2 = __webpack_require__(31); +/** + * Intent recognizer. + * @class + */ +var IntentRecognizer = /** @class */ (function (_super) { + __extends(IntentRecognizer, _super); + /** + * Initializes an instance of the IntentRecognizer. + * @constructor + * @param {SpeechConfig} speechConfig - The set of configuration properties. + * @param {AudioConfig} audioConfig - An optional audio input config associated with the recognizer + */ + function IntentRecognizer(speechConfig, audioConfig) { + var _this = this; + Contracts_1.Contracts.throwIfNullOrUndefined(speechConfig, "speechConfig"); + var configImpl = speechConfig; + Contracts_1.Contracts.throwIfNullOrUndefined(configImpl, "speechConfig"); + _this = _super.call(this, audioConfig, configImpl.properties, new Exports_1.IntentConnectionFactory()) || this; + _this.privAddedIntents = []; + _this.privAddedLmIntents = {}; + _this.privDisposedIntentRecognizer = false; + _this.privProperties = configImpl.properties; + Contracts_1.Contracts.throwIfNullOrWhitespace(_this.properties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage), Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage]); + return _this; + } + Object.defineProperty(IntentRecognizer.prototype, "speechRecognitionLanguage", { + /** + * Gets the spoken language of recognition. + * @member IntentRecognizer.prototype.speechRecognitionLanguage + * @function + * @public + * @returns {string} the spoken language of recognition. + */ + get: function () { + Contracts_1.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer); + return this.properties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(IntentRecognizer.prototype, "authorizationToken", { + /** + * Gets the authorization token used to communicate with the service. + * @member IntentRecognizer.prototype.authorizationToken + * @function + * @public + * @returns {string} Authorization token. + */ + get: function () { + return this.properties.getProperty(Exports_2.PropertyId.SpeechServiceAuthorization_Token); + }, + /** + * Gets/Sets the authorization token used to communicate with the service. + * Note: Please use a token derived from your LanguageUnderstanding subscription key for the Intent recognizer. + * @member IntentRecognizer.prototype.authorizationToken + * @function + * @public + * @param {string} value - Authorization token. + */ + set: function (value) { + this.properties.setProperty(Exports_2.PropertyId.SpeechServiceAuthorization_Token, value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(IntentRecognizer.prototype, "properties", { + /** + * The collection of properties and their values defined for this IntentRecognizer. + * @member IntentRecognizer.prototype.properties + * @function + * @public + * @returns {PropertyCollection} The collection of properties and their + * values defined for this IntentRecognizer. + */ + get: function () { + return this.privProperties; + }, + enumerable: true, + configurable: true + }); + /** + * Starts intent recognition, and stops after the first utterance is recognized. + * The task returns the recognition text and intent as result. + * Note: RecognizeOnceAsync() returns when the first utterance has been recognized, + * so it is suitable only for single shot recognition like command or query. + * For long-running recognition, use StartContinuousRecognitionAsync() instead. + * @member IntentRecognizer.prototype.recognizeOnceAsync + * @function + * @public + * @param cb - Callback that received the recognition has finished with an IntentRecognitionResult. + * @param err - Callback invoked in case of an error. + */ + IntentRecognizer.prototype.recognizeOnceAsync = function (cb, err) { + Contracts_1.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer); + if (Object.keys(this.privAddedLmIntents).length !== 0 || undefined !== this.privUmbrellaIntent) { + var context = this.buildSpeechContext(); + this.privReco.speechContext.setSection("intent", context.Intent); + this.privReco.dynamicGrammar.addReferenceGrammar(context.ReferenceGrammars); + var intentReco = this.privReco; + intentReco.setIntents(this.privAddedLmIntents, this.privUmbrellaIntent); + } + this.recognizeOnceAsyncImpl(Exports_1.RecognitionMode.Interactive, cb, err); + }; + /** + * Starts speech recognition, until stopContinuousRecognitionAsync() is called. + * User must subscribe to events to receive recognition results. + * @member IntentRecognizer.prototype.startContinuousRecognitionAsync + * @function + * @public + * @param cb - Callback invoked once the recognition has started. + * @param err - Callback invoked in case of an error. + */ + IntentRecognizer.prototype.startContinuousRecognitionAsync = function (cb, err) { + if (Object.keys(this.privAddedLmIntents).length !== 0) { + var context = this.buildSpeechContext(); + this.privReco.speechContext.setSection("intent", context.Intent); + this.privReco.dynamicGrammar.addReferenceGrammar(context.ReferenceGrammars); + var intentReco = this.privReco; + intentReco.setIntents(this.privAddedLmIntents, this.privUmbrellaIntent); + } + this.startContinuousRecognitionAsyncImpl(Exports_1.RecognitionMode.Conversation, cb, err); + }; + /** + * Stops continuous intent recognition. + * @member IntentRecognizer.prototype.stopContinuousRecognitionAsync + * @function + * @public + * @param cb - Callback invoked once the recognition has stopped. + * @param err - Callback invoked in case of an error. + */ + IntentRecognizer.prototype.stopContinuousRecognitionAsync = function (cb, err) { + this.stopContinuousRecognitionAsyncImpl(cb, err); + }; + /** + * Starts speech recognition with keyword spotting, until stopKeywordRecognitionAsync() is called. + * User must subscribe to events to receive recognition results. + * Note: Key word spotting functionality is only available on the Speech Devices SDK. + * This functionality is currently not included in the SDK itself. + * @member IntentRecognizer.prototype.startKeywordRecognitionAsync + * @function + * @public + * @param {KeywordRecognitionModel} model - The keyword recognition model that specifies the keyword to be recognized. + * @param cb - Callback invoked once the recognition has started. + * @param err - Callback invoked in case of an error. + */ + IntentRecognizer.prototype.startKeywordRecognitionAsync = function (model, cb, err) { + Contracts_1.Contracts.throwIfNull(model, "model"); + if (!!err) { + err("Not yet implemented."); + } + }; + /** + * Stops continuous speech recognition. + * Note: Key word spotting functionality is only available on the Speech Devices SDK. + * This functionality is currently not included in the SDK itself. + * @member IntentRecognizer.prototype.stopKeywordRecognitionAsync + * @function + * @public + * @param cb - Callback invoked once the recognition has stopped. + * @param err - Callback invoked in case of an error. + */ + IntentRecognizer.prototype.stopKeywordRecognitionAsync = function (cb, err) { + if (!!cb) { + cb(); + } + }; + /** + * Adds a phrase that should be recognized as intent. + * @member IntentRecognizer.prototype.addIntent + * @function + * @public + * @param {string} intentId - A String that represents the identifier of the intent to be recognized. + * @param {string} phrase - A String that specifies the phrase representing the intent. + */ + IntentRecognizer.prototype.addIntent = function (simplePhrase, intentId) { + Contracts_1.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer); + Contracts_1.Contracts.throwIfNullOrWhitespace(intentId, "intentId"); + Contracts_1.Contracts.throwIfNullOrWhitespace(simplePhrase, "simplePhrase"); + this.privAddedIntents.push([intentId, simplePhrase]); + }; + /** + * Adds an intent from Language Understanding service for recognition. + * @member IntentRecognizer.prototype.addIntentWithLanguageModel + * @function + * @public + * @param {string} intentId - A String that represents the identifier of the intent + * to be recognized. Ignored if intentName is empty. + * @param {string} model - The intent model from Language Understanding service. + * @param {string} intentName - The intent name defined in the intent model. If it + * is empty, all intent names defined in the model will be added. + */ + IntentRecognizer.prototype.addIntentWithLanguageModel = function (intentId, model, intentName) { + Contracts_1.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer); + Contracts_1.Contracts.throwIfNullOrWhitespace(intentId, "intentId"); + Contracts_1.Contracts.throwIfNull(model, "model"); + var modelImpl = model; + Contracts_1.Contracts.throwIfNullOrWhitespace(modelImpl.appId, "model.appId"); + this.privAddedLmIntents[intentId] = new Exports_1.AddedLmIntent(modelImpl, intentName); + }; + /** + * @summary Adds all intents from the specified Language Understanding Model. + * @member IntentRecognizer.prototype.addAllIntents + * @function + * @public + * @function + * @public + * @param {LanguageUnderstandingModel} model - The language understanding model containing the intents. + * @param {string} intentId - A custom id String to be returned in the IntentRecognitionResult's getIntentId() method. + */ + IntentRecognizer.prototype.addAllIntents = function (model, intentId) { + Contracts_1.Contracts.throwIfNull(model, "model"); + var modelImpl = model; + Contracts_1.Contracts.throwIfNullOrWhitespace(modelImpl.appId, "model.appId"); + this.privUmbrellaIntent = new Exports_1.AddedLmIntent(modelImpl, intentId); + }; + /** + * closes all external resources held by an instance of this class. + * @member IntentRecognizer.prototype.close + * @function + * @public + */ + IntentRecognizer.prototype.close = function () { + Contracts_1.Contracts.throwIfDisposed(this.privDisposedIntentRecognizer); + this.dispose(true); + }; + IntentRecognizer.prototype.createRecognizerConfig = function (speechConfig) { + return new Exports_1.RecognizerConfig(speechConfig, this.properties); + }; + IntentRecognizer.prototype.createServiceRecognizer = function (authentication, connectionFactory, audioConfig, recognizerConfig) { + var audioImpl = audioConfig; + return new Exports_1.IntentServiceRecognizer(authentication, connectionFactory, audioImpl, recognizerConfig, this); + }; + IntentRecognizer.prototype.dispose = function (disposing) { + if (this.privDisposedIntentRecognizer) { + return; + } + if (disposing) { + this.privDisposedIntentRecognizer = true; + _super.prototype.dispose.call(this, disposing); + } + }; + IntentRecognizer.prototype.buildSpeechContext = function () { + var appId; + var region; + var subscriptionKey; + var refGrammers = []; + if (undefined !== this.privUmbrellaIntent) { + appId = this.privUmbrellaIntent.modelImpl.appId; + region = this.privUmbrellaIntent.modelImpl.region; + subscriptionKey = this.privUmbrellaIntent.modelImpl.subscriptionKey; + } + // Build the reference grammer array. + for (var _i = 0, _a = Object.keys(this.privAddedLmIntents); _i < _a.length; _i++) { + var intentId = _a[_i]; + var addedLmIntent = this.privAddedLmIntents[intentId]; + // validate all the same model, region, and key... + if (appId === undefined) { + appId = addedLmIntent.modelImpl.appId; + } + else { + if (appId !== addedLmIntent.modelImpl.appId) { + throw new Error("Intents must all be from the same LUIS model"); + } + } + if (region === undefined) { + region = addedLmIntent.modelImpl.region; + } + else { + if (region !== addedLmIntent.modelImpl.region) { + throw new Error("Intents must all be from the same LUIS model in a single region"); + } + } + if (subscriptionKey === undefined) { + subscriptionKey = addedLmIntent.modelImpl.subscriptionKey; + } + else { + if (subscriptionKey !== addedLmIntent.modelImpl.subscriptionKey) { + throw new Error("Intents must all use the same subscription key"); + } + } + var grammer = "luis/" + appId + "-PRODUCTION#" + intentId; + refGrammers.push(grammer); + } + return { + Intent: { + id: appId, + key: (subscriptionKey === undefined) ? this.privProperties.getProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_Key]) : subscriptionKey, + provider: "LUIS", + }, + ReferenceGrammars: (undefined === this.privUmbrellaIntent) ? refGrammers : ["luis/" + appId + "-PRODUCTION"], + }; + }; + return IntentRecognizer; +}(Exports_2.Recognizer)); +exports.IntentRecognizer = IntentRecognizer; + + + +/***/ }), +/* 75 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Output format + * @class VoiceProfileType + */ +var VoiceProfileType; +(function (VoiceProfileType) { + /** + * Text independent speaker identification + * @member VoiceProfileType.TextIndependentIdentification + */ + VoiceProfileType[VoiceProfileType["TextIndependentIdentification"] = 0] = "TextIndependentIdentification"; + /** + * Text dependent speaker verification + * @member VoiceProfileType.TextDependentVerification + */ + VoiceProfileType[VoiceProfileType["TextDependentVerification"] = 1] = "TextDependentVerification"; + /** + * Text independent speaker verification + * @member VoiceProfileType.TextIndependentVerification + */ + VoiceProfileType[VoiceProfileType["TextIndependentVerification"] = 2] = "TextIndependentVerification"; +})(VoiceProfileType = exports.VoiceProfileType || (exports.VoiceProfileType = {})); + + + +/***/ }), +/* 76 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(26); +var Contracts_1 = __webpack_require__(33); +var Exports_2 = __webpack_require__(31); +/** + * Translation recognizer + * @class TranslationRecognizer + */ +var TranslationRecognizer = /** @class */ (function (_super) { + __extends(TranslationRecognizer, _super); + /** + * Initializes an instance of the TranslationRecognizer. + * @constructor + * @param {SpeechTranslationConfig} speechConfig - Set of properties to configure this recognizer. + * @param {AudioConfig} audioConfig - An optional audio config associated with the recognizer + */ + function TranslationRecognizer(speechConfig, audioConfig) { + var _this = this; + var configImpl = speechConfig; + Contracts_1.Contracts.throwIfNull(configImpl, "speechConfig"); + _this = _super.call(this, audioConfig, configImpl.properties, new Exports_1.TranslationConnectionFactory()) || this; + _this.privDisposedTranslationRecognizer = false; + _this.privProperties = configImpl.properties.clone(); + if (_this.properties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_TranslationVoice, undefined) !== undefined) { + Contracts_1.Contracts.throwIfNullOrWhitespace(_this.properties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_TranslationVoice), Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_TranslationVoice]); + } + Contracts_1.Contracts.throwIfNullOrWhitespace(_this.properties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_TranslationToLanguages), Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_TranslationToLanguages]); + Contracts_1.Contracts.throwIfNullOrWhitespace(_this.properties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage), Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage]); + return _this; + } + Object.defineProperty(TranslationRecognizer.prototype, "speechRecognitionLanguage", { + /** + * Gets the language name that was set when the recognizer was created. + * @member TranslationRecognizer.prototype.speechRecognitionLanguage + * @function + * @public + * @returns {string} Gets the language name that was set when the recognizer was created. + */ + get: function () { + Contracts_1.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer); + return this.properties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TranslationRecognizer.prototype, "targetLanguages", { + /** + * Gets target languages for translation that were set when the recognizer was created. + * The language is specified in BCP-47 format. The translation will provide translated text for each of language. + * @member TranslationRecognizer.prototype.targetLanguages + * @function + * @public + * @returns {string[]} Gets target languages for translation that were set when the recognizer was created. + */ + get: function () { + Contracts_1.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer); + return this.properties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_TranslationToLanguages).split(","); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TranslationRecognizer.prototype, "voiceName", { + /** + * Gets the name of output voice. + * @member TranslationRecognizer.prototype.voiceName + * @function + * @public + * @returns {string} the name of output voice. + */ + get: function () { + Contracts_1.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer); + return this.properties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_TranslationVoice, undefined); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TranslationRecognizer.prototype, "authorizationToken", { + /** + * Gets the authorization token used to communicate with the service. + * @member TranslationRecognizer.prototype.authorizationToken + * @function + * @public + * @returns {string} Authorization token. + */ + get: function () { + return this.properties.getProperty(Exports_2.PropertyId.SpeechServiceAuthorization_Token); + }, + /** + * Gets/Sets the authorization token used to communicate with the service. + * @member TranslationRecognizer.prototype.authorizationToken + * @function + * @public + * @param {string} value - Authorization token. + */ + set: function (value) { + this.properties.setProperty(Exports_2.PropertyId.SpeechServiceAuthorization_Token, value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TranslationRecognizer.prototype, "properties", { + /** + * The collection of properties and their values defined for this TranslationRecognizer. + * @member TranslationRecognizer.prototype.properties + * @function + * @public + * @returns {PropertyCollection} The collection of properties and their values defined for this TranslationRecognizer. + */ + get: function () { + return this.privProperties; + }, + enumerable: true, + configurable: true + }); + /** + * Starts recognition and translation, and stops after the first utterance is recognized. + * The task returns the translation text as result. + * Note: recognizeOnceAsync returns when the first utterance has been recognized, so it is suitableonly + * for single shot recognition like command or query. For long-running recognition, + * use startContinuousRecognitionAsync() instead. + * @member TranslationRecognizer.prototype.recognizeOnceAsync + * @function + * @public + * @param cb - Callback that received the result when the translation has completed. + * @param err - Callback invoked in case of an error. + */ + TranslationRecognizer.prototype.recognizeOnceAsync = function (cb, err) { + Contracts_1.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer); + this.recognizeOnceAsyncImpl(Exports_1.RecognitionMode.Conversation, cb, err); + }; + /** + * Starts recognition and translation, until stopContinuousRecognitionAsync() is called. + * User must subscribe to events to receive translation results. + * @member TranslationRecognizer.prototype.startContinuousRecognitionAsync + * @function + * @public + * @param cb - Callback that received the translation has started. + * @param err - Callback invoked in case of an error. + */ + TranslationRecognizer.prototype.startContinuousRecognitionAsync = function (cb, err) { + this.startContinuousRecognitionAsyncImpl(Exports_1.RecognitionMode.Conversation, cb, err); + }; + /** + * Stops continuous recognition and translation. + * @member TranslationRecognizer.prototype.stopContinuousRecognitionAsync + * @function + * @public + * @param cb - Callback that received the translation has stopped. + * @param err - Callback invoked in case of an error. + */ + TranslationRecognizer.prototype.stopContinuousRecognitionAsync = function (cb, err) { + this.stopContinuousRecognitionAsyncImpl(cb, err); + }; + /** + * closes all external resources held by an instance of this class. + * @member TranslationRecognizer.prototype.close + * @function + * @public + */ + TranslationRecognizer.prototype.close = function () { + Contracts_1.Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer); + this.dispose(true); + }; + TranslationRecognizer.prototype.dispose = function (disposing) { + if (this.privDisposedTranslationRecognizer) { + return; + } + if (disposing) { + this.implRecognizerStop(); + this.privDisposedTranslationRecognizer = true; + _super.prototype.dispose.call(this, disposing); + } + }; + TranslationRecognizer.prototype.createRecognizerConfig = function (speechConfig) { + return new Exports_1.RecognizerConfig(speechConfig, this.properties); + }; + TranslationRecognizer.prototype.createServiceRecognizer = function (authentication, connectionFactory, audioConfig, recognizerConfig) { + var configImpl = audioConfig; + return new Exports_1.TranslationServiceRecognizer(authentication, connectionFactory, configImpl, recognizerConfig, this); + }; + return TranslationRecognizer; +}(Exports_2.Recognizer)); +exports.TranslationRecognizer = TranslationRecognizer; + + + +/***/ }), +/* 77 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(31); +/** + * Represents collection of parameters and their values. + * @class Translation + */ +var Translations = /** @class */ (function () { + function Translations() { + // Use an PropertyCollection internally, just wrapping it to hide the | enum syntax it has. + this.privMap = new Exports_1.PropertyCollection(); + } + /** + * Returns the parameter value in type String. The parameter must have the same type as String. + * Currently only String, int and bool are allowed. + * If the name is not available, the specified defaultValue is returned. + * @member Translation.prototype.get + * @function + * @public + * @param {string} key - The parameter name. + * @param {string} def - The default value which is returned if the parameter is not available in the collection. + * @returns {string} value of the parameter. + */ + Translations.prototype.get = function (key, def) { + return this.privMap.getProperty(key, def); + }; + /** + * Sets the String value of the parameter specified by name. + * @member Translation.prototype.set + * @function + * @public + * @param {string} key - The parameter name. + * @param {string} value - The value of the parameter. + */ + Translations.prototype.set = function (key, value) { + this.privMap.setProperty(key, value); + }; + return Translations; +}()); +exports.Translations = Translations; + + + +/***/ }), +/* 78 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Defines the possible reasons a recognition result might not be recognized. + * @class NoMatchReason + */ +var NoMatchReason; +(function (NoMatchReason) { + /** + * Indicates that speech was detected, but not recognized. + * @member NoMatchReason.NotRecognized + */ + NoMatchReason[NoMatchReason["NotRecognized"] = 0] = "NotRecognized"; + /** + * Indicates that the start of the audio stream contained only silence, + * and the service timed out waiting for speech. + * @member NoMatchReason.InitialSilenceTimeout + */ + NoMatchReason[NoMatchReason["InitialSilenceTimeout"] = 1] = "InitialSilenceTimeout"; + /** + * Indicates that the start of the audio stream contained only noise, + * and the service timed out waiting for speech. + * @member NoMatchReason.InitialBabbleTimeout + */ + NoMatchReason[NoMatchReason["InitialBabbleTimeout"] = 2] = "InitialBabbleTimeout"; +})(NoMatchReason = exports.NoMatchReason || (exports.NoMatchReason = {})); + + + +/***/ }), +/* 79 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var Exports_2 = __webpack_require__(31); +/** + * Contains detailed information for NoMatch recognition results. + * @class NoMatchDetails + */ +var NoMatchDetails = /** @class */ (function () { + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {NoMatchReason} reason - The no-match reason. + */ + function NoMatchDetails(reason) { + this.privReason = reason; + } + /** + * Creates an instance of NoMatchDetails object for the NoMatch SpeechRecognitionResults. + * @member NoMatchDetails.fromResult + * @function + * @public + * @param {SpeechRecognitionResult | IntentRecognitionResult | TranslationRecognitionResult} + * result - The recognition result that was not recognized. + * @returns {NoMatchDetails} The no match details object being created. + */ + NoMatchDetails.fromResult = function (result) { + var simpleSpeech = Exports_1.SimpleSpeechPhrase.fromJSON(result.json); + var reason = Exports_2.NoMatchReason.NotRecognized; + switch (simpleSpeech.RecognitionStatus) { + case Exports_1.RecognitionStatus.BabbleTimeout: + reason = Exports_2.NoMatchReason.InitialBabbleTimeout; + break; + case Exports_1.RecognitionStatus.InitialSilenceTimeout: + reason = Exports_2.NoMatchReason.InitialSilenceTimeout; + break; + default: + reason = Exports_2.NoMatchReason.NotRecognized; + break; + } + return new NoMatchDetails(reason); + }; + Object.defineProperty(NoMatchDetails.prototype, "reason", { + /** + * The reason the recognition was canceled. + * @member NoMatchDetails.prototype.reason + * @function + * @public + * @returns {NoMatchReason} Specifies the reason canceled. + */ + get: function () { + return this.privReason; + }, + enumerable: true, + configurable: true + }); + return NoMatchDetails; +}()); +exports.NoMatchDetails = NoMatchDetails; + + + +/***/ }), +/* 80 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Define payload of speech recognition canceled result events. + * @class TranslationRecognitionCanceledEventArgs + */ +var TranslationRecognitionCanceledEventArgs = /** @class */ (function () { + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {string} sessionid - The session id. + * @param {CancellationReason} cancellationReason - The cancellation reason. + * @param {string} errorDetails - Error details, if provided. + * @param {TranslationRecognitionResult} result - The result. + */ + function TranslationRecognitionCanceledEventArgs(sessionid, cancellationReason, errorDetails, errorCode, result) { + this.privCancelReason = cancellationReason; + this.privErrorDetails = errorDetails; + this.privResult = result; + this.privSessionId = sessionid; + this.privErrorCode = errorCode; + } + Object.defineProperty(TranslationRecognitionCanceledEventArgs.prototype, "result", { + /** + * Specifies the recognition result. + * @member TranslationRecognitionCanceledEventArgs.prototype.result + * @function + * @public + * @returns {TranslationRecognitionResult} the recognition result. + */ + get: function () { + return this.privResult; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TranslationRecognitionCanceledEventArgs.prototype, "sessionId", { + /** + * Specifies the session identifier. + * @member TranslationRecognitionCanceledEventArgs.prototype.sessionId + * @function + * @public + * @returns {string} the session identifier. + */ + get: function () { + return this.privSessionId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TranslationRecognitionCanceledEventArgs.prototype, "reason", { + /** + * The reason the recognition was canceled. + * @member TranslationRecognitionCanceledEventArgs.prototype.reason + * @function + * @public + * @returns {CancellationReason} Specifies the reason canceled. + */ + get: function () { + return this.privCancelReason; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TranslationRecognitionCanceledEventArgs.prototype, "errorCode", { + /** + * The error code in case of an unsuccessful recognition. + * Added in version 1.1.0. + * @return An error code that represents the error reason. + */ + get: function () { + return this.privErrorCode; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TranslationRecognitionCanceledEventArgs.prototype, "errorDetails", { + /** + * In case of an unsuccessful recognition, provides details of the occurred error. + * @member TranslationRecognitionCanceledEventArgs.prototype.errorDetails + * @function + * @public + * @returns {string} A String that represents the error details. + */ + get: function () { + return this.privErrorDetails; + }, + enumerable: true, + configurable: true + }); + return TranslationRecognitionCanceledEventArgs; +}()); +exports.TranslationRecognitionCanceledEventArgs = TranslationRecognitionCanceledEventArgs; + + + +/***/ }), +/* 81 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(31); +/** + * Define payload of intent recognition canceled result events. + * @class IntentRecognitionCanceledEventArgs + */ +var IntentRecognitionCanceledEventArgs = /** @class */ (function (_super) { + __extends(IntentRecognitionCanceledEventArgs, _super); + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {CancellationReason} result - The result of the intent recognition. + * @param {string} offset - The offset. + * @param {IntentRecognitionResult} sessionId - The session id. + */ + function IntentRecognitionCanceledEventArgs(reason, errorDetails, errorCode, result, offset, sessionId) { + var _this = _super.call(this, result, offset, sessionId) || this; + _this.privReason = reason; + _this.privErrorDetails = errorDetails; + _this.privErrorCode = errorCode; + return _this; + } + Object.defineProperty(IntentRecognitionCanceledEventArgs.prototype, "reason", { + /** + * The reason the recognition was canceled. + * @member IntentRecognitionCanceledEventArgs.prototype.reason + * @function + * @public + * @returns {CancellationReason} Specifies the reason canceled. + */ + get: function () { + return this.privReason; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(IntentRecognitionCanceledEventArgs.prototype, "errorCode", { + /** + * The error code in case of an unsuccessful recognition. + * Added in version 1.1.0. + * @return An error code that represents the error reason. + */ + get: function () { + return this.privErrorCode; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(IntentRecognitionCanceledEventArgs.prototype, "errorDetails", { + /** + * In case of an unsuccessful recognition, provides details of the occurred error. + * @member IntentRecognitionCanceledEventArgs.prototype.errorDetails + * @function + * @public + * @returns {string} A String that represents the error details. + */ + get: function () { + return this.privErrorDetails; + }, + enumerable: true, + configurable: true + }); + return IntentRecognitionCanceledEventArgs; +}(Exports_1.IntentRecognitionEventArgs)); +exports.IntentRecognitionCanceledEventArgs = IntentRecognitionCanceledEventArgs; + + + +/***/ }), +/* 82 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Contains detailed information about why a result was canceled. + * @class CancellationDetailsBase + */ +var CancellationDetailsBase = /** @class */ (function () { + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {CancellationReason} reason - The cancellation reason. + * @param {string} errorDetails - The error details, if provided. + */ + function CancellationDetailsBase(reason, errorDetails, errorCode) { + this.privReason = reason; + this.privErrorDetails = errorDetails; + this.privErrorCode = errorCode; + } + Object.defineProperty(CancellationDetailsBase.prototype, "reason", { + /** + * The reason the recognition was canceled. + * @member CancellationDetailsBase.prototype.reason + * @function + * @public + * @returns {CancellationReason} Specifies the reason canceled. + */ + get: function () { + return this.privReason; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CancellationDetailsBase.prototype, "errorDetails", { + /** + * In case of an unsuccessful recognition, provides details of the occurred error. + * @member CancellationDetailsBase.prototype.errorDetails + * @function + * @public + * @returns {string} A String that represents the error details. + */ + get: function () { + return this.privErrorDetails; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CancellationDetailsBase.prototype, "ErrorCode", { + /** + * The error code in case of an unsuccessful recognition. + * Added in version 1.1.0. + * @return An error code that represents the error reason. + */ + get: function () { + return this.privErrorCode; + }, + enumerable: true, + configurable: true + }); + return CancellationDetailsBase; +}()); +exports.CancellationDetailsBase = CancellationDetailsBase; + + + +/***/ }), +/* 83 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(26); +var CancellationDetailsBase_1 = __webpack_require__(82); +var Exports_2 = __webpack_require__(31); +/** + * Contains detailed information about why a result was canceled. + * @class CancellationDetails + */ +var CancellationDetails = /** @class */ (function (_super) { + __extends(CancellationDetails, _super); + function CancellationDetails(reason, errorDetails, errorCode) { + return _super.call(this, reason, errorDetails, errorCode) || this; + } + /** + * Creates an instance of CancellationDetails object for the canceled RecognitionResult. + * @member CancellationDetails.fromResult + * @function + * @public + * @param {RecognitionResult | SpeechSynthesisResult} result - The result that was canceled. + * @returns {CancellationDetails} The cancellation details object being created. + */ + CancellationDetails.fromResult = function (result) { + var reason = Exports_2.CancellationReason.Error; + var errorCode = Exports_2.CancellationErrorCode.NoError; + if (result instanceof Exports_2.RecognitionResult && !!result.json) { + var simpleSpeech = Exports_1.SimpleSpeechPhrase.fromJSON(result.json); + reason = Exports_1.EnumTranslation.implTranslateCancelResult(simpleSpeech.RecognitionStatus); + } + if (!!result.properties) { + errorCode = Exports_2.CancellationErrorCode[result.properties.getProperty(Exports_1.CancellationErrorCodePropertyName, Exports_2.CancellationErrorCode[Exports_2.CancellationErrorCode.NoError])]; + } + return new CancellationDetails(reason, result.errorDetails, errorCode); + }; + return CancellationDetails; +}(CancellationDetailsBase_1.CancellationDetailsBase)); +exports.CancellationDetails = CancellationDetails; + + + +/***/ }), +/* 84 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Defines error code in case that CancellationReason is Error. + * Added in version 1.1.0. + */ +var CancellationErrorCode; +(function (CancellationErrorCode) { + /** + * Indicates that no error occurred during speech recognition. + */ + CancellationErrorCode[CancellationErrorCode["NoError"] = 0] = "NoError"; + /** + * Indicates an authentication error. + */ + CancellationErrorCode[CancellationErrorCode["AuthenticationFailure"] = 1] = "AuthenticationFailure"; + /** + * Indicates that one or more recognition parameters are invalid. + */ + CancellationErrorCode[CancellationErrorCode["BadRequestParameters"] = 2] = "BadRequestParameters"; + /** + * Indicates that the number of parallel requests exceeded the number of allowed + * concurrent transcriptions for the subscription. + */ + CancellationErrorCode[CancellationErrorCode["TooManyRequests"] = 3] = "TooManyRequests"; + /** + * Indicates a connection error. + */ + CancellationErrorCode[CancellationErrorCode["ConnectionFailure"] = 4] = "ConnectionFailure"; + /** + * Indicates a time-out error when waiting for response from service. + */ + CancellationErrorCode[CancellationErrorCode["ServiceTimeout"] = 5] = "ServiceTimeout"; + /** + * Indicates that an error is returned by the service. + */ + CancellationErrorCode[CancellationErrorCode["ServiceError"] = 6] = "ServiceError"; + /** + * Indicates an unexpected runtime error. + */ + CancellationErrorCode[CancellationErrorCode["RuntimeError"] = 7] = "RuntimeError"; +})(CancellationErrorCode = exports.CancellationErrorCode || (exports.CancellationErrorCode = {})); + + + +/***/ }), +/* 85 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE.md file in the project root for full license information. +// +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 Exports_1 = __webpack_require__(31); +/** + * Defines payload for connection events like Connected/Disconnected. + * Added in version 1.2.0 + */ +var ConnectionEventArgs = /** @class */ (function (_super) { + __extends(ConnectionEventArgs, _super); + function ConnectionEventArgs() { + return _super !== null && _super.apply(this, arguments) || this; + } + return ConnectionEventArgs; +}(Exports_1.SessionEventArgs)); +exports.ConnectionEventArgs = ConnectionEventArgs; + + + +/***/ }), +/* 86 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE.md file in the project root for full license information. +// +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 Exports_1 = __webpack_require__(31); +/** + * Defines payload for any Service message event + * Added in version 1.9.0 + */ +var ServiceEventArgs = /** @class */ (function (_super) { + __extends(ServiceEventArgs, _super); + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {string} json - json payload of the USP message. + */ + function ServiceEventArgs(json, name, sessionId) { + var _this = _super.call(this, sessionId) || this; + _this.privJsonResult = json; + _this.privEventName = name; + return _this; + } + Object.defineProperty(ServiceEventArgs.prototype, "jsonString", { + get: function () { + return this.privJsonResult; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ServiceEventArgs.prototype, "eventName", { + get: function () { + return this.privEventName; + }, + enumerable: true, + configurable: true + }); + return ServiceEventArgs; +}(Exports_1.SessionEventArgs)); +exports.ServiceEventArgs = ServiceEventArgs; + + + +/***/ }), +/* 87 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE.md file in the project root for full license information. +// +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var ConnectionMessage_1 = __webpack_require__(88); +var Contracts_1 = __webpack_require__(33); +var Exports_2 = __webpack_require__(31); +/** + * Connection is a proxy class for managing connection to the speech service of the specified Recognizer. + * By default, a Recognizer autonomously manages connection to service when needed. + * The Connection class provides additional methods for users to explicitly open or close a connection and + * to subscribe to connection status changes. + * The use of Connection is optional, and mainly for scenarios where fine tuning of application + * behavior based on connection status is needed. Users can optionally call Open() to manually set up a connection + * in advance before starting recognition on the Recognizer associated with this Connection. + * If the Recognizer needs to connect or disconnect to service, it will + * setup or shutdown the connection independently. In this case the Connection will be notified by change of connection + * status via Connected/Disconnected events. + * Added in version 1.2.1. + */ +var Connection = /** @class */ (function () { + function Connection() { + } + /** + * Gets the Connection instance from the specified recognizer. + * @param recognizer The recognizer associated with the connection. + * @return The Connection instance of the recognizer. + */ + Connection.fromRecognizer = function (recognizer) { + var recoBase = recognizer.internalData; + var ret = new Connection(); + ret.privInternalData = recoBase; + ret.setupEvents(); + return ret; + }; + /** + * Gets the Connection instance from the specified synthesizer. + * @param synthesizer The synthesizer associated with the connection. + * @return The Connection instance of the synthesizer. + */ + Connection.fromSynthesizer = function (synthesizer) { + var synthBase = synthesizer.internalData; + var ret = new Connection(); + ret.privInternalData = synthBase; + ret.setupEvents(); + return ret; + }; + /** + * Starts to set up connection to the service. + * Users can optionally call openConnection() to manually set up a connection in advance before starting recognition on the + * Recognizer associated with this Connection. After starting recognition, calling Open() will have no effect + * + * Note: On return, the connection might not be ready yet. Please subscribe to the Connected event to + * be notified when the connection is established. + */ + Connection.prototype.openConnection = function () { + this.privInternalData.connect(); + }; + /** + * Closes the connection the service. + * Users can optionally call closeConnection() to manually shutdown the connection of the associated Recognizer. + * + * If closeConnection() is called during recognition, recognition will fail and cancel with an error. + */ + Connection.prototype.closeConnection = function () { + if (this.privInternalData instanceof Exports_1.SynthesisAdapterBase) { + throw new Error("Disconnecting a synthesizer's connection is currently not supported"); + } + else { + this.privInternalData.disconnect(); + } + }; + /** + * Appends a parameter in a message to service. + * Added in version 1.12.1. + * @param path The path of the network message. + * @param propertyName Name of the property + * @param propertyValue Value of the property. This is a json string. + */ + Connection.prototype.setMessageProperty = function (path, propertyName, propertyValue) { + Contracts_1.Contracts.throwIfNullOrWhitespace(propertyName, "propertyName"); + if (this.privInternalData instanceof Exports_1.ServiceRecognizerBase) { + if (path.toLowerCase() !== "speech.context") { + throw new Error("Only speech.context message property sets are currently supported for recognizer"); + } + else { + this.privInternalData.speechContext.setSection(propertyName, propertyValue); + } + } + else if (this.privInternalData instanceof Exports_1.SynthesisAdapterBase) { + if (path.toLowerCase() !== "synthesis.context") { + throw new Error("Only synthesis.context message property sets are currently supported for synthesizer"); + } + else { + this.privInternalData.synthesisContext.setSection(propertyName, propertyValue); + } + } + }; + /** + * Sends a message to the speech service. + * Added in version 1.13.0. + * @param path The WebSocket path of the message + * @param payload The payload of the message. This is a json string or a ArrayBuffer. + * @param success A callback to indicate success. + * @param error A callback to indicate an error. + */ + Connection.prototype.sendMessageAsync = function (path, payload, success, error) { + this.privInternalData.sendNetworkMessage(path, payload, success, error); + }; + /** + * Dispose of associated resources. + */ + Connection.prototype.close = function () { + /* tslint:disable:no-empty */ + }; + Connection.prototype.setupEvents = function () { + var _this = this; + this.privEventListener = this.privInternalData.connectionEvents.attach(function (connectionEvent) { + if (connectionEvent.name === "ConnectionEstablishedEvent") { + if (!!_this.connected) { + _this.connected(new Exports_2.ConnectionEventArgs(connectionEvent.connectionId)); + } + } + else if (connectionEvent.name === "ConnectionClosedEvent") { + if (!!_this.disconnected) { + _this.disconnected(new Exports_2.ConnectionEventArgs(connectionEvent.connectionId)); + } + } + else if (connectionEvent.name === "ConnectionMessageSentEvent") { + if (!!_this.messageSent) { + _this.messageSent(new Exports_2.ConnectionMessageEventArgs(new ConnectionMessage_1.ConnectionMessageImpl(connectionEvent.message))); + } + } + else if (connectionEvent.name === "ConnectionMessageReceivedEvent") { + if (!!_this.messageReceived) { + _this.messageReceived(new Exports_2.ConnectionMessageEventArgs(new ConnectionMessage_1.ConnectionMessageImpl(connectionEvent.message))); + } + } + }); + this.privServiceEventListener = this.privInternalData.serviceEvents.attach(function (e) { + if (!!_this.receivedServiceMessage) { + _this.receivedServiceMessage(new Exports_2.ServiceEventArgs(e.jsonString, e.name)); + } + }); + }; + return Connection; +}()); +exports.Connection = Connection; + + + +/***/ }), +/* 88 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE.md file in the project root for full license information. +// +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(4); +var PropertyCollection_1 = __webpack_require__(67); +var PropertyId_1 = __webpack_require__(68); +/** + * ConnectionMessage represents implementation specific messages sent to and received from + * the speech service. These messages are provided for debugging purposes and should not + * be used for production use cases with the Azure Cognitive Services Speech Service. + * Messages sent to and received from the Speech Service are subject to change without + * notice. This includes message contents, headers, payloads, ordering, etc. + * Added in version 1.11.0. + */ +var ConnectionMessage = /** @class */ (function () { + function ConnectionMessage() { + } + return ConnectionMessage; +}()); +exports.ConnectionMessage = ConnectionMessage; +// tslint:disable-next-line:max-classes-per-file +var ConnectionMessageImpl = /** @class */ (function () { + function ConnectionMessageImpl(message) { + var _this = this; + this.privConnectionMessage = message; + this.privProperties = new PropertyCollection_1.PropertyCollection(); + if (!!this.privConnectionMessage.headers["X-ConnectionId"]) { + this.privProperties.setProperty(PropertyId_1.PropertyId.Speech_SessionId, this.privConnectionMessage.headers["X-ConnectionId"]); + } + Object.keys(this.privConnectionMessage.headers).forEach(function (header, index, array) { + _this.privProperties.setProperty(header, _this.privConnectionMessage.headers[header]); + }); + } + Object.defineProperty(ConnectionMessageImpl.prototype, "path", { + /** + * The message path. + */ + get: function () { + return this.privConnectionMessage.headers[Object.keys(this.privConnectionMessage.headers).find(function (key) { return key.toLowerCase() === "path".toLowerCase(); })]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConnectionMessageImpl.prototype, "isTextMessage", { + /** + * Checks to see if the ConnectionMessage is a text message. + * See also IsBinaryMessage(). + */ + get: function () { + return this.privConnectionMessage.messageType === Exports_1.MessageType.Text; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConnectionMessageImpl.prototype, "isBinaryMessage", { + /** + * Checks to see if the ConnectionMessage is a binary message. + * See also GetBinaryMessage(). + */ + get: function () { + return this.privConnectionMessage.messageType === Exports_1.MessageType.Binary; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConnectionMessageImpl.prototype, "TextMessage", { + /** + * Gets the text message payload. Typically the text message content-type is + * application/json. To determine other content-types use + * Properties.GetProperty("Content-Type"). + */ + get: function () { + return this.privConnectionMessage.textBody; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConnectionMessageImpl.prototype, "binaryMessage", { + /** + * Gets the binary message payload. + */ + get: function () { + return this.privConnectionMessage.binaryBody; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConnectionMessageImpl.prototype, "properties", { + /** + * A collection of properties and their values defined for this . + * Message headers can be accessed via this collection (e.g. "Content-Type"). + */ + get: function () { + return this.privProperties; + }, + enumerable: true, + configurable: true + }); + /** + * Returns a string that represents the connection message. + */ + ConnectionMessageImpl.prototype.toString = function () { + return ""; + }; + return ConnectionMessageImpl; +}()); +exports.ConnectionMessageImpl = ConnectionMessageImpl; + + + +/***/ }), +/* 89 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Allows additions of new phrases to improve speech recognition. + * + * Phrases added to the recognizer are effective at the start of the next recognition, or the next time the SpeechSDK must reconnect + * to the speech service. + */ +var PhraseListGrammar = /** @class */ (function () { + function PhraseListGrammar(recogBase) { + this.privGrammerBuilder = recogBase.dynamicGrammar; + } + /** + * Creates a PhraseListGrammar from a given speech recognizer. Will accept any recognizer that derives from @class Recognizer. + * @param recognizer The recognizer to add phrase lists to. + */ + PhraseListGrammar.fromRecognizer = function (recognizer) { + var recoBase = recognizer.internalData; + return new PhraseListGrammar(recoBase); + }; + /** + * Adds a single phrase to the current recognizer. + * @param phrase Phrase to add. + */ + PhraseListGrammar.prototype.addPhrase = function (phrase) { + this.privGrammerBuilder.addPhrase(phrase); + }; + /** + * Adds multiple phrases to the current recognizer. + * @param phrases Array of phrases to add. + */ + PhraseListGrammar.prototype.addPhrases = function (phrases) { + this.privGrammerBuilder.addPhrase(phrases); + }; + /** + * Clears all phrases added to the current recognizer. + */ + PhraseListGrammar.prototype.clear = function () { + this.privGrammerBuilder.clearPhrases(); + }; + return PhraseListGrammar; +}()); +exports.PhraseListGrammar = PhraseListGrammar; + + + +/***/ }), +/* 90 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 = __webpack_require__(33); +var Exports_1 = __webpack_require__(31); +/** + * Class that defines base configurations for dialog service connector + * @class DialogServiceConfig + */ +var DialogServiceConfig = /** @class */ (function () { + /** + * Creates an instance of DialogService config. + * @constructor + */ + function DialogServiceConfig() { + } + return DialogServiceConfig; +}()); +exports.DialogServiceConfig = DialogServiceConfig; +/** + * Dialog Service configuration. + * @class DialogServiceConfigImpl + */ +// tslint:disable-next-line:max-classes-per-file +var DialogServiceConfigImpl = /** @class */ (function (_super) { + __extends(DialogServiceConfigImpl, _super); + /** + * Creates an instance of dialogService config. + */ + function DialogServiceConfigImpl() { + var _this = _super.call(this) || this; + _this.privSpeechConfig = new Exports_1.SpeechConfigImpl(); + return _this; + } + Object.defineProperty(DialogServiceConfigImpl.prototype, "properties", { + /** + * Provides access to custom properties. + * @member DialogServiceConfigImpl.prototype.properties + * @function + * @public + * @returns {PropertyCollection} The properties. + */ + get: function () { + return this.privSpeechConfig.properties; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DialogServiceConfigImpl.prototype, "speechRecognitionLanguage", { + /** + * Gets the speech recognition language. + * @member DialogServiceConfigImpl.prototype.speechRecognitionLanguage + * @function + * @public + */ + get: function () { + return this.privSpeechConfig.speechRecognitionLanguage; + }, + /** + * Sets the speech recognition language. + * @member DialogServiceConfigImpl.prototype.speechRecognitionLanguage + * @function + * @public + * @param {string} value - The language to set. + */ + set: function (value) { + Contracts_1.Contracts.throwIfNullOrWhitespace(value, "value"); + this.privSpeechConfig.speechRecognitionLanguage = value; + }, + enumerable: true, + configurable: true + }); + /** + * Sets a named property as value + * @member DialogServiceConfigImpl.prototype.setProperty + * @function + * @public + * @param {PropertyId | string} name - The property to set. + * @param {string} value - The value. + */ + DialogServiceConfigImpl.prototype.setProperty = function (name, value) { + this.privSpeechConfig.setProperty(name, value); + }; + /** + * Sets a named property as value + * @member DialogServiceConfigImpl.prototype.getProperty + * @function + * @public + * @param {PropertyId | string} name - The property to get. + * @param {string} def - The default value to return in case the property is not known. + * @returns {string} The current value, or provided default, of the given property. + */ + DialogServiceConfigImpl.prototype.getProperty = function (name, def) { + return this.privSpeechConfig.getProperty(name); + }; + /** + * Sets the proxy configuration. + * Only relevant in Node.js environments. + * Added in version 1.4.0. + * @param proxyHostName The host name of the proxy server, without the protocol scheme (http://) + * @param proxyPort The port number of the proxy server. + * @param proxyUserName The user name of the proxy server. + * @param proxyPassword The password of the proxy server. + */ + DialogServiceConfigImpl.prototype.setProxy = function (proxyHostName, proxyPort, proxyUserName, proxyPassword) { + this.setProperty(Exports_1.PropertyId.SpeechServiceConnection_ProxyHostName, proxyHostName); + this.setProperty(Exports_1.PropertyId.SpeechServiceConnection_ProxyPort, "" + proxyPort); + if (proxyUserName) { + this.setProperty(Exports_1.PropertyId.SpeechServiceConnection_ProxyUserName, proxyUserName); + } + if (proxyPassword) { + this.setProperty(Exports_1.PropertyId.SpeechServiceConnection_ProxyPassword, proxyPassword); + } + }; + DialogServiceConfigImpl.prototype.setServiceProperty = function (name, value, channel) { + this.privSpeechConfig.setServiceProperty(name, value, channel); + }; + /** + * Dispose of associated resources. + * @member DialogServiceConfigImpl.prototype.close + * @function + * @public + */ + DialogServiceConfigImpl.prototype.close = function () { + return; + }; + return DialogServiceConfigImpl; +}(DialogServiceConfig)); +exports.DialogServiceConfigImpl = DialogServiceConfigImpl; + + + +/***/ }), +/* 91 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 = __webpack_require__(33); +var DialogServiceConfig_1 = __webpack_require__(90); +var Exports_1 = __webpack_require__(31); +/** + * 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 region page). + * @param botId Optional, ID for using a specific bot. + * @returns {BotFrameworkConfig} A new bot framework config. + */ + BotFrameworkConfig.fromSubscription = function (subscription, region, botId) { + 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); + if (botId) { + botFrameworkConfig.setProperty(Exports_1.PropertyId.Conversation_ApplicationId, botId); + } + 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 region page). + * @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; + + + +/***/ }), +/* 92 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 = __webpack_require__(33); +var DialogServiceConfig_1 = __webpack_require__(90); +var Exports_1 = __webpack_require__(31); +/** + * Class that defines configurations for the dialog service connector object for using a CustomCommands backend. + * @class CustomCommandsConfig + */ +var CustomCommandsConfig = /** @class */ (function (_super) { + __extends(CustomCommandsConfig, _super); + /** + * Creates an instance of CustomCommandsConfig. + */ + function CustomCommandsConfig() { + return _super.call(this) || this; + } + /** + * Creates an instance of the bot framework config with the specified subscription and region. + * @member CustomCommandsConfig.fromSubscription + * @function + * @public + * @param applicationId Speech Commands application id. + * @param subscription Subscription key associated with the bot + * @param region The region name (see the region page). + * @returns {CustomCommandsConfig} A new bot framework config. + */ + CustomCommandsConfig.fromSubscription = function (applicationId, subscription, region) { + Contracts_1.Contracts.throwIfNullOrWhitespace(applicationId, "applicationId"); + Contracts_1.Contracts.throwIfNullOrWhitespace(subscription, "subscription"); + Contracts_1.Contracts.throwIfNullOrWhitespace(region, "region"); + var customCommandsConfig = new DialogServiceConfig_1.DialogServiceConfigImpl(); + customCommandsConfig.setProperty(Exports_1.PropertyId.Conversation_DialogType, "custom_commands"); + customCommandsConfig.setProperty(Exports_1.PropertyId.Conversation_ApplicationId, applicationId); + customCommandsConfig.setProperty(Exports_1.PropertyId.SpeechServiceConnection_Key, subscription); + customCommandsConfig.setProperty(Exports_1.PropertyId.SpeechServiceConnection_Region, region); + return customCommandsConfig; + }; + /** + * Creates an instance of the bot framework config with the specified Speech Commands application id, 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 CustomCommandsConfig.fromAuthorizationToken + * @function + * @public + * @param applicationId Speech Commands application id. + * @param authorizationToken The authorization token associated with the application. + * @param region The region name (see the region page). + * @returns {CustomCommandsConfig} A new speech commands config. + */ + CustomCommandsConfig.fromAuthorizationToken = function (applicationId, authorizationToken, region) { + Contracts_1.Contracts.throwIfNullOrWhitespace(applicationId, "applicationId"); + Contracts_1.Contracts.throwIfNullOrWhitespace(authorizationToken, "authorizationToken"); + Contracts_1.Contracts.throwIfNullOrWhitespace(region, "region"); + var customCommandsConfig = new DialogServiceConfig_1.DialogServiceConfigImpl(); + customCommandsConfig.setProperty(Exports_1.PropertyId.Conversation_DialogType, "custom_commands"); + customCommandsConfig.setProperty(Exports_1.PropertyId.Conversation_ApplicationId, applicationId); + customCommandsConfig.setProperty(Exports_1.PropertyId.SpeechServiceAuthorization_Token, authorizationToken); + customCommandsConfig.setProperty(Exports_1.PropertyId.SpeechServiceConnection_Region, region); + return customCommandsConfig; + }; + Object.defineProperty(CustomCommandsConfig.prototype, "applicationId", { + /** + * Gets the corresponding backend application identifier. + * @member CustomCommandsConfig.prototype.Conversation_ApplicationId + * @function + * @public + * @param {string} value - The application identifier to get. + */ + get: function () { + return this.getProperty(Exports_1.PropertyId.Conversation_ApplicationId); + }, + /** + * Sets the corresponding backend application identifier. + * @member CustomCommandsConfig.prototype.Conversation_ApplicationId + * @function + * @public + * @param {string} value - The application identifier to set. + */ + set: function (value) { + Contracts_1.Contracts.throwIfNullOrWhitespace(value, "value"); + this.setProperty(Exports_1.PropertyId.Conversation_ApplicationId, value); + }, + enumerable: true, + configurable: true + }); + return CustomCommandsConfig; +}(DialogServiceConfig_1.DialogServiceConfigImpl)); +exports.CustomCommandsConfig = CustomCommandsConfig; + + + +/***/ }), +/* 93 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 DialogConnectorFactory_1 = __webpack_require__(94); +var Exports_1 = __webpack_require__(26); +var Contracts_1 = __webpack_require__(33); +var Exports_2 = __webpack_require__(31); +var PropertyId_1 = __webpack_require__(68); +var SpeechSynthesisOutputFormat_1 = __webpack_require__(45); +/** + * Dialog Service Connector + * @class DialogServiceConnector + */ +var DialogServiceConnector = /** @class */ (function (_super) { + __extends(DialogServiceConnector, _super); + /** + * Initializes an instance of the DialogServiceConnector. + * @constructor + * @param {DialogServiceConfig} dialogConfig - Set of properties to configure this recognizer. + * @param {AudioConfig} audioConfig - An optional audio config associated with the recognizer + */ + function DialogServiceConnector(dialogConfig, audioConfig) { + var _this = this; + var dialogServiceConfigImpl = dialogConfig; + Contracts_1.Contracts.throwIfNull(dialogConfig, "dialogConfig"); + _this = _super.call(this, audioConfig, dialogServiceConfigImpl.properties, new DialogConnectorFactory_1.DialogConnectionFactory()) || this; + _this.isTurnComplete = true; + _this.privIsDisposed = false; + _this.privProperties = dialogServiceConfigImpl.properties.clone(); + var agentConfig = _this.buildAgentConfig(); + _this.privReco.agentConfig.set(agentConfig); + return _this; + } + /** + * Starts a connection to the service. + * Users can optionally call connect() to manually set up a connection in advance, before starting interactions. + * + * Note: On return, the connection might not be ready yet. Please subscribe to the Connected event to + * be notified when the connection is established. + * @member DialogServiceConnector.prototype.connect + * @function + * @public + */ + DialogServiceConnector.prototype.connect = function () { + this.privReco.connect(); + }; + /** + * Closes the connection the service. + * Users can optionally call disconnect() to manually shutdown the connection of the associated DialogServiceConnector. + * + * If disconnect() is called during a recognition, recognition will fail and cancel with an error. + */ + DialogServiceConnector.prototype.disconnect = function () { + this.privReco.disconnect(); + }; + Object.defineProperty(DialogServiceConnector.prototype, "authorizationToken", { + /** + * Gets the authorization token used to communicate with the service. + * @member DialogServiceConnector.prototype.authorizationToken + * @function + * @public + * @returns {string} Authorization token. + */ + get: function () { + return this.properties.getProperty(PropertyId_1.PropertyId.SpeechServiceAuthorization_Token); + }, + /** + * Sets the authorization token used to communicate with the service. + * @member DialogServiceConnector.prototype.authorizationToken + * @function + * @public + * @param {string} token - Authorization token. + */ + set: function (token) { + Contracts_1.Contracts.throwIfNullOrWhitespace(token, "token"); + this.properties.setProperty(PropertyId_1.PropertyId.SpeechServiceAuthorization_Token, token); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DialogServiceConnector.prototype, "properties", { + /** + * The collection of properties and their values defined for this DialogServiceConnector. + * @member DialogServiceConnector.prototype.properties + * @function + * @public + * @returns {PropertyCollection} The collection of properties and their values defined for this DialogServiceConnector. + */ + get: function () { + return this.privProperties; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DialogServiceConnector.prototype, "speechActivityTemplate", { + /** Gets the template for the activity generated by service from speech. + * Properties from the template will be stamped on the generated activity. + * It can be empty + */ + get: function () { + return this.properties.getProperty(PropertyId_1.PropertyId.Conversation_Speech_Activity_Template); + }, + /** Sets the template for the activity generated by service from speech. + * Properties from the template will be stamped on the generated activity. + * It can be null or empty. + * Note: it has to be a valid Json object. + */ + set: function (speechActivityTemplate) { + this.properties.setProperty(PropertyId_1.PropertyId.Conversation_Speech_Activity_Template, speechActivityTemplate); + }, + enumerable: true, + configurable: true + }); + /** + * Starts recognition and stops after the first utterance is recognized. + * @member DialogServiceConnector.prototype.listenOnceAsync + * @function + * @public + * @param cb - Callback that received the result when the reco has completed. + * @param err - Callback invoked in case of an error. + */ + DialogServiceConnector.prototype.listenOnceAsync = function (cb, err) { + var _this = this; + if (this.isTurnComplete) { + try { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + this.connect(); + this.implRecognizerStop(); + this.isTurnComplete = false; + this.privReco.recognize(Exports_1.RecognitionMode.Conversation, function (e) { + _this.implRecognizerStop(); + _this.isTurnComplete = true; + if (!!cb) { + cb(e); + } + }, function (e) { + _this.implRecognizerStop(); + _this.isTurnComplete = true; + if (!!err) { + err(e); + } + /* tslint:disable:no-empty */ + }).on(function (_) { }, function (error) { + if (!!err) { + err(error); + } + }); + } + catch (error) { + if (!!err) { + if (error instanceof Error) { + var typedError = error; + err(typedError.name + ": " + typedError.message); + } + else { + err(error); + } + } + // Destroy the recognizer. + this.dispose(true); + } + } + }; + DialogServiceConnector.prototype.sendActivityAsync = function (activity) { + this.privReco.sendMessage(activity); + }; + /** + * closes all external resources held by an instance of this class. + * @member DialogServiceConnector.prototype.close + * @function + * @public + */ + DialogServiceConnector.prototype.close = function () { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + this.dispose(true); + }; + DialogServiceConnector.prototype.dispose = function (disposing) { + if (this.privIsDisposed) { + return; + } + if (disposing) { + this.implRecognizerStop(); + this.privIsDisposed = true; + _super.prototype.dispose.call(this, disposing); + } + }; + DialogServiceConnector.prototype.createRecognizerConfig = function (speechConfig) { + return new Exports_1.RecognizerConfig(speechConfig, this.privProperties); + }; + DialogServiceConnector.prototype.createServiceRecognizer = function (authentication, connectionFactory, audioConfig, recognizerConfig) { + var audioSource = audioConfig; + return new Exports_1.DialogServiceAdapter(authentication, connectionFactory, audioSource, recognizerConfig, this); + }; + DialogServiceConnector.prototype.buildAgentConfig = function () { + var communicationType = this.properties.getProperty("Conversation_Communication_Type", "Default"); + return { + botInfo: { + commType: communicationType, + commandsCulture: undefined, + connectionId: this.properties.getProperty(PropertyId_1.PropertyId.Conversation_ApplicationId), + conversationId: this.properties.getProperty(PropertyId_1.PropertyId.Conversation_Conversation_Id, undefined), + fromId: this.properties.getProperty(PropertyId_1.PropertyId.Conversation_From_Id, undefined), + ttsAudioFormat: SpeechSynthesisOutputFormat_1.SpeechSynthesisOutputFormat[this.properties.getProperty(PropertyId_1.PropertyId.SpeechServiceConnection_SynthOutputFormat, undefined)] + }, + version: 0.2 + }; + }; + return DialogServiceConnector; +}(Exports_2.Recognizer)); +exports.DialogServiceConnector = DialogServiceConnector; + + + +/***/ }), +/* 94 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(2); +var Exports_2 = __webpack_require__(31); +var ConnectionFactoryBase_1 = __webpack_require__(72); +var Exports_3 = __webpack_require__(26); +var QueryParameterNames_1 = __webpack_require__(73); +var baseUrl = "convai.speech"; +var botFramework = { + authHeader: "X-DLS-Secret", + resourcePath: "", + version: "v3" +}; +var customCommands = { + authHeader: "X-CommandsAppId", + resourcePath: "commands", + version: "v1" +}; +var pathSuffix = "api"; +function getDialogSpecificValues(dialogType) { + switch (dialogType) { + case "custom_commands": { + return customCommands; + } + case "bot_framework": { + return botFramework; + } + } + throw new Error("Invalid dialog type '" + dialogType + "'"); +} +var DialogConnectionFactory = /** @class */ (function (_super) { + __extends(DialogConnectionFactory, _super); + function DialogConnectionFactory() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.create = function (config, authInfo, connectionId) { + var applicationId = config.parameters.getProperty(Exports_2.PropertyId.Conversation_ApplicationId, ""); + var dialogType = config.parameters.getProperty(Exports_2.PropertyId.Conversation_DialogType); + var region = config.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_Region); + var language = config.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage, "en-US"); + var queryParams = {}; + queryParams[QueryParameterNames_1.QueryParameterNames.LanguageParamName] = language; + queryParams[QueryParameterNames_1.QueryParameterNames.FormatParamName] = config.parameters.getProperty(Exports_2.PropertyId.SpeechServiceResponse_OutputFormatOption, Exports_2.OutputFormat[Exports_2.OutputFormat.Simple]).toLowerCase(); + var _a = getDialogSpecificValues(dialogType), resourcePath = _a.resourcePath, version = _a.version, authHeader = _a.authHeader; + var headers = {}; + if (authInfo.token != null && authInfo.token !== "") { + headers[authInfo.headerName] = authInfo.token; + } + headers[QueryParameterNames_1.QueryParameterNames.ConnectionIdHeader] = connectionId; + if (applicationId !== "") { + headers[authHeader] = applicationId; + } + var endpoint = config.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_Endpoint, ""); + if (endpoint === "") { + var hostSuffix = (region && region.toLowerCase().startsWith("china")) ? ".azure.cn" : ".microsoft.com"; + // ApplicationId is only required for CustomCommands, so we're using that to determine default endpoint + if (applicationId === "") { + endpoint = "wss://" + region + "." + baseUrl + hostSuffix + "/" + pathSuffix + "/" + version; + } + else { + endpoint = "wss://" + region + "." + baseUrl + hostSuffix + "/" + resourcePath + "/" + pathSuffix + "/" + version; + } + } + _this.setCommonUrlParams(config, queryParams, endpoint); + return new Exports_1.WebsocketConnection(endpoint, queryParams, headers, new Exports_3.WebsocketMessageFormatter(), Exports_1.ProxyInfo.fromRecognizerConfig(config), connectionId); + }; + return _this; + } + return DialogConnectionFactory; +}(ConnectionFactoryBase_1.ConnectionFactoryBase)); +exports.DialogConnectionFactory = DialogConnectionFactory; + + + +/***/ }), +/* 95 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Defines contents of received message/events. + * @class ActivityReceivedEventArgs + */ +var ActivityReceivedEventArgs = /** @class */ (function () { + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {any} activity - The activity.. + */ + function ActivityReceivedEventArgs(activity, audioStream) { + this.privActivity = activity; + this.privAudioStream = audioStream; + } + Object.defineProperty(ActivityReceivedEventArgs.prototype, "activity", { + /** + * Gets the received activity + * @member ActivityReceivedEventArgs.prototype.activity + * @function + * @public + * @returns {any} the received activity. + */ + get: function () { + return this.privActivity; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ActivityReceivedEventArgs.prototype, "audioStream", { + get: function () { + return this.privAudioStream; + }, + enumerable: true, + configurable: true + }); + return ActivityReceivedEventArgs; +}()); +exports.ActivityReceivedEventArgs = ActivityReceivedEventArgs; + + + +/***/ }), +/* 96 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Defines channels used to pass property settings to service. + * Added in version 1.7.0. + */ +var ServicePropertyChannel; +(function (ServicePropertyChannel) { + /** + * Uses URI query parameter to pass property settings to service. + */ + ServicePropertyChannel[ServicePropertyChannel["UriQueryParameter"] = 0] = "UriQueryParameter"; +})(ServicePropertyChannel = exports.ServicePropertyChannel || (exports.ServicePropertyChannel = {})); + + + +/***/ }), +/* 97 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Profanity option. + * Added in version 1.7.0. + */ +var ProfanityOption; +(function (ProfanityOption) { + ProfanityOption[ProfanityOption["Masked"] = 0] = "Masked"; + ProfanityOption[ProfanityOption["Removed"] = 1] = "Removed"; + ProfanityOption[ProfanityOption["Raw"] = 2] = "Raw"; +})(ProfanityOption = exports.ProfanityOption || (exports.ProfanityOption = {})); + + + +/***/ }), +/* 98 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Error_1 = __webpack_require__(10); +/** + * Base audio player class + * TODO: Plays only PCM for now. + * @class + */ +var BaseAudioPlayer = /** @class */ (function () { + /** + * Creates and initializes an instance of this class. + * @constructor + */ + function BaseAudioPlayer(audioFormat) { + this.audioContext = null; + this.gainNode = null; + this.autoUpdateBufferTimer = 0; + this.init(audioFormat); + } + /** + * play Audio sample + * @param newAudioData audio data to be played. + */ + BaseAudioPlayer.prototype.playAudioSample = function (newAudioData) { + this.ensureInitializedContext(); + var audioData = this.formatAudioData(newAudioData); + var newSamplesData = new Float32Array(this.samples.length + audioData.length); + newSamplesData.set(this.samples, 0); + newSamplesData.set(audioData, this.samples.length); + this.samples = newSamplesData; + }; + /** + * stops audio and clears the buffers + */ + BaseAudioPlayer.prototype.stopAudio = function () { + if (this.audioContext !== null) { + this.samples = new Float32Array(); + clearInterval(this.autoUpdateBufferTimer); + this.audioContext.close(); + this.audioContext = null; + } + }; + BaseAudioPlayer.prototype.init = function (audioFormat) { + this.audioFormat = audioFormat; + this.samples = new Float32Array(); + }; + BaseAudioPlayer.prototype.ensureInitializedContext = function () { + var _this = this; + if (this.audioContext === null) { + this.createAudioContext(); + var timerPeriod = 200; + this.autoUpdateBufferTimer = setInterval(function () { + _this.updateAudioBuffer(); + }, timerPeriod); + } + }; + BaseAudioPlayer.prototype.createAudioContext = function () { + // new ((window as any).AudioContext || (window as any).webkitAudioContext)(); + this.audioContext = new AudioContext(); + // TODO: Various examples shows this gain node, it does not seem to be needed unless we plan + // to control the volume, not likely + this.gainNode = this.audioContext.createGain(); + this.gainNode.gain.value = 1; + this.gainNode.connect(this.audioContext.destination); + this.startTime = this.audioContext.currentTime; + }; + BaseAudioPlayer.prototype.formatAudioData = function (audioData) { + switch (this.audioFormat.bitsPerSample) { + case 8: + return this.formatArrayBuffer(new Int8Array(audioData), 128); + case 16: + return this.formatArrayBuffer(new Int16Array(audioData), 32768); + case 32: + return this.formatArrayBuffer(new Int32Array(audioData), 2147483648); + default: + throw new Error_1.InvalidOperationError("Only WAVE_FORMAT_PCM (8/16/32 bps) format supported at this time"); + } + }; + BaseAudioPlayer.prototype.formatArrayBuffer = function (audioData, maxValue) { + var float32Data = new Float32Array(audioData.length); + for (var i = 0; i < audioData.length; i++) { + float32Data[i] = audioData[i] / maxValue; + } + return float32Data; + }; + BaseAudioPlayer.prototype.updateAudioBuffer = function () { + if (this.samples.length === 0) { + return; + } + var channelCount = this.audioFormat.channels; + var bufferSource = this.audioContext.createBufferSource(); + var frameCount = this.samples.length / channelCount; + var audioBuffer = this.audioContext.createBuffer(channelCount, frameCount, this.audioFormat.samplesPerSec); + // TODO: Should we do the conversion in the pushAudioSample instead? + for (var channel = 0; channel < channelCount; channel++) { + // Fill in individual channel data + var channelOffset = channel; + var audioData = audioBuffer.getChannelData(channel); + for (var i = 0; i < this.samples.length; i++, channelOffset += channelCount) { + audioData[i] = this.samples[channelOffset]; + } + } + if (this.startTime < this.audioContext.currentTime) { + this.startTime = this.audioContext.currentTime; + } + bufferSource.buffer = audioBuffer; + bufferSource.connect(this.gainNode); + bufferSource.start(this.startTime); + // Make sure we play the next sample after the current one. + this.startTime += audioBuffer.duration; + // Clear the samples for the next pushed data. + this.samples = new Float32Array(); + }; + return BaseAudioPlayer; +}()); +exports.BaseAudioPlayer = BaseAudioPlayer; + + + +/***/ }), +/* 99 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE.md file in the project root for full license information. +// +Object.defineProperty(exports, "__esModule", { value: true }); +var ConnectionMessageEventArgs = /** @class */ (function () { + function ConnectionMessageEventArgs(message) { + this.privConnectionMessage = message; + } + Object.defineProperty(ConnectionMessageEventArgs.prototype, "message", { + /** + * Gets the associated with this . + */ + get: function () { + return this.privConnectionMessage; + }, + enumerable: true, + configurable: true + }); + /** + * Returns a string that represents the connection message event. + */ + ConnectionMessageEventArgs.prototype.toString = function () { + return "Message: " + this.privConnectionMessage.toString(); + }; + return ConnectionMessageEventArgs; +}()); +exports.ConnectionMessageEventArgs = ConnectionMessageEventArgs; + + + +/***/ }), +/* 100 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Defines Voice Profile class for Speaker Recognition + * @class VoiceProfile + */ +var VoiceProfile = /** @class */ (function () { + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {string} profileId - profileId of this Voice Profile. + * @param {VoiceProfileType} profileType - profileType of this Voice Profile. + */ + function VoiceProfile(profileId, profileType) { + this.privId = profileId; + this.privProfileType = profileType; + } + Object.defineProperty(VoiceProfile.prototype, "profileId", { + /** + * profileId of this Voice Profile instance + * @member VoiceProfile.prototype.profileId + * @function + * @public + * @returns {string} profileId of this Voice Profile instance. + */ + get: function () { + return this.privId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(VoiceProfile.prototype, "profileType", { + /** + * profileType of this Voice Profile instance + * @member VoiceProfile.prototype.profileType + * @function + * @public + * @returns {VoiceProfileType} profile type of this Voice Profile instance. + */ + get: function () { + return this.privProfileType; + }, + enumerable: true, + configurable: true + }); + return VoiceProfile; +}()); +exports.VoiceProfile = VoiceProfile; + + + +/***/ }), +/* 101 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(26); +var Contracts_1 = __webpack_require__(33); +var Exports_2 = __webpack_require__(31); +/** + * Output format + * @class VoiceProfileEnrollmentResult + */ +var VoiceProfileEnrollmentResult = /** @class */ (function () { + function VoiceProfileEnrollmentResult(reason, json, statusText) { + this.privReason = reason; + this.privProperties = new Exports_2.PropertyCollection(); + if (this.privReason !== Exports_2.ResultReason.Canceled) { + this.privDetails = JSON.parse(json); + Contracts_1.Contracts.throwIfNullOrUndefined(json, "JSON"); + if (this.privDetails.enrollmentStatus.toLowerCase() === "enrolling") { + this.privReason = Exports_2.ResultReason.EnrollingVoiceProfile; + } + } + else { + this.privErrorDetails = statusText; + this.privProperties.setProperty(Exports_1.CancellationErrorCodePropertyName, Exports_2.CancellationErrorCode[Exports_2.CancellationErrorCode.ServiceError]); + } + } + Object.defineProperty(VoiceProfileEnrollmentResult.prototype, "reason", { + get: function () { + return this.privReason; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(VoiceProfileEnrollmentResult.prototype, "enrollmentsCount", { + get: function () { + return this.privDetails.enrollmentsCount; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(VoiceProfileEnrollmentResult.prototype, "enrollmentsLength", { + get: function () { + return this.privDetails.enrollmentsLength; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(VoiceProfileEnrollmentResult.prototype, "properties", { + get: function () { + return this.privProperties; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(VoiceProfileEnrollmentResult.prototype, "errorDetails", { + get: function () { + return this.privErrorDetails; + }, + enumerable: true, + configurable: true + }); + return VoiceProfileEnrollmentResult; +}()); +exports.VoiceProfileEnrollmentResult = VoiceProfileEnrollmentResult; +/** + * @class VoiceProfileEnrollmentCancellationDetails + */ +// tslint:disable-next-line:max-classes-per-file +var VoiceProfileEnrollmentCancellationDetails = /** @class */ (function (_super) { + __extends(VoiceProfileEnrollmentCancellationDetails, _super); + function VoiceProfileEnrollmentCancellationDetails(reason, errorDetails, errorCode) { + return _super.call(this, reason, errorDetails, errorCode) || this; + } + /** + * Creates an instance of VoiceProfileEnrollmentCancellationDetails object for the canceled VoiceProfileEnrollmentResult. + * @member VoiceProfileEnrollmentCancellationDetails.fromResult + * @function + * @public + * @param {VoiceProfileEnrollmentResult} result - The result that was canceled. + * @returns {VoiceProfileEnrollmentCancellationDetails} The cancellation details object being created. + */ + VoiceProfileEnrollmentCancellationDetails.fromResult = function (result) { + var reason = Exports_2.CancellationReason.Error; + var errorCode = Exports_2.CancellationErrorCode.NoError; + if (!!result.properties) { + errorCode = Exports_2.CancellationErrorCode[result.properties.getProperty(Exports_1.CancellationErrorCodePropertyName, Exports_2.CancellationErrorCode[Exports_2.CancellationErrorCode.NoError])]; + } + return new VoiceProfileEnrollmentCancellationDetails(reason, result.errorDetails, errorCode); + }; + return VoiceProfileEnrollmentCancellationDetails; +}(Exports_2.CancellationDetailsBase)); +exports.VoiceProfileEnrollmentCancellationDetails = VoiceProfileEnrollmentCancellationDetails; + + + +/***/ }), +/* 102 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(26); +var Contracts_1 = __webpack_require__(33); +var Exports_2 = __webpack_require__(31); +/** + * Output format + * @class VoiceProfileResult + */ +var VoiceProfileResult = /** @class */ (function () { + function VoiceProfileResult(reason, statusText) { + this.privReason = reason; + this.privProperties = new Exports_2.PropertyCollection(); + if (reason === Exports_2.ResultReason.Canceled) { + Contracts_1.Contracts.throwIfNullOrUndefined(statusText, "statusText"); + this.privErrorDetails = statusText; + this.privProperties.setProperty(Exports_1.CancellationErrorCodePropertyName, Exports_2.CancellationErrorCode[Exports_2.CancellationErrorCode.ServiceError]); + } + } + Object.defineProperty(VoiceProfileResult.prototype, "reason", { + get: function () { + return this.privReason; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(VoiceProfileResult.prototype, "properties", { + get: function () { + return this.privProperties; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(VoiceProfileResult.prototype, "errorDetails", { + get: function () { + return this.privErrorDetails; + }, + enumerable: true, + configurable: true + }); + return VoiceProfileResult; +}()); +exports.VoiceProfileResult = VoiceProfileResult; +/** + * @class VoiceProfileCancellationDetails + */ +// tslint:disable-next-line:max-classes-per-file +var VoiceProfileCancellationDetails = /** @class */ (function (_super) { + __extends(VoiceProfileCancellationDetails, _super); + function VoiceProfileCancellationDetails(reason, errorDetails, errorCode) { + return _super.call(this, reason, errorDetails, errorCode) || this; + } + /** + * Creates an instance of VoiceProfileCancellationDetails object for the canceled VoiceProfileResult. + * @member VoiceProfileCancellationDetails.fromResult + * @function + * @public + * @param {VoiceProfileResult} result - The result that was canceled. + * @returns {VoiceProfileCancellationDetails} The cancellation details object being created. + */ + VoiceProfileCancellationDetails.fromResult = function (result) { + var reason = Exports_2.CancellationReason.Error; + var errorCode = Exports_2.CancellationErrorCode.NoError; + if (!!result.properties) { + errorCode = Exports_2.CancellationErrorCode[result.properties.getProperty(Exports_1.CancellationErrorCodePropertyName, Exports_2.CancellationErrorCode[Exports_2.CancellationErrorCode.NoError])]; + } + return new VoiceProfileCancellationDetails(reason, result.errorDetails, errorCode); + }; + return VoiceProfileCancellationDetails; +}(Exports_2.CancellationDetailsBase)); +exports.VoiceProfileCancellationDetails = VoiceProfileCancellationDetails; + + + +/***/ }), +/* 103 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var Contracts_1 = __webpack_require__(33); +var Exports_2 = __webpack_require__(31); +/** + * Defines VoiceProfileClient class for Speaker Recognition + * Handles operations from user for Voice Profile operations (e.g. createProfile, deleteProfile) + * @class VoiceProfileClient + */ +var VoiceProfileClient = /** @class */ (function () { + /** + * VoiceProfileClient constructor. + * @constructor + * @param {SpeechConfig} speechConfig - An set of initial properties for this synthesizer (authentication key, region, &c) + */ + function VoiceProfileClient(speechConfig) { + var speechConfigImpl = speechConfig; + Contracts_1.Contracts.throwIfNull(speechConfigImpl, "speechConfig"); + this.privProperties = speechConfigImpl.properties.clone(); + this.implClientSetup(); + } + Object.defineProperty(VoiceProfileClient.prototype, "authorizationToken", { + /** + * Gets the authorization token used to communicate with the service. + * @member VoiceProfileClient.prototype.authorizationToken + * @function + * @public + * @returns {string} Authorization token. + */ + get: function () { + return this.properties.getProperty(Exports_2.PropertyId.SpeechServiceAuthorization_Token); + }, + /** + * Gets/Sets the authorization token used to communicate with the service. + * @member VoiceProfileClient.prototype.authorizationToken + * @function + * @public + * @param {string} token - Authorization token. + */ + set: function (token) { + Contracts_1.Contracts.throwIfNullOrWhitespace(token, "token"); + this.properties.setProperty(Exports_2.PropertyId.SpeechServiceAuthorization_Token, token); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(VoiceProfileClient.prototype, "properties", { + /** + * The collection of properties and their values defined for this VoiceProfileClient. + * @member VoiceProfileClient.prototype.properties + * @function + * @public + * @returns {PropertyCollection} The collection of properties and their values defined for this VoiceProfileClient. + */ + get: function () { + return this.privProperties; + }, + enumerable: true, + configurable: true + }); + /** + * Create a speaker recognition voice profile + * @member VoiceProfileClient.prototype.createProfileAsync + * @function + * @public + * @param {VoiceProfileType} profileType Type of Voice Profile to be created + * specifies the keyword to be recognized. + * @param {string} lang Language string (locale) for Voice Profile + * @param cb - Callback invoked once Voice Profile has been created. + * @param err - Callback invoked in case of an error. + */ + VoiceProfileClient.prototype.createProfileAsync = function (profileType, lang, cb, err) { + this.privAdapter.createProfile(profileType, lang).on(function (result) { + if (!!cb) { + var response = result.json(); + var profile = new Exports_2.VoiceProfile(response.profileId, profileType); + cb(profile); + } + }, function (error) { + if (!!err) { + err(error); + } + }); + }; + /** + * Create a speaker recognition voice profile + * @member VoiceProfileClient.prototype.enrollProfileAsync + * @function + * @public + * @param {VoiceProfile} profile Voice Profile to create enrollment for + * @param {AudioConfig} audioConfig source info from which to create enrollment + * @param cb - Callback invoked once Enrollment request has been submitted. + * @param err - Callback invoked in case of an error. + */ + VoiceProfileClient.prototype.enrollProfileAsync = function (profile, audioConfig, cb, err) { + var configImpl = audioConfig; + Contracts_1.Contracts.throwIfNullOrUndefined(configImpl, "audioConfig"); + this.privAdapter.createEnrollment(profile, configImpl).on(function (result) { + if (!!cb) { + cb(new Exports_2.VoiceProfileEnrollmentResult(result.ok ? Exports_2.ResultReason.EnrolledVoiceProfile : Exports_2.ResultReason.Canceled, result.data, result.statusText)); + } + }, function (error) { + if (!!err) { + err(error); + } + }); + }; + /** + * Delete a speaker recognition voice profile + * @member VoiceProfileClient.prototype.deleteProfileAsync + * @function + * @public + * @param {VoiceProfile} profile Voice Profile to be deleted + * @param cb - Callback invoked once Voice Profile has been deleted. + * @param err - Callback invoked in case of an error. + */ + VoiceProfileClient.prototype.deleteProfileAsync = function (profile, cb, err) { + var _this = this; + this.privAdapter.deleteProfile(profile).on(function (result) { + _this.handleResultCallbacks(result, Exports_2.ResultReason.DeletedVoiceProfile, cb); + }, function (error) { + if (!!err) { + err(error); + } + }); + }; + /** + * Remove all enrollments for a speaker recognition voice profile + * @member VoiceProfileClient.prototype.resetProfileAsync + * @function + * @public + * @param {VoiceProfile} profile Voice Profile to be reset + * @param cb - Callback invoked once Voice Profile has been reset. + * @param err - Callback invoked in case of an error. + */ + VoiceProfileClient.prototype.resetProfileAsync = function (profile, cb, err) { + var _this = this; + this.privAdapter.resetProfile(profile).on(function (result) { + _this.handleResultCallbacks(result, Exports_2.ResultReason.ResetVoiceProfile, cb); + }, function (error) { + if (!!err) { + err(error); + } + }); + }; + /** + * Included for compatibility + * @member VoiceProfileClient.prototype.close + * @function + * @public + */ + VoiceProfileClient.prototype.close = function () { + return; + }; + // Does class setup, swiped from Recognizer. + VoiceProfileClient.prototype.implClientSetup = function () { + var osPlatform = (typeof window !== "undefined") ? "Browser" : "Node"; + var osName = "unknown"; + var osVersion = "unknown"; + if (typeof navigator !== "undefined") { + osPlatform = osPlatform + "/" + navigator.platform; + osName = navigator.userAgent; + osVersion = navigator.appVersion; + } + var recognizerConfig = new Exports_1.SpeakerRecognitionConfig(new Exports_1.Context(new Exports_1.OS(osPlatform, osName, osVersion)), this.privProperties); + this.privAdapter = new Exports_1.SpeakerIdMessageAdapter(recognizerConfig); + }; + VoiceProfileClient.prototype.handleResultCallbacks = function (result, successReason, cb) { + if (!!cb) { + var response = new Exports_2.VoiceProfileResult(result.ok ? successReason : Exports_2.ResultReason.Canceled, result.statusText); + cb(response); + } + }; + return VoiceProfileClient; +}()); +exports.VoiceProfileClient = VoiceProfileClient; + + + +/***/ }), +/* 104 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var Contracts_1 = __webpack_require__(33); +var Exports_2 = __webpack_require__(31); +/** + * Defines SpeakerRecognizer class for Speaker Recognition + * Handles operations from user for Voice Profile operations (e.g. createProfile, deleteProfile) + * @class SpeakerRecognizer + */ +var SpeakerRecognizer = /** @class */ (function () { + /** + * SpeakerRecognizer constructor. + * @constructor + * @param {SpeechConfig} speechConfig - An set of initial properties for this recognizer (authentication key, region, &c) + */ + function SpeakerRecognizer(speechConfig, audioConfig) { + var speechConfigImpl = speechConfig; + Contracts_1.Contracts.throwIfNull(speechConfigImpl, "speechConfig"); + this.privAudioConfigImpl = audioConfig; + Contracts_1.Contracts.throwIfNull(this.privAudioConfigImpl, "audioConfig"); + this.privProperties = speechConfigImpl.properties.clone(); + this.implSRSetup(); + } + Object.defineProperty(SpeakerRecognizer.prototype, "authorizationToken", { + /** + * Gets the authorization token used to communicate with the service. + * @member SpeakerRecognizer.prototype.authorizationToken + * @function + * @public + * @returns {string} Authorization token. + */ + get: function () { + return this.properties.getProperty(Exports_2.PropertyId.SpeechServiceAuthorization_Token); + }, + /** + * Gets/Sets the authorization token used to communicate with the service. + * @member SpeakerRecognizer.prototype.authorizationToken + * @function + * @public + * @param {string} token - Authorization token. + */ + set: function (token) { + Contracts_1.Contracts.throwIfNullOrWhitespace(token, "token"); + this.properties.setProperty(Exports_2.PropertyId.SpeechServiceAuthorization_Token, token); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeakerRecognizer.prototype, "properties", { + /** + * The collection of properties and their values defined for this SpeakerRecognizer. + * @member SpeakerRecognizer.prototype.properties + * @function + * @public + * @returns {PropertyCollection} The collection of properties and their values defined for this SpeakerRecognizer. + */ + get: function () { + return this.privProperties; + }, + enumerable: true, + configurable: true + }); + /** + * Get recognition result for model using given audio + * @member SpeakerRecognizer.prototype.recognizeOnceAsync + * @function + * @public + * @param {SpeakerIdentificationModel} model Model containing Voice Profiles to be identified + * @param cb - Callback invoked once result is returned. + * @param err - Callback invoked in case of an error. + */ + SpeakerRecognizer.prototype.recognizeOnceAsync = function (model, cb, err) { + var _this = this; + if (model instanceof Exports_2.SpeakerIdentificationModel) { + this.privAdapter.identifySpeaker(model, this.privAudioConfigImpl).continueWith(function (promiseResult) { + _this.handleResultCallbacks(promiseResult, Exports_2.SpeakerRecognitionResultType.Identify, undefined, cb, err); + }); + } + else if (model instanceof Exports_2.SpeakerVerificationModel) { + this.privAdapter.verifySpeaker(model, this.privAudioConfigImpl).continueWith(function (promiseResult) { + _this.handleResultCallbacks(promiseResult, Exports_2.SpeakerRecognitionResultType.Verify, model.voiceProfile.profileId, cb, err); + }); + } + else { + throw new Error("SpeakerRecognizer.recognizeOnce: Unexpected model type"); + } + }; + /** + * Included for compatibility + * @member SpeakerRecognizer.prototype.close + * @function + * @public + */ + SpeakerRecognizer.prototype.close = function () { + return; + }; + // Does class setup, swiped from Recognizer. + SpeakerRecognizer.prototype.implSRSetup = function () { + var osPlatform = (typeof window !== "undefined") ? "Browser" : "Node"; + var osName = "unknown"; + var osVersion = "unknown"; + if (typeof navigator !== "undefined") { + osPlatform = osPlatform + "/" + navigator.platform; + osName = navigator.userAgent; + osVersion = navigator.appVersion; + } + var recognizerConfig = new Exports_1.SpeakerRecognitionConfig(new Exports_1.Context(new Exports_1.OS(osPlatform, osName, osVersion)), this.privProperties); + this.privAdapter = new Exports_1.SpeakerIdMessageAdapter(recognizerConfig); + }; + SpeakerRecognizer.prototype.handleResultCallbacks = function (promiseResult, resultType, profileId, cb, err) { + try { + if (promiseResult.isError) { + if (!!err) { + err(promiseResult.error); + } + } + else if (promiseResult.isCompleted && !!cb) { + cb(new Exports_2.SpeakerRecognitionResult(resultType, promiseResult.result.data, profileId, promiseResult.result.ok ? Exports_2.ResultReason.RecognizedSpeaker : Exports_2.ResultReason.Canceled)); + } + } + catch (e) { + if (!!err) { + err(e); + } + } + }; + return SpeakerRecognizer; +}()); +exports.SpeakerRecognizer = SpeakerRecognizer; + + + +/***/ }), +/* 105 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Contracts_1 = __webpack_require__(33); +var Exports_1 = __webpack_require__(31); +/** + * Defines SpeakerIdentificationModel class for Speaker Recognition + * Model contains a set of profiles against which to identify speaker(s) + * @class SpeakerIdentificationModel + */ +var SpeakerIdentificationModel = /** @class */ (function () { + function SpeakerIdentificationModel(profiles) { + var _this = this; + this.privVoiceProfiles = []; + Contracts_1.Contracts.throwIfNullOrUndefined(profiles, "VoiceProfiles"); + if (profiles.length === 0) { + throw new Error("Empty Voice Profiles array"); + } + profiles.forEach(function (profile) { + if (profile.profileType !== Exports_1.VoiceProfileType.TextIndependentIdentification) { + throw new Error("Identification model can only be created from Identification profile: " + profile.profileId); + } + _this.privVoiceProfiles.push(profile); + }); + } + SpeakerIdentificationModel.fromProfiles = function (profiles) { + return new SpeakerIdentificationModel(profiles); + }; + Object.defineProperty(SpeakerIdentificationModel.prototype, "voiceProfileIds", { + get: function () { + return this.privVoiceProfiles.map(function (profile) { return profile.profileId; }).join(","); + }, + enumerable: true, + configurable: true + }); + return SpeakerIdentificationModel; +}()); +exports.SpeakerIdentificationModel = SpeakerIdentificationModel; + + + +/***/ }), +/* 106 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Contracts_1 = __webpack_require__(33); +var Exports_1 = __webpack_require__(31); +/** + * Defines SpeakerVerificationModel class for Speaker Recognition + * Model contains a profile against which to verify a speaker + * @class SpeakerVerificationModel + */ +var SpeakerVerificationModel = /** @class */ (function () { + function SpeakerVerificationModel(profile) { + Contracts_1.Contracts.throwIfNullOrUndefined(profile, "VoiceProfile"); + if (profile.profileType === Exports_1.VoiceProfileType.TextIndependentIdentification) { + throw new Error("Verification model cannot be created from Identification profile"); + } + this.privVoiceProfile = profile; + } + SpeakerVerificationModel.fromProfile = function (profile) { + return new SpeakerVerificationModel(profile); + }; + Object.defineProperty(SpeakerVerificationModel.prototype, "voiceProfile", { + get: function () { + return this.privVoiceProfile; + }, + enumerable: true, + configurable: true + }); + return SpeakerVerificationModel; +}()); +exports.SpeakerVerificationModel = SpeakerVerificationModel; + + + +/***/ }), +/* 107 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var Contracts_1 = __webpack_require__(33); +var Exports_2 = __webpack_require__(31); +/** + * Language auto detect configuration. + * @class AutoDetectSourceLanguageConfig + * Added in version 1.13.0. + */ +var AutoDetectSourceLanguageConfig = /** @class */ (function () { + function AutoDetectSourceLanguageConfig() { + this.privProperties = new Exports_2.PropertyCollection(); + } + /** + * @member AutoDetectSourceLanguageConfig.fromOpenRange + * @function + * @public + * Only [[SpeechSynthesizer]] supports source language auto detection from open range, + * for [[Recognizer]], please use AutoDetectSourceLanguageConfig with specific source languages. + * @return {AutoDetectSourceLanguageConfig} Instance of AutoDetectSourceLanguageConfig + * @summary Creates an instance of the AutoDetectSourceLanguageConfig with open range. + */ + AutoDetectSourceLanguageConfig.fromOpenRange = function () { + var config = new AutoDetectSourceLanguageConfig(); + config.properties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, Exports_1.AutoDetectSourceLanguagesOpenRangeOptionName); + return config; + }; + /** + * @member AutoDetectSourceLanguageConfig.fromLanguages + * @function + * @public + * @param {string[]} languages Comma-separated string of languages (eg. "en-US,fr-FR") to populate properties of config. + * @return {AutoDetectSourceLanguageConfig} Instance of AutoDetectSourceLanguageConfig + * @summary Creates an instance of the AutoDetectSourceLanguageConfig with given languages. + */ + AutoDetectSourceLanguageConfig.fromLanguages = function (languages) { + Contracts_1.Contracts.throwIfArrayEmptyOrWhitespace(languages, "languages"); + var config = new AutoDetectSourceLanguageConfig(); + config.properties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, languages.join()); + return config; + }; + /** + * @member AutoDetectSourceLanguageConfig.fromSourceLanguageConfigs + * @function + * @public + * @param {SourceLanguageConfig[]} configs SourceLanguageConfigs to populate properties of config. + * @return {AutoDetectSourceLanguageConfig} Instance of AutoDetectSourceLanguageConfig + * @summary Creates an instance of the AutoDetectSourceLanguageConfig with given SourceLanguageConfigs. + */ + AutoDetectSourceLanguageConfig.fromSourceLanguageConfigs = function (configs) { + if (configs.length < 1) { + throw new Error("Expected non-empty SourceLanguageConfig array."); + } + var autoConfig = new AutoDetectSourceLanguageConfig(); + var langs = []; + configs.forEach(function (config) { + langs.push(config.language); + if (config.endpointId !== undefined && config.endpointId !== "") { + var customProperty = config.language + Exports_2.PropertyId.SpeechServiceConnection_EndpointId.toString(); + autoConfig.properties.setProperty(customProperty, config.endpointId); + } + }); + autoConfig.properties.setProperty(Exports_2.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, langs.join()); + return autoConfig; + }; + Object.defineProperty(AutoDetectSourceLanguageConfig.prototype, "properties", { + /** + * @member AutoDetectSourceLanguageConfig.prototype.properties + * @function + * @public + * @return {PropertyCollection} Properties of the config. + * @summary Gets a auto detected language config properties + */ + get: function () { + return this.privProperties; + }, + enumerable: true, + configurable: true + }); + return AutoDetectSourceLanguageConfig; +}()); +exports.AutoDetectSourceLanguageConfig = AutoDetectSourceLanguageConfig; + + + +/***/ }), +/* 108 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Contracts_1 = __webpack_require__(33); +/** + * Output format + * @class AutoDetectSourceLanguageResult + */ +var AutoDetectSourceLanguageResult = /** @class */ (function () { + function AutoDetectSourceLanguageResult(language, languageDetectionConfidence) { + Contracts_1.Contracts.throwIfNullOrUndefined(language, "language"); + Contracts_1.Contracts.throwIfNullOrUndefined(languageDetectionConfidence, "languageDetectionConfidence"); + this.privLanguage = language; + this.privLanguageDetectionConfidence = languageDetectionConfidence; + } + /** + * Creates an instance of AutoDetectSourceLanguageResult object from a SpeechRecognitionResult instance. + * @member AutoDetectSourceLanguageResult.fromResult + * @function + * @public + * @param {SpeechRecognitionResult} result - The recognition result. + * @returns {AutoDetectSourceLanguageResult} AutoDetectSourceLanguageResult object being created. + */ + AutoDetectSourceLanguageResult.fromResult = function (result) { + return new AutoDetectSourceLanguageResult(result.language, result.languageDetectionConfidence); + }; + Object.defineProperty(AutoDetectSourceLanguageResult.prototype, "language", { + get: function () { + return this.privLanguage; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AutoDetectSourceLanguageResult.prototype, "languageDetectionConfidence", { + get: function () { + return this.privLanguageDetectionConfidence; + }, + enumerable: true, + configurable: true + }); + return AutoDetectSourceLanguageResult; +}()); +exports.AutoDetectSourceLanguageResult = AutoDetectSourceLanguageResult; + + + +/***/ }), +/* 109 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Contracts_1 = __webpack_require__(33); +/** + * Source Language configuration. + * @class SourceLanguageConfig + */ +var SourceLanguageConfig = /** @class */ (function () { + function SourceLanguageConfig(language, endpointId) { + Contracts_1.Contracts.throwIfNullOrUndefined(language, "language"); + this.privLanguage = language; + this.privEndpointId = endpointId; + } + /** + * @member SourceLanguageConfig.fromLanguage + * @function + * @public + * @param {string} language language (eg. "en-US") value of config. + * @param {string?} endpointId endpointId of model bound to given language of config. + * @return {SourceLanguageConfig} Instance of SourceLanguageConfig + * @summary Creates an instance of the SourceLanguageConfig with the given language and optional endpointId. + * Added in version 1.13.0. + */ + SourceLanguageConfig.fromLanguage = function (language, endpointId) { + return new SourceLanguageConfig(language, endpointId); + }; + Object.defineProperty(SourceLanguageConfig.prototype, "language", { + get: function () { + return this.privLanguage; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SourceLanguageConfig.prototype, "endpointId", { + get: function () { + return this.privEndpointId; + }, + enumerable: true, + configurable: true + }); + return SourceLanguageConfig; +}()); +exports.SourceLanguageConfig = SourceLanguageConfig; + + + +/***/ }), +/* 110 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(26); +var Contracts_1 = __webpack_require__(33); +var Exports_2 = __webpack_require__(31); +var SpeakerRecognitionResultType; +(function (SpeakerRecognitionResultType) { + SpeakerRecognitionResultType[SpeakerRecognitionResultType["Verify"] = 0] = "Verify"; + SpeakerRecognitionResultType[SpeakerRecognitionResultType["Identify"] = 1] = "Identify"; +})(SpeakerRecognitionResultType = exports.SpeakerRecognitionResultType || (exports.SpeakerRecognitionResultType = {})); +/** + * Output format + * @class SpeakerRecognitionResult + */ +var SpeakerRecognitionResult = /** @class */ (function () { + function SpeakerRecognitionResult(resultType, data, profileId, resultReason) { + if (resultReason === void 0) { resultReason = Exports_2.ResultReason.RecognizedSpeaker; } + this.privProperties = new Exports_2.PropertyCollection(); + this.privReason = resultReason; + if (this.privReason !== Exports_2.ResultReason.Canceled) { + if (resultType === SpeakerRecognitionResultType.Identify) { + var json = JSON.parse(data); + Contracts_1.Contracts.throwIfNullOrUndefined(json, "JSON"); + this.privProfileId = json.identifiedProfile.profileId; + this.privScore = json.identifiedProfile.score; + } + else { + var json = JSON.parse(data); + Contracts_1.Contracts.throwIfNullOrUndefined(json, "JSON"); + this.privScore = json.score; + if (json.recognitionResult.toLowerCase() !== "accept") { + this.privReason = Exports_2.ResultReason.NoMatch; + } + if (profileId !== undefined && profileId !== "") { + this.privProfileId = profileId; + } + } + } + else { + var json = JSON.parse(data); + Contracts_1.Contracts.throwIfNullOrUndefined(json, "JSON"); + this.privErrorDetails = json.statusText; + this.privProperties.setProperty(Exports_1.CancellationErrorCodePropertyName, Exports_2.CancellationErrorCode[Exports_2.CancellationErrorCode.ServiceError]); + } + this.privProperties.setProperty(Exports_2.PropertyId.SpeechServiceResponse_JsonResult, data); + } + Object.defineProperty(SpeakerRecognitionResult.prototype, "properties", { + get: function () { + return this.privProperties; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeakerRecognitionResult.prototype, "reason", { + get: function () { + return this.privReason; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeakerRecognitionResult.prototype, "profileId", { + get: function () { + return this.privProfileId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeakerRecognitionResult.prototype, "errorDetails", { + get: function () { + return this.privErrorDetails; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeakerRecognitionResult.prototype, "score", { + get: function () { + return this.privScore; + }, + enumerable: true, + configurable: true + }); + return SpeakerRecognitionResult; +}()); +exports.SpeakerRecognitionResult = SpeakerRecognitionResult; +/** + * @class SpeakerRecognitionCancellationDetails + */ +// tslint:disable-next-line:max-classes-per-file +var SpeakerRecognitionCancellationDetails = /** @class */ (function (_super) { + __extends(SpeakerRecognitionCancellationDetails, _super); + function SpeakerRecognitionCancellationDetails(reason, errorDetails, errorCode) { + return _super.call(this, reason, errorDetails, errorCode) || this; + } + /** + * Creates an instance of SpeakerRecognitionCancellationDetails object for the canceled SpeakerRecognitionResult + * @member SpeakerRecognitionCancellationDetails.fromResult + * @function + * @public + * @param {SpeakerRecognitionResult} result - The result that was canceled. + * @returns {SpeakerRecognitionCancellationDetails} The cancellation details object being created. + */ + SpeakerRecognitionCancellationDetails.fromResult = function (result) { + var reason = Exports_2.CancellationReason.Error; + var errorCode = Exports_2.CancellationErrorCode.NoError; + if (!!result.properties) { + errorCode = Exports_2.CancellationErrorCode[result.properties.getProperty(Exports_1.CancellationErrorCodePropertyName, Exports_2.CancellationErrorCode[Exports_2.CancellationErrorCode.NoError])]; + } + return new SpeakerRecognitionCancellationDetails(reason, result.errorDetails, errorCode); + }; + return SpeakerRecognitionCancellationDetails; +}(Exports_2.CancellationDetailsBase)); +exports.SpeakerRecognitionCancellationDetails = SpeakerRecognitionCancellationDetails; + + + +/***/ }), +/* 111 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +// Multi-device Conversation is a Preview feature. +Object.defineProperty(exports, "__esModule", { value: true }); +var Conversation_1 = __webpack_require__(112); +exports.Conversation = Conversation_1.Conversation; +var ConversationExpirationEventArgs_1 = __webpack_require__(113); +exports.ConversationExpirationEventArgs = ConversationExpirationEventArgs_1.ConversationExpirationEventArgs; +var ConversationParticipantsChangedEventArgs_1 = __webpack_require__(114); +exports.ConversationParticipantsChangedEventArgs = ConversationParticipantsChangedEventArgs_1.ConversationParticipantsChangedEventArgs; +var ConversationTranslationCanceledEventArgs_1 = __webpack_require__(115); +exports.ConversationTranslationCanceledEventArgs = ConversationTranslationCanceledEventArgs_1.ConversationTranslationCanceledEventArgs; +var ConversationTranslationEventArgs_1 = __webpack_require__(116); +exports.ConversationTranslationEventArgs = ConversationTranslationEventArgs_1.ConversationTranslationEventArgs; +var ConversationTranslationResult_1 = __webpack_require__(117); +exports.ConversationTranslationResult = ConversationTranslationResult_1.ConversationTranslationResult; +var ConversationTranslator_1 = __webpack_require__(118); +exports.ConversationTranslator = ConversationTranslator_1.ConversationTranslator; +var IParticipant_1 = __webpack_require__(119); +exports.Participant = IParticipant_1.Participant; +exports.User = IParticipant_1.User; +var ParticipantChangedReason_1 = __webpack_require__(120); +exports.ParticipantChangedReason = ParticipantChangedReason_1.ParticipantChangedReason; + + + +/***/ }), +/* 112 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +// Multi-device Conversation is a Preview feature. +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 __()); + }; +})(); +var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var Contracts_1 = __webpack_require__(33); +var Exports_2 = __webpack_require__(31); +var Conversation = /** @class */ (function () { + function Conversation() { + } + /** + * Create a conversation + * @param speechConfig + * @param cb + * @param err + */ + Conversation.createConversationAsync = function (speechConfig, cb, err) { + Contracts_1.Contracts.throwIfNullOrUndefined(speechConfig, Exports_1.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}", "config")); + Contracts_1.Contracts.throwIfNullOrUndefined(speechConfig.region, Exports_1.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}", "SpeechServiceConnection_Region")); + if (!speechConfig.subscriptionKey && !speechConfig.getProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceAuthorization_Token])) { + Contracts_1.Contracts.throwIfNullOrUndefined(speechConfig.subscriptionKey, Exports_1.ConversationConnectionConfig.restErrors.invalidArgs.replace("{arg}", "SpeechServiceConnection_Key")); + } + var conversationImpl = new ConversationImpl(speechConfig); + conversationImpl.createConversationAsync((function () { + if (!!cb) { + cb(); + } + }), function (error) { + if (!!err) { + err(error); + } + }); + return conversationImpl; + }; + return Conversation; +}()); +exports.Conversation = Conversation; +// tslint:disable-next-line:max-classes-per-file +var ConversationImpl = /** @class */ (function (_super) { + __extends(ConversationImpl, _super); + /** + * Create a conversation impl + * @param speechConfig + */ + function ConversationImpl(speechConfig) { + var _this = _super.call(this) || this; + _this.privIsDisposed = false; + _this.privIsConnected = false; + _this.privErrors = Exports_1.ConversationConnectionConfig.restErrors; + /** websocket callbacks */ + _this.onConnected = function (e) { + _this.privIsConnected = true; + try { + if (!!_this.privConversationTranslator.sessionStarted) { + _this.privConversationTranslator.sessionStarted(_this.privConversationTranslator, e); + } + } + catch (e) { + // + } + }; + _this.onDisconnected = function (e) { + _this.close(false); + try { + if (!!_this.privConversationTranslator.sessionStopped) { + _this.privConversationTranslator.sessionStopped(_this.privConversationTranslator, e); + } + } + catch (e) { + // + } + }; + _this.onCanceled = function (r, e) { + _this.close(false); // ? + try { + if (!!_this.privConversationTranslator.canceled) { + _this.privConversationTranslator.canceled(_this.privConversationTranslator, e); + } + } + catch (e) { + // + } + }; + _this.onParticipantUpdateCommandReceived = function (r, e) { + var _a, _b; + try { + var updatedParticipant = _this.privParticipants.getParticipant(e.id); + if (updatedParticipant !== undefined) { + switch (e.key) { + case Exports_1.ConversationTranslatorCommandTypes.changeNickname: + updatedParticipant.displayName = e.value; + break; + case Exports_1.ConversationTranslatorCommandTypes.setUseTTS: + updatedParticipant.useTts = e.value; + break; + case Exports_1.ConversationTranslatorCommandTypes.setProfanityFiltering: + updatedParticipant.profanity = e.value; + break; + case Exports_1.ConversationTranslatorCommandTypes.setMute: + updatedParticipant.isMuted = e.value; + break; + case Exports_1.ConversationTranslatorCommandTypes.setTranslateToLanguages: + updatedParticipant.translateToLanguages = e.value; + break; + } + _this.privParticipants.addOrUpdateParticipant(updatedParticipant); + if (!!((_a = _this.privConversationTranslator) === null || _a === void 0 ? void 0 : _a.participantsChanged)) { + (_b = _this.privConversationTranslator) === null || _b === void 0 ? void 0 : _b.participantsChanged(_this.privConversationTranslator, new Exports_2.ConversationParticipantsChangedEventArgs(Exports_2.ParticipantChangedReason.Updated, [_this.toParticipant(updatedParticipant)], e.sessionId)); + } + } + } + catch (e) { + // + } + }; + _this.onLockRoomCommandReceived = function (r, e) { + // TODO + }; + _this.onMuteAllCommandReceived = function (r, e) { + var _a, _b; + try { + _this.privParticipants.participants.forEach(function (p) { return p.isMuted = (p.isHost ? false : e.isMuted); }); + if (!!((_a = _this.privConversationTranslator) === null || _a === void 0 ? void 0 : _a.participantsChanged)) { + (_b = _this.privConversationTranslator) === null || _b === void 0 ? void 0 : _b.participantsChanged(_this.privConversationTranslator, new Exports_2.ConversationParticipantsChangedEventArgs(Exports_2.ParticipantChangedReason.Updated, _this.toParticipants(false), e.sessionId)); + } + } + catch (e) { + // + } + }; + _this.onParticipantJoinCommandReceived = function (r, e) { + var _a, _b; + try { + var newParticipant = _this.privParticipants.addOrUpdateParticipant(e.participant); + if (newParticipant !== undefined) { + if (!!((_a = _this.privConversationTranslator) === null || _a === void 0 ? void 0 : _a.participantsChanged)) { + (_b = _this.privConversationTranslator) === null || _b === void 0 ? void 0 : _b.participantsChanged(_this.privConversationTranslator, new Exports_2.ConversationParticipantsChangedEventArgs(Exports_2.ParticipantChangedReason.JoinedConversation, [_this.toParticipant(newParticipant)], e.sessionId)); + } + } + } + catch (e) { + // + } + }; + _this.onParticipantLeaveCommandReceived = function (r, e) { + var _a, _b; + try { + var ejectedParticipant = _this.privParticipants.getParticipant(e.participant.id); + if (ejectedParticipant !== undefined) { + // remove the participant from the internal participants list + _this.privParticipants.deleteParticipant(e.participant.id); + if (!!((_a = _this.privConversationTranslator) === null || _a === void 0 ? void 0 : _a.participantsChanged)) { + // notify subscribers that the participant has left the conversation + (_b = _this.privConversationTranslator) === null || _b === void 0 ? void 0 : _b.participantsChanged(_this.privConversationTranslator, new Exports_2.ConversationParticipantsChangedEventArgs(Exports_2.ParticipantChangedReason.LeftConversation, [_this.toParticipant(ejectedParticipant)], e.sessionId)); + } + } + } + catch (e) { + // + } + }; + _this.onTranslationReceived = function (r, e) { + var _a, _b, _c, _d, _e, _f; + try { + switch (e.command) { + case Exports_1.ConversationTranslatorMessageTypes.final: + if (!!((_a = _this.privConversationTranslator) === null || _a === void 0 ? void 0 : _a.transcribed)) { + (_b = _this.privConversationTranslator) === null || _b === void 0 ? void 0 : _b.transcribed(_this.privConversationTranslator, new Exports_2.ConversationTranslationEventArgs(e.payload, undefined, e.sessionId)); + } + break; + case Exports_1.ConversationTranslatorMessageTypes.partial: + if (!!((_c = _this.privConversationTranslator) === null || _c === void 0 ? void 0 : _c.transcribing)) { + (_d = _this.privConversationTranslator) === null || _d === void 0 ? void 0 : _d.transcribing(_this.privConversationTranslator, new Exports_2.ConversationTranslationEventArgs(e.payload, undefined, e.sessionId)); + } + break; + case Exports_1.ConversationTranslatorMessageTypes.instantMessage: + if (!!((_e = _this.privConversationTranslator) === null || _e === void 0 ? void 0 : _e.textMessageReceived)) { + (_f = _this.privConversationTranslator) === null || _f === void 0 ? void 0 : _f.textMessageReceived(_this.privConversationTranslator, new Exports_2.ConversationTranslationEventArgs(e.payload, undefined, e.sessionId)); + } + break; + } + } + catch (e) { + // + } + }; + _this.onParticipantsListReceived = function (r, e) { + var _a, _b; + try { + // check if the session token needs to be updated + if (e.sessionToken !== undefined && e.sessionToken !== null) { + _this.privRoom.token = e.sessionToken; + } + // save the participants + _this.privParticipants.participants = __spreadArrays(e.participants); + // enable the conversation + if (_this.privParticipants.me !== undefined) { + _this.privIsReady = true; + } + if (!!((_a = _this.privConversationTranslator) === null || _a === void 0 ? void 0 : _a.participantsChanged)) { + (_b = _this.privConversationTranslator) === null || _b === void 0 ? void 0 : _b.participantsChanged(_this.privConversationTranslator, new Exports_2.ConversationParticipantsChangedEventArgs(Exports_2.ParticipantChangedReason.JoinedConversation, _this.toParticipants(true), e.sessionId)); + } + // if this is the host, update the nickname if needed + if (_this.me.isHost) { + var nickname = _this.privConversationTranslator.properties.getProperty(Exports_2.PropertyId.ConversationTranslator_Name); + if (nickname !== undefined && nickname.length > 0 && nickname !== _this.me.displayName) { + // issue a change nickname request + _this.changeNicknameAsync(nickname); + } + } + } + catch (e) { + // + } + }; + _this.onConversationExpiration = function (r, e) { + var _a, _b; + try { + if (!!((_a = _this.privConversationTranslator) === null || _a === void 0 ? void 0 : _a.conversationExpiration)) { + (_b = _this.privConversationTranslator) === null || _b === void 0 ? void 0 : _b.conversationExpiration(_this.privConversationTranslator, e); + } + } + catch (e) { + // + } + }; + _this.privProperties = new Exports_2.PropertyCollection(); + _this.privManager = new Exports_1.ConversationManager(); + // check the speech language + var language = speechConfig.getProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage]); + if (!language) { + speechConfig.setProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage], Exports_1.ConversationConnectionConfig.defaultLanguageCode); + } + _this.privLanguage = speechConfig.getProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage]); + // check the target language(s) + if (speechConfig.targetLanguages.length === 0) { + speechConfig.addTargetLanguage(_this.privLanguage); + } + // check the profanity setting: speech and conversationTranslator should be in sync + var profanity = speechConfig.getProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceResponse_ProfanityOption]); + if (!profanity) { + speechConfig.setProfanity(Exports_2.ProfanityOption.Masked); + } + // check the nickname: it should pass this regex: ^\w+([\s-][\w\(\)]+)*$" + // TODO: specify the regex required. Nicknames must be unique or get the duplicate nickname error + // TODO: check what the max length is and if a truncation is required or if the service handles it without an error + var hostNickname = speechConfig.getProperty(Exports_2.PropertyId[Exports_2.PropertyId.ConversationTranslator_Name]); + if (hostNickname === undefined || hostNickname === null || hostNickname.length <= 1 || hostNickname.length > 50) { + hostNickname = "Host"; + } + speechConfig.setProperty(Exports_2.PropertyId[Exports_2.PropertyId.ConversationTranslator_Name], hostNickname); + // save the speech config for future usage + _this.privConfig = speechConfig; + // save the config properties + var configImpl = speechConfig; + Contracts_1.Contracts.throwIfNull(configImpl, "speechConfig"); + _this.privProperties = configImpl.properties.clone(); + _this.privIsConnected = false; + _this.privParticipants = new Exports_1.InternalParticipants(); + _this.privIsReady = false; + _this.privTextMessageMaxLength = 1000; + return _this; + } + Object.defineProperty(ConversationImpl.prototype, "conversationTranslator", { + set: function (value) { + this.privConversationTranslator = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationImpl.prototype, "room", { + // get the internal data about a conversation + get: function () { + return this.privRoom; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationImpl.prototype, "connection", { + // get the wrapper for connecting to the websockets + get: function () { + return this.privConversationRecognizer; // this.privConnection; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationImpl.prototype, "authorizationToken", { + // get / set the speech auth token + get: function () { + return this.privToken; + }, + set: function (value) { + Contracts_1.Contracts.throwIfNullOrWhitespace(value, "authorizationToken"); + this.privToken = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationImpl.prototype, "config", { + // get the config + get: function () { + return this.privConfig; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationImpl.prototype, "conversationId", { + // get the conversation Id + get: function () { + return this.privRoom ? this.privRoom.roomId : ""; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationImpl.prototype, "properties", { + // get the properties + get: function () { + return this.privProperties; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationImpl.prototype, "speechRecognitionLanguage", { + // get the speech language + get: function () { + return this.privLanguage; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationImpl.prototype, "isMutedByHost", { + get: function () { + var _a, _b; + return ((_a = this.privParticipants.me) === null || _a === void 0 ? void 0 : _a.isHost) ? false : (_b = this.privParticipants.me) === null || _b === void 0 ? void 0 : _b.isMuted; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationImpl.prototype, "isConnected", { + get: function () { + return this.privIsConnected && this.privIsReady; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationImpl.prototype, "participants", { + get: function () { + return this.toParticipants(true); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationImpl.prototype, "me", { + get: function () { + return this.toParticipant(this.privParticipants.me); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationImpl.prototype, "host", { + get: function () { + return this.toParticipant(this.privParticipants.host); + }, + enumerable: true, + configurable: true + }); + /** + * Create a new conversation as Host + * @param cb + * @param err + */ + ConversationImpl.prototype.createConversationAsync = function (cb, err) { + var _this = this; + try { + if (!!this.privConversationRecognizer) { + this.handleError(new Error(this.privErrors.permissionDeniedStart), err); + } + this.privManager.createOrJoin(this.privProperties, undefined, (function (room) { + if (!room) { + _this.handleError(new Error(_this.privErrors.permissionDeniedConnect), err); + } + _this.privRoom = room; + _this.handleCallback(cb, err); + }), (function (error) { + _this.handleError(error, err); + })); + } + catch (error) { + this.handleError(error, err); + } + }; + /** + * Starts a new conversation as host. + * @param cb + * @param err + */ + ConversationImpl.prototype.startConversationAsync = function (cb, err) { + var _this = this; + try { + // check if there is already a recognizer + if (!!this.privConversationRecognizer) { + this.handleError(new Error(this.privErrors.permissionDeniedStart), err); + } + // check if there is conversation data available + Contracts_1.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedConnect); + // connect to the conversation websocket + this.privParticipants.meId = this.privRoom.participantId; + this.privConversationRecognizer = new Exports_1.ConversationTranslatorRecognizer(this.privConfig); + this.privConversationRecognizer.conversation = this.privRoom; + this.privConversationRecognizerConnection = Exports_2.Connection.fromRecognizer(this.privConversationRecognizer); + this.privConversationRecognizerConnection.connected = this.onConnected; + this.privConversationRecognizerConnection.disconnected = this.onDisconnected; + this.privConversationRecognizer.canceled = this.onCanceled; + this.privConversationRecognizer.participantUpdateCommandReceived = this.onParticipantUpdateCommandReceived; + this.privConversationRecognizer.lockRoomCommandReceived = this.onLockRoomCommandReceived; + this.privConversationRecognizer.muteAllCommandReceived = this.onMuteAllCommandReceived; + this.privConversationRecognizer.participantJoinCommandReceived = this.onParticipantJoinCommandReceived; + this.privConversationRecognizer.participantLeaveCommandReceived = this.onParticipantLeaveCommandReceived; + this.privConversationRecognizer.translationReceived = this.onTranslationReceived; + this.privConversationRecognizer.participantsListReceived = this.onParticipantsListReceived; + this.privConversationRecognizer.conversationExpiration = this.onConversationExpiration; + this.privConversationRecognizer.connect(this.privRoom.token, (function () { + _this.handleCallback(cb, err); + }), (function (error) { + _this.handleError(error, err); + })); + } + catch (error) { + this.handleError(error, err); + } + }; + /** + * Join a conversation as a participant. + * @param conversation + * @param nickname + * @param lang + * @param cb + * @param err + */ + ConversationImpl.prototype.joinConversationAsync = function (conversationId, nickname, lang, cb, err) { + var _this = this; + try { + // TODO + // if (!!this.privConversationRecognizer) { + // throw new Error(this.privErrors.permissionDeniedStart); + // } + Contracts_1.Contracts.throwIfNullOrWhitespace(conversationId, this.privErrors.invalidArgs.replace("{arg}", "conversationId")); + Contracts_1.Contracts.throwIfNullOrWhitespace(nickname, this.privErrors.invalidArgs.replace("{arg}", "nickname")); + Contracts_1.Contracts.throwIfNullOrWhitespace(lang, this.privErrors.invalidArgs.replace("{arg}", "language")); + // join the conversation + this.privManager.createOrJoin(this.privProperties, conversationId, (function (room) { + Contracts_1.Contracts.throwIfNullOrUndefined(room, _this.privErrors.permissionDeniedConnect); + _this.privRoom = room; + _this.privConfig.authorizationToken = room.cognitiveSpeechAuthToken; + // join callback + if (!!cb) { + cb(room.cognitiveSpeechAuthToken); + } + }), (function (error) { + _this.handleError(error, err); + })); + } + catch (error) { + this.handleError(error, err); + } + }; + /** + * Deletes a conversation + * @param cb + * @param err + */ + ConversationImpl.prototype.deleteConversationAsync = function (cb, err) { + var _this = this; + try { + Contracts_1.Contracts.throwIfNullOrUndefined(this.privProperties, this.privErrors.permissionDeniedConnect); + Contracts_1.Contracts.throwIfNullOrWhitespace(this.privRoom.token, this.privErrors.permissionDeniedConnect); + this.privManager.leave(this.privProperties, this.privRoom.token, (function () { + _this.handleCallback(cb, err); + }), (function (error) { + _this.handleError(error, err); + })); + this.dispose(); + } + catch (error) { + this.handleError(error, err); + } + }; + /** + * Issues a request to close the client websockets + * @param cb + * @param err + */ + ConversationImpl.prototype.endConversationAsync = function (cb, err) { + try { + this.close(true); + this.handleCallback(cb, err); + } + catch (error) { + this.handleError(error, err); + } + }; + /** + * Issues a request to lock the conversation + * @param cb + * @param err + */ + ConversationImpl.prototype.lockConversationAsync = function (cb, err) { + var _this = this; + var _a; + try { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + Contracts_1.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()); + Contracts_1.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend); + if (!this.canSendAsHost) { + this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}", "lock")), err); + } + (_a = this.privConversationRecognizer) === null || _a === void 0 ? void 0 : _a.sendLockRequest(true, (function () { + _this.handleCallback(cb, err); + }), (function (error) { + _this.handleError(error, err); + })); + } + catch (error) { + this.handleError(error, err); + } + }; + /** + * Issues a request to mute the conversation + * @param cb + * @param err + */ + ConversationImpl.prototype.muteAllParticipantsAsync = function (cb, err) { + var _this = this; + var _a; + try { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + Contracts_1.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()); + Contracts_1.Contracts.throwIfNullOrUndefined(this.privConversationRecognizer, this.privErrors.permissionDeniedSend); + Contracts_1.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend); + // check the user's permissions + if (!this.canSendAsHost) { + this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}", "mute")), err); + } + (_a = this.privConversationRecognizer) === null || _a === void 0 ? void 0 : _a.sendMuteAllRequest(true, (function () { + _this.handleCallback(cb, err); + }), (function (error) { + _this.handleError(error, err); + })); + } + catch (error) { + this.handleError(error, err); + } + }; + /** + * Issues a request to mute a participant in the conversation + * @param userId + * @param cb + * @param err + */ + ConversationImpl.prototype.muteParticipantAsync = function (userId, cb, err) { + var _this = this; + var _a; + try { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + Contracts_1.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()); + Contracts_1.Contracts.throwIfNullOrWhitespace(userId, this.privErrors.invalidArgs.replace("{arg}", "userId")); + Contracts_1.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend); + // check the connection is open (host + participant can perform the mute command) + if (!this.canSend) { + this.handleError(new Error(this.privErrors.permissionDeniedSend), err); + } + // if not host, check the participant is not muting another participant + if (!this.me.isHost && this.me.id !== userId) { + this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}", "mute")), err); + } + // check the user exists + var exists = this.privParticipants.getParticipantIndex(userId); + if (exists === -1) { + this.handleError(new Error(this.privErrors.invalidParticipantRequest), err); + } + (_a = this.privConversationRecognizer) === null || _a === void 0 ? void 0 : _a.sendMuteRequest(userId, true, (function () { + _this.handleCallback(cb, err); + }), (function (error) { + _this.handleError(error, err); + })); + } + catch (error) { + this.handleError(error, err); + } + }; + /** + * Issues a request to remove a participant from the conversation + * @param userId + * @param cb + * @param err + */ + ConversationImpl.prototype.removeParticipantAsync = function (userId, cb, err) { + var _this = this; + var _a; + try { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + Contracts_1.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()); + Contracts_1.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend); + if (!this.canSendAsHost) { + this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}", "remove")), err); + } + var participantId_1 = ""; + if (typeof userId === "string") { + participantId_1 = userId; + } + else if (userId.hasOwnProperty("id")) { + var participant = userId; + participantId_1 = participant.id; + } + else if (userId.hasOwnProperty("userId")) { + var user = userId; + participantId_1 = user.userId; + } + Contracts_1.Contracts.throwIfNullOrWhitespace(participantId_1, this.privErrors.invalidArgs.replace("{arg}", "userId")); + // check the participant exists + var index = this.participants.findIndex(function (p) { return p.id === participantId_1; }); + if (index === -1) { + this.handleError(new Error(this.privErrors.invalidParticipantRequest), err); + } + (_a = this.privConversationRecognizer) === null || _a === void 0 ? void 0 : _a.sendEjectRequest(participantId_1, (function () { + _this.handleCallback(cb, err); + }), (function (error) { + _this.handleError(error, err); + })); + } + catch (error) { + this.handleError(error, err); + } + }; + /** + * Issues a request to unlock the conversation + * @param cb + * @param err + */ + ConversationImpl.prototype.unlockConversationAsync = function (cb, err) { + var _this = this; + var _a; + try { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + Contracts_1.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()); + Contracts_1.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend); + if (!this.canSendAsHost) { + this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}", "unlock")), err); + } + (_a = this.privConversationRecognizer) === null || _a === void 0 ? void 0 : _a.sendLockRequest(false, (function () { + _this.handleCallback(cb, err); + }), (function (error) { + _this.handleError(error, err); + })); + } + catch (error) { + this.handleError(error, err); + } + }; + /** + * Issues a request to unmute all participants in the conversation + * @param cb + * @param err + */ + ConversationImpl.prototype.unmuteAllParticipantsAsync = function (cb, err) { + var _this = this; + var _a; + try { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + Contracts_1.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()); + Contracts_1.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend); + if (!this.canSendAsHost) { + this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace("{command}", "unmute all")), err); + } + (_a = this.privConversationRecognizer) === null || _a === void 0 ? void 0 : _a.sendMuteAllRequest(false, (function () { + _this.handleCallback(cb, err); + }), (function (error) { + _this.handleError(error, err); + })); + } + catch (error) { + this.handleError(error, err); + } + }; + /** + * Issues a request to unmute a participant in the conversation + * @param userId + * @param cb + * @param err + */ + ConversationImpl.prototype.unmuteParticipantAsync = function (userId, cb, err) { + var _this = this; + var _a; + try { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + Contracts_1.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()); + Contracts_1.Contracts.throwIfNullOrWhitespace(userId, this.privErrors.invalidArgs.replace("{arg}", "userId")); + Contracts_1.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend); + // check the connection is open (host + participant can perform the mute command) + if (!this.canSend) { + this.handleError(new Error(this.privErrors.permissionDeniedSend), err); + } + // if not host, check the participant is not muting another participant + if (!this.me.isHost && this.me.id !== userId) { + this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace("{command}", "mute")), err); + } + // check the user exists + var exists = this.privParticipants.getParticipantIndex(userId); + if (exists === -1) { + this.handleError(new Error(this.privErrors.invalidParticipantRequest), err); + } + (_a = this.privConversationRecognizer) === null || _a === void 0 ? void 0 : _a.sendMuteRequest(userId, false, (function () { + _this.handleCallback(cb, err); + }), (function (error) { + _this.handleError(error, err); + })); + } + catch (error) { + this.handleError(error, err); + } + }; + /** + * Send a text message + * @param message + * @param cb + * @param err + */ + ConversationImpl.prototype.sendTextMessageAsync = function (message, cb, err) { + var _this = this; + var _a; + try { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + Contracts_1.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()); + Contracts_1.Contracts.throwIfNullOrWhitespace(message, this.privErrors.invalidArgs.replace("{arg}", "message")); + Contracts_1.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend); + if (!this.canSend) { + this.handleError(new Error(this.privErrors.permissionDeniedSend), err); + } + // TODO: is a max length check required? + if (message.length > this.privTextMessageMaxLength) { + this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}", "message length")), err); + } + (_a = this.privConversationRecognizer) === null || _a === void 0 ? void 0 : _a.sendMessageRequest(message, (function () { + _this.handleCallback(cb, err); + }), (function (error) { + _this.handleError(error, err); + })); + } + catch (error) { + this.handleError(error, err); + } + }; + /** + * Change nickname + * @param message + * @param cb + * @param err + */ + ConversationImpl.prototype.changeNicknameAsync = function (nickname, cb, err) { + var _this = this; + var _a; + try { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + Contracts_1.Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed()); + Contracts_1.Contracts.throwIfNullOrWhitespace(nickname, this.privErrors.invalidArgs.replace("{arg}", "nickname")); + Contracts_1.Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend); + if (!this.canSend) { + this.handleError(new Error(this.privErrors.permissionDeniedSend), err); + } + (_a = this.privConversationRecognizer) === null || _a === void 0 ? void 0 : _a.sendChangeNicknameRequest(nickname, (function () { + _this.handleCallback(cb, err); + }), (function (error) { + _this.handleError(error, err); + })); + } + catch (error) { + this.handleError(error, err); + } + }; + ConversationImpl.prototype.isDisposed = function () { + return this.privIsDisposed; + }; + ConversationImpl.prototype.dispose = function (reason) { + var _a; + if (this.isDisposed) { + return; + } + this.privIsDisposed = true; + (_a = this.config) === null || _a === void 0 ? void 0 : _a.close(); + if (this.privConversationRecognizerConnection) { + this.privConversationRecognizerConnection.closeConnection(); + this.privConversationRecognizerConnection.close(); + this.privConversationRecognizerConnection = undefined; + } + this.privConfig = undefined; + this.privLanguage = undefined; + this.privProperties = undefined; + this.privRoom = undefined; + this.privToken = undefined; + this.privManager = undefined; + this.privConversationRecognizer = undefined; + this.privIsConnected = false; + this.privIsReady = false; + this.privParticipants = undefined; + this.privRoom = undefined; + }; + ConversationImpl.prototype.close = function (dispose) { + var _a, _b, _c; + try { + this.privIsConnected = false; + (_a = this.privConversationRecognizerConnection) === null || _a === void 0 ? void 0 : _a.closeConnection(); + (_b = this.privConversationRecognizerConnection) === null || _b === void 0 ? void 0 : _b.close(); + this.privConversationRecognizer.close(); + this.privConversationRecognizerConnection = undefined; + this.privConversationRecognizer = undefined; + (_c = this.privConversationTranslator) === null || _c === void 0 ? void 0 : _c.dispose(); + } + catch (e) { + // ignore error + } + if (dispose) { + this.dispose(); + } + }; + Object.defineProperty(ConversationImpl.prototype, "canSend", { + /** Helpers */ + get: function () { + var _a; + return this.privIsConnected && !((_a = this.privParticipants.me) === null || _a === void 0 ? void 0 : _a.isMuted); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationImpl.prototype, "canSendAsHost", { + get: function () { + var _a; + return this.privIsConnected && ((_a = this.privParticipants.me) === null || _a === void 0 ? void 0 : _a.isHost); + }, + enumerable: true, + configurable: true + }); + ConversationImpl.prototype.handleCallback = function (cb, err) { + if (!!cb) { + try { + cb(); + } + catch (e) { + if (!!err) { + err(e); + } + } + cb = undefined; + } + }; + ConversationImpl.prototype.handleError = function (error, err) { + if (!!err) { + if (error instanceof Error) { + var typedError = error; + err(typedError.name + ": " + typedError.message); + } + else { + err(error); + } + } + }; + /** Participant Helpers */ + ConversationImpl.prototype.toParticipants = function (includeHost) { + var _this = this; + var participants = this.privParticipants.participants.map(function (p) { + return _this.toParticipant(p); + }); + if (!includeHost) { + return participants.filter(function (p) { return p.isHost === false; }); + } + else { + return participants; + } + }; + ConversationImpl.prototype.toParticipant = function (p) { + return new Exports_2.Participant(p.id, p.avatar, p.displayName, p.isHost, p.isMuted, p.isUsingTts, p.preferredLanguage); + }; + return ConversationImpl; +}(Conversation)); +exports.ConversationImpl = ConversationImpl; + + + +/***/ }), +/* 113 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +// Multi-device Conversation is a Preview feature. +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 Exports_1 = __webpack_require__(31); +var ConversationExpirationEventArgs = /** @class */ (function (_super) { + __extends(ConversationExpirationEventArgs, _super); + function ConversationExpirationEventArgs(expirationTime, sessionId) { + var _this = _super.call(this, sessionId) || this; + _this.privExpirationTime = expirationTime; + return _this; + } + Object.defineProperty(ConversationExpirationEventArgs.prototype, "expirationTime", { + /** How much longer until the conversation expires (in minutes). */ + get: function () { + return this.privExpirationTime; + }, + enumerable: true, + configurable: true + }); + return ConversationExpirationEventArgs; +}(Exports_1.SessionEventArgs)); +exports.ConversationExpirationEventArgs = ConversationExpirationEventArgs; + + + +/***/ }), +/* 114 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +// Multi-device Conversation is a Preview feature. +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 Exports_1 = __webpack_require__(31); +var ConversationParticipantsChangedEventArgs = /** @class */ (function (_super) { + __extends(ConversationParticipantsChangedEventArgs, _super); + function ConversationParticipantsChangedEventArgs(reason, participants, sessionId) { + var _this = _super.call(this, sessionId) || this; + _this.privReason = reason; + _this.privParticipant = participants; + return _this; + } + Object.defineProperty(ConversationParticipantsChangedEventArgs.prototype, "reason", { + get: function () { + return this.privReason; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationParticipantsChangedEventArgs.prototype, "participants", { + get: function () { + return this.privParticipant; + }, + enumerable: true, + configurable: true + }); + return ConversationParticipantsChangedEventArgs; +}(Exports_1.SessionEventArgs)); +exports.ConversationParticipantsChangedEventArgs = ConversationParticipantsChangedEventArgs; + + + +/***/ }), +/* 115 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +// Multi-device Conversation is a Preview feature. +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 Exports_1 = __webpack_require__(31); +var ConversationTranslationCanceledEventArgs = /** @class */ (function (_super) { + __extends(ConversationTranslationCanceledEventArgs, _super); + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {CancellationReason} reason - The cancellation reason. + * @param {string} errorDetails - Error details, if provided. + * @param {number} offset - The offset. + * @param {string} sessionId - The session id. + */ + function ConversationTranslationCanceledEventArgs(reason, errorDetails, errorCode, offset, sessionId) { + var _this = _super.call(this, offset, sessionId) || this; + _this.privReason = reason; + _this.privErrorDetails = errorDetails; + _this.privErrorCode = errorCode; + return _this; + } + Object.defineProperty(ConversationTranslationCanceledEventArgs.prototype, "reason", { + /** + * The reason the recognition was canceled. + * @member SpeechRecognitionCanceledEventArgs.prototype.reason + * @function + * @public + * @returns {CancellationReason} Specifies the reason canceled. + */ + get: function () { + return this.privReason; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationTranslationCanceledEventArgs.prototype, "errorCode", { + /** + * The error code in case of an unsuccessful recognition. + * Added in version 1.1.0. + * @return An error code that represents the error reason. + */ + get: function () { + return this.privErrorCode; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationTranslationCanceledEventArgs.prototype, "errorDetails", { + /** + * In case of an unsuccessful recognition, provides details of the occurred error. + * @member SpeechRecognitionCanceledEventArgs.prototype.errorDetails + * @function + * @public + * @returns {string} A String that represents the error details. + */ + get: function () { + return this.privErrorDetails; + }, + enumerable: true, + configurable: true + }); + return ConversationTranslationCanceledEventArgs; +}(Exports_1.RecognitionEventArgs)); +exports.ConversationTranslationCanceledEventArgs = ConversationTranslationCanceledEventArgs; + + + +/***/ }), +/* 116 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +// Multi-device Conversation is a Preview feature. +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 Exports_1 = __webpack_require__(31); +var ConversationTranslationEventArgs = /** @class */ (function (_super) { + __extends(ConversationTranslationEventArgs, _super); + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {ConversationTranslationResult} result - The translation recognition result. + * @param {number} offset - The offset. + * @param {string} sessionId - The session id. + */ + function ConversationTranslationEventArgs(result, offset, sessionId) { + var _this = _super.call(this, offset, sessionId) || this; + _this.privResult = result; + return _this; + } + Object.defineProperty(ConversationTranslationEventArgs.prototype, "result", { + /** + * Specifies the recognition result. + * @returns {ConversationTranslationResult} the recognition result. + */ + get: function () { + return this.privResult; + }, + enumerable: true, + configurable: true + }); + return ConversationTranslationEventArgs; +}(Exports_1.RecognitionEventArgs)); +exports.ConversationTranslationEventArgs = ConversationTranslationEventArgs; + + + +/***/ }), +/* 117 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +// Multi-device Conversation is a Preview feature. +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 TranslationRecognitionResult_1 = __webpack_require__(62); +var ConversationTranslationResult = /** @class */ (function (_super) { + __extends(ConversationTranslationResult, _super); + function ConversationTranslationResult(participantId, translations, originalLanguage, resultId, reason, text, duration, offset, errorDetails, json, properties) { + var _this = _super.call(this, translations, resultId, reason, text, duration, offset, errorDetails, json, properties) || this; + _this.privId = participantId; + _this.privOrigLang = originalLanguage; + return _this; + } + Object.defineProperty(ConversationTranslationResult.prototype, "participantId", { + /** + * The unique identifier for the participant this result is for. + */ + get: function () { + return this.privId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationTranslationResult.prototype, "originalLang", { + /** + * The original language this result was in. + */ + get: function () { + return this.privOrigLang; + }, + enumerable: true, + configurable: true + }); + return ConversationTranslationResult; +}(TranslationRecognitionResult_1.TranslationRecognitionResult)); +exports.ConversationTranslationResult = ConversationTranslationResult; + + + +/***/ }), +/* 118 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +// Multi-device Conversation is a Preview feature. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var Contracts_1 = __webpack_require__(33); +var Exports_2 = __webpack_require__(31); +var Conversation_1 = __webpack_require__(112); +var Exports_3 = __webpack_require__(111); +var SpeechState; +(function (SpeechState) { + SpeechState[SpeechState["Inactive"] = 0] = "Inactive"; + SpeechState[SpeechState["Connecting"] = 1] = "Connecting"; + SpeechState[SpeechState["Connected"] = 2] = "Connected"; +})(SpeechState = exports.SpeechState || (exports.SpeechState = {})); +/*** + * Join, leave or connect to a conversation. + */ +var ConversationTranslator = /** @class */ (function () { + function ConversationTranslator(audioConfig) { + var _this = this; + this.privIsDisposed = false; + this.privIsSpeaking = false; + this.privSpeechState = SpeechState.Inactive; + this.privErrors = Exports_1.ConversationConnectionConfig.restErrors; + this.privPlaceholderKey = "abcdefghijklmnopqrstuvwxyz012345"; + this.privPlaceholderRegion = "westus"; + /** Recognizer callbacks */ + this.onSpeechConnected = function (e) { + _this.privSpeechState = SpeechState.Connected; + }; + this.onSpeechDisconnected = function (e) { + _this.privSpeechState = SpeechState.Inactive; + _this.cancelSpeech(); + }; + this.onSpeechRecognized = function (r, e) { + // TODO: add support for getting recognitions from here if own speech + var _a; + // if there is an error connecting to the conversation service from the speech service the error will be returned in the ErrorDetails field. + if ((_a = e.result) === null || _a === void 0 ? void 0 : _a.errorDetails) { + _this.cancelSpeech(); + // TODO: format the error message contained in 'errorDetails' + _this.fireCancelEvent(e.result.errorDetails); + } + }; + this.onSpeechRecognizing = function (r, e) { + // TODO: add support for getting recognitions from here if own speech + }; + this.onSpeechCanceled = function (r, e) { + if (_this.privSpeechState !== SpeechState.Inactive) { + try { + _this.cancelSpeech(); + } + catch (error) { + _this.privSpeechState = SpeechState.Inactive; + } + } + }; + this.onSpeechSessionStarted = function (r, e) { + _this.privSpeechState = SpeechState.Connected; + }; + this.onSpeechSessionStopped = function (r, e) { + _this.privSpeechState = SpeechState.Inactive; + }; + this.privProperties = new Exports_2.PropertyCollection(); + this.privAudioConfig = audioConfig; + } + Object.defineProperty(ConversationTranslator.prototype, "properties", { + get: function () { + return this.privProperties; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationTranslator.prototype, "speechRecognitionLanguage", { + get: function () { + return this.privSpeechRecognitionLanguage; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationTranslator.prototype, "participants", { + get: function () { + var _a; + return (_a = this.privConversation) === null || _a === void 0 ? void 0 : _a.participants; + }, + enumerable: true, + configurable: true + }); + ConversationTranslator.prototype.joinConversationAsync = function (conversation, nickname, param1, param2, param3) { + var _this = this; + try { + if (typeof conversation === "string") { + Contracts_1.Contracts.throwIfNullOrUndefined(conversation, this.privErrors.invalidArgs.replace("{arg}", "conversation id")); + Contracts_1.Contracts.throwIfNullOrWhitespace(nickname, this.privErrors.invalidArgs.replace("{arg}", "nickname")); + if (!!this.privConversation) { + this.handleError(new Error(this.privErrors.permissionDeniedStart), param3); + } + var lang = param1; + if (lang === undefined || lang === null || lang === "") { + lang = Exports_1.ConversationConnectionConfig.defaultLanguageCode; + } + // create a placecholder config + this.privSpeechTranslationConfig = Exports_2.SpeechTranslationConfig.fromSubscription(this.privPlaceholderKey, this.privPlaceholderRegion); + this.privSpeechTranslationConfig.setProfanity(Exports_2.ProfanityOption.Masked); + this.privSpeechTranslationConfig.addTargetLanguage(lang); + this.privSpeechTranslationConfig.setProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage], lang); + this.privSpeechTranslationConfig.setProperty(Exports_2.PropertyId[Exports_2.PropertyId.ConversationTranslator_Name], nickname); + var endpoint = this.privProperties.getProperty(Exports_2.PropertyId.ConversationTranslator_Host); + if (endpoint) { + this.privSpeechTranslationConfig.setProperty(Exports_2.PropertyId[Exports_2.PropertyId.ConversationTranslator_Host], endpoint); + } + var speechEndpointHost = this.privProperties.getProperty(Exports_2.PropertyId.SpeechServiceConnection_Host); + if (speechEndpointHost) { + this.privSpeechTranslationConfig.setProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_Host], speechEndpointHost); + } + // join the conversation + this.privConversation = new Conversation_1.ConversationImpl(this.privSpeechTranslationConfig); + this.privConversation.conversationTranslator = this; + this.privConversation.joinConversationAsync(conversation, nickname, lang, (function (result) { + if (!result) { + _this.handleError(new Error(_this.privErrors.permissionDeniedConnect), param3); + } + _this.privSpeechTranslationConfig.authorizationToken = result; + // connect to the ws + _this.privConversation.startConversationAsync((function () { + _this.handleCallback(param2, param3); + }), (function (error) { + _this.handleError(error, param3); + })); + }), (function (error) { + _this.handleError(error, param3); + })); + } + else if (typeof conversation === "object") { + Contracts_1.Contracts.throwIfNullOrUndefined(conversation, this.privErrors.invalidArgs.replace("{arg}", "conversation id")); + Contracts_1.Contracts.throwIfNullOrWhitespace(nickname, this.privErrors.invalidArgs.replace("{arg}", "nickname")); + // save the nickname + this.privProperties.setProperty(Exports_2.PropertyId.ConversationTranslator_Name, nickname); + // ref the conversation object + this.privConversation = conversation; + // ref the conversation translator object + this.privConversation.conversationTranslator = this; + Contracts_1.Contracts.throwIfNullOrUndefined(this.privConversation, this.privErrors.permissionDeniedConnect); + Contracts_1.Contracts.throwIfNullOrUndefined(this.privConversation.room.token, this.privErrors.permissionDeniedConnect); + this.privSpeechTranslationConfig = conversation.config; + this.handleCallback(param1, param2); + } + else { + this.handleError(new Error(this.privErrors.invalidArgs.replace("{arg}", "invalid conversation type")), param2); + } + } + catch (error) { + this.handleError(error, typeof param1 === "string" ? param3 : param2); + } + }; + /** + * Leave the conversation + * @param cb + * @param err + */ + ConversationTranslator.prototype.leaveConversationAsync = function (cb, err) { + var _this = this; + try { + // stop the speech websocket + this.cancelSpeech(); + // stop the websocket + this.privConversation.endConversationAsync((function () { + // https delete request + _this.privConversation.deleteConversationAsync((function () { + _this.handleCallback(cb, err); + _this.dispose(); + }), (function (error) { + _this.handleError(error, err); + })); + }), (function (error) { + _this.handleError(error, err); + })); + } + catch (error) { + this.handleError(error, err); + } + }; + /** + * Send a text message + * @param message + * @param cb + * @param err + */ + ConversationTranslator.prototype.sendTextMessageAsync = function (message, cb, err) { + var _a; + try { + Contracts_1.Contracts.throwIfNullOrUndefined(this.privConversation, this.privErrors.permissionDeniedSend); + Contracts_1.Contracts.throwIfNullOrWhitespace(message, this.privErrors.invalidArgs.replace("{arg}", message)); + (_a = this.privConversation) === null || _a === void 0 ? void 0 : _a.sendTextMessageAsync(message, cb, err); + } + catch (error) { + this.handleError(error, err); + } + }; + /** + * Start speaking + * @param cb + * @param err + */ + ConversationTranslator.prototype.startTranscribingAsync = function (cb, err) { + var _this = this; + try { + Contracts_1.Contracts.throwIfNullOrUndefined(this.privConversation, this.privErrors.permissionDeniedSend); + Contracts_1.Contracts.throwIfNullOrUndefined(this.privConversation.room.token, this.privErrors.permissionDeniedConnect); + if (!this.canSpeak) { + this.handleError(new Error(this.privErrors.permissionDeniedSend), err); + } + if (this.privTranslationRecognizer === undefined) { + this.connectTranslatorRecognizer((function () { + _this.startContinuousRecognition((function () { + _this.privIsSpeaking = true; + _this.handleCallback(cb, err); + }), (function (error) { + _this.privIsSpeaking = false; + // this.fireCancelEvent(error); + _this.cancelSpeech(); + _this.handleError(error, err); + })); + }), (function (error) { + _this.handleError(error, err); + })); + } + else { + this.startContinuousRecognition((function () { + _this.privIsSpeaking = true; + _this.handleCallback(cb, err); + }), (function (error) { + _this.privIsSpeaking = false; + // this.fireCancelEvent(error); + _this.cancelSpeech(); + _this.handleError(error, err); + })); + } + } + catch (error) { + this.handleError(error, err); + this.cancelSpeech(); + } + }; + /** + * Stop speaking + * @param cb + * @param err + */ + ConversationTranslator.prototype.stopTranscribingAsync = function (cb, err) { + var _this = this; + var _a; + try { + if (!this.privIsSpeaking) { + // stop speech + this.cancelSpeech(); + this.handleCallback(cb, err); + return; + } + // stop the recognition but leave the websocket open + this.privIsSpeaking = false; + (_a = this.privTranslationRecognizer) === null || _a === void 0 ? void 0 : _a.stopContinuousRecognitionAsync(function () { + _this.handleCallback(cb, err); + }, function (error) { + _this.handleError(error, err); + _this.cancelSpeech(); + }); + } + catch (error) { + this.handleError(error, err); + this.cancelSpeech(); + } + }; + ConversationTranslator.prototype.isDisposed = function () { + return this.privIsDisposed; + }; + ConversationTranslator.prototype.dispose = function (reason) { + var _a, _b; + if (this.isDisposed && !this.privIsSpeaking) { + return; + } + this.cancelSpeech(); + this.privIsDisposed = true; + (_a = this.privSpeechTranslationConfig) === null || _a === void 0 ? void 0 : _a.close(); + this.privSpeechRecognitionLanguage = undefined; + this.privProperties = undefined; + this.privAudioConfig = undefined; + this.privSpeechTranslationConfig = undefined; + (_b = this.privConversation) === null || _b === void 0 ? void 0 : _b.dispose(); + this.privConversation = undefined; + }; + /** + * Connect to the speech translation recognizer. + * Currently there is no language validation performed before sending the SpeechLanguage code to the service. + * If it's an invalid language the raw error will be: 'Error during WebSocket handshake: Unexpected response code: 400' + * e.g. pass in 'fr' instead of 'fr-FR', or a text-only language 'cy' + * @param cb + * @param err + */ + ConversationTranslator.prototype.connectTranslatorRecognizer = function (cb, err) { + try { + if (this.privAudioConfig === undefined) { + this.privAudioConfig = Exports_2.AudioConfig.fromDefaultMicrophoneInput(); + } + // clear the temp subscription key if it's a participant joining + if (this.privSpeechTranslationConfig.getProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_Key]) + === this.privPlaceholderKey) { + this.privSpeechTranslationConfig.setProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_Key], ""); + } + // TODO + var token = encodeURIComponent(this.privConversation.room.token); + var endpointHost = this.privSpeechTranslationConfig.getProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_Host], Exports_1.ConversationConnectionConfig.speechHost); + endpointHost = endpointHost.replace("{region}", this.privConversation.room.cognitiveSpeechRegion); + var url = "wss://" + endpointHost + Exports_1.ConversationConnectionConfig.speechPath + "?" + Exports_1.ConversationConnectionConfig.configParams.token + "=" + token; + this.privSpeechTranslationConfig.setProperty(Exports_2.PropertyId[Exports_2.PropertyId.SpeechServiceConnection_Endpoint], url); + this.privTranslationRecognizer = new Exports_2.TranslationRecognizer(this.privSpeechTranslationConfig, this.privAudioConfig); + this.privTranslationRecognizerConnection = Exports_2.Connection.fromRecognizer(this.privTranslationRecognizer); + this.privTranslationRecognizerConnection.connected = this.onSpeechConnected; + this.privTranslationRecognizerConnection.disconnected = this.onSpeechDisconnected; + this.privTranslationRecognizer.recognized = this.onSpeechRecognized; + this.privTranslationRecognizer.recognizing = this.onSpeechRecognizing; + this.privTranslationRecognizer.canceled = this.onSpeechCanceled; + this.privTranslationRecognizer.sessionStarted = this.onSpeechSessionStarted; + this.privTranslationRecognizer.sessionStopped = this.onSpeechSessionStopped; + this.handleCallback(cb, err); + } + catch (error) { + this.handleError(error, err); + this.cancelSpeech(); + // this.fireCancelEvent(error); ? + } + }; + /** + * Handle the start speaking request + * @param cb + * @param err + */ + ConversationTranslator.prototype.startContinuousRecognition = function (cb, err) { + this.privTranslationRecognizer.startContinuousRecognitionAsync(cb, err); + }; + /** + * Fire a cancel event + * @param error + */ + ConversationTranslator.prototype.fireCancelEvent = function (error) { + var _a, _b, _c, _d, _e, _f, _g; + try { + if (!!this.canceled) { + var cancelEvent = new Exports_3.ConversationTranslationCanceledEventArgs((_b = (_a = error) === null || _a === void 0 ? void 0 : _a.reason, (_b !== null && _b !== void 0 ? _b : Exports_2.CancellationReason.Error)), (_d = (_c = error) === null || _c === void 0 ? void 0 : _c.errorDetails, (_d !== null && _d !== void 0 ? _d : error)), (_f = (_e = error) === null || _e === void 0 ? void 0 : _e.errorCode, (_f !== null && _f !== void 0 ? _f : Exports_2.CancellationErrorCode.RuntimeError)), undefined, (_g = error) === null || _g === void 0 ? void 0 : _g.sessionId); + this.canceled(this, cancelEvent); + } + } + catch (e) { + // + } + }; + /** + * Cancel the speech websocket + */ + ConversationTranslator.prototype.cancelSpeech = function () { + var _a, _b; + try { + this.privIsSpeaking = false; + (_a = this.privTranslationRecognizer) === null || _a === void 0 ? void 0 : _a.stopContinuousRecognitionAsync(); + (_b = this.privTranslationRecognizerConnection) === null || _b === void 0 ? void 0 : _b.closeConnection(); + this.privTranslationRecognizerConnection = undefined; + this.privTranslationRecognizer = undefined; + this.privSpeechState = SpeechState.Inactive; + } + catch (e) { + // ignore the error + } + }; + Object.defineProperty(ConversationTranslator.prototype, "canSpeak", { + get: function () { + // is there a Conversation websocket available + if (!this.privConversation.isConnected) { + return false; + } + // is the user already speaking + if (this.privIsSpeaking || this.privSpeechState === SpeechState.Connected || this.privSpeechState === SpeechState.Connecting) { + return false; + } + // is the user muted + if (this.privConversation.isMutedByHost) { + return false; + } + return true; + }, + enumerable: true, + configurable: true + }); + ConversationTranslator.prototype.handleCallback = function (cb, err) { + if (!!cb) { + try { + cb(); + } + catch (e) { + if (!!err) { + err(e); + } + } + cb = undefined; + } + }; + ConversationTranslator.prototype.handleError = function (error, err) { + if (!!err) { + if (error instanceof Error) { + var typedError = error; + err(typedError.name + ": " + typedError.message); + } + else { + err(error); + } + } + }; + return ConversationTranslator; +}()); +exports.ConversationTranslator = ConversationTranslator; + + + +/***/ }), +/* 119 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +// Multi-device Conversation is a Preview feature. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(31); +var User = /** @class */ (function () { + function User(userId) { + this.privUserId = userId; + } + Object.defineProperty(User.prototype, "userId", { + get: function () { + return this.privUserId; + }, + enumerable: true, + configurable: true + }); + return User; +}()); +exports.User = User; +// tslint:disable-next-line: max-classes-per-file +var Participant = /** @class */ (function () { + function Participant(id, avatar, displayName, isHost, isMuted, isUsingTts, preferredLanguage) { + this.privId = id; + this.privAvatar = avatar; + this.privDisplayName = displayName; + this.privIsHost = isHost; + this.privIsMuted = isMuted; + this.privIsUsingTts = isUsingTts; + this.privPreferredLanguage = preferredLanguage; + this.privPoperties = new Exports_1.PropertyCollection(); + } + Object.defineProperty(Participant.prototype, "avatar", { + get: function () { + return this.privAvatar; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Participant.prototype, "displayName", { + get: function () { + return this.privDisplayName; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Participant.prototype, "id", { + get: function () { + return this.privId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Participant.prototype, "preferredLanguage", { + get: function () { + return this.privPreferredLanguage; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Participant.prototype, "isHost", { + get: function () { + return this.privIsHost; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Participant.prototype, "isMuted", { + get: function () { + return this.privIsMuted; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Participant.prototype, "isUsingTts", { + get: function () { + return this.privIsUsingTts; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Participant.prototype, "properties", { + get: function () { + return this.privPoperties; + }, + enumerable: true, + configurable: true + }); + return Participant; +}()); +exports.Participant = Participant; + + + +/***/ }), +/* 120 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +// Multi-device Conversation is a Preview feature. +Object.defineProperty(exports, "__esModule", { value: true }); +var ParticipantChangedReason; +(function (ParticipantChangedReason) { + /** Participant has joined the conversation. */ + ParticipantChangedReason[ParticipantChangedReason["JoinedConversation"] = 0] = "JoinedConversation"; + /** Participant has left the conversation. This could be voluntary, or involuntary + * (e.g. they are experiencing networking issues). + */ + ParticipantChangedReason[ParticipantChangedReason["LeftConversation"] = 1] = "LeftConversation"; + /** The participants' state has changed (e.g. they became muted, changed their nickname). */ + ParticipantChangedReason[ParticipantChangedReason["Updated"] = 2] = "Updated"; +})(ParticipantChangedReason = exports.ParticipantChangedReason || (exports.ParticipantChangedReason = {})); + + + +/***/ }), +/* 121 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var Exports_2 = __webpack_require__(4); +var AudioFileWriter_1 = __webpack_require__(34); +var AudioOutputFormat_1 = __webpack_require__(44); +var AudioOutputStream_1 = __webpack_require__(43); +var Contracts_1 = __webpack_require__(33); +var Exports_3 = __webpack_require__(31); +/** + * Defines the class SpeechSynthesizer for text to speech. + * Added in version 1.11.0 + * @class SpeechSynthesizer + */ +var SpeechSynthesizer = /** @class */ (function () { + /** + * SpeechSynthesizer constructor. + * @constructor + * @param {SpeechConfig} speechConfig - An set of initial properties for this synthesizer + * @param {AudioConfig} audioConfig - An optional audio configuration associated with the synthesizer + */ + function SpeechSynthesizer(speechConfig, audioConfig) { + var speechConfigImpl = speechConfig; + Contracts_1.Contracts.throwIfNull(speechConfigImpl, "speechConfig"); + if (audioConfig !== null) { + this.audioConfig = (audioConfig !== undefined) ? audioConfig : Exports_3.AudioConfig.fromDefaultSpeakerOutput(); + } + this.privProperties = speechConfigImpl.properties.clone(); + this.privDisposed = false; + this.privSynthesizing = false; + this.privConnectionFactory = new Exports_1.SpeechSynthesisConnectionFactory(); + this.synthesisRequestQueue = new Exports_2.Queue(); + this.implCommonSynthesizeSetup(); + } + Object.defineProperty(SpeechSynthesizer.prototype, "authorizationToken", { + /** + * Gets the authorization token used to communicate with the service. + * @member SpeechSynthesizer.prototype.authorizationToken + * @function + * @public + * @returns {string} Authorization token. + */ + get: function () { + return this.properties.getProperty(Exports_3.PropertyId.SpeechServiceAuthorization_Token); + }, + /** + * Gets/Sets the authorization token used to communicate with the service. + * @member SpeechSynthesizer.prototype.authorizationToken + * @function + * @public + * @param {string} token - Authorization token. + */ + set: function (token) { + Contracts_1.Contracts.throwIfNullOrWhitespace(token, "token"); + this.properties.setProperty(Exports_3.PropertyId.SpeechServiceAuthorization_Token, token); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechSynthesizer.prototype, "properties", { + /** + * The collection of properties and their values defined for this SpeechSynthesizer. + * @member SpeechSynthesizer.prototype.properties + * @function + * @public + * @returns {PropertyCollection} The collection of properties and their values defined for this SpeechSynthesizer. + */ + get: function () { + return this.privProperties; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechSynthesizer.prototype, "autoDetectSourceLanguage", { + /** + * Indicates if auto detect source language is enabled + * @member SpeechSynthesizer.prototype.properties + * @function + * @public + * @returns {boolean} if auto detect source language is enabled + */ + get: function () { + return this.properties.getProperty(Exports_3.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages) === Exports_1.AutoDetectSourceLanguagesOpenRangeOptionName; + }, + enumerable: true, + configurable: true + }); + /** + * SpeechSynthesizer constructor. + * @constructor + * @param {SpeechConfig} speechConfig - an set of initial properties for this synthesizer + * @param {AutoDetectSourceLanguageConfig} autoDetectSourceLanguageConfig - An source language detection configuration associated with the synthesizer + * @param {AudioConfig} audioConfig - An optional audio configuration associated with the synthesizer + */ + SpeechSynthesizer.FromConfig = function (speechConfig, autoDetectSourceLanguageConfig, audioConfig) { + var speechConfigImpl = speechConfig; + autoDetectSourceLanguageConfig.properties.mergeTo(speechConfigImpl.properties); + return new SpeechSynthesizer(speechConfig, audioConfig); + }; + SpeechSynthesizer.prototype.buildSsml = function (text) { + var _a; + var languageToDefaultVoice = (_a = {}, + _a["ar-EG"] = "Microsoft Server Speech Text to Speech Voice (ar-EG, Hoda)", + _a["ar-SA"] = "Microsoft Server Speech Text to Speech Voice (ar-SA, Naayf)", + _a["bg-BG"] = "Microsoft Server Speech Text to Speech Voice (bg-BG, Ivan)", + _a["ca-ES"] = "Microsoft Server Speech Text to Speech Voice (ca-ES, HerenaRUS)", + _a["cs-CZ"] = "Microsoft Server Speech Text to Speech Voice (cs-CZ, Jakub)", + _a["da-DK"] = "Microsoft Server Speech Text to Speech Voice (da-DK, HelleRUS)", + _a["de-AT"] = "Microsoft Server Speech Text to Speech Voice (de-AT, Michael)", + _a["de-CH"] = "Microsoft Server Speech Text to Speech Voice (de-CH, Karsten)", + _a["de-DE"] = "Microsoft Server Speech Text to Speech Voice (de-DE, HeddaRUS)", + _a["el-GR"] = "Microsoft Server Speech Text to Speech Voice (el-GR, Stefanos)", + _a["en-AU"] = "Microsoft Server Speech Text to Speech Voice (en-AU, HayleyRUS)", + _a["en-CA"] = "Microsoft Server Speech Text to Speech Voice (en-CA, HeatherRUS)", + _a["en-GB"] = "Microsoft Server Speech Text to Speech Voice (en-GB, HazelRUS)", + _a["en-IE"] = "Microsoft Server Speech Text to Speech Voice (en-IE, Sean)", + _a["en-IN"] = "Microsoft Server Speech Text to Speech Voice (en-IN, PriyaRUS)", + _a["en-US"] = "Microsoft Server Speech Text to Speech Voice (en-US, AriaRUS)", + _a["es-ES"] = "Microsoft Server Speech Text to Speech Voice (es-ES, HelenaRUS)", + _a["es-MX"] = "Microsoft Server Speech Text to Speech Voice (es-MX, HildaRUS)", + _a["fi-FI"] = "Microsoft Server Speech Text to Speech Voice (fi-FI, HeidiRUS)", + _a["fr-CA"] = "Microsoft Server Speech Text to Speech Voice (fr-CA, HarmonieRUS)", + _a["fr-CH"] = "Microsoft Server Speech Text to Speech Voice (fr-CH, Guillaume)", + _a["fr-FR"] = "Microsoft Server Speech Text to Speech Voice (fr-FR, HortenseRUS)", + _a["he-IL"] = "Microsoft Server Speech Text to Speech Voice (he-IL, Asaf)", + _a["hi-IN"] = "Microsoft Server Speech Text to Speech Voice (hi-IN, Kalpana)", + _a["hr-HR"] = "Microsoft Server Speech Text to Speech Voice (hr-HR, Matej)", + _a["hu-HU"] = "Microsoft Server Speech Text to Speech Voice (hu-HU, Szabolcs)", + _a["id-ID"] = "Microsoft Server Speech Text to Speech Voice (id-ID, Andika)", + _a["it-IT"] = "Microsoft Server Speech Text to Speech Voice (it-IT, LuciaRUS)", + _a["ja-JP"] = "Microsoft Server Speech Text to Speech Voice (ja-JP, HarukaRUS)", + _a["ko-KR"] = "Microsoft Server Speech Text to Speech Voice (ko-KR, HeamiRUS)", + _a["ms-MY"] = "Microsoft Server Speech Text to Speech Voice (ms-MY, Rizwan)", + _a["nb-NO"] = "Microsoft Server Speech Text to Speech Voice (nb-NO, HuldaRUS)", + _a["nl-NL"] = "Microsoft Server Speech Text to Speech Voice (nl-NL, HannaRUS)", + _a["pl-PL"] = "Microsoft Server Speech Text to Speech Voice (pl-PL, PaulinaRUS)", + _a["pt-BR"] = "Microsoft Server Speech Text to Speech Voice (pt-BR, HeloisaRUS)", + _a["pt-PT"] = "Microsoft Server Speech Text to Speech Voice (pt-PT, HeliaRUS)", + _a["ro-RO"] = "Microsoft Server Speech Text to Speech Voice (ro-RO, Andrei)", + _a["ru-RU"] = "Microsoft Server Speech Text to Speech Voice (ru-RU, EkaterinaRUS)", + _a["sk-SK"] = "Microsoft Server Speech Text to Speech Voice (sk-SK, Filip)", + _a["sl-SI"] = "Microsoft Server Speech Text to Speech Voice (sl-SI, Lado)", + _a["sv-SE"] = "Microsoft Server Speech Text to Speech Voice (sv-SE, HedvigRUS)", + _a["ta-IN"] = "Microsoft Server Speech Text to Speech Voice (ta-IN, Valluvar)", + _a["te-IN"] = "Microsoft Server Speech Text to Speech Voice (te-IN, Chitra)", + _a["th-TH"] = "Microsoft Server Speech Text to Speech Voice (th-TH, Pattara)", + _a["tr-TR"] = "Microsoft Server Speech Text to Speech Voice (tr-TR, SedaRUS)", + _a["vi-VN"] = "Microsoft Server Speech Text to Speech Voice (vi-VN, An)", + _a["zh-CN"] = "Microsoft Server Speech Text to Speech Voice (zh-CN, HuihuiRUS)", + _a["zh-HK"] = "Microsoft Server Speech Text to Speech Voice (zh-HK, TracyRUS)", + _a["zh-TW"] = "Microsoft Server Speech Text to Speech Voice (zh-TW, HanHanRUS)", + _a); + var language = this.properties.getProperty(Exports_3.PropertyId.SpeechServiceConnection_SynthLanguage, "en-US"); + var voice = this.properties.getProperty(Exports_3.PropertyId.SpeechServiceConnection_SynthVoice, ""); + var ssml = SpeechSynthesizer.XMLEncode(text); + if (this.autoDetectSourceLanguage) { + language = "en-US"; + } + else { + voice = voice || languageToDefaultVoice[language]; + } + if (voice) { + ssml = "" + ssml + ""; + } + ssml = "" + ssml + ""; + return ssml; + }; + /** + * Executes speech synthesis on plain text. + * The task returns the synthesis result. + * @member SpeechSynthesizer.prototype.speakTextAsync + * @function + * @public + * @param text - Text to be synthesized. + * @param cb - Callback that received the SpeechSynthesisResult. + * @param err - Callback invoked in case of an error. + * @param stream - AudioOutputStream to receive the synthesized audio. + */ + SpeechSynthesizer.prototype.speakTextAsync = function (text, cb, err, stream) { + this.speakImpl(text, false, cb, err, stream); + }; + /** + * Executes speech synthesis on SSML. + * The task returns the synthesis result. + * @member SpeechSynthesizer.prototype.speakSsmlAsync + * @function + * @public + * @param ssml - SSML to be synthesized. + * @param cb - Callback that received the SpeechSynthesisResult. + * @param err - Callback invoked in case of an error. + * @param stream - AudioOutputStream to receive the synthesized audio. + */ + SpeechSynthesizer.prototype.speakSsmlAsync = function (ssml, cb, err, stream) { + this.speakImpl(ssml, true, cb, err, stream); + }; + /** + * Dispose of associated resources. + * @member SpeechSynthesizer.prototype.close + * @function + * @public + */ + SpeechSynthesizer.prototype.close = function () { + Contracts_1.Contracts.throwIfDisposed(this.privDisposed); + this.dispose(true); + }; + Object.defineProperty(SpeechSynthesizer.prototype, "internalData", { + /** + * @Internal + * Do not use externally, object returned will change without warning or notice. + */ + get: function () { + return this.privAdapter; + }, + enumerable: true, + configurable: true + }); + /** + * This method performs cleanup of resources. + * The Boolean parameter disposing indicates whether the method is called + * from Dispose (if disposing is true) or from the finalizer (if disposing is false). + * Derived classes should override this method to dispose resource if needed. + * @member SpeechSynthesizer.prototype.dispose + * @function + * @public + * @param {boolean} disposing - Flag to request disposal. + */ + SpeechSynthesizer.prototype.dispose = function (disposing) { + if (this.privDisposed) { + return; + } + if (disposing) { + if (this.privAdapter) { + this.privAdapter.dispose(); + } + } + this.privDisposed = true; + }; + // + // ################################################################################################################ + // IMPLEMENTATION. + // Move to independent class + // ################################################################################################################ + // + SpeechSynthesizer.prototype.createSynthesizerConfig = function (speechConfig) { + return new Exports_1.SynthesizerConfig(speechConfig, this.privProperties); + }; + // Creates the synthesis adapter + SpeechSynthesizer.prototype.createSynthesisAdapter = function (authentication, connectionFactory, audioConfig, synthesizerConfig) { + return new Exports_1.SynthesisAdapterBase(authentication, connectionFactory, synthesizerConfig, this, this.audioConfig); + }; + SpeechSynthesizer.prototype.implCommonSynthesizeSetup = function () { + var _this = this; + var osPlatform = (typeof window !== "undefined") ? "Browser" : "Node"; + var osName = "unknown"; + var osVersion = "unknown"; + if (typeof navigator !== "undefined") { + osPlatform = osPlatform + "/" + navigator.platform; + osName = navigator.userAgent; + osVersion = navigator.appVersion; + } + var synthesizerConfig = this.createSynthesizerConfig(new Exports_1.SpeechServiceConfig(new Exports_1.Context(new Exports_1.OS(osPlatform, osName, osVersion)))); + var subscriptionKey = this.privProperties.getProperty(Exports_3.PropertyId.SpeechServiceConnection_Key, undefined); + var authentication = (subscriptionKey && subscriptionKey !== "") ? + new Exports_1.CognitiveSubscriptionKeyAuthentication(subscriptionKey) : + new Exports_1.CognitiveTokenAuthentication(function (authFetchEventId) { + var authorizationToken = _this.privProperties.getProperty(Exports_3.PropertyId.SpeechServiceAuthorization_Token, undefined); + return Exports_2.PromiseHelper.fromResult(authorizationToken); + }, function (authFetchEventId) { + var authorizationToken = _this.privProperties.getProperty(Exports_3.PropertyId.SpeechServiceAuthorization_Token, undefined); + return Exports_2.PromiseHelper.fromResult(authorizationToken); + }); + this.privAdapter = this.createSynthesisAdapter(authentication, this.privConnectionFactory, this.audioConfig, synthesizerConfig); + this.privAdapter.audioOutputFormat = AudioOutputFormat_1.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(Exports_3.SpeechSynthesisOutputFormat[this.properties.getProperty(Exports_3.PropertyId.SpeechServiceConnection_SynthOutputFormat, undefined)]); + }; + SpeechSynthesizer.prototype.speakImpl = function (text, IsSsml, cb, err, dataStream) { + var _this = this; + try { + Contracts_1.Contracts.throwIfDisposed(this.privDisposed); + var requestId = Exports_2.createNoDashGuid(); + var audioDestination = void 0; + if (dataStream instanceof Exports_3.PushAudioOutputStreamCallback) { + audioDestination = new AudioOutputStream_1.PushAudioOutputStreamImpl(dataStream); + } + else if (dataStream instanceof Exports_3.PullAudioOutputStream) { + audioDestination = dataStream; + } + else if (dataStream !== undefined) { + audioDestination = new AudioFileWriter_1.AudioFileWriter(dataStream); + } + else { + audioDestination = undefined; + } + this.synthesisRequestQueue.enqueue(new SynthesisRequest(requestId, text, IsSsml, function (e) { + _this.privSynthesizing = false; + if (!!cb) { + try { + cb(e); + } + catch (e) { + if (!!err) { + err(e); + } + } + } + cb = undefined; + _this.adapterSpeak(); + }, function (e) { + if (!!err) { + err(e); + } + }, audioDestination)); + this.adapterSpeak(); + } + catch (error) { + if (!!err) { + if (error instanceof Error) { + var typedError = error; + err(typedError.name + ": " + typedError.message); + } + else { + err(error); + } + } + // Destroy the synthesizer. + this.dispose(true); + } + }; + SpeechSynthesizer.prototype.adapterSpeak = function () { + var _this = this; + if (!this.privDisposed && !this.privSynthesizing) { + this.privSynthesizing = true; + return this.synthesisRequestQueue.dequeue(). + onSuccessContinueWithPromise(function (request) { + return _this.privAdapter.Speak(request.text, request.isSSML, request.requestId, request.cb, request.err, request.dataStream); + }); + } + return Exports_2.PromiseHelper.fromResult(true); + }; + SpeechSynthesizer.XMLEncode = function (text) { + return text.replace(/&/g, "&") + .replace(//g, ">") + .replace(/"/g, """) + .replace(/'/g, "'"); + }; + return SpeechSynthesizer; +}()); +exports.SpeechSynthesizer = SpeechSynthesizer; +// tslint:disable-next-line:max-classes-per-file +var SynthesisRequest = /** @class */ (function () { + function SynthesisRequest(requestId, text, isSSML, cb, err, dataStream) { + this.requestId = requestId; + this.text = text; + this.isSSML = isSSML; + this.cb = cb; + this.err = err; + this.dataStream = dataStream; + } + return SynthesisRequest; +}()); +exports.SynthesisRequest = SynthesisRequest; + + + +/***/ }), +/* 122 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Defines result of speech synthesis. + * @class SpeechSynthesisResult + * Added in version 1.11.0 + */ +var SpeechSynthesisResult = /** @class */ (function () { + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {string} resultId - The result id. + * @param {ResultReason} reason - The reason. + * @param {number} audioData - The offset into the stream. + * @param {string} errorDetails - Error details, if provided. + * @param {PropertyCollection} properties - Additional properties, if provided. + */ + function SpeechSynthesisResult(resultId, reason, audioData, errorDetails, properties) { + this.privResultId = resultId; + this.privReason = reason; + this.privAudioData = audioData; + this.privErrorDetails = errorDetails; + this.privProperties = properties; + } + Object.defineProperty(SpeechSynthesisResult.prototype, "resultId", { + /** + * Specifies the result identifier. + * @member SpeechSynthesisResult.prototype.resultId + * @function + * @public + * @returns {string} Specifies the result identifier. + */ + get: function () { + return this.privResultId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechSynthesisResult.prototype, "reason", { + /** + * Specifies status of the result. + * @member SpeechSynthesisResult.prototype.reason + * @function + * @public + * @returns {ResultReason} Specifies status of the result. + */ + get: function () { + return this.privReason; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechSynthesisResult.prototype, "audioData", { + /** + * The synthesized audio data + * @member SpeechSynthesisResult.prototype.audioData + * @function + * @public + * @returns {ArrayBuffer} The synthesized audio data. + */ + get: function () { + return this.privAudioData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechSynthesisResult.prototype, "errorDetails", { + /** + * In case of an unsuccessful synthesis, provides details of the occurred error. + * @member SpeechSynthesisResult.prototype.errorDetails + * @function + * @public + * @returns {string} a brief description of an error. + */ + get: function () { + return this.privErrorDetails; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechSynthesisResult.prototype, "properties", { + /** + * The set of properties exposed in the result. + * @member SpeechSynthesisResult.prototype.properties + * @function + * @public + * @returns {PropertyCollection} The set of properties exposed in the result. + */ + get: function () { + return this.privProperties; + }, + enumerable: true, + configurable: true + }); + return SpeechSynthesisResult; +}()); +exports.SpeechSynthesisResult = SpeechSynthesisResult; + + + +/***/ }), +/* 123 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Defines contents of speech synthesis events. + * @class SpeechSynthesisEventArgs + * Added in version 1.11.0 + */ +var SpeechSynthesisEventArgs = /** @class */ (function () { + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {SpeechSynthesisResult} result - The speech synthesis result. + */ + function SpeechSynthesisEventArgs(result) { + this.privResult = result; + } + Object.defineProperty(SpeechSynthesisEventArgs.prototype, "result", { + /** + * Specifies the synthesis result. + * @member SpeechSynthesisEventArgs.prototype.result + * @function + * @public + * @returns {SpeechSynthesisResult} the synthesis result. + */ + get: function () { + return this.privResult; + }, + enumerable: true, + configurable: true + }); + return SpeechSynthesisEventArgs; +}()); +exports.SpeechSynthesisEventArgs = SpeechSynthesisEventArgs; + + + +/***/ }), +/* 124 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Defines contents of speech synthesis word boundary event. + * @class SpeechSynthesisWordBoundaryEventArgs + * Added in version 1.11.0 + */ +var SpeechSynthesisWordBoundaryEventArgs = /** @class */ (function () { + /** + * Creates and initializes an instance of this class. + * @constructor + * @param {number} audioOffset - The audio offset. + * @param {string} text - The text. + * @param {number} wordLength - The length of the word. + * @param {number} textOffset - The text offset. + */ + function SpeechSynthesisWordBoundaryEventArgs(audioOffset, text, wordLength, textOffset) { + this.privAduioOffset = audioOffset; + this.privText = text; + this.privWordLength = wordLength; + this.privTextOffset = textOffset; + } + Object.defineProperty(SpeechSynthesisWordBoundaryEventArgs.prototype, "audioOffset", { + /** + * Specifies the audio offset. + * @member SpeechSynthesisWordBoundaryEventArgs.prototype.audioOffset + * @function + * @public + * @returns {number} the audio offset. + */ + get: function () { + return this.privAduioOffset; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechSynthesisWordBoundaryEventArgs.prototype, "text", { + /** + * Specifies the text of the word boundary event. + * @member SpeechSynthesisWordBoundaryEventArgs.prototype.text + * @function + * @public + * @returns {string} the text. + */ + get: function () { + return this.privText; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechSynthesisWordBoundaryEventArgs.prototype, "wordLength", { + /** + * Specifies the word length + * @member SpeechSynthesisWordBoundaryEventArgs.prototype.wordLength + * @function + * @public + * @returns {number} the word length + */ + get: function () { + return this.privWordLength; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechSynthesisWordBoundaryEventArgs.prototype, "textOffset", { + /** + * Specifies the text offset. + * @member SpeechSynthesisWordBoundaryEventArgs.prototype.textOffset + * @function + * @public + * @returns {number} the text offset. + */ + get: function () { + return this.privTextOffset; + }, + enumerable: true, + configurable: true + }); + return SpeechSynthesisWordBoundaryEventArgs; +}()); +exports.SpeechSynthesisWordBoundaryEventArgs = SpeechSynthesisWordBoundaryEventArgs; + + + +/***/ }), +/* 125 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +var _a; +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var Exports_2 = __webpack_require__(4); +var AudioOutputFormat_1 = __webpack_require__(44); +var AudioOutputStream_1 = __webpack_require__(43); +var MediaDurationPlaceholderSeconds = 60 * 30; +var AudioFormatToMimeType = (_a = {}, + _a[AudioOutputFormat_1.AudioFormatTag.PCM] = "audio/wav", + _a[AudioOutputFormat_1.AudioFormatTag.MP3] = "audio/mpeg", + _a[AudioOutputFormat_1.AudioFormatTag.Opus] = "audio/ogg", + _a); +/** + * Represents the speaker playback audio destination, which only works in browser. + * Note: the SDK will try to use Media Source Extensions to play audio. + * Mp3 format has better supports on Microsoft Edge, Chrome and Safari (desktop), so, it's better to specify mp3 format for playback. + * @class SpeakerAudioDestination + * Updated in version 1.12.1 + */ +var SpeakerAudioDestination = /** @class */ (function () { + function SpeakerAudioDestination(audioDestinationId) { + this.privPlaybackStarted = false; + this.privAppendingToBuffer = false; + this.privMediaSourceOpened = false; + this.privBytesReceived = 0; + this.privId = audioDestinationId ? audioDestinationId : Exports_2.createNoDashGuid(); + this.privIsPaused = false; + this.privIsClosed = false; + } + SpeakerAudioDestination.prototype.id = function () { + return this.privId; + }; + SpeakerAudioDestination.prototype.write = function (buffer) { + if (this.privAudioBuffer !== undefined) { + this.privAudioBuffer.push(buffer); + this.updateSourceBuffer(); + } + else if (this.privAudioOutputStream !== undefined) { + this.privAudioOutputStream.write(buffer); + this.privBytesReceived += buffer.byteLength; + } + }; + SpeakerAudioDestination.prototype.close = function () { + this.privIsClosed = true; + if (this.privSourceBuffer !== undefined) { + this.handleSourceBufferUpdateEnd(); + } + else if (this.privAudioOutputStream !== undefined) { + var receivedAudio = new ArrayBuffer(this.privBytesReceived); + this.privAudioOutputStream.read(receivedAudio); + if (this.privFormat.hasHeader) { + receivedAudio = Exports_1.SynthesisAdapterBase.addHeader(receivedAudio, this.privFormat); + } + var audioBlob = new Blob([receivedAudio], { type: AudioFormatToMimeType[this.privFormat.formatTag] }); + this.privAudio.src = window.URL.createObjectURL(audioBlob); + this.notifyPlayback(); + } + }; + Object.defineProperty(SpeakerAudioDestination.prototype, "format", { + set: function (format) { + var _this = this; + if (typeof (AudioContext) !== "undefined" || typeof (window.webkitAudioContext) !== "undefined") { + this.privFormat = format; + var mimeType_1 = AudioFormatToMimeType[this.privFormat.formatTag]; + if (mimeType_1 === undefined) { + // tslint:disable-next-line:no-console + console.warn("Unknown mimeType for format " + AudioOutputFormat_1.AudioFormatTag[this.privFormat.formatTag] + "."); + } + else if (typeof (MediaSource) !== "undefined" && MediaSource.isTypeSupported(mimeType_1)) { + this.privAudio = new Audio(); + this.privAudioBuffer = []; + this.privMediaSource = new MediaSource(); + this.privAudio.src = URL.createObjectURL(this.privMediaSource); + this.privAudio.load(); + this.privMediaSource.onsourceopen = function (event) { + _this.privMediaSourceOpened = true; + _this.privMediaSource.duration = MediaDurationPlaceholderSeconds; + _this.privSourceBuffer = _this.privMediaSource.addSourceBuffer(mimeType_1); + _this.privSourceBuffer.onupdate = function (_) { + _this.updateSourceBuffer(); + }; + _this.privSourceBuffer.onupdateend = function (_) { + _this.handleSourceBufferUpdateEnd(); + }; + _this.privSourceBuffer.onupdatestart = function (_) { + _this.privAppendingToBuffer = false; + }; + }; + this.updateSourceBuffer(); + } + else { + // tslint:disable-next-line:no-console + console.warn("Format " + AudioOutputFormat_1.AudioFormatTag[this.privFormat.formatTag] + " could not be played by MSE, streaming playback is not enabled."); + this.privAudioOutputStream = new AudioOutputStream_1.PullAudioOutputStreamImpl(); + this.privAudioOutputStream.format = this.privFormat; + this.privAudio = new Audio(); + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeakerAudioDestination.prototype, "isClosed", { + get: function () { + return this.privIsClosed; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeakerAudioDestination.prototype, "currentTime", { + get: function () { + if (this.privAudio !== undefined) { + return this.privAudio.currentTime; + } + return -1; + }, + enumerable: true, + configurable: true + }); + SpeakerAudioDestination.prototype.pause = function () { + if (!this.privIsPaused && this.privAudio !== undefined) { + this.privAudio.pause(); + this.privIsPaused = true; + } + }; + SpeakerAudioDestination.prototype.resume = function () { + if (this.privIsPaused && this.privAudio !== undefined) { + this.privAudio.play(); + this.privIsPaused = false; + } + }; + Object.defineProperty(SpeakerAudioDestination.prototype, "internalAudio", { + get: function () { + return this.privAudio; + }, + enumerable: true, + configurable: true + }); + SpeakerAudioDestination.prototype.updateSourceBuffer = function () { + if (this.privAudioBuffer !== undefined && (this.privAudioBuffer.length > 0) && this.sourceBufferAvailable()) { + this.privAppendingToBuffer = true; + var binary = this.privAudioBuffer.shift(); + try { + this.privSourceBuffer.appendBuffer(binary); + } + catch (error) { + this.privAudioBuffer.unshift(binary); + // tslint:disable-next-line:no-console + console.log("buffer filled, pausing addition of binaries until space is made"); + return; + } + this.notifyPlayback(); + } + else if (this.canEndStream()) { + this.handleSourceBufferUpdateEnd(); + } + }; + SpeakerAudioDestination.prototype.handleSourceBufferUpdateEnd = function () { + if (this.canEndStream() && this.sourceBufferAvailable()) { + this.privMediaSource.endOfStream(); + this.notifyPlayback(); + } + }; + SpeakerAudioDestination.prototype.notifyPlayback = function () { + var _this = this; + if (!this.privPlaybackStarted && this.privAudio !== undefined) { + this.privAudio.onended = function () { + if (!!_this.onAudioEnd) { + _this.onAudioEnd(_this); + } + }; + if (!this.privIsPaused) { + this.privAudio.play(); + } + this.privPlaybackStarted = true; + } + }; + SpeakerAudioDestination.prototype.canEndStream = function () { + return (this.isClosed && this.privSourceBuffer !== undefined && (this.privAudioBuffer.length === 0) + && this.privMediaSourceOpened && !this.privAppendingToBuffer && this.privMediaSource.readyState === "open"); + }; + SpeakerAudioDestination.prototype.sourceBufferAvailable = function () { + return (this.privSourceBuffer !== undefined && !this.privSourceBuffer.updating); + }; + return SpeakerAudioDestination; +}()); +exports.SpeakerAudioDestination = SpeakerAudioDestination; + + + +/***/ }), +/* 126 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(4); +var SpeechRecognitionEvent = /** @class */ (function (_super) { + __extends(SpeechRecognitionEvent, _super); + function SpeechRecognitionEvent(eventName, requestId, sessionId, eventType) { + if (eventType === void 0) { eventType = Exports_1.EventType.Info; } + var _this = _super.call(this, eventName, eventType) || this; + _this.privRequestId = requestId; + _this.privSessionId = sessionId; + return _this; + } + Object.defineProperty(SpeechRecognitionEvent.prototype, "requestId", { + get: function () { + return this.privRequestId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechRecognitionEvent.prototype, "sessionId", { + get: function () { + return this.privSessionId; + }, + enumerable: true, + configurable: true + }); + return SpeechRecognitionEvent; +}(Exports_1.PlatformEvent)); +exports.SpeechRecognitionEvent = SpeechRecognitionEvent; +// tslint:disable-next-line:max-classes-per-file +var RecognitionTriggeredEvent = /** @class */ (function (_super) { + __extends(RecognitionTriggeredEvent, _super); + function RecognitionTriggeredEvent(requestId, sessionId, audioSourceId, audioNodeId) { + var _this = _super.call(this, "RecognitionTriggeredEvent", requestId, sessionId) || this; + _this.privAudioSourceId = audioSourceId; + _this.privAudioNodeId = audioNodeId; + return _this; + } + Object.defineProperty(RecognitionTriggeredEvent.prototype, "audioSourceId", { + get: function () { + return this.privAudioSourceId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognitionTriggeredEvent.prototype, "audioNodeId", { + get: function () { + return this.privAudioNodeId; + }, + enumerable: true, + configurable: true + }); + return RecognitionTriggeredEvent; +}(SpeechRecognitionEvent)); +exports.RecognitionTriggeredEvent = RecognitionTriggeredEvent; +// tslint:disable-next-line:max-classes-per-file +var ListeningStartedEvent = /** @class */ (function (_super) { + __extends(ListeningStartedEvent, _super); + function ListeningStartedEvent(requestId, sessionId, audioSourceId, audioNodeId) { + var _this = _super.call(this, "ListeningStartedEvent", requestId, sessionId) || this; + _this.privAudioSourceId = audioSourceId; + _this.privAudioNodeId = audioNodeId; + return _this; + } + Object.defineProperty(ListeningStartedEvent.prototype, "audioSourceId", { + get: function () { + return this.privAudioSourceId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ListeningStartedEvent.prototype, "audioNodeId", { + get: function () { + return this.privAudioNodeId; + }, + enumerable: true, + configurable: true + }); + return ListeningStartedEvent; +}(SpeechRecognitionEvent)); +exports.ListeningStartedEvent = ListeningStartedEvent; +// tslint:disable-next-line:max-classes-per-file +var ConnectingToServiceEvent = /** @class */ (function (_super) { + __extends(ConnectingToServiceEvent, _super); + function ConnectingToServiceEvent(requestId, authFetchEventid, sessionId) { + var _this = _super.call(this, "ConnectingToServiceEvent", requestId, sessionId) || this; + _this.privAuthFetchEventid = authFetchEventid; + return _this; + } + Object.defineProperty(ConnectingToServiceEvent.prototype, "authFetchEventid", { + get: function () { + return this.privAuthFetchEventid; + }, + enumerable: true, + configurable: true + }); + return ConnectingToServiceEvent; +}(SpeechRecognitionEvent)); +exports.ConnectingToServiceEvent = ConnectingToServiceEvent; +// tslint:disable-next-line:max-classes-per-file +var RecognitionStartedEvent = /** @class */ (function (_super) { + __extends(RecognitionStartedEvent, _super); + function RecognitionStartedEvent(requestId, audioSourceId, audioNodeId, authFetchEventId, sessionId) { + var _this = _super.call(this, "RecognitionStartedEvent", requestId, sessionId) || this; + _this.privAudioSourceId = audioSourceId; + _this.privAudioNodeId = audioNodeId; + _this.privAuthFetchEventId = authFetchEventId; + return _this; + } + Object.defineProperty(RecognitionStartedEvent.prototype, "audioSourceId", { + get: function () { + return this.privAudioSourceId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognitionStartedEvent.prototype, "audioNodeId", { + get: function () { + return this.privAudioNodeId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognitionStartedEvent.prototype, "authFetchEventId", { + get: function () { + return this.privAuthFetchEventId; + }, + enumerable: true, + configurable: true + }); + return RecognitionStartedEvent; +}(SpeechRecognitionEvent)); +exports.RecognitionStartedEvent = RecognitionStartedEvent; +var RecognitionCompletionStatus; +(function (RecognitionCompletionStatus) { + RecognitionCompletionStatus[RecognitionCompletionStatus["Success"] = 0] = "Success"; + RecognitionCompletionStatus[RecognitionCompletionStatus["AudioSourceError"] = 1] = "AudioSourceError"; + RecognitionCompletionStatus[RecognitionCompletionStatus["AudioSourceTimeout"] = 2] = "AudioSourceTimeout"; + RecognitionCompletionStatus[RecognitionCompletionStatus["AuthTokenFetchError"] = 3] = "AuthTokenFetchError"; + RecognitionCompletionStatus[RecognitionCompletionStatus["AuthTokenFetchTimeout"] = 4] = "AuthTokenFetchTimeout"; + RecognitionCompletionStatus[RecognitionCompletionStatus["UnAuthorized"] = 5] = "UnAuthorized"; + RecognitionCompletionStatus[RecognitionCompletionStatus["ConnectTimeout"] = 6] = "ConnectTimeout"; + RecognitionCompletionStatus[RecognitionCompletionStatus["ConnectError"] = 7] = "ConnectError"; + RecognitionCompletionStatus[RecognitionCompletionStatus["ClientRecognitionActivityTimeout"] = 8] = "ClientRecognitionActivityTimeout"; + RecognitionCompletionStatus[RecognitionCompletionStatus["UnknownError"] = 9] = "UnknownError"; +})(RecognitionCompletionStatus = exports.RecognitionCompletionStatus || (exports.RecognitionCompletionStatus = {})); +// tslint:disable-next-line:max-classes-per-file +var RecognitionEndedEvent = /** @class */ (function (_super) { + __extends(RecognitionEndedEvent, _super); + function RecognitionEndedEvent(requestId, audioSourceId, audioNodeId, authFetchEventId, sessionId, serviceTag, status, error) { + var _this = _super.call(this, "RecognitionEndedEvent", requestId, sessionId, status === RecognitionCompletionStatus.Success ? Exports_1.EventType.Info : Exports_1.EventType.Error) || this; + _this.privAudioSourceId = audioSourceId; + _this.privAudioNodeId = audioNodeId; + _this.privAuthFetchEventId = authFetchEventId; + _this.privStatus = status; + _this.privError = error; + _this.privServiceTag = serviceTag; + return _this; + } + Object.defineProperty(RecognitionEndedEvent.prototype, "audioSourceId", { + get: function () { + return this.privAudioSourceId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognitionEndedEvent.prototype, "audioNodeId", { + get: function () { + return this.privAudioNodeId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognitionEndedEvent.prototype, "authFetchEventId", { + get: function () { + return this.privAuthFetchEventId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognitionEndedEvent.prototype, "serviceTag", { + get: function () { + return this.privServiceTag; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognitionEndedEvent.prototype, "status", { + get: function () { + return this.privStatus; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognitionEndedEvent.prototype, "error", { + get: function () { + return this.privError; + }, + enumerable: true, + configurable: true + }); + return RecognitionEndedEvent; +}(SpeechRecognitionEvent)); +exports.RecognitionEndedEvent = RecognitionEndedEvent; + + + +/***/ }), +/* 127 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(2); +var Exports_2 = __webpack_require__(4); +var Exports_3 = __webpack_require__(31); +var Exports_4 = __webpack_require__(26); +var SpeechConnectionMessage_Internal_1 = __webpack_require__(128); +var ServiceRecognizerBase = /** @class */ (function () { + function ServiceRecognizerBase(authentication, connectionFactory, audioSource, recognizerConfig, recognizer) { + var _this = this; + this.privSetTimeout = setTimeout; + this.recognizeOverride = undefined; + this.disconnectOverride = undefined; + this.sendTelemetryData = function () { + var telemetryData = _this.privRequestSession.getTelemetry(); + if (ServiceRecognizerBase.telemetryDataEnabled !== true || + _this.privIsDisposed || + null === telemetryData) { + return Exports_2.PromiseHelper.fromResult(true); + } + if (!!ServiceRecognizerBase.telemetryData) { + try { + ServiceRecognizerBase.telemetryData(telemetryData); + /* tslint:disable:no-empty */ + } + catch (_a) { } + } + return _this.fetchConnection().onSuccessContinueWith(function (connection) { + return connection.send(new SpeechConnectionMessage_Internal_1.SpeechConnectionMessage(Exports_2.MessageType.Text, "telemetry", _this.privRequestSession.requestId, "application/json", telemetryData)); + }); + }; + this.receiveMessageOverride = undefined; + this.receiveMessage = function () { + return _this.fetchConnection().on(function (connection) { + return connection.read() + .onSuccessContinueWithPromise(function (message) { + if (_this.receiveMessageOverride !== undefined) { + return _this.receiveMessageOverride(); + } + if (_this.privIsDisposed) { + // We're done. + return Exports_2.PromiseHelper.fromResult(undefined); + } + // indicates we are draining the queue and it came with no message; + if (!message) { + if (!_this.privRequestSession.isRecognizing) { + return Exports_2.PromiseHelper.fromResult(true); + } + else { + return _this.receiveMessage(); + } + } + _this.privServiceHasSentMessage = true; + var connectionMessage = SpeechConnectionMessage_Internal_1.SpeechConnectionMessage.fromConnectionMessage(message); + if (connectionMessage.requestId.toLowerCase() === _this.privRequestSession.requestId.toLowerCase()) { + switch (connectionMessage.path.toLowerCase()) { + case "turn.start": + _this.privMustReportEndOfStream = true; + _this.privRequestSession.onServiceTurnStartResponse(); + break; + case "speech.startdetected": + var speechStartDetected = Exports_4.SpeechDetected.fromJSON(connectionMessage.textBody); + var speechStartEventArgs = new Exports_3.RecognitionEventArgs(speechStartDetected.Offset, _this.privRequestSession.sessionId); + if (!!_this.privRecognizer.speechStartDetected) { + _this.privRecognizer.speechStartDetected(_this.privRecognizer, speechStartEventArgs); + } + break; + case "speech.enddetected": + var json = void 0; + if (connectionMessage.textBody.length > 0) { + json = connectionMessage.textBody; + } + else { + // If the request was empty, the JSON returned is empty. + json = "{ Offset: 0 }"; + } + var speechStopDetected = Exports_4.SpeechDetected.fromJSON(json); + // Only shrink the buffers for continuous recognition. + // For single shot, the speech.phrase message will come after the speech.end and it should own buffer shrink. + if (_this.privRecognizerConfig.isContinuousRecognition) { + _this.privRequestSession.onServiceRecognized(speechStopDetected.Offset + _this.privRequestSession.currentTurnAudioOffset); + } + var speechStopEventArgs = new Exports_3.RecognitionEventArgs(speechStopDetected.Offset + _this.privRequestSession.currentTurnAudioOffset, _this.privRequestSession.sessionId); + if (!!_this.privRecognizer.speechEndDetected) { + _this.privRecognizer.speechEndDetected(_this.privRecognizer, speechStopEventArgs); + } + break; + case "turn.end": + _this.sendTelemetryData(); + if (_this.privRequestSession.isSpeechEnded && _this.privMustReportEndOfStream) { + _this.privMustReportEndOfStream = false; + _this.cancelRecognitionLocal(Exports_3.CancellationReason.EndOfStream, Exports_3.CancellationErrorCode.NoError, undefined); + } + var sessionStopEventArgs = new Exports_3.SessionEventArgs(_this.privRequestSession.sessionId); + _this.privRequestSession.onServiceTurnEndResponse(_this.privRecognizerConfig.isContinuousRecognition); + if (!_this.privRecognizerConfig.isContinuousRecognition || _this.privRequestSession.isSpeechEnded || !_this.privRequestSession.isRecognizing) { + if (!!_this.privRecognizer.sessionStopped) { + _this.privRecognizer.sessionStopped(_this.privRecognizer, sessionStopEventArgs); + } + return Exports_2.PromiseHelper.fromResult(true); + } + else { + _this.fetchConnection().onSuccessContinueWith(function (connection) { + _this.sendSpeechContext(connection); + _this.sendWaveHeader(connection); + }); + } + break; + default: + if (!_this.processTypeSpecificMessages(connectionMessage)) { + // here are some messages that the derived class has not processed, dispatch them to connect class + if (!!_this.privServiceEvents) { + _this.serviceEvents.onEvent(new Exports_2.ServiceEvent(connectionMessage.path.toLowerCase(), connectionMessage.textBody)); + } + } + } + } + return _this.receiveMessage(); + }); + }, function (error) { + }); + }; + this.sendSpeechContext = function (connection) { + var speechContextJson = _this.speechContext.toJSON(); + if (speechContextJson) { + return connection.send(new SpeechConnectionMessage_Internal_1.SpeechConnectionMessage(Exports_2.MessageType.Text, "speech.context", _this.privRequestSession.requestId, "application/json", speechContextJson)); + } + return Exports_2.PromiseHelper.fromResult(true); + }; + this.connectImplOverride = undefined; + this.configConnectionOverride = undefined; + this.fetchConnectionOverride = undefined; + this.sendSpeechServiceConfig = function (connection, requestSession, SpeechServiceConfigJson) { + // filter out anything that is not required for the service to work. + if (ServiceRecognizerBase.telemetryDataEnabled !== true) { + var withTelemetry = JSON.parse(SpeechServiceConfigJson); + var replacement = { + context: { + system: withTelemetry.context.system, + }, + }; + SpeechServiceConfigJson = JSON.stringify(replacement); + } + if (SpeechServiceConfigJson) { // && this.privConnectionId !== this.privSpeechServiceConfigConnectionId) { + // this.privSpeechServiceConfigConnectionId = this.privConnectionId; + return connection.send(new SpeechConnectionMessage_Internal_1.SpeechConnectionMessage(Exports_2.MessageType.Text, "speech.config", requestSession.requestId, "application/json", SpeechServiceConfigJson)); + } + return Exports_2.PromiseHelper.fromResult(true); + }; + this.sendAudio = function (audioStreamNode) { + return _this.audioSource.format.onSuccessContinueWithPromise(function (audioFormat) { + // NOTE: Home-baked promises crash ios safari during the invocation + // of the error callback chain (looks like the recursion is way too deep, and + // it blows up the stack). The following construct is a stop-gap that does not + // bubble the error up the callback chain and hence circumvents this problem. + // TODO: rewrite with ES6 promises. + var deferred = new Exports_2.Deferred(); + // The time we last sent data to the service. + var nextSendTime = Date.now(); + // Max amount to send before we start to throttle + var fastLaneSizeMs = _this.privRecognizerConfig.parameters.getProperty("SPEECH-TransmitLengthBeforThrottleMs", "5000"); + var maxSendUnthrottledBytes = audioFormat.avgBytesPerSec / 1000 * parseInt(fastLaneSizeMs, 10); + var startRecogNumber = _this.privRequestSession.recogNumber; + var readAndUploadCycle = function () { + // If speech is done, stop sending audio. + if (!_this.privIsDisposed && + !_this.privRequestSession.isSpeechEnded && + _this.privRequestSession.isRecognizing && + _this.privRequestSession.recogNumber === startRecogNumber) { + _this.fetchConnection().on(function (connection) { + audioStreamNode.read().on(function (audioStreamChunk) { + // we have a new audio chunk to upload. + if (_this.privRequestSession.isSpeechEnded) { + // If service already recognized audio end then don't send any more audio + deferred.resolve(true); + return; + } + var payload; + var sendDelay; + if (!audioStreamChunk || audioStreamChunk.isEnd) { + payload = null; + sendDelay = 0; + } + else { + payload = audioStreamChunk.buffer; + _this.privRequestSession.onAudioSent(payload.byteLength); + if (maxSendUnthrottledBytes >= _this.privRequestSession.bytesSent) { + sendDelay = 0; + } + else { + sendDelay = Math.max(0, nextSendTime - Date.now()); + } + } + // Are we ready to send, or need we delay more? + _this.privSetTimeout(function () { + var _a; + if (payload !== null) { + nextSendTime = Date.now() + (payload.byteLength * 1000 / (audioFormat.avgBytesPerSec * 2)); + } + var uploaded = connection.send(new SpeechConnectionMessage_Internal_1.SpeechConnectionMessage(Exports_2.MessageType.Binary, "audio", _this.privRequestSession.requestId, null, payload)); + if (!((_a = audioStreamChunk) === null || _a === void 0 ? void 0 : _a.isEnd)) { + uploaded.continueWith(function (_) { + // this.writeBufferToConsole(payload); + // Regardless of success or failure, schedule the next upload. + // If the underlying connection was broken, the next cycle will + // get a new connection and re-transmit missing audio automatically. + readAndUploadCycle(); + }); + } + else { + // the audio stream has been closed, no need to schedule next + // read-upload cycle. + _this.privRequestSession.onSpeechEnded(); + deferred.resolve(true); + } + }, sendDelay); + }, function (error) { + if (_this.privRequestSession.isSpeechEnded) { + // For whatever reason, Reject is used to remove queue subscribers inside + // the Queue.DrainAndDispose invoked from DetachAudioNode down below, which + // means that sometimes things can be rejected in normal circumstances, without + // any errors. + deferred.resolve(true); // TODO: remove the argument, it's is completely meaningless. + } + else { + // Only reject, if there was a proper error. + deferred.reject(error); + } + }); + }, function (error) { + deferred.reject(error); + }); + } + }; + readAndUploadCycle(); + return deferred.promise(); + }); + }; + this.fetchConnection = function () { + if (_this.fetchConnectionOverride !== undefined) { + return _this.fetchConnectionOverride(); + } + return _this.configureConnection(); + }; + if (!authentication) { + throw new Exports_2.ArgumentNullError("authentication"); + } + if (!connectionFactory) { + throw new Exports_2.ArgumentNullError("connectionFactory"); + } + if (!audioSource) { + throw new Exports_2.ArgumentNullError("audioSource"); + } + if (!recognizerConfig) { + throw new Exports_2.ArgumentNullError("recognizerConfig"); + } + this.privMustReportEndOfStream = false; + this.privAuthentication = authentication; + this.privConnectionFactory = connectionFactory; + this.privAudioSource = audioSource; + this.privRecognizerConfig = recognizerConfig; + this.privIsDisposed = false; + this.privRecognizer = recognizer; + this.privRequestSession = new Exports_4.RequestSession(this.privAudioSource.id()); + this.privConnectionEvents = new Exports_2.EventSource(); + this.privServiceEvents = new Exports_2.EventSource(); + this.privDynamicGrammar = new Exports_4.DynamicGrammarBuilder(); + this.privSpeechContext = new Exports_4.SpeechContext(this.privDynamicGrammar); + this.privAgentConfig = new Exports_4.AgentConfig(); + if (typeof (Blob) !== "undefined" && typeof (Worker) !== "undefined") { + this.privSetTimeout = Exports_2.Timeout.setTimeout; + } + } + Object.defineProperty(ServiceRecognizerBase.prototype, "audioSource", { + get: function () { + return this.privAudioSource; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ServiceRecognizerBase.prototype, "speechContext", { + get: function () { + return this.privSpeechContext; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ServiceRecognizerBase.prototype, "dynamicGrammar", { + get: function () { + return this.privDynamicGrammar; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ServiceRecognizerBase.prototype, "agentConfig", { + get: function () { + return this.privAgentConfig; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ServiceRecognizerBase.prototype, "conversationTranslatorToken", { + set: function (token) { + this.privRecognizerConfig.parameters.setProperty(Exports_3.PropertyId.ConversationTranslator_Token, token); + }, + enumerable: true, + configurable: true + }); + ServiceRecognizerBase.prototype.isDisposed = function () { + return this.privIsDisposed; + }; + ServiceRecognizerBase.prototype.dispose = function (reason) { + this.privIsDisposed = true; + if (this.privConnectionConfigurationPromise) { + this.privConnectionConfigurationPromise.onSuccessContinueWith(function (connection) { + connection.dispose(reason); + }); + } + }; + Object.defineProperty(ServiceRecognizerBase.prototype, "connectionEvents", { + get: function () { + return this.privConnectionEvents; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ServiceRecognizerBase.prototype, "serviceEvents", { + get: function () { + return this.privServiceEvents; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ServiceRecognizerBase.prototype, "recognitionMode", { + get: function () { + return this.privRecognizerConfig.recognitionMode; + }, + enumerable: true, + configurable: true + }); + ServiceRecognizerBase.prototype.recognize = function (recoMode, successCallback, errorCallBack) { + var _this = this; + if (this.recognizeOverride !== undefined) { + return this.recognizeOverride(recoMode, successCallback, errorCallBack); + } + // Clear the existing configuration promise to force a re-transmission of config and context. + this.privConnectionConfigurationPromise = null; + this.privRecognizerConfig.recognitionMode = recoMode; + this.privSuccessCallback = successCallback; + this.privErrorCallback = errorCallBack; + this.privRequestSession.startNewRecognition(); + this.privRequestSession.listenForServiceTelemetry(this.privAudioSource.events); + // Start the connection to the service. The promise this will create is stored and will be used by configureConnection(). + this.connectImpl(); + return this.audioSource + .attach(this.privRequestSession.audioNodeId) + .onSuccessContinueWithPromise(function (result) { + var audioNode; + return _this.audioSource.format.onSuccessContinueWithPromise(function (format) { + audioNode = new Exports_1.ReplayableAudioNode(result, format.avgBytesPerSec); + _this.privRequestSession.onAudioSourceAttachCompleted(audioNode, false); + return _this.audioSource.deviceInfo.onSuccessContinueWithPromise(function (deviceInfo) { + _this.privRecognizerConfig.SpeechServiceConfig.Context.audio = { source: deviceInfo }; + return _this.configureConnection() + .continueWithPromise(function (result) { + if (result.isError) { + _this.cancelRecognitionLocal(Exports_3.CancellationReason.Error, Exports_3.CancellationErrorCode.ConnectionFailure, result.error); + return Exports_2.PromiseHelper.fromError(result.error); + } + var sessionStartEventArgs = new Exports_3.SessionEventArgs(_this.privRequestSession.sessionId); + if (!!_this.privRecognizer.sessionStarted) { + _this.privRecognizer.sessionStarted(_this.privRecognizer, sessionStartEventArgs); + } + var messageRetrievalPromise = _this.receiveMessage(); + var audioSendPromise = _this.sendAudio(audioNode); + /* tslint:disable:no-empty */ + audioSendPromise.on(function (_) { }, function (error) { + _this.cancelRecognitionLocal(Exports_3.CancellationReason.Error, Exports_3.CancellationErrorCode.RuntimeError, error); + }); + return Exports_2.PromiseHelper.fromResult(true); + }); + }); + }); + }); + }; + ServiceRecognizerBase.prototype.stopRecognizing = function () { + var _this = this; + if (this.privRequestSession.isRecognizing) { + this.audioSource.turnOff(); + return this.sendFinalAudio().onSuccessContinueWithPromise(function (_) { + _this.privRequestSession.onStopRecognizing(); + return _this.privRequestSession.turnCompletionPromise.onSuccessContinueWith(function (_) { + _this.privRequestSession.onStopRecognizing(); + _this.privRequestSession.dispose(); + return true; + }); + }); + } + return Exports_2.PromiseHelper.fromResult(true); + }; + ServiceRecognizerBase.prototype.connect = function () { + this.connectImpl().result(); + }; + ServiceRecognizerBase.prototype.connectAsync = function (cb, err) { + this.connectImpl().continueWith(function (promiseResult) { + try { + if (promiseResult.isError) { + if (!!err) { + err(promiseResult.error); + } + } + else if (promiseResult.isCompleted) { + if (!!cb) { + cb(); + } + } + } + catch (e) { + if (!!err) { + err(e); + } + } + }); + }; + ServiceRecognizerBase.prototype.disconnect = function () { + if (this.disconnectOverride !== undefined) { + this.disconnectOverride(); + return; + } + this.cancelRecognitionLocal(Exports_3.CancellationReason.Error, Exports_3.CancellationErrorCode.NoError, "Disconnecting"); + if (this.privConnectionPromise.result().isCompleted) { + if (!this.privConnectionPromise.result().isError) { + this.privConnectionPromise.result().result.dispose(); + this.privConnectionPromise = null; + } + } + else { + this.privConnectionPromise.onSuccessContinueWith(function (connection) { + connection.dispose(); + }); + } + }; + ServiceRecognizerBase.prototype.disconnectAsync = function (cb, err) { + try { + if (this.disconnectOverride !== undefined) { + this.disconnectOverride(); + if (!!cb) { + cb(); + } + return; + } + this.cancelRecognitionLocal(Exports_3.CancellationReason.Error, Exports_3.CancellationErrorCode.NoError, "Disconnecting"); + this.privConnectionPromise.continueWith(function (result) { + try { + if (result.isError) { + if (!!err) { + err(result.error); + } + } + else if (result.isCompleted) { + result.result.dispose(); + if (!!cb) { + cb(); + } + } + } + catch (e) { + if (!!err) { + err(e); + } + } + }); + } + catch (e) { + if (!!err) { + err(e); + } + } + }; + ServiceRecognizerBase.prototype.sendMessage = function (message) { }; + ServiceRecognizerBase.prototype.sendNetworkMessage = function (path, payload, success, err) { + var _this = this; + var type = typeof payload === "string" ? Exports_2.MessageType.Text : Exports_2.MessageType.Binary; + var contentType = typeof payload === "string" ? "application/json" : ""; + this.fetchConnection().on(function (connection) { + connection.send(new SpeechConnectionMessage_Internal_1.SpeechConnectionMessage(type, path, _this.privRequestSession.requestId, contentType, payload)).on(function () { + if (!!success) { + success(); + } + }, function (error) { + if (!!err) { + err(error); + } + }); + }, function (error) { + if (!!err) { + err(error); + } + }); + }; + Object.defineProperty(ServiceRecognizerBase.prototype, "activityTemplate", { + get: function () { return this.privActivityTemplate; }, + set: function (messagePayload) { this.privActivityTemplate = messagePayload; }, + enumerable: true, + configurable: true + }); + // Cancels recognition. + ServiceRecognizerBase.prototype.cancelRecognitionLocal = function (cancellationReason, errorCode, error) { + if (!!this.privRequestSession.isRecognizing) { + this.privRequestSession.onStopRecognizing(); + this.cancelRecognition(this.privRequestSession.sessionId, this.privRequestSession.requestId, cancellationReason, errorCode, error); + } + }; + ServiceRecognizerBase.prototype.sendWaveHeader = function (connection) { + var _this = this; + return this.audioSource.format.onSuccessContinueWithPromise(function (format) { + // this.writeBufferToConsole(format.header); + return connection.send(new SpeechConnectionMessage_Internal_1.SpeechConnectionMessage(Exports_2.MessageType.Binary, "audio", _this.privRequestSession.requestId, "audio/x-wav", format.header)); + }); + }; + // Establishes a websocket connection to the end point. + ServiceRecognizerBase.prototype.connectImpl = function (isUnAuthorized) { + var _this = this; + if (isUnAuthorized === void 0) { isUnAuthorized = false; } + if (this.connectImplOverride !== undefined) { + return this.connectImplOverride(isUnAuthorized); + } + if (this.privConnectionPromise) { + if (this.privConnectionPromise.result().isCompleted && + (this.privConnectionPromise.result().isError + || this.privConnectionPromise.result().result.state() === Exports_2.ConnectionState.Disconnected) && + this.privServiceHasSentMessage === true) { + this.privConnectionId = null; + this.privConnectionPromise = null; + this.privServiceHasSentMessage = false; + return this.connectImpl(); + } + else { + return this.privConnectionPromise; + } + } + this.privAuthFetchEventId = Exports_2.createNoDashGuid(); + this.privConnectionId = Exports_2.createNoDashGuid(); + this.privRequestSession.onPreConnectionStart(this.privAuthFetchEventId, this.privConnectionId); + var authPromise = isUnAuthorized ? this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId) : this.privAuthentication.fetch(this.privAuthFetchEventId); + this.privConnectionPromise = authPromise + .continueWithPromise(function (result) { + if (result.isError) { + _this.privRequestSession.onAuthCompleted(true, result.error); + throw new Error(result.error); + } + else { + _this.privRequestSession.onAuthCompleted(false); + } + var connection = _this.privConnectionFactory.create(_this.privRecognizerConfig, result.result, _this.privConnectionId); + _this.privRequestSession.listenForServiceTelemetry(connection.events); + // Attach to the underlying event. No need to hold onto the detach pointers as in the event the connection goes away, + // it'll stop sending events. + connection.events.attach(function (event) { + _this.connectionEvents.onEvent(event); + }); + return connection.open().onSuccessContinueWithPromise(function (response) { + if (response.statusCode === 200) { + _this.privRequestSession.onPreConnectionStart(_this.privAuthFetchEventId, _this.privConnectionId); + _this.privRequestSession.onConnectionEstablishCompleted(response.statusCode); + return Exports_2.PromiseHelper.fromResult(connection); + } + else if (response.statusCode === 403 && !isUnAuthorized) { + return _this.connectImpl(true); + } + else { + _this.privRequestSession.onConnectionEstablishCompleted(response.statusCode, response.reason); + return Exports_2.PromiseHelper.fromError("Unable to contact server. StatusCode: " + response.statusCode + ", " + _this.privRecognizerConfig.parameters.getProperty(Exports_3.PropertyId.SpeechServiceConnection_Endpoint) + " Reason: " + response.reason); + } + }); + }); + return this.privConnectionPromise; + }; + ServiceRecognizerBase.prototype.writeBufferToConsole = function (buffer) { + var out = "Buffer Size: "; + if (null === buffer) { + out += "null"; + } + else { + var readView = new Uint8Array(buffer); + out += buffer.byteLength + "\r\n"; + for (var i = 0; i < buffer.byteLength; i++) { + out += readView[i].toString(16).padStart(2, "0") + " "; + } + } + // tslint:disable-next-line:no-console + console.info(out); + }; + ServiceRecognizerBase.prototype.sendFinalAudio = function () { + var _this = this; + var deferred = new Exports_2.Deferred(); + this.fetchConnection().on(function (connection) { + connection.send(new SpeechConnectionMessage_Internal_1.SpeechConnectionMessage(Exports_2.MessageType.Binary, "audio", _this.privRequestSession.requestId, null, null)).on(function (_) { + deferred.resolve(true); + }, function (error) { + deferred.reject(error); + }); + }, function (error) { + deferred.reject(error); + }); + return deferred.promise(); + }; + // Takes an established websocket connection to the endpoint and sends speech configuration information. + ServiceRecognizerBase.prototype.configureConnection = function () { + var _this = this; + if (this.configConnectionOverride !== undefined) { + return this.configConnectionOverride(); + } + if (this.privConnectionConfigurationPromise) { + if (this.privConnectionConfigurationPromise.result().isCompleted && + (this.privConnectionConfigurationPromise.result().isError + || this.privConnectionConfigurationPromise.result().result.state() === Exports_2.ConnectionState.Disconnected)) { + this.privConnectionConfigurationPromise = null; + return this.configureConnection(); + } + else { + return this.privConnectionConfigurationPromise; + } + } + this.privConnectionConfigurationPromise = this.connectImpl().onSuccessContinueWithPromise(function (connection) { + return _this.sendSpeechServiceConfig(connection, _this.privRequestSession, _this.privRecognizerConfig.SpeechServiceConfig.serialize()) + .onSuccessContinueWithPromise(function (_) { + return _this.sendSpeechContext(connection).onSuccessContinueWithPromise(function (_) { + return _this.sendWaveHeader(connection).onSuccessContinueWith(function (_) { + return connection; + }); + }); + }); + }); + return this.privConnectionConfigurationPromise; + }; + ServiceRecognizerBase.telemetryDataEnabled = true; + return ServiceRecognizerBase; +}()); +exports.ServiceRecognizerBase = ServiceRecognizerBase; + + + +/***/ }), +/* 128 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(4); +var PathHeaderName = "Path"; +var ContentTypeHeaderName = "Content-Type"; +var RequestIdHeaderName = "X-RequestId"; +var RequestTimestampHeaderName = "X-Timestamp"; +var RequestStreamIdHeaderName = "x-streamid"; +var SpeechConnectionMessage = /** @class */ (function (_super) { + __extends(SpeechConnectionMessage, _super); + function SpeechConnectionMessage(messageType, path, requestId, contentType, body, streamId, additionalHeaders, id) { + var _this = this; + if (!path) { + throw new Exports_1.ArgumentNullError("path"); + } + if (!requestId) { + throw new Exports_1.ArgumentNullError("requestId"); + } + var headers = {}; + headers[PathHeaderName] = path; + headers[RequestIdHeaderName] = requestId; + headers[RequestTimestampHeaderName] = new Date().toISOString(); + if (contentType) { + headers[ContentTypeHeaderName] = contentType; + } + if (streamId) { + headers[RequestStreamIdHeaderName] = streamId; + } + if (additionalHeaders) { + for (var headerName in additionalHeaders) { + if (headerName) { + headers[headerName] = additionalHeaders[headerName]; + } + } + } + if (id) { + _this = _super.call(this, messageType, body, headers, id) || this; + } + else { + _this = _super.call(this, messageType, body, headers) || this; + } + _this.privPath = path; + _this.privRequestId = requestId; + _this.privContentType = contentType; + _this.privStreamId = streamId; + _this.privAdditionalHeaders = additionalHeaders; + return _this; + } + Object.defineProperty(SpeechConnectionMessage.prototype, "path", { + get: function () { + return this.privPath; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechConnectionMessage.prototype, "requestId", { + get: function () { + return this.privRequestId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechConnectionMessage.prototype, "contentType", { + get: function () { + return this.privContentType; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechConnectionMessage.prototype, "streamId", { + get: function () { + return this.privStreamId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechConnectionMessage.prototype, "additionalHeaders", { + get: function () { + return this.privAdditionalHeaders; + }, + enumerable: true, + configurable: true + }); + SpeechConnectionMessage.fromConnectionMessage = function (message) { + var path = null; + var requestId = null; + var contentType = null; + var requestTimestamp = null; + var streamId = null; + var additionalHeaders = {}; + if (message.headers) { + for (var headerName in message.headers) { + if (headerName) { + if (headerName.toLowerCase() === PathHeaderName.toLowerCase()) { + path = message.headers[headerName]; + } + else if (headerName.toLowerCase() === RequestIdHeaderName.toLowerCase()) { + requestId = message.headers[headerName]; + } + else if (headerName.toLowerCase() === RequestTimestampHeaderName.toLowerCase()) { + requestTimestamp = message.headers[headerName]; + } + else if (headerName.toLowerCase() === ContentTypeHeaderName.toLowerCase()) { + contentType = message.headers[headerName]; + } + else if (headerName.toLowerCase() === RequestStreamIdHeaderName.toLowerCase()) { + streamId = message.headers[headerName]; + } + else { + additionalHeaders[headerName] = message.headers[headerName]; + } + } + } + } + return new SpeechConnectionMessage(message.messageType, path, requestId, contentType, message.body, streamId, additionalHeaders, message.id); + }; + return SpeechConnectionMessage; +}(Exports_1.ConnectionMessage)); +exports.SpeechConnectionMessage = SpeechConnectionMessage; + + + +/***/ }), +/* 129 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(31); +var RecognitionMode; +(function (RecognitionMode) { + RecognitionMode[RecognitionMode["Interactive"] = 0] = "Interactive"; + RecognitionMode[RecognitionMode["Conversation"] = 1] = "Conversation"; + RecognitionMode[RecognitionMode["Dictation"] = 2] = "Dictation"; +})(RecognitionMode = exports.RecognitionMode || (exports.RecognitionMode = {})); +var SpeechResultFormat; +(function (SpeechResultFormat) { + SpeechResultFormat[SpeechResultFormat["Simple"] = 0] = "Simple"; + SpeechResultFormat[SpeechResultFormat["Detailed"] = 1] = "Detailed"; +})(SpeechResultFormat = exports.SpeechResultFormat || (exports.SpeechResultFormat = {})); +var RecognizerConfig = /** @class */ (function () { + function RecognizerConfig(speechServiceConfig, parameters) { + this.privRecognitionMode = RecognitionMode.Interactive; + this.privSpeechServiceConfig = speechServiceConfig ? speechServiceConfig : new SpeechServiceConfig(new Context(null)); + this.privParameters = parameters; + } + Object.defineProperty(RecognizerConfig.prototype, "parameters", { + get: function () { + return this.privParameters; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognizerConfig.prototype, "recognitionMode", { + get: function () { + return this.privRecognitionMode; + }, + set: function (value) { + this.privRecognitionMode = value; + this.privRecognitionActivityTimeout = value === RecognitionMode.Interactive ? 8000 : 25000; + this.privSpeechServiceConfig.Recognition = RecognitionMode[value]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognizerConfig.prototype, "SpeechServiceConfig", { + get: function () { + return this.privSpeechServiceConfig; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognizerConfig.prototype, "recognitionActivityTimeout", { + get: function () { + return this.privRecognitionActivityTimeout; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognizerConfig.prototype, "isContinuousRecognition", { + get: function () { + return this.privRecognitionMode !== RecognitionMode.Interactive; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RecognizerConfig.prototype, "autoDetectSourceLanguages", { + get: function () { + return this.parameters.getProperty(Exports_1.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, undefined); + }, + enumerable: true, + configurable: true + }); + return RecognizerConfig; +}()); +exports.RecognizerConfig = RecognizerConfig; +// The config is serialized and sent as the Speech.Config +// tslint:disable-next-line:max-classes-per-file +var SpeechServiceConfig = /** @class */ (function () { + function SpeechServiceConfig(context) { + var _this = this; + this.serialize = function () { + return JSON.stringify(_this, function (key, value) { + if (value && typeof value === "object") { + var replacement = {}; + for (var k in value) { + if (Object.hasOwnProperty.call(value, k)) { + replacement[k && k.charAt(0).toLowerCase() + k.substring(1)] = value[k]; + } + } + return replacement; + } + return value; + }); + }; + this.context = context; + } + Object.defineProperty(SpeechServiceConfig.prototype, "Context", { + get: function () { + return this.context; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechServiceConfig.prototype, "Recognition", { + get: function () { + return this.recognition; + }, + set: function (value) { + this.recognition = value.toLowerCase(); + }, + enumerable: true, + configurable: true + }); + return SpeechServiceConfig; +}()); +exports.SpeechServiceConfig = SpeechServiceConfig; +// tslint:disable-next-line:max-classes-per-file +var Context = /** @class */ (function () { + function Context(os) { + this.system = new System(); + this.os = os; + } + return Context; +}()); +exports.Context = Context; +// tslint:disable-next-line:max-classes-per-file +var System = /** @class */ (function () { + function System() { + // Note: below will be patched for official builds. + var SPEECHSDK_CLIENTSDK_VERSION = "1.13.0"; + this.name = "SpeechSDK"; + this.version = SPEECHSDK_CLIENTSDK_VERSION; + this.build = "JavaScript"; + this.lang = "JavaScript"; + } + return System; +}()); +exports.System = System; +// tslint:disable-next-line:max-classes-per-file +var OS = /** @class */ (function () { + function OS(platform, name, version) { + this.platform = platform; + this.name = name; + this.version = version; + } + return OS; +}()); +exports.OS = OS; +// tslint:disable-next-line:max-classes-per-file +var Device = /** @class */ (function () { + function Device(manufacturer, model, version) { + this.manufacturer = manufacturer; + this.model = model; + this.version = version; + } + return Device; +}()); +exports.Device = Device; +var connectivity; +(function (connectivity) { + connectivity["Bluetooth"] = "Bluetooth"; + connectivity["Wired"] = "Wired"; + connectivity["WiFi"] = "WiFi"; + connectivity["Cellular"] = "Cellular"; + connectivity["InBuilt"] = "InBuilt"; + connectivity["Unknown"] = "Unknown"; +})(connectivity = exports.connectivity || (exports.connectivity = {})); +var type; +(function (type) { + type["Phone"] = "Phone"; + type["Speaker"] = "Speaker"; + type["Car"] = "Car"; + type["Headset"] = "Headset"; + type["Thermostat"] = "Thermostat"; + type["Microphones"] = "Microphones"; + type["Deskphone"] = "Deskphone"; + type["RemoteControl"] = "RemoteControl"; + type["Unknown"] = "Unknown"; + type["File"] = "File"; + type["Stream"] = "Stream"; +})(type = exports.type || (exports.type = {})); + + + +/***/ }), +/* 130 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(4); +var CRLF = "\r\n"; +var WebsocketMessageFormatter = /** @class */ (function () { + function WebsocketMessageFormatter() { + var _this = this; + this.toConnectionMessage = function (message) { + var deferral = new Exports_1.Deferred(); + try { + if (message.messageType === Exports_1.MessageType.Text) { + var textMessage = message.textContent; + var headers = {}; + var body = null; + if (textMessage) { + var headerBodySplit = textMessage.split("\r\n\r\n"); + if (headerBodySplit && headerBodySplit.length > 0) { + headers = _this.parseHeaders(headerBodySplit[0]); + if (headerBodySplit.length > 1) { + body = headerBodySplit[1]; + } + } + } + deferral.resolve(new Exports_1.ConnectionMessage(message.messageType, body, headers, message.id)); + } + else if (message.messageType === Exports_1.MessageType.Binary) { + var binaryMessage = message.binaryContent; + var headers = {}; + var body = null; + if (!binaryMessage || binaryMessage.byteLength < 2) { + throw new Error("Invalid binary message format. Header length missing."); + } + var dataView = new DataView(binaryMessage); + var headerLength = dataView.getInt16(0); + if (binaryMessage.byteLength < headerLength + 2) { + throw new Error("Invalid binary message format. Header content missing."); + } + var headersString = ""; + for (var i = 0; i < headerLength; i++) { + headersString += String.fromCharCode((dataView).getInt8(i + 2)); + } + headers = _this.parseHeaders(headersString); + if (binaryMessage.byteLength > headerLength + 2) { + body = binaryMessage.slice(2 + headerLength); + } + deferral.resolve(new Exports_1.ConnectionMessage(message.messageType, body, headers, message.id)); + } + } + catch (e) { + deferral.reject("Error formatting the message. Error: " + e); + } + return deferral.promise(); + }; + this.fromConnectionMessage = function (message) { + var deferral = new Exports_1.Deferred(); + try { + if (message.messageType === Exports_1.MessageType.Text) { + var payload = "" + _this.makeHeaders(message) + CRLF + (message.textBody ? message.textBody : ""); + deferral.resolve(new Exports_1.RawWebsocketMessage(Exports_1.MessageType.Text, payload, message.id)); + } + else if (message.messageType === Exports_1.MessageType.Binary) { + var headersString = _this.makeHeaders(message); + var content = message.binaryBody; + var headerInt8Array = new Int8Array(_this.stringToArrayBuffer(headersString)); + var payload = new ArrayBuffer(2 + headerInt8Array.byteLength + (content ? content.byteLength : 0)); + var dataView = new DataView(payload); + dataView.setInt16(0, headerInt8Array.length); + for (var i = 0; i < headerInt8Array.byteLength; i++) { + dataView.setInt8(2 + i, headerInt8Array[i]); + } + if (content) { + var bodyInt8Array = new Int8Array(content); + for (var i = 0; i < bodyInt8Array.byteLength; i++) { + dataView.setInt8(2 + headerInt8Array.byteLength + i, bodyInt8Array[i]); + } + } + deferral.resolve(new Exports_1.RawWebsocketMessage(Exports_1.MessageType.Binary, payload, message.id)); + } + } + catch (e) { + deferral.reject("Error formatting the message. " + e); + } + return deferral.promise(); + }; + this.makeHeaders = function (message) { + var headersString = ""; + if (message.headers) { + for (var header in message.headers) { + if (header) { + headersString += header + ": " + message.headers[header] + CRLF; + } + } + } + return headersString; + }; + this.parseHeaders = function (headersString) { + var headers = {}; + if (headersString) { + var headerMatches = headersString.match(/[^\r\n]+/g); + if (headers) { + for (var _i = 0, headerMatches_1 = headerMatches; _i < headerMatches_1.length; _i++) { + var header = headerMatches_1[_i]; + if (header) { + var separatorIndex = header.indexOf(":"); + var headerName = separatorIndex > 0 ? header.substr(0, separatorIndex).trim().toLowerCase() : header; + var headerValue = separatorIndex > 0 && header.length > (separatorIndex + 1) ? + header.substr(separatorIndex + 1).trim() : + ""; + headers[headerName] = headerValue; + } + } + } + } + return headers; + }; + this.stringToArrayBuffer = function (str) { + var buffer = new ArrayBuffer(str.length); + var view = new DataView(buffer); + for (var i = 0; i < str.length; i++) { + view.setUint8(i, str.charCodeAt(i)); + } + return buffer; + }; + } + return WebsocketMessageFormatter; +}()); +exports.WebsocketMessageFormatter = WebsocketMessageFormatter; + + + +/***/ }), +/* 131 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(2); +var Exports_2 = __webpack_require__(31); +var ConnectionFactoryBase_1 = __webpack_require__(72); +var Exports_3 = __webpack_require__(26); +var QueryParameterNames_1 = __webpack_require__(73); +var TestHooksParamName = "testhooks"; +var ConnectionIdHeader = "X-ConnectionId"; +var TranslationConnectionFactory = /** @class */ (function (_super) { + __extends(TranslationConnectionFactory, _super); + function TranslationConnectionFactory() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.create = function (config, authInfo, connectionId) { + var endpoint = config.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_Endpoint, undefined); + if (!endpoint) { + var region = config.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_Region, undefined); + var hostSuffix = (region && region.toLowerCase().startsWith("china")) ? ".azure.cn" : ".microsoft.com"; + var host = config.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_Host, "wss://" + region + ".s2s.speech" + hostSuffix); + endpoint = host + "/speech/translation/cognitiveservices/v1"; + } + var queryParams = { + from: config.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_RecoLanguage), + to: config.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_TranslationToLanguages), + }; + _this.setCommonUrlParams(config, queryParams, endpoint); + _this.setUrlParameter(Exports_2.PropertyId.SpeechServiceResponse_TranslationRequestStablePartialResult, QueryParameterNames_1.QueryParameterNames.StableTranslation, config, queryParams, endpoint); + var voiceName = "voice"; + var featureName = "features"; + if (config.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_TranslationVoice, undefined) !== undefined) { + queryParams[voiceName] = config.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_TranslationVoice); + queryParams[featureName] = "texttospeech"; + } + var headers = {}; + if (authInfo.token !== undefined && authInfo.token !== "") { + headers[authInfo.headerName] = authInfo.token; + } + headers[ConnectionIdHeader] = connectionId; + config.parameters.setProperty(Exports_2.PropertyId.SpeechServiceConnection_Url, endpoint); + return new Exports_1.WebsocketConnection(endpoint, queryParams, headers, new Exports_3.WebsocketMessageFormatter(), Exports_1.ProxyInfo.fromRecognizerConfig(config), connectionId); + }; + return _this; + } + return TranslationConnectionFactory; +}(ConnectionFactoryBase_1.ConnectionFactoryBase)); +exports.TranslationConnectionFactory = TranslationConnectionFactory; + + + +/***/ }), +/* 132 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(2); +var Exports_2 = __webpack_require__(31); +var Exports_3 = __webpack_require__(26); +var QueryParameterNames_1 = __webpack_require__(73); +var SpeechSynthesisConnectionFactory = /** @class */ (function () { + function SpeechSynthesisConnectionFactory() { + var _this = this; + this.synthesisUri = "/cognitiveservices/websocket/v1"; + this.create = function (config, authInfo, connectionId) { + var endpoint = config.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_Endpoint, undefined); + var region = config.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_Region, undefined); + var hostSuffix = (region && region.toLowerCase().startsWith("china")) ? ".azure.cn" : ".microsoft.com"; + var host = config.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_Host, "wss://" + region + ".tts.speech" + hostSuffix); + var queryParams = {}; + if (!endpoint) { + endpoint = host + _this.synthesisUri; + } + var headers = {}; + if (authInfo.token !== undefined && authInfo.token !== "") { + headers[authInfo.headerName] = authInfo.token; + } + headers[QueryParameterNames_1.QueryParameterNames.ConnectionIdHeader] = connectionId; + config.parameters.setProperty(Exports_2.PropertyId.SpeechServiceConnection_Url, endpoint); + return new Exports_1.WebsocketConnection(endpoint, queryParams, headers, new Exports_3.WebsocketMessageFormatter(), Exports_1.ProxyInfo.fromParameters(config.parameters), connectionId); + }; + } + return SpeechSynthesisConnectionFactory; +}()); +exports.SpeechSynthesisConnectionFactory = SpeechSynthesisConnectionFactory; + + + +/***/ }), +/* 133 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(31); +var Exports_2 = __webpack_require__(26); +var EnumTranslation = /** @class */ (function () { + function EnumTranslation() { + } + EnumTranslation.implTranslateRecognitionResult = function (recognitionStatus) { + var reason = Exports_1.ResultReason.Canceled; + switch (recognitionStatus) { + case Exports_2.RecognitionStatus.Success: + reason = Exports_1.ResultReason.RecognizedSpeech; + break; + case Exports_2.RecognitionStatus.NoMatch: + case Exports_2.RecognitionStatus.InitialSilenceTimeout: + case Exports_2.RecognitionStatus.BabbleTimeout: + case Exports_2.RecognitionStatus.EndOfDictation: + reason = Exports_1.ResultReason.NoMatch; + break; + case Exports_2.RecognitionStatus.Error: + default: + reason = Exports_1.ResultReason.Canceled; + break; + } + return reason; + }; + EnumTranslation.implTranslateCancelResult = function (recognitionStatus) { + var reason = Exports_1.CancellationReason.EndOfStream; + switch (recognitionStatus) { + case Exports_2.RecognitionStatus.Success: + case Exports_2.RecognitionStatus.EndOfDictation: + case Exports_2.RecognitionStatus.NoMatch: + reason = Exports_1.CancellationReason.EndOfStream; + break; + case Exports_2.RecognitionStatus.InitialSilenceTimeout: + case Exports_2.RecognitionStatus.BabbleTimeout: + case Exports_2.RecognitionStatus.Error: + default: + reason = Exports_1.CancellationReason.Error; + break; + } + return reason; + }; + EnumTranslation.implTranslateCancelErrorCode = function (recognitionStatus) { + var reason = Exports_1.CancellationErrorCode.NoError; + switch (recognitionStatus) { + case Exports_2.RecognitionStatus.Error: + reason = Exports_1.CancellationErrorCode.ServiceError; + break; + case Exports_2.RecognitionStatus.TooManyRequests: + reason = Exports_1.CancellationErrorCode.TooManyRequests; + break; + default: + reason = Exports_1.CancellationErrorCode.NoError; + break; + } + return reason; + }; + return EnumTranslation; +}()); +exports.EnumTranslation = EnumTranslation; + + + +/***/ }), +/* 134 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * @class SynthesisStatus + * @private + */ +var SynthesisStatus; +(function (SynthesisStatus) { + /** + * The response contains valid audio data. + * @member SynthesisStatus.Success + */ + SynthesisStatus[SynthesisStatus["Success"] = 0] = "Success"; + /** + * Indicates the end of audio data. No valid audio data is included in the message. + * @member SynthesisStatus.SynthesisEnd + */ + SynthesisStatus[SynthesisStatus["SynthesisEnd"] = 1] = "SynthesisEnd"; + /** + * Indicates an error occurred during synthesis data processing. + * @member SynthesisStatus.Error + */ + SynthesisStatus[SynthesisStatus["Error"] = 2] = "Error"; +})(SynthesisStatus = exports.SynthesisStatus || (exports.SynthesisStatus = {})); +var RecognitionStatus; +(function (RecognitionStatus) { + RecognitionStatus[RecognitionStatus["Success"] = 0] = "Success"; + RecognitionStatus[RecognitionStatus["NoMatch"] = 1] = "NoMatch"; + RecognitionStatus[RecognitionStatus["InitialSilenceTimeout"] = 2] = "InitialSilenceTimeout"; + RecognitionStatus[RecognitionStatus["BabbleTimeout"] = 3] = "BabbleTimeout"; + RecognitionStatus[RecognitionStatus["Error"] = 4] = "Error"; + RecognitionStatus[RecognitionStatus["EndOfDictation"] = 5] = "EndOfDictation"; + RecognitionStatus[RecognitionStatus["TooManyRequests"] = 6] = "TooManyRequests"; +})(RecognitionStatus = exports.RecognitionStatus || (exports.RecognitionStatus = {})); + + + +/***/ }), +/* 135 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var TranslationSynthesisEnd = /** @class */ (function () { + function TranslationSynthesisEnd(json) { + this.privSynthesisEnd = JSON.parse(json); + this.privSynthesisEnd.SynthesisStatus = Exports_1.SynthesisStatus[this.privSynthesisEnd.SynthesisStatus]; + } + TranslationSynthesisEnd.fromJSON = function (json) { + return new TranslationSynthesisEnd(json); + }; + Object.defineProperty(TranslationSynthesisEnd.prototype, "SynthesisStatus", { + get: function () { + return this.privSynthesisEnd.SynthesisStatus; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TranslationSynthesisEnd.prototype, "FailureReason", { + get: function () { + return this.privSynthesisEnd.FailureReason; + }, + enumerable: true, + configurable: true + }); + return TranslationSynthesisEnd; +}()); +exports.TranslationSynthesisEnd = TranslationSynthesisEnd; + + + +/***/ }), +/* 136 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var TranslationStatus_1 = __webpack_require__(21); +var TranslationHypothesis = /** @class */ (function () { + function TranslationHypothesis(json) { + this.privTranslationHypothesis = JSON.parse(json); + this.privTranslationHypothesis.Translation.TranslationStatus = TranslationStatus_1.TranslationStatus[this.privTranslationHypothesis.Translation.TranslationStatus]; + } + TranslationHypothesis.fromJSON = function (json) { + return new TranslationHypothesis(json); + }; + Object.defineProperty(TranslationHypothesis.prototype, "Duration", { + get: function () { + return this.privTranslationHypothesis.Duration; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TranslationHypothesis.prototype, "Offset", { + get: function () { + return this.privTranslationHypothesis.Offset; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TranslationHypothesis.prototype, "Text", { + get: function () { + return this.privTranslationHypothesis.Text; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TranslationHypothesis.prototype, "Translation", { + get: function () { + return this.privTranslationHypothesis.Translation; + }, + enumerable: true, + configurable: true + }); + return TranslationHypothesis; +}()); +exports.TranslationHypothesis = TranslationHypothesis; + + + +/***/ }), +/* 137 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var TranslationStatus_1 = __webpack_require__(21); +var TranslationPhrase = /** @class */ (function () { + function TranslationPhrase(json) { + this.privTranslationPhrase = JSON.parse(json); + this.privTranslationPhrase.RecognitionStatus = Exports_1.RecognitionStatus[this.privTranslationPhrase.RecognitionStatus]; + if (this.privTranslationPhrase.Translation !== undefined) { + this.privTranslationPhrase.Translation.TranslationStatus = TranslationStatus_1.TranslationStatus[this.privTranslationPhrase.Translation.TranslationStatus]; + } + } + TranslationPhrase.fromJSON = function (json) { + return new TranslationPhrase(json); + }; + Object.defineProperty(TranslationPhrase.prototype, "RecognitionStatus", { + get: function () { + return this.privTranslationPhrase.RecognitionStatus; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TranslationPhrase.prototype, "Offset", { + get: function () { + return this.privTranslationPhrase.Offset; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TranslationPhrase.prototype, "Duration", { + get: function () { + return this.privTranslationPhrase.Duration; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TranslationPhrase.prototype, "Text", { + get: function () { + return this.privTranslationPhrase.Text; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TranslationPhrase.prototype, "Translation", { + get: function () { + return this.privTranslationPhrase.Translation; + }, + enumerable: true, + configurable: true + }); + return TranslationPhrase; +}()); +exports.TranslationPhrase = TranslationPhrase; + + + +/***/ }), +/* 138 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(4); +var Exports_2 = __webpack_require__(31); +var Exports_3 = __webpack_require__(26); +// tslint:disable-next-line:max-classes-per-file +var TranslationServiceRecognizer = /** @class */ (function (_super) { + __extends(TranslationServiceRecognizer, _super); + function TranslationServiceRecognizer(authentication, connectionFactory, audioSource, recognizerConfig, translationRecognizer) { + var _this = _super.call(this, authentication, connectionFactory, audioSource, recognizerConfig, translationRecognizer) || this; + _this.privTranslationRecognizer = translationRecognizer; + return _this; + } + TranslationServiceRecognizer.prototype.processTypeSpecificMessages = function (connectionMessage) { + var resultProps = new Exports_2.PropertyCollection(); + var processed = false; + if (connectionMessage.messageType === Exports_1.MessageType.Text) { + resultProps.setProperty(Exports_2.PropertyId.SpeechServiceResponse_JsonResult, connectionMessage.textBody); + } + switch (connectionMessage.path.toLowerCase()) { + case "translation.hypothesis": + var result = this.fireEventForResult(Exports_3.TranslationHypothesis.fromJSON(connectionMessage.textBody), resultProps); + this.privRequestSession.onHypothesis(this.privRequestSession.currentTurnAudioOffset + result.offset); + if (!!this.privTranslationRecognizer.recognizing) { + try { + this.privTranslationRecognizer.recognizing(this.privTranslationRecognizer, result); + /* tslint:disable:no-empty */ + } + catch (error) { + // Not going to let errors in the event handler + // trip things up. + } + } + processed = true; + break; + case "translation.phrase": + var translatedPhrase = Exports_3.TranslationPhrase.fromJSON(connectionMessage.textBody); + this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset + translatedPhrase.Offset + translatedPhrase.Duration); + if (translatedPhrase.RecognitionStatus === Exports_3.RecognitionStatus.Success) { + // OK, the recognition was successful. How'd the translation do? + var result_1 = this.fireEventForResult(translatedPhrase, resultProps); + if (!!this.privTranslationRecognizer.recognized) { + try { + this.privTranslationRecognizer.recognized(this.privTranslationRecognizer, result_1); + /* tslint:disable:no-empty */ + } + catch (error) { + // Not going to let errors in the event handler + // trip things up. + } + } + // report result to promise. + if (!!this.privSuccessCallback) { + try { + this.privSuccessCallback(result_1.result); + } + catch (e) { + if (!!this.privErrorCallback) { + this.privErrorCallback(e); + } + } + // Only invoke the call back once. + // and if it's successful don't invoke the + // error after that. + this.privSuccessCallback = undefined; + this.privErrorCallback = undefined; + } + break; + } + else { + var reason = Exports_3.EnumTranslation.implTranslateRecognitionResult(translatedPhrase.RecognitionStatus); + var result_2 = new Exports_2.TranslationRecognitionResult(undefined, this.privRequestSession.requestId, reason, translatedPhrase.Text, translatedPhrase.Duration, this.privRequestSession.currentTurnAudioOffset + translatedPhrase.Offset, undefined, connectionMessage.textBody, resultProps); + if (reason === Exports_2.ResultReason.Canceled) { + var cancelReason = Exports_3.EnumTranslation.implTranslateCancelResult(translatedPhrase.RecognitionStatus); + this.cancelRecognitionLocal(cancelReason, Exports_3.EnumTranslation.implTranslateCancelErrorCode(translatedPhrase.RecognitionStatus), undefined); + } + else { + if (!(this.privRequestSession.isSpeechEnded && reason === Exports_2.ResultReason.NoMatch && translatedPhrase.RecognitionStatus !== Exports_3.RecognitionStatus.InitialSilenceTimeout)) { + var ev = new Exports_2.TranslationRecognitionEventArgs(result_2, result_2.offset, this.privRequestSession.sessionId); + if (!!this.privTranslationRecognizer.recognized) { + try { + this.privTranslationRecognizer.recognized(this.privTranslationRecognizer, ev); + /* tslint:disable:no-empty */ + } + catch (error) { + // Not going to let errors in the event handler + // trip things up. + } + } + } + // report result to promise. + if (!!this.privSuccessCallback) { + try { + this.privSuccessCallback(result_2); + } + catch (e) { + if (!!this.privErrorCallback) { + this.privErrorCallback(e); + } + } + // Only invoke the call back once. + // and if it's successful don't invoke the + // error after that. + this.privSuccessCallback = undefined; + this.privErrorCallback = undefined; + } + } + } + processed = true; + break; + case "translation.synthesis": + this.sendSynthesisAudio(connectionMessage.binaryBody, this.privRequestSession.sessionId); + processed = true; + break; + case "translation.synthesis.end": + var synthEnd = Exports_3.TranslationSynthesisEnd.fromJSON(connectionMessage.textBody); + switch (synthEnd.SynthesisStatus) { + case Exports_3.SynthesisStatus.Error: + if (!!this.privTranslationRecognizer.synthesizing) { + var result_3 = new Exports_2.TranslationSynthesisResult(Exports_2.ResultReason.Canceled, undefined); + var retEvent = new Exports_2.TranslationSynthesisEventArgs(result_3, this.privRequestSession.sessionId); + try { + this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer, retEvent); + /* tslint:disable:no-empty */ + } + catch (error) { + // Not going to let errors in the event handler + // trip things up. + } + } + if (!!this.privTranslationRecognizer.canceled) { + // And raise a canceled event to send the rich(er) error message back. + var canceledResult = new Exports_2.TranslationRecognitionCanceledEventArgs(this.privRequestSession.sessionId, Exports_2.CancellationReason.Error, synthEnd.FailureReason, Exports_2.CancellationErrorCode.ServiceError, null); + try { + this.privTranslationRecognizer.canceled(this.privTranslationRecognizer, canceledResult); + /* tslint:disable:no-empty */ + } + catch (error) { + // Not going to let errors in the event handler + // trip things up. + } + } + break; + case Exports_3.SynthesisStatus.Success: + this.sendSynthesisAudio(undefined, this.privRequestSession.sessionId); + break; + default: + break; + } + processed = true; + break; + default: + break; + } + return processed; + }; + // Cancels recognition. + TranslationServiceRecognizer.prototype.cancelRecognition = function (sessionId, requestId, cancellationReason, errorCode, error) { + var properties = new Exports_2.PropertyCollection(); + properties.setProperty(Exports_3.CancellationErrorCodePropertyName, Exports_2.CancellationErrorCode[errorCode]); + if (!!this.privTranslationRecognizer.canceled) { + var cancelEvent = new Exports_2.TranslationRecognitionCanceledEventArgs(sessionId, cancellationReason, error, errorCode, undefined); + try { + this.privTranslationRecognizer.canceled(this.privTranslationRecognizer, cancelEvent); + /* tslint:disable:no-empty */ + } + catch (_a) { } + } + if (!!this.privSuccessCallback) { + var result = new Exports_2.TranslationRecognitionResult(undefined, // Translations + requestId, Exports_2.ResultReason.Canceled, undefined, // Text + undefined, // Druation + undefined, // Offset + error, undefined, // Json + properties); + try { + this.privSuccessCallback(result); + /* tslint:disable:no-empty */ + this.privSuccessCallback = undefined; + } + catch (_b) { } + } + }; + TranslationServiceRecognizer.prototype.fireEventForResult = function (serviceResult, properties) { + var translations; + if (undefined !== serviceResult.Translation.Translations) { + translations = new Exports_2.Translations(); + for (var _i = 0, _a = serviceResult.Translation.Translations; _i < _a.length; _i++) { + var translation = _a[_i]; + translations.set(translation.Language, translation.Text); + } + } + var resultReason; + if (serviceResult instanceof Exports_3.TranslationPhrase) { + if (serviceResult.Translation.TranslationStatus === Exports_1.TranslationStatus.Success) { + resultReason = Exports_2.ResultReason.TranslatedSpeech; + } + else { + resultReason = Exports_2.ResultReason.RecognizedSpeech; + } + } + else { + resultReason = Exports_2.ResultReason.TranslatingSpeech; + } + var offset = serviceResult.Offset + this.privRequestSession.currentTurnAudioOffset; + var result = new Exports_2.TranslationRecognitionResult(translations, this.privRequestSession.requestId, resultReason, serviceResult.Text, serviceResult.Duration, offset, serviceResult.Translation.FailureReason, JSON.stringify(serviceResult), properties); + var ev = new Exports_2.TranslationRecognitionEventArgs(result, offset, this.privRequestSession.sessionId); + return ev; + }; + TranslationServiceRecognizer.prototype.sendSynthesisAudio = function (audio, sessionId) { + var reason = (undefined === audio) ? Exports_2.ResultReason.SynthesizingAudioCompleted : Exports_2.ResultReason.SynthesizingAudio; + var result = new Exports_2.TranslationSynthesisResult(reason, audio); + var retEvent = new Exports_2.TranslationSynthesisEventArgs(result, sessionId); + if (!!this.privTranslationRecognizer.synthesizing) { + try { + this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer, retEvent); + /* tslint:disable:no-empty */ + } + catch (error) { + // Not going to let errors in the event handler + // trip things up. + } + } + }; + return TranslationServiceRecognizer; +}(Exports_3.ServiceRecognizerBase)); +exports.TranslationServiceRecognizer = TranslationServiceRecognizer; + + + +/***/ }), +/* 139 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var SpeechDetected = /** @class */ (function () { + function SpeechDetected(json) { + this.privSpeechStartDetected = JSON.parse(json); + } + SpeechDetected.fromJSON = function (json) { + return new SpeechDetected(json); + }; + Object.defineProperty(SpeechDetected.prototype, "Offset", { + get: function () { + return this.privSpeechStartDetected.Offset; + }, + enumerable: true, + configurable: true + }); + return SpeechDetected; +}()); +exports.SpeechDetected = SpeechDetected; + + + +/***/ }), +/* 140 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var SpeechHypothesis = /** @class */ (function () { + function SpeechHypothesis(json) { + this.privSpeechHypothesis = JSON.parse(json); + } + SpeechHypothesis.fromJSON = function (json) { + return new SpeechHypothesis(json); + }; + Object.defineProperty(SpeechHypothesis.prototype, "Text", { + get: function () { + return this.privSpeechHypothesis.Text; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechHypothesis.prototype, "Offset", { + get: function () { + return this.privSpeechHypothesis.Offset; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechHypothesis.prototype, "Duration", { + get: function () { + return this.privSpeechHypothesis.Duration; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechHypothesis.prototype, "Language", { + get: function () { + return this.privSpeechHypothesis.PrimaryLanguage === undefined ? undefined : this.privSpeechHypothesis.PrimaryLanguage.Language; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechHypothesis.prototype, "LanguageDetectionConfidence", { + get: function () { + return this.privSpeechHypothesis.PrimaryLanguage === undefined ? undefined : this.privSpeechHypothesis.PrimaryLanguage.Confidence; + }, + enumerable: true, + configurable: true + }); + return SpeechHypothesis; +}()); +exports.SpeechHypothesis = SpeechHypothesis; + + + +/***/ }), +/* 141 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(31); +var Exports_2 = __webpack_require__(26); +// tslint:disable-next-line:max-classes-per-file +var SpeechServiceRecognizer = /** @class */ (function (_super) { + __extends(SpeechServiceRecognizer, _super); + function SpeechServiceRecognizer(authentication, connectionFactory, audioSource, recognizerConfig, speechRecognizer) { + var _this = _super.call(this, authentication, connectionFactory, audioSource, recognizerConfig, speechRecognizer) || this; + _this.privSpeechRecognizer = speechRecognizer; + if (recognizerConfig.autoDetectSourceLanguages !== undefined) { + var sourceLanguages = recognizerConfig.autoDetectSourceLanguages.split(","); + _this.privSpeechContext.setSection("languageId", { + languages: sourceLanguages, + onSuccess: { action: "Recognize" }, + onUnknown: { action: "None" } + }); + _this.privSpeechContext.setSection("phraseOutput", { + interimResults: { + resultType: "Auto" + }, + phraseResults: { + resultType: "Always" + } + }); + } + return _this; + } + SpeechServiceRecognizer.prototype.processTypeSpecificMessages = function (connectionMessage) { + var result; + var resultProps = new Exports_1.PropertyCollection(); + resultProps.setProperty(Exports_1.PropertyId.SpeechServiceResponse_JsonResult, connectionMessage.textBody); + var processed = false; + switch (connectionMessage.path.toLowerCase()) { + case "speech.hypothesis": + case "speech.fragment": + var hypothesis = Exports_2.SpeechHypothesis.fromJSON(connectionMessage.textBody); + var offset = hypothesis.Offset + this.privRequestSession.currentTurnAudioOffset; + result = new Exports_1.SpeechRecognitionResult(this.privRequestSession.requestId, Exports_1.ResultReason.RecognizingSpeech, hypothesis.Text, hypothesis.Duration, offset, hypothesis.Language, hypothesis.LanguageDetectionConfidence, undefined, connectionMessage.textBody, resultProps); + this.privRequestSession.onHypothesis(offset); + var ev = new Exports_1.SpeechRecognitionEventArgs(result, hypothesis.Duration, this.privRequestSession.sessionId); + if (!!this.privSpeechRecognizer.recognizing) { + try { + this.privSpeechRecognizer.recognizing(this.privSpeechRecognizer, ev); + /* tslint:disable:no-empty */ + } + catch (error) { + // Not going to let errors in the event handler + // trip things up. + } + } + processed = true; + break; + case "speech.phrase": + var simple = Exports_2.SimpleSpeechPhrase.fromJSON(connectionMessage.textBody); + var resultReason = Exports_2.EnumTranslation.implTranslateRecognitionResult(simple.RecognitionStatus); + this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset + simple.Offset + simple.Duration); + if (Exports_1.ResultReason.Canceled === resultReason) { + var cancelReason = Exports_2.EnumTranslation.implTranslateCancelResult(simple.RecognitionStatus); + this.cancelRecognitionLocal(cancelReason, Exports_2.EnumTranslation.implTranslateCancelErrorCode(simple.RecognitionStatus), undefined); + } + else { + if (!(this.privRequestSession.isSpeechEnded && resultReason === Exports_1.ResultReason.NoMatch && simple.RecognitionStatus !== Exports_2.RecognitionStatus.InitialSilenceTimeout)) { + if (this.privRecognizerConfig.parameters.getProperty(Exports_2.OutputFormatPropertyName) === Exports_1.OutputFormat[Exports_1.OutputFormat.Simple]) { + result = new Exports_1.SpeechRecognitionResult(this.privRequestSession.requestId, resultReason, simple.DisplayText, simple.Duration, simple.Offset + this.privRequestSession.currentTurnAudioOffset, simple.Language, simple.LanguageDetectionConfidence, undefined, connectionMessage.textBody, resultProps); + } + else { + var detailed = Exports_2.DetailedSpeechPhrase.fromJSON(connectionMessage.textBody); + result = new Exports_1.SpeechRecognitionResult(this.privRequestSession.requestId, resultReason, detailed.RecognitionStatus === Exports_2.RecognitionStatus.Success ? detailed.NBest[0].Display : undefined, detailed.Duration, detailed.Offset + this.privRequestSession.currentTurnAudioOffset, detailed.Language, detailed.LanguageDetectionConfidence, undefined, connectionMessage.textBody, resultProps); + } + var event_1 = new Exports_1.SpeechRecognitionEventArgs(result, result.offset, this.privRequestSession.sessionId); + if (!!this.privSpeechRecognizer.recognized) { + try { + this.privSpeechRecognizer.recognized(this.privSpeechRecognizer, event_1); + /* tslint:disable:no-empty */ + } + catch (error) { + // Not going to let errors in the event handler + // trip things up. + } + } + } + if (!!this.privSuccessCallback) { + try { + this.privSuccessCallback(result); + } + catch (e) { + if (!!this.privErrorCallback) { + this.privErrorCallback(e); + } + } + // Only invoke the call back once. + // and if it's successful don't invoke the + // error after that. + this.privSuccessCallback = undefined; + this.privErrorCallback = undefined; + } + } + processed = true; + break; + default: + break; + } + return processed; + }; + // Cancels recognition. + SpeechServiceRecognizer.prototype.cancelRecognition = function (sessionId, requestId, cancellationReason, errorCode, error) { + var properties = new Exports_1.PropertyCollection(); + properties.setProperty(Exports_2.CancellationErrorCodePropertyName, Exports_1.CancellationErrorCode[errorCode]); + if (!!this.privSpeechRecognizer.canceled) { + var cancelEvent = new Exports_1.SpeechRecognitionCanceledEventArgs(cancellationReason, error, errorCode, undefined, sessionId); + try { + this.privSpeechRecognizer.canceled(this.privSpeechRecognizer, cancelEvent); + /* tslint:disable:no-empty */ + } + catch (_a) { } + } + if (!!this.privSuccessCallback) { + var result = new Exports_1.SpeechRecognitionResult(requestId, Exports_1.ResultReason.Canceled, undefined, // Text + undefined, // Duration + undefined, // Offset + undefined, // Language + undefined, // Language Detection Confidence + error, undefined, // Json + properties); + try { + this.privSuccessCallback(result); + this.privSuccessCallback = undefined; + /* tslint:disable:no-empty */ + } + catch (_b) { } + } + }; + return SpeechServiceRecognizer; +}(Exports_2.ServiceRecognizerBase)); +exports.SpeechServiceRecognizer = SpeechServiceRecognizer; + + + +/***/ }), +/* 142 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var DetailedSpeechPhrase = /** @class */ (function () { + function DetailedSpeechPhrase(json) { + this.privDetailedSpeechPhrase = JSON.parse(json); + this.privDetailedSpeechPhrase.RecognitionStatus = Exports_1.RecognitionStatus[this.privDetailedSpeechPhrase.RecognitionStatus]; + } + DetailedSpeechPhrase.fromJSON = function (json) { + return new DetailedSpeechPhrase(json); + }; + Object.defineProperty(DetailedSpeechPhrase.prototype, "RecognitionStatus", { + get: function () { + return this.privDetailedSpeechPhrase.RecognitionStatus; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DetailedSpeechPhrase.prototype, "NBest", { + get: function () { + return this.privDetailedSpeechPhrase.NBest; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DetailedSpeechPhrase.prototype, "Duration", { + get: function () { + return this.privDetailedSpeechPhrase.Duration; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DetailedSpeechPhrase.prototype, "Offset", { + get: function () { + return this.privDetailedSpeechPhrase.Offset; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DetailedSpeechPhrase.prototype, "Language", { + get: function () { + return this.privDetailedSpeechPhrase.PrimaryLanguage === undefined ? undefined : this.privDetailedSpeechPhrase.PrimaryLanguage.Language; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DetailedSpeechPhrase.prototype, "LanguageDetectionConfidence", { + get: function () { + return this.privDetailedSpeechPhrase.PrimaryLanguage === undefined ? undefined : this.privDetailedSpeechPhrase.PrimaryLanguage.Confidence; + }, + enumerable: true, + configurable: true + }); + return DetailedSpeechPhrase; +}()); +exports.DetailedSpeechPhrase = DetailedSpeechPhrase; + + + +/***/ }), +/* 143 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var SimpleSpeechPhrase = /** @class */ (function () { + function SimpleSpeechPhrase(json) { + this.privSimpleSpeechPhrase = JSON.parse(json); + this.privSimpleSpeechPhrase.RecognitionStatus = Exports_1.RecognitionStatus[this.privSimpleSpeechPhrase.RecognitionStatus]; + } + SimpleSpeechPhrase.fromJSON = function (json) { + return new SimpleSpeechPhrase(json); + }; + Object.defineProperty(SimpleSpeechPhrase.prototype, "RecognitionStatus", { + get: function () { + return this.privSimpleSpeechPhrase.RecognitionStatus; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SimpleSpeechPhrase.prototype, "DisplayText", { + get: function () { + return this.privSimpleSpeechPhrase.DisplayText; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SimpleSpeechPhrase.prototype, "Offset", { + get: function () { + return this.privSimpleSpeechPhrase.Offset; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SimpleSpeechPhrase.prototype, "Duration", { + get: function () { + return this.privSimpleSpeechPhrase.Duration; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SimpleSpeechPhrase.prototype, "Language", { + get: function () { + return this.privSimpleSpeechPhrase.PrimaryLanguage === undefined ? undefined : this.privSimpleSpeechPhrase.PrimaryLanguage.Language; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SimpleSpeechPhrase.prototype, "LanguageDetectionConfidence", { + get: function () { + return this.privSimpleSpeechPhrase.PrimaryLanguage === undefined ? undefined : this.privSimpleSpeechPhrase.PrimaryLanguage.Confidence; + }, + enumerable: true, + configurable: true + }); + return SimpleSpeechPhrase; +}()); +exports.SimpleSpeechPhrase = SimpleSpeechPhrase; + + + +/***/ }), +/* 144 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * @class AddedLmIntent + */ +// tslint:disable-next-line:max-classes-per-file +var AddedLmIntent = /** @class */ (function () { + /** + * Creates and initializes an instance of this class. + * @constructor + * @param modelImpl - The model. + * @param intentName - The intent name. + */ + function AddedLmIntent(modelImpl, intentName) { + this.modelImpl = modelImpl; + this.intentName = intentName; + } + return AddedLmIntent; +}()); +exports.AddedLmIntent = AddedLmIntent; + + + +/***/ }), +/* 145 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(4); +var Exports_2 = __webpack_require__(31); +var Exports_3 = __webpack_require__(26); +// tslint:disable-next-line:max-classes-per-file +var IntentServiceRecognizer = /** @class */ (function (_super) { + __extends(IntentServiceRecognizer, _super); + function IntentServiceRecognizer(authentication, connectionFactory, audioSource, recognizerConfig, recognizer) { + var _this = _super.call(this, authentication, connectionFactory, audioSource, recognizerConfig, recognizer) || this; + _this.privIntentRecognizer = recognizer; + _this.privIntentDataSent = false; + return _this; + } + IntentServiceRecognizer.prototype.setIntents = function (addedIntents, umbrellaIntent) { + this.privAddedLmIntents = addedIntents; + this.privUmbrellaIntent = umbrellaIntent; + this.privIntentDataSent = true; + }; + IntentServiceRecognizer.prototype.processTypeSpecificMessages = function (connectionMessage) { + var _this = this; + var result; + var ev; + var processed = false; + var resultProps = new Exports_2.PropertyCollection(); + if (connectionMessage.messageType === Exports_1.MessageType.Text) { + resultProps.setProperty(Exports_2.PropertyId.SpeechServiceResponse_JsonResult, connectionMessage.textBody); + } + switch (connectionMessage.path.toLowerCase()) { + case "speech.hypothesis": + var speechHypothesis = Exports_3.SpeechHypothesis.fromJSON(connectionMessage.textBody); + result = new Exports_2.IntentRecognitionResult(undefined, this.privRequestSession.requestId, Exports_2.ResultReason.RecognizingIntent, speechHypothesis.Text, speechHypothesis.Duration, speechHypothesis.Offset + this.privRequestSession.currentTurnAudioOffset, speechHypothesis.Language, speechHypothesis.LanguageDetectionConfidence, undefined, connectionMessage.textBody, resultProps); + this.privRequestSession.onHypothesis(result.offset); + ev = new Exports_2.IntentRecognitionEventArgs(result, speechHypothesis.Offset + this.privRequestSession.currentTurnAudioOffset, this.privRequestSession.sessionId); + if (!!this.privIntentRecognizer.recognizing) { + try { + this.privIntentRecognizer.recognizing(this.privIntentRecognizer, ev); + /* tslint:disable:no-empty */ + } + catch (error) { + // Not going to let errors in the event handler + // trip things up. + } + } + processed = true; + break; + case "speech.phrase": + var simple = Exports_3.SimpleSpeechPhrase.fromJSON(connectionMessage.textBody); + result = new Exports_2.IntentRecognitionResult(undefined, this.privRequestSession.requestId, Exports_3.EnumTranslation.implTranslateRecognitionResult(simple.RecognitionStatus), simple.DisplayText, simple.Duration, simple.Offset + this.privRequestSession.currentTurnAudioOffset, simple.Language, simple.LanguageDetectionConfidence, undefined, connectionMessage.textBody, resultProps); + ev = new Exports_2.IntentRecognitionEventArgs(result, result.offset, this.privRequestSession.sessionId); + var sendEvent = function () { + if (!!_this.privIntentRecognizer.recognized) { + try { + _this.privIntentRecognizer.recognized(_this.privIntentRecognizer, ev); + /* tslint:disable:no-empty */ + } + catch (error) { + // Not going to let errors in the event handler + // trip things up. + } + } + // report result to promise. + if (!!_this.privSuccessCallback) { + try { + _this.privSuccessCallback(result); + } + catch (e) { + if (!!_this.privErrorCallback) { + _this.privErrorCallback(e); + } + } + // Only invoke the call back once. + // and if it's successful don't invoke the + // error after that. + _this.privSuccessCallback = undefined; + _this.privErrorCallback = undefined; + } + }; + // If intent data was sent, the terminal result for this recognizer is an intent being found. + // If no intent data was sent, the terminal event is speech recognition being successful. + if (false === this.privIntentDataSent || Exports_2.ResultReason.NoMatch === ev.result.reason) { + // Advance the buffers. + this.privRequestSession.onPhraseRecognized(ev.offset + ev.result.duration); + sendEvent(); + } + else { + // Squirrel away the args, when the response event arrives it will build upon them + // and then return + this.privPendingIntentArgs = ev; + } + processed = true; + break; + case "response": + // Response from LUIS + ev = this.privPendingIntentArgs; + this.privPendingIntentArgs = undefined; + if (undefined === ev) { + if ("" === connectionMessage.textBody) { + // This condition happens if there is nothing but silence in the + // audio sent to the service. + return; + } + // Odd... Not sure this can happen + ev = new Exports_2.IntentRecognitionEventArgs(new Exports_2.IntentRecognitionResult(), 0 /*TODO*/, this.privRequestSession.sessionId); + } + var intentResponse = Exports_3.IntentResponse.fromJSON(connectionMessage.textBody); + // If LUIS didn't return anything, send the existing event, else + // modify it to show the match. + // See if the intent found is in the list of intents asked for. + var addedIntent = this.privAddedLmIntents[intentResponse.topScoringIntent.intent]; + if (this.privUmbrellaIntent !== undefined) { + addedIntent = this.privUmbrellaIntent; + } + if (null !== intentResponse && addedIntent !== undefined) { + var intentId = addedIntent.intentName === undefined ? intentResponse.topScoringIntent.intent : addedIntent.intentName; + var reason = ev.result.reason; + if (undefined !== intentId) { + reason = Exports_2.ResultReason.RecognizedIntent; + } + // make sure, properties is set. + var properties = (undefined !== ev.result.properties) ? + ev.result.properties : new Exports_2.PropertyCollection(); + properties.setProperty(Exports_2.PropertyId.LanguageUnderstandingServiceResponse_JsonResult, connectionMessage.textBody); + ev = new Exports_2.IntentRecognitionEventArgs(new Exports_2.IntentRecognitionResult(intentId, ev.result.resultId, reason, ev.result.text, ev.result.duration, ev.result.offset, undefined, undefined, ev.result.errorDetails, ev.result.json, properties), ev.offset, ev.sessionId); + } + this.privRequestSession.onPhraseRecognized(ev.offset + ev.result.duration); + if (!!this.privIntentRecognizer.recognized) { + try { + this.privIntentRecognizer.recognized(this.privIntentRecognizer, ev); + /* tslint:disable:no-empty */ + } + catch (error) { + // Not going to let errors in the event handler + // trip things up. + } + } + // report result to promise. + if (!!this.privSuccessCallback) { + try { + this.privSuccessCallback(ev.result); + } + catch (e) { + if (!!this.privErrorCallback) { + this.privErrorCallback(e); + } + } + // Only invoke the call back once. + // and if it's successful don't invoke the + // error after that. + this.privSuccessCallback = undefined; + this.privErrorCallback = undefined; + } + processed = true; + break; + default: + break; + } + return processed; + }; + // Cancels recognition. + IntentServiceRecognizer.prototype.cancelRecognition = function (sessionId, requestId, cancellationReason, errorCode, error) { + var properties = new Exports_2.PropertyCollection(); + properties.setProperty(Exports_3.CancellationErrorCodePropertyName, Exports_2.CancellationErrorCode[errorCode]); + if (!!this.privIntentRecognizer.canceled) { + var cancelEvent = new Exports_2.IntentRecognitionCanceledEventArgs(cancellationReason, error, errorCode, undefined, undefined, sessionId); + try { + this.privIntentRecognizer.canceled(this.privIntentRecognizer, cancelEvent); + /* tslint:disable:no-empty */ + } + catch (_a) { } + } + if (!!this.privSuccessCallback) { + var result = new Exports_2.IntentRecognitionResult(undefined, // Intent Id + requestId, Exports_2.ResultReason.Canceled, undefined, // Text + undefined, // Duration + undefined, // Offset + undefined, // Language + undefined, // LanguageDetectionConfidence + error, undefined, // Json + properties); + try { + this.privSuccessCallback(result); + this.privSuccessCallback = undefined; + /* tslint:disable:no-empty */ + } + catch (_b) { } + } + }; + return IntentServiceRecognizer; +}(Exports_3.ServiceRecognizerBase)); +exports.IntentServiceRecognizer = IntentServiceRecognizer; + + + +/***/ }), +/* 146 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +// response +Object.defineProperty(exports, "__esModule", { value: true }); +var IntentResponse = /** @class */ (function () { + function IntentResponse(json) { + this.privIntentResponse = JSON.parse(json); + } + IntentResponse.fromJSON = function (json) { + return new IntentResponse(json); + }; + Object.defineProperty(IntentResponse.prototype, "query", { + get: function () { + return this.privIntentResponse.query; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(IntentResponse.prototype, "topScoringIntent", { + get: function () { + return this.privIntentResponse.topScoringIntent; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(IntentResponse.prototype, "entities", { + get: function () { + return this.privIntentResponse.entities; + }, + enumerable: true, + configurable: true + }); + return IntentResponse; +}()); +exports.IntentResponse = IntentResponse; + + + +/***/ }), +/* 147 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(4); +var RecognitionEvents_1 = __webpack_require__(126); +var ServiceTelemetryListener_Internal_1 = __webpack_require__(148); +var RequestSession = /** @class */ (function () { + function RequestSession(audioSourceId) { + var _this = this; + this.privIsDisposed = false; + this.privDetachables = new Array(); + this.privIsAudioNodeDetached = false; + this.privIsRecognizing = false; + this.privIsSpeechEnded = false; + this.privTurnStartAudioOffset = 0; + this.privLastRecoOffset = 0; + this.privHypothesisReceived = false; + this.privBytesSent = 0; + this.privRecogNumber = 0; + this.onAudioSourceAttachCompleted = function (audioNode, isError, error) { + _this.privAudioNode = audioNode; + _this.privIsAudioNodeDetached = false; + if (isError) { + _this.onComplete(); + } + else { + _this.onEvent(new RecognitionEvents_1.ListeningStartedEvent(_this.privRequestId, _this.privSessionId, _this.privAudioSourceId, _this.privAudioNodeId)); + } + }; + this.onPreConnectionStart = function (authFetchEventId, connectionId) { + _this.privAuthFetchEventId = authFetchEventId; + _this.privSessionId = connectionId; + _this.onEvent(new RecognitionEvents_1.ConnectingToServiceEvent(_this.privRequestId, _this.privAuthFetchEventId, _this.privSessionId)); + }; + this.onAuthCompleted = function (isError, error) { + if (isError) { + _this.onComplete(); + } + }; + this.onConnectionEstablishCompleted = function (statusCode, reason) { + if (statusCode === 200) { + _this.onEvent(new RecognitionEvents_1.RecognitionStartedEvent(_this.requestId, _this.privAudioSourceId, _this.privAudioNodeId, _this.privAuthFetchEventId, _this.privSessionId)); + if (!!_this.privAudioNode) { + _this.privAudioNode.replay(); + } + _this.privTurnStartAudioOffset = _this.privLastRecoOffset; + _this.privBytesSent = 0; + return; + } + else if (statusCode === 403) { + _this.onComplete(); + } + }; + this.onServiceTurnEndResponse = function (continuousRecognition) { + _this.privTurnDeferral.resolve(true); + if (!continuousRecognition || _this.isSpeechEnded) { + _this.onComplete(); + } + else { + // Start a new request set. + _this.privTurnStartAudioOffset = _this.privLastRecoOffset; + _this.privRequestId = Exports_1.createNoDashGuid(); + _this.privAudioNode.replay(); + } + }; + this.onServiceTurnStartResponse = function () { + if (_this.privTurnDeferral.state() === Exports_1.PromiseState.None) { + // What? How are we starting a turn with another not done? + _this.privTurnDeferral.reject("Another turn started before current completed."); + } + _this.privTurnDeferral = new Exports_1.Deferred(); + }; + this.dispose = function (error) { + if (!_this.privIsDisposed) { + // we should have completed by now. If we did not its an unknown error. + _this.privIsDisposed = true; + for (var _i = 0, _a = _this.privDetachables; _i < _a.length; _i++) { + var detachable = _a[_i]; + detachable.detach(); + } + _this.privServiceTelemetryListener.dispose(); + } + }; + this.getTelemetry = function () { + if (_this.privServiceTelemetryListener.hasTelemetry) { + return _this.privServiceTelemetryListener.getTelemetry(); + } + else { + return null; + } + }; + this.onEvent = function (event) { + if (!!_this.privServiceTelemetryListener) { + _this.privServiceTelemetryListener.onEvent(event); + } + Exports_1.Events.instance.onEvent(event); + }; + this.onComplete = function () { + if (!!_this.privIsRecognizing) { + _this.privIsRecognizing = false; + _this.detachAudioNode(); + } + }; + this.detachAudioNode = function () { + if (!_this.privIsAudioNodeDetached) { + _this.privIsAudioNodeDetached = true; + if (_this.privAudioNode) { + _this.privAudioNode.detach(); + } + } + }; + this.privAudioSourceId = audioSourceId; + this.privRequestId = Exports_1.createNoDashGuid(); + this.privAudioNodeId = Exports_1.createNoDashGuid(); + this.privTurnDeferral = new Exports_1.Deferred(); + // We're not in a turn, so resolve. + this.privTurnDeferral.resolve(true); + } + Object.defineProperty(RequestSession.prototype, "sessionId", { + get: function () { + return this.privSessionId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RequestSession.prototype, "requestId", { + get: function () { + return this.privRequestId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RequestSession.prototype, "audioNodeId", { + get: function () { + return this.privAudioNodeId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RequestSession.prototype, "turnCompletionPromise", { + get: function () { + return this.privTurnDeferral.promise(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RequestSession.prototype, "isSpeechEnded", { + get: function () { + return this.privIsSpeechEnded; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RequestSession.prototype, "isRecognizing", { + get: function () { + return this.privIsRecognizing; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RequestSession.prototype, "currentTurnAudioOffset", { + get: function () { + return this.privTurnStartAudioOffset; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RequestSession.prototype, "recogNumber", { + get: function () { + return this.privRecogNumber; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RequestSession.prototype, "bytesSent", { + // The number of bytes sent for the current connection. + // Counter is reset to 0 each time a connection is established. + get: function () { + return this.privBytesSent; + }, + enumerable: true, + configurable: true + }); + RequestSession.prototype.listenForServiceTelemetry = function (eventSource) { + if (!!this.privServiceTelemetryListener) { + this.privDetachables.push(eventSource.attachListener(this.privServiceTelemetryListener)); + } + }; + RequestSession.prototype.startNewRecognition = function () { + this.privIsSpeechEnded = false; + this.privIsRecognizing = true; + this.privTurnStartAudioOffset = 0; + this.privLastRecoOffset = 0; + this.privRequestId = Exports_1.createNoDashGuid(); + this.privRecogNumber++; + this.privServiceTelemetryListener = new ServiceTelemetryListener_Internal_1.ServiceTelemetryListener(this.privRequestId, this.privAudioSourceId, this.privAudioNodeId); + this.onEvent(new RecognitionEvents_1.RecognitionTriggeredEvent(this.requestId, this.privSessionId, this.privAudioSourceId, this.privAudioNodeId)); + }; + RequestSession.prototype.onHypothesis = function (offset) { + if (!this.privHypothesisReceived) { + this.privHypothesisReceived = true; + this.privServiceTelemetryListener.hypothesisReceived(this.privAudioNode.findTimeAtOffset(offset)); + } + }; + RequestSession.prototype.onPhraseRecognized = function (offset) { + this.privServiceTelemetryListener.phraseReceived(this.privAudioNode.findTimeAtOffset(offset)); + this.onServiceRecognized(offset); + }; + RequestSession.prototype.onServiceRecognized = function (offset) { + this.privLastRecoOffset = offset; + this.privHypothesisReceived = false; + this.privAudioNode.shrinkBuffers(offset); + }; + RequestSession.prototype.onAudioSent = function (bytesSent) { + this.privBytesSent += bytesSent; + }; + RequestSession.prototype.onStopRecognizing = function () { + this.onComplete(); + }; + // Should be called with the audioNode for this session has indicated that it is out of speech. + RequestSession.prototype.onSpeechEnded = function () { + this.privIsSpeechEnded = true; + }; + return RequestSession; +}()); +exports.RequestSession = RequestSession; + + + +/***/ }), +/* 148 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(4); +var RecognitionEvents_1 = __webpack_require__(126); +// tslint:disable-next-line:max-classes-per-file +var ServiceTelemetryListener = /** @class */ (function () { + function ServiceTelemetryListener(requestId, audioSourceId, audioNodeId) { + var _this = this; + this.privIsDisposed = false; + this.privListeningTriggerMetric = null; + this.privMicMetric = null; + this.privConnectionEstablishMetric = null; + this.onEvent = function (e) { + if (_this.privIsDisposed) { + return; + } + if (e instanceof RecognitionEvents_1.RecognitionTriggeredEvent && e.requestId === _this.privRequestId) { + _this.privListeningTriggerMetric = { + End: e.eventTime, + Name: "ListeningTrigger", + Start: e.eventTime, + }; + } + if (e instanceof Exports_1.AudioStreamNodeAttachingEvent && e.audioSourceId === _this.privAudioSourceId && e.audioNodeId === _this.privAudioNodeId) { + _this.privMicStartTime = e.eventTime; + } + if (e instanceof Exports_1.AudioStreamNodeAttachedEvent && e.audioSourceId === _this.privAudioSourceId && e.audioNodeId === _this.privAudioNodeId) { + _this.privMicStartTime = e.eventTime; + } + if (e instanceof Exports_1.AudioSourceErrorEvent && e.audioSourceId === _this.privAudioSourceId) { + if (!_this.privMicMetric) { + _this.privMicMetric = { + End: e.eventTime, + Error: e.error, + Name: "Microphone", + Start: _this.privMicStartTime, + }; + } + } + if (e instanceof Exports_1.AudioStreamNodeErrorEvent && e.audioSourceId === _this.privAudioSourceId && e.audioNodeId === _this.privAudioNodeId) { + if (!_this.privMicMetric) { + _this.privMicMetric = { + End: e.eventTime, + Error: e.error, + Name: "Microphone", + Start: _this.privMicStartTime, + }; + } + } + if (e instanceof Exports_1.AudioStreamNodeDetachedEvent && e.audioSourceId === _this.privAudioSourceId && e.audioNodeId === _this.privAudioNodeId) { + if (!_this.privMicMetric) { + _this.privMicMetric = { + End: e.eventTime, + Name: "Microphone", + Start: _this.privMicStartTime, + }; + } + } + if (e instanceof RecognitionEvents_1.ConnectingToServiceEvent && e.requestId === _this.privRequestId) { + _this.privConnectionId = e.sessionId; + } + if (e instanceof Exports_1.ConnectionStartEvent && e.connectionId === _this.privConnectionId) { + _this.privConnectionStartTime = e.eventTime; + } + if (e instanceof Exports_1.ConnectionEstablishedEvent && e.connectionId === _this.privConnectionId) { + if (!_this.privConnectionEstablishMetric) { + _this.privConnectionEstablishMetric = { + End: e.eventTime, + Id: _this.privConnectionId, + Name: "Connection", + Start: _this.privConnectionStartTime, + }; + } + } + if (e instanceof Exports_1.ConnectionEstablishErrorEvent && e.connectionId === _this.privConnectionId) { + if (!_this.privConnectionEstablishMetric) { + _this.privConnectionEstablishMetric = { + End: e.eventTime, + Error: _this.getConnectionError(e.statusCode), + Id: _this.privConnectionId, + Name: "Connection", + Start: _this.privConnectionStartTime, + }; + } + } + if (e instanceof Exports_1.ConnectionMessageReceivedEvent && e.connectionId === _this.privConnectionId) { + if (e.message && e.message.headers && e.message.headers.path) { + if (!_this.privReceivedMessages[e.message.headers.path]) { + _this.privReceivedMessages[e.message.headers.path] = new Array(); + } + _this.privReceivedMessages[e.message.headers.path].push(e.networkReceivedTime); + } + } + }; + this.getTelemetry = function () { + var metrics = new Array(); + if (_this.privListeningTriggerMetric) { + metrics.push(_this.privListeningTriggerMetric); + } + if (_this.privMicMetric) { + metrics.push(_this.privMicMetric); + } + if (_this.privConnectionEstablishMetric) { + metrics.push(_this.privConnectionEstablishMetric); + } + if (_this.privPhraseLatencies.length > 0) { + metrics.push({ + PhraseLatencyMs: _this.privPhraseLatencies, + }); + } + if (_this.privHypothesisLatencies.length > 0) { + metrics.push({ + FirstHypothesisLatencyMs: _this.privHypothesisLatencies, + }); + } + var telemetry = { + Metrics: metrics, + ReceivedMessages: _this.privReceivedMessages, + }; + var json = JSON.stringify(telemetry); + // We dont want to send the same telemetry again. So clean those out. + _this.privReceivedMessages = {}; + _this.privListeningTriggerMetric = null; + _this.privMicMetric = null; + _this.privConnectionEstablishMetric = null; + _this.privPhraseLatencies = []; + _this.privHypothesisLatencies = []; + return json; + }; + this.dispose = function () { + _this.privIsDisposed = true; + }; + this.getConnectionError = function (statusCode) { + /* + -- Websocket status codes -- + NormalClosure = 1000, + EndpointUnavailable = 1001, + ProtocolError = 1002, + InvalidMessageType = 1003, + Empty = 1005, + InvalidPayloadData = 1007, + PolicyViolation = 1008, + MessageTooBig = 1009, + MandatoryExtension = 1010, + InternalServerError = 1011 + */ + switch (statusCode) { + case 400: + case 1002: + case 1003: + case 1005: + case 1007: + case 1008: + case 1009: return "BadRequest"; + case 401: return "Unauthorized"; + case 403: return "Forbidden"; + case 503: + case 1001: return "ServerUnavailable"; + case 500: + case 1011: return "ServerError"; + case 408: + case 504: return "Timeout"; + default: return "statuscode:" + statusCode.toString(); + } + }; + this.privRequestId = requestId; + this.privAudioSourceId = audioSourceId; + this.privAudioNodeId = audioNodeId; + this.privReceivedMessages = {}; + this.privPhraseLatencies = []; + this.privHypothesisLatencies = []; + } + ServiceTelemetryListener.prototype.phraseReceived = function (audioReceivedTime) { + if (audioReceivedTime > 0) { // 0 indicates the time is unknown. Drop it. + this.privPhraseLatencies.push(Date.now() - audioReceivedTime); + } + }; + ServiceTelemetryListener.prototype.hypothesisReceived = function (audioReceivedTime) { + if (audioReceivedTime > 0) { // 0 indicates the time is unknown. Drop it. + this.privHypothesisLatencies.push(Date.now() - audioReceivedTime); + } + }; + Object.defineProperty(ServiceTelemetryListener.prototype, "hasTelemetry", { + // Determines if there are any telemetry events to send to the service. + get: function () { + return (Object.keys(this.privReceivedMessages).length !== 0 || + this.privListeningTriggerMetric !== null || + this.privMicMetric !== null || + this.privConnectionEstablishMetric !== null || + this.privPhraseLatencies.length !== 0 || + this.privHypothesisLatencies.length !== 0); + }, + enumerable: true, + configurable: true + }); + return ServiceTelemetryListener; +}()); +exports.ServiceTelemetryListener = ServiceTelemetryListener; + + + +/***/ }), +/* 149 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Represents the JSON used in the speech.context message sent to the speech service. + * The dynamic grammar is always refreshed from the encapsulated dynamic grammar object. + */ +var SpeechContext = /** @class */ (function () { + function SpeechContext(dynamicGrammar) { + this.privContext = {}; + this.privDynamicGrammar = dynamicGrammar; + } + /** + * Adds a section to the speech.context object. + * @param sectionName Name of the section to add. + * @param value JSON serializable object that represents the value. + */ + SpeechContext.prototype.setSection = function (sectionName, value) { + this.privContext[sectionName] = value; + }; + SpeechContext.prototype.toJSON = function () { + var dgi = this.privDynamicGrammar.generateGrammarObject(); + this.setSection("dgi", dgi); + var ret = JSON.stringify(this.privContext); + return ret; + }; + return SpeechContext; +}()); +exports.SpeechContext = SpeechContext; + + + +/***/ }), +/* 150 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Responsible for building the object to be sent to the speech service to support dynamic grammars. + * @class DynamicGrammarBuilder + */ +var DynamicGrammarBuilder = /** @class */ (function () { + function DynamicGrammarBuilder() { + } + // Adds one more reference phrases to the dynamic grammar to send. + // All added phrases are generic phrases. + DynamicGrammarBuilder.prototype.addPhrase = function (phrase) { + if (!this.privPhrases) { + this.privPhrases = []; + } + if (phrase instanceof Array) { + this.privPhrases = this.privPhrases.concat(phrase); + } + else { + this.privPhrases.push(phrase); + } + }; + // Clears all phrases stored in the current object. + DynamicGrammarBuilder.prototype.clearPhrases = function () { + this.privPhrases = undefined; + }; + // Adds one or more reference grammars to the current grammar. + DynamicGrammarBuilder.prototype.addReferenceGrammar = function (grammar) { + if (!this.privGrammars) { + this.privGrammars = []; + } + if (grammar instanceof Array) { + this.privGrammars = this.privGrammars.concat(grammar); + } + else { + this.privGrammars.push(grammar); + } + }; + // clears all grammars stored on the recognizer. + DynamicGrammarBuilder.prototype.clearGrammars = function () { + this.privGrammars = undefined; + }; + // Generates an object that represents the dynamic grammar used by the Speech Service. + // This is done by building an object with the correct layout based on the phrases and reference grammars added to this instance + // of a DynamicGrammarBuilder + DynamicGrammarBuilder.prototype.generateGrammarObject = function () { + if (this.privGrammars === undefined && this.privPhrases === undefined) { + return undefined; + } + var retObj = {}; + retObj.ReferenceGrammars = this.privGrammars; + if (undefined !== this.privPhrases && 0 !== this.privPhrases.length) { + var retPhrases_1 = []; + this.privPhrases.forEach(function (value, index, array) { + retPhrases_1.push({ + Text: value, + }); + }); + retObj.Groups = [{ Type: "Generic", Items: retPhrases_1 }]; + } + return retObj; + }; + return DynamicGrammarBuilder; +}()); +exports.DynamicGrammarBuilder = DynamicGrammarBuilder; + + + +/***/ }), +/* 151 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(2); +var Exports_2 = __webpack_require__(4); +var Exports_3 = __webpack_require__(31); +var DialogServiceTurnStateManager_1 = __webpack_require__(152); +var Exports_4 = __webpack_require__(26); +var ActivityResponsePayload_1 = __webpack_require__(154); +var SpeechConnectionMessage_Internal_1 = __webpack_require__(128); +var DialogServiceAdapter = /** @class */ (function (_super) { + __extends(DialogServiceAdapter, _super); + function DialogServiceAdapter(authentication, connectionFactory, audioSource, recognizerConfig, dialogServiceConnector) { + var _this = _super.call(this, authentication, connectionFactory, audioSource, recognizerConfig, dialogServiceConnector) || this; + _this.sendMessage = function (message) { + var interactionGuid = Exports_2.createGuid(); + var requestId = Exports_2.createNoDashGuid(); + var agentMessage = { + context: { + interactionId: interactionGuid + }, + messagePayload: JSON.parse(message), + version: 0.5 + }; + var agentMessageJson = JSON.stringify(agentMessage); + _this.fetchDialogConnection().onSuccessContinueWith(function (connection) { + connection.send(new SpeechConnectionMessage_Internal_1.SpeechConnectionMessage(Exports_2.MessageType.Text, "agent", requestId, "application/json", agentMessageJson)); + }); + }; + _this.listenOnce = function (recoMode, successCallback, errorCallback) { + _this.privRecognizerConfig.recognitionMode = recoMode; + _this.privSuccessCallback = successCallback; + _this.privErrorCallback = errorCallback; + _this.privDialogRequestSession.startNewRecognition(); + _this.privDialogRequestSession.listenForServiceTelemetry(_this.privDialogAudioSource.events); + // Start the connection to the service. The promise this will create is stored and will be used by configureConnection(). + _this.dialogConnectImpl(); + _this.sendPreAudioMessages(); + return _this.privDialogAudioSource + .attach(_this.privDialogRequestSession.audioNodeId) + .continueWithPromise(function (result) { + var audioNode; + if (result.isError) { + _this.cancelRecognition(_this.privDialogRequestSession.sessionId, _this.privDialogRequestSession.requestId, Exports_3.CancellationReason.Error, Exports_3.CancellationErrorCode.ConnectionFailure, result.error); + return Exports_2.PromiseHelper.fromError(result.error); + } + return _this.privDialogAudioSource.format.onSuccessContinueWithPromise(function (format) { + audioNode = new Exports_1.ReplayableAudioNode(result.result, format.avgBytesPerSec); + _this.privDialogRequestSession.onAudioSourceAttachCompleted(audioNode, false); + return _this.privDialogAudioSource.deviceInfo.onSuccessContinueWithPromise(function (deviceInfo) { + _this.privRecognizerConfig.SpeechServiceConfig.Context.audio = { source: deviceInfo }; + return _this.configConnection() + .continueWithPromise(function (result) { + if (result.isError) { + _this.cancelRecognitionLocal(Exports_3.CancellationReason.Error, Exports_3.CancellationErrorCode.ConnectionFailure, result.error); + return Exports_2.PromiseHelper.fromError(result.error); + } + var sessionStartEventArgs = new Exports_3.SessionEventArgs(_this.privDialogRequestSession.sessionId); + if (!!_this.privRecognizer.sessionStarted) { + _this.privRecognizer.sessionStarted(_this.privRecognizer, sessionStartEventArgs); + } + var audioSendPromise = _this.sendAudio(audioNode); + // /* tslint:disable:no-empty */ + audioSendPromise.on(function (_) { }, function (error) { + _this.cancelRecognition(_this.privDialogRequestSession.sessionId, _this.privDialogRequestSession.requestId, Exports_3.CancellationReason.Error, Exports_3.CancellationErrorCode.RuntimeError, error); + }); + return Exports_2.PromiseHelper.fromResult(true); + }); + }); + }); + }); + }; + _this.sendAudio = function (audioStreamNode) { + return _this.privDialogAudioSource.format.onSuccessContinueWithPromise(function (audioFormat) { + // NOTE: Home-baked promises crash ios safari during the invocation + // of the error callback chain (looks like the recursion is way too deep, and + // it blows up the stack). The following construct is a stop-gap that does not + // bubble the error up the callback chain and hence circumvents this problem. + // TODO: rewrite with ES6 promises. + var deferred = new Exports_2.Deferred(); + // The time we last sent data to the service. + var nextSendTime = Date.now(); + // Max amount to send before we start to throttle + var fastLaneSizeMs = _this.privRecognizerConfig.parameters.getProperty("SPEECH-TransmitLengthBeforThrottleMs", "5000"); + var maxSendUnthrottledBytes = audioFormat.avgBytesPerSec / 1000 * parseInt(fastLaneSizeMs, 10); + var startRecogNumber = _this.privDialogRequestSession.recogNumber; + var readAndUploadCycle = function () { + // If speech is done, stop sending audio. + if (!_this.privDialogIsDisposed && + !_this.privDialogRequestSession.isSpeechEnded && + _this.privDialogRequestSession.isRecognizing && + _this.privDialogRequestSession.recogNumber === startRecogNumber) { + _this.fetchDialogConnection().on(function (connection) { + audioStreamNode.read().on(function (audioStreamChunk) { + // we have a new audio chunk to upload. + if (_this.privDialogRequestSession.isSpeechEnded) { + // If service already recognized audio end then don't send any more audio + deferred.resolve(true); + return; + } + var payload; + var sendDelay; + if (!audioStreamChunk || audioStreamChunk.isEnd) { + payload = null; + sendDelay = 0; + } + else { + payload = audioStreamChunk.buffer; + _this.privDialogRequestSession.onAudioSent(payload.byteLength); + if (maxSendUnthrottledBytes >= _this.privDialogRequestSession.bytesSent) { + sendDelay = 0; + } + else { + sendDelay = Math.max(0, nextSendTime - Date.now()); + } + } + // Are we ready to send, or need we delay more? + setTimeout(function () { + if (payload !== null) { + nextSendTime = Date.now() + (payload.byteLength * 1000 / (audioFormat.avgBytesPerSec * 2)); + } + var uploaded = connection.send(new SpeechConnectionMessage_Internal_1.SpeechConnectionMessage(Exports_2.MessageType.Binary, "audio", _this.privDialogRequestSession.requestId, null, payload)); + if (audioStreamChunk && !audioStreamChunk.isEnd) { + uploaded.continueWith(function (_) { + // Regardless of success or failure, schedule the next upload. + // If the underlying connection was broken, the next cycle will + // get a new connection and re-transmit missing audio automatically. + readAndUploadCycle(); + }); + } + else { + // the audio stream has been closed, no need to schedule next + // read-upload cycle. + _this.privDialogRequestSession.onSpeechEnded(); + deferred.resolve(true); + } + }, sendDelay); + }, function (error) { + if (_this.privDialogRequestSession.isSpeechEnded) { + // For whatever reason, Reject is used to remove queue subscribers inside + // the Queue.DrainAndDispose invoked from DetachAudioNode down below, which + // means that sometimes things can be rejected in normal circumstances, without + // any errors. + deferred.resolve(true); // TODO: remove the argument, it's is completely meaningless. + } + else { + // Only reject, if there was a proper error. + deferred.reject(error); + } + }); + }, function (error) { + deferred.reject(error); + }); + } + }; + readAndUploadCycle(); + return deferred.promise(); + }); + }; + _this.receiveDialogMessageOverride = function () { + // we won't rely on the cascading promises of the connection since we want to continually be available to receive messages + var communicationCustodian = new Exports_2.Deferred(); + _this.fetchDialogConnection().on(function (connection) { + return connection.read() + .onSuccessContinueWithPromise(function (message) { + var isDisposed = _this.isDisposed(); + var terminateMessageLoop = (!_this.isDisposed() && _this.terminateMessageLoop); + if (isDisposed || terminateMessageLoop) { + // We're done. + communicationCustodian.resolve(undefined); + return Exports_2.PromiseHelper.fromResult(undefined); + } + if (!message) { + return _this.receiveDialogMessageOverride(); + } + var connectionMessage = SpeechConnectionMessage_Internal_1.SpeechConnectionMessage.fromConnectionMessage(message); + switch (connectionMessage.path.toLowerCase()) { + case "turn.start": + { + var turnRequestId = connectionMessage.requestId.toUpperCase(); + var audioSessionReqId = _this.privDialogRequestSession.requestId.toUpperCase(); + // turn started by the service + if (turnRequestId !== audioSessionReqId) { + _this.privTurnStateManager.StartTurn(turnRequestId); + } + else { + _this.privDialogRequestSession.onServiceTurnStartResponse(); + } + } + break; + case "speech.startdetected": + var speechStartDetected = Exports_4.SpeechDetected.fromJSON(connectionMessage.textBody); + var speechStartEventArgs = new Exports_3.RecognitionEventArgs(speechStartDetected.Offset, _this.privDialogRequestSession.sessionId); + if (!!_this.privRecognizer.speechStartDetected) { + _this.privRecognizer.speechStartDetected(_this.privRecognizer, speechStartEventArgs); + } + break; + case "speech.enddetected": + var json = void 0; + if (connectionMessage.textBody.length > 0) { + json = connectionMessage.textBody; + } + else { + // If the request was empty, the JSON returned is empty. + json = "{ Offset: 0 }"; + } + var speechStopDetected = Exports_4.SpeechDetected.fromJSON(json); + _this.privDialogRequestSession.onServiceRecognized(speechStopDetected.Offset + _this.privDialogRequestSession.currentTurnAudioOffset); + var speechStopEventArgs = new Exports_3.RecognitionEventArgs(speechStopDetected.Offset + _this.privDialogRequestSession.currentTurnAudioOffset, _this.privDialogRequestSession.sessionId); + if (!!_this.privRecognizer.speechEndDetected) { + _this.privRecognizer.speechEndDetected(_this.privRecognizer, speechStopEventArgs); + } + break; + case "turn.end": + { + var turnEndRequestId = connectionMessage.requestId.toUpperCase(); + var audioSessionReqId = _this.privDialogRequestSession.requestId.toUpperCase(); + // turn started by the service + if (turnEndRequestId !== audioSessionReqId) { + _this.privTurnStateManager.CompleteTurn(turnEndRequestId); + } + else { + // Audio session turn + var sessionStopEventArgs = new Exports_3.SessionEventArgs(_this.privDialogRequestSession.sessionId); + _this.privDialogRequestSession.onServiceTurnEndResponse(false); + if (_this.privDialogRequestSession.isSpeechEnded) { + if (!!_this.privRecognizer.sessionStopped) { + _this.privRecognizer.sessionStopped(_this.privRecognizer, sessionStopEventArgs); + } + } + // report result to promise. + if (!!_this.privSuccessCallback && _this.privLastResult) { + try { + _this.privSuccessCallback(_this.privLastResult); + _this.privLastResult = null; + } + catch (e) { + if (!!_this.privErrorCallback) { + _this.privErrorCallback(e); + } + } + // Only invoke the call back once. + // and if it's successful don't invoke the + // error after that. + _this.privSuccessCallback = undefined; + _this.privErrorCallback = undefined; + } + } + } + break; + default: + if (!_this.processTypeSpecificMessages(connectionMessage)) { + if (!!_this.serviceEvents) { + _this.serviceEvents.onEvent(new Exports_2.ServiceEvent(connectionMessage.path.toLowerCase(), connectionMessage.textBody)); + } + } + } + return _this.receiveDialogMessageOverride(); + }); + }, function (error) { + _this.terminateMessageLoop = true; + communicationCustodian.resolve(undefined); + return Exports_2.PromiseHelper.fromResult(undefined); + }); + return communicationCustodian.promise(); + }; + _this.fetchDialogConnection = function () { + return _this.configConnection(); + }; + _this.sendAgentConfig = function (connection) { + if (_this.agentConfig && !_this.agentConfigSent) { + if (_this.privRecognizerConfig.parameters.getProperty(Exports_3.PropertyId.Conversation_DialogType) === "custom_commands") { + var config = _this.agentConfig.get(); + config.botInfo.commandsCulture = _this.privRecognizerConfig.parameters.getProperty(Exports_3.PropertyId.SpeechServiceConnection_RecoLanguage, "en-us"); + _this.agentConfig.set(config); + } + var agentConfigJson = _this.agentConfig.toJsonString(); + // guard against sending this multiple times on one connection + _this.agentConfigSent = true; + return connection.send(new SpeechConnectionMessage_Internal_1.SpeechConnectionMessage(Exports_2.MessageType.Text, "agent.config", _this.privDialogRequestSession.requestId, "application/json", agentConfigJson)); + } + return Exports_2.PromiseHelper.fromResult(true); + }; + _this.sendAgentContext = function (connection) { + var guid = Exports_2.createGuid(); + var speechActivityTemplate = _this.privDialogServiceConnector.properties.getProperty(Exports_3.PropertyId.Conversation_Speech_Activity_Template); + var agentContext = { + channelData: "", + context: { + interactionId: guid + }, + messagePayload: typeof speechActivityTemplate === undefined ? undefined : speechActivityTemplate, + version: 0.5 + }; + var agentContextJson = JSON.stringify(agentContext); + return connection.send(new SpeechConnectionMessage_Internal_1.SpeechConnectionMessage(Exports_2.MessageType.Text, "speech.agent.context", _this.privDialogRequestSession.requestId, "application/json", agentContextJson)); + }; + _this.privDialogServiceConnector = dialogServiceConnector; + _this.privDialogAuthentication = authentication; + _this.receiveMessageOverride = _this.receiveDialogMessageOverride; + _this.privTurnStateManager = new DialogServiceTurnStateManager_1.DialogServiceTurnStateManager(); + _this.recognizeOverride = _this.listenOnce; + _this.connectImplOverride = _this.dialogConnectImpl; + _this.configConnectionOverride = _this.configConnection; + _this.fetchConnectionOverride = _this.fetchDialogConnection; + _this.disconnectOverride = _this.privDisconnect; + _this.privDialogAudioSource = audioSource; + _this.privDialogRequestSession = new Exports_4.RequestSession(audioSource.id()); + _this.privDialogConnectionFactory = connectionFactory; + _this.privDialogIsDisposed = false; + _this.agentConfigSent = false; + _this.privLastResult = null; + return _this; + } + DialogServiceAdapter.prototype.isDisposed = function () { + return this.privDialogIsDisposed; + }; + DialogServiceAdapter.prototype.dispose = function (reason) { + this.privDialogIsDisposed = true; + if (this.privConnectionConfigPromise) { + this.privConnectionConfigPromise.onSuccessContinueWith(function (connection) { + connection.dispose(reason); + }); + } + }; + DialogServiceAdapter.prototype.privDisconnect = function () { + this.cancelRecognition(this.privDialogRequestSession.sessionId, this.privDialogRequestSession.requestId, Exports_3.CancellationReason.Error, Exports_3.CancellationErrorCode.NoError, "Disconnecting"); + this.terminateMessageLoop = true; + this.agentConfigSent = false; + if (this.privDialogConnectionPromise.result().isCompleted) { + if (!this.privDialogConnectionPromise.result().isError) { + this.privDialogConnectionPromise.result().result.dispose(); + this.privDialogConnectionPromise = null; + } + } + else { + this.privDialogConnectionPromise.onSuccessContinueWith(function (connection) { + connection.dispose(); + }); + } + }; + DialogServiceAdapter.prototype.processTypeSpecificMessages = function (connectionMessage) { + var resultProps = new Exports_3.PropertyCollection(); + if (connectionMessage.messageType === Exports_2.MessageType.Text) { + resultProps.setProperty(Exports_3.PropertyId.SpeechServiceResponse_JsonResult, connectionMessage.textBody); + } + var result; + var processed; + switch (connectionMessage.path.toLowerCase()) { + case "speech.phrase": + var speechPhrase = Exports_4.SimpleSpeechPhrase.fromJSON(connectionMessage.textBody); + this.privDialogRequestSession.onPhraseRecognized(this.privDialogRequestSession.currentTurnAudioOffset + speechPhrase.Offset + speechPhrase.Duration); + if (speechPhrase.RecognitionStatus === Exports_4.RecognitionStatus.Success) { + var args = this.fireEventForResult(speechPhrase, resultProps); + this.privLastResult = args.result; + if (!!this.privDialogServiceConnector.recognized) { + try { + this.privDialogServiceConnector.recognized(this.privDialogServiceConnector, args); + /* tslint:disable:no-empty */ + } + catch (error) { + // Not going to let errors in the event handler + // trip things up. + } + } + } + processed = true; + break; + case "speech.hypothesis": + var hypothesis = Exports_4.SpeechHypothesis.fromJSON(connectionMessage.textBody); + var offset = hypothesis.Offset + this.privDialogRequestSession.currentTurnAudioOffset; + result = new Exports_3.SpeechRecognitionResult(this.privDialogRequestSession.requestId, Exports_3.ResultReason.RecognizingSpeech, hypothesis.Text, hypothesis.Duration, offset, hypothesis.Language, hypothesis.LanguageDetectionConfidence, undefined, connectionMessage.textBody, resultProps); + this.privDialogRequestSession.onHypothesis(offset); + var ev = new Exports_3.SpeechRecognitionEventArgs(result, hypothesis.Duration, this.privDialogRequestSession.sessionId); + if (!!this.privDialogServiceConnector.recognizing) { + try { + this.privDialogServiceConnector.recognizing(this.privDialogServiceConnector, ev); + /* tslint:disable:no-empty */ + } + catch (error) { + // Not going to let errors in the event handler + // trip things up. + } + } + processed = true; + break; + case "audio": + { + var audioRequestId = connectionMessage.requestId.toUpperCase(); + var turn = this.privTurnStateManager.GetTurn(audioRequestId); + try { + // Empty binary message signals end of stream. + if (!connectionMessage.binaryBody) { + turn.endAudioStream(); + } + else { + turn.audioStream.write(connectionMessage.binaryBody); + } + } + catch (error) { + // Not going to let errors in the event handler + // trip things up. + } + } + processed = true; + break; + case "response": + { + var responseRequestId = connectionMessage.requestId.toUpperCase(); + var activityPayload = ActivityResponsePayload_1.ActivityPayloadResponse.fromJSON(connectionMessage.textBody); + var turn = this.privTurnStateManager.GetTurn(responseRequestId); + // update the conversation Id + if (activityPayload.conversationId) { + var updateAgentConfig = this.agentConfig.get(); + updateAgentConfig.botInfo.conversationId = activityPayload.conversationId; + this.agentConfig.set(updateAgentConfig); + } + var pullAudioOutputStream = turn.processActivityPayload(activityPayload, Exports_3.SpeechSynthesisOutputFormat[this.privDialogServiceConnector.properties.getProperty(Exports_3.PropertyId.SpeechServiceConnection_SynthOutputFormat, undefined)]); + var activity = new Exports_3.ActivityReceivedEventArgs(activityPayload.messagePayload, pullAudioOutputStream); + if (!!this.privDialogServiceConnector.activityReceived) { + try { + this.privDialogServiceConnector.activityReceived(this.privDialogServiceConnector, activity); + /* tslint:disable:no-empty */ + } + catch (error) { + // Not going to let errors in the event handler + // trip things up. + } + } + } + processed = true; + break; + default: + break; + } + return processed; + }; + // Cancels recognition. + DialogServiceAdapter.prototype.cancelRecognition = function (sessionId, requestId, cancellationReason, errorCode, error) { + this.terminateMessageLoop = true; + if (!!this.privDialogRequestSession.isRecognizing) { + this.privDialogRequestSession.onStopRecognizing(); + } + if (!!this.privDialogServiceConnector.canceled) { + var properties = new Exports_3.PropertyCollection(); + properties.setProperty(Exports_4.CancellationErrorCodePropertyName, Exports_3.CancellationErrorCode[errorCode]); + var cancelEvent = new Exports_3.SpeechRecognitionCanceledEventArgs(cancellationReason, error, errorCode, undefined, sessionId); + try { + this.privDialogServiceConnector.canceled(this.privDialogServiceConnector, cancelEvent); + /* tslint:disable:no-empty */ + } + catch (_a) { } + if (!!this.privSuccessCallback) { + var result = new Exports_3.SpeechRecognitionResult(undefined, // ResultId + Exports_3.ResultReason.Canceled, undefined, // Text + undefined, // Druation + undefined, // Offset + undefined, // Language + undefined, // Language Detection Confidence + error, undefined, // Json + properties); + try { + this.privSuccessCallback(result); + this.privSuccessCallback = undefined; + /* tslint:disable:no-empty */ + } + catch (_b) { } + } + } + }; + DialogServiceAdapter.prototype.sendWaveHeader = function (connection) { + var _this = this; + return this.audioSource.format.onSuccessContinueWithPromise(function (format) { + return connection.send(new SpeechConnectionMessage_Internal_1.SpeechConnectionMessage(Exports_2.MessageType.Binary, "audio", _this.privDialogRequestSession.requestId, "audio/x-wav", format.header)); + }); + }; + // Establishes a websocket connection to the end point. + DialogServiceAdapter.prototype.dialogConnectImpl = function (isUnAuthorized) { + var _this = this; + if (isUnAuthorized === void 0) { isUnAuthorized = false; } + if (this.privDialogConnectionPromise) { + if (this.privDialogConnectionPromise.result().isCompleted && + (this.privDialogConnectionPromise.result().isError + || this.privDialogConnectionPromise.result().result.state() === Exports_2.ConnectionState.Disconnected)) { + this.agentConfigSent = false; + this.privDialogConnectionPromise = null; + this.terminateMessageLoop = true; + return this.configConnection(); + } + else { + return this.privDialogConnectionPromise; + } + } + this.privDialogAuthFetchEventId = Exports_2.createNoDashGuid(); + // keep the connectionId for reconnect events + if (this.privConnectionId === undefined) { + this.privConnectionId = Exports_2.createNoDashGuid(); + } + this.privDialogRequestSession.onPreConnectionStart(this.privDialogAuthFetchEventId, this.privConnectionId); + var authPromise = isUnAuthorized ? this.privDialogAuthentication.fetchOnExpiry(this.privDialogAuthFetchEventId) : this.privDialogAuthentication.fetch(this.privDialogAuthFetchEventId); + this.privDialogConnectionPromise = authPromise + .continueWithPromise(function (result) { + if (result.isError) { + _this.privDialogRequestSession.onAuthCompleted(true, result.error); + throw new Error(result.error); + } + else { + _this.privDialogRequestSession.onAuthCompleted(false); + } + var connection = _this.privDialogConnectionFactory.create(_this.privRecognizerConfig, result.result, _this.privConnectionId); + _this.privDialogRequestSession.listenForServiceTelemetry(connection.events); + // Attach to the underlying event. No need to hold onto the detach pointers as in the event the connection goes away, + // it'll stop sending events. + connection.events.attach(function (event) { + _this.connectionEvents.onEvent(event); + }); + return connection.open().onSuccessContinueWithPromise(function (response) { + if (response.statusCode === 200) { + _this.privDialogRequestSession.onPreConnectionStart(_this.privDialogAuthFetchEventId, _this.privConnectionId); + _this.privDialogRequestSession.onConnectionEstablishCompleted(response.statusCode); + return Exports_2.PromiseHelper.fromResult(connection); + } + else if (response.statusCode === 403 && !isUnAuthorized) { + return _this.dialogConnectImpl(true); + } + else { + _this.privDialogRequestSession.onConnectionEstablishCompleted(response.statusCode, response.reason); + return Exports_2.PromiseHelper.fromError("Unable to contact server. StatusCode: " + response.statusCode + ", " + _this.privRecognizerConfig.parameters.getProperty(Exports_3.PropertyId.SpeechServiceConnection_Endpoint) + " Reason: " + response.reason); + } + }); + }); + this.privConnectionLoop = this.startMessageLoop(); + return this.privDialogConnectionPromise; + }; + DialogServiceAdapter.prototype.startMessageLoop = function () { + var _this = this; + this.terminateMessageLoop = false; + var messageRetrievalPromise = this.receiveDialogMessageOverride(); + return messageRetrievalPromise.on(function (r) { + return true; + }, function (error) { + _this.cancelRecognition(_this.privDialogRequestSession.sessionId, _this.privDialogRequestSession.requestId, Exports_3.CancellationReason.Error, Exports_3.CancellationErrorCode.RuntimeError, error); + }); + }; + // Takes an established websocket connection to the endpoint and sends speech configuration information. + DialogServiceAdapter.prototype.configConnection = function () { + var _this = this; + if (this.privConnectionConfigPromise) { + if (this.privConnectionConfigPromise.result().isCompleted && + (this.privConnectionConfigPromise.result().isError + || this.privConnectionConfigPromise.result().result.state() === Exports_2.ConnectionState.Disconnected)) { + this.privConnectionConfigPromise = null; + return this.configConnection(); + } + else { + return this.privConnectionConfigPromise; + } + } + if (this.terminateMessageLoop) { + this.terminateMessageLoop = false; + return Exports_2.PromiseHelper.fromError("Connection to service terminated."); + } + this.privConnectionConfigPromise = this.dialogConnectImpl().onSuccessContinueWithPromise(function (connection) { + return _this.sendSpeechServiceConfig(connection, _this.privDialogRequestSession, _this.privRecognizerConfig.SpeechServiceConfig.serialize()) + .onSuccessContinueWithPromise(function (_) { + return _this.sendAgentConfig(connection).onSuccessContinueWith(function (_) { + return connection; + }); + }); + }); + return this.privConnectionConfigPromise; + }; + DialogServiceAdapter.prototype.sendPreAudioMessages = function () { + var _this = this; + this.fetchDialogConnection().onSuccessContinueWith(function (connection) { + _this.sendAgentContext(connection); + _this.sendWaveHeader(connection); + }); + }; + DialogServiceAdapter.prototype.fireEventForResult = function (serviceResult, properties) { + var resultReason = Exports_4.EnumTranslation.implTranslateRecognitionResult(serviceResult.RecognitionStatus); + var offset = serviceResult.Offset + this.privDialogRequestSession.currentTurnAudioOffset; + var result = new Exports_3.SpeechRecognitionResult(this.privDialogRequestSession.requestId, resultReason, serviceResult.DisplayText, serviceResult.Duration, offset, serviceResult.Language, serviceResult.LanguageDetectionConfidence, undefined, JSON.stringify(serviceResult), properties); + var ev = new Exports_3.SpeechRecognitionEventArgs(result, offset, this.privDialogRequestSession.sessionId); + return ev; + }; + return DialogServiceAdapter; +}(Exports_4.ServiceRecognizerBase)); +exports.DialogServiceAdapter = DialogServiceAdapter; + + + +/***/ }), +/* 152 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Error_1 = __webpack_require__(10); +var DialogServiceTurnState_1 = __webpack_require__(153); +var DialogServiceTurnStateManager = /** @class */ (function () { + function DialogServiceTurnStateManager() { + this.privTurnMap = new Map(); + return; + } + DialogServiceTurnStateManager.prototype.StartTurn = function (id) { + if (this.privTurnMap.has(id)) { + throw new Error_1.InvalidOperationError("Service error: There is already a turn with id:" + id); + } + var turnState = new DialogServiceTurnState_1.DialogServiceTurnState(this, id); + this.privTurnMap.set(id, turnState); + return this.privTurnMap.get(id); + }; + DialogServiceTurnStateManager.prototype.GetTurn = function (id) { + return this.privTurnMap.get(id); + }; + DialogServiceTurnStateManager.prototype.CompleteTurn = function (id) { + if (!this.privTurnMap.has(id)) { + throw new Error_1.InvalidOperationError("Service error: Received turn end for an unknown turn id:" + id); + } + var turnState = this.privTurnMap.get(id); + turnState.complete(); + this.privTurnMap.delete(id); + return turnState; + }; + return DialogServiceTurnStateManager; +}()); +exports.DialogServiceTurnStateManager = DialogServiceTurnStateManager; + + + +/***/ }), +/* 153 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var AudioOutputFormat_1 = __webpack_require__(44); +var AudioOutputStream_1 = __webpack_require__(43); +var ActivityResponsePayload_1 = __webpack_require__(154); +var DialogServiceTurnState = /** @class */ (function () { + function DialogServiceTurnState(manager, requestId) { + this.privRequestId = requestId; + this.privIsCompleted = false; + this.privAudioStream = null; + this.privTurnManager = manager; + this.resetTurnEndTimeout(); + // tslint:disable-next-line:no-console + // console.info("DialogServiceTurnState debugturn start:" + this.privRequestId); + } + Object.defineProperty(DialogServiceTurnState.prototype, "audioStream", { + get: function () { + // Called when is needed to stream. + this.resetTurnEndTimeout(); + return this.privAudioStream; + }, + enumerable: true, + configurable: true + }); + DialogServiceTurnState.prototype.processActivityPayload = function (payload, audioFormat) { + if (payload.messageDataStreamType === ActivityResponsePayload_1.MessageDataStreamType.TextToSpeechAudio) { + this.privAudioStream = AudioOutputStream_1.AudioOutputStream.createPullStream(); + this.privAudioStream.format = (audioFormat !== undefined) ? audioFormat : AudioOutputFormat_1.AudioOutputFormatImpl.getDefaultOutputFormat(); + // tslint:disable-next-line:no-console + // console.info("Audio start debugturn:" + this.privRequestId); + } + return this.privAudioStream; + }; + DialogServiceTurnState.prototype.endAudioStream = function () { + if (this.privAudioStream !== null && !this.privAudioStream.isClosed) { + this.privAudioStream.close(); + } + }; + DialogServiceTurnState.prototype.complete = function () { + if (this.privTimeoutToken !== undefined) { + clearTimeout(this.privTimeoutToken); + } + this.endAudioStream(); + }; + DialogServiceTurnState.prototype.resetTurnEndTimeout = function () { + var _this = this; + if (this.privTimeoutToken !== undefined) { + clearTimeout(this.privTimeoutToken); + } + // tslint:disable-next-line:no-console + // console.info("Timeout reset debugturn:" + this.privRequestId); + this.privTimeoutToken = setTimeout(function () { + // tslint:disable-next-line:no-console + // console.info("Timeout complete debugturn:" + this.privRequestId); + _this.privTurnManager.CompleteTurn(_this.privRequestId); + return; + }, 2000); + }; + return DialogServiceTurnState; +}()); +exports.DialogServiceTurnState = DialogServiceTurnState; + + + +/***/ }), +/* 154 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +// response +Object.defineProperty(exports, "__esModule", { value: true }); +var ActivityPayloadResponse = /** @class */ (function () { + function ActivityPayloadResponse(json) { + this.privActivityResponse = JSON.parse(json); + } + ActivityPayloadResponse.fromJSON = function (json) { + return new ActivityPayloadResponse(json); + }; + Object.defineProperty(ActivityPayloadResponse.prototype, "conversationId", { + get: function () { + return this.privActivityResponse.conversationId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ActivityPayloadResponse.prototype, "messageDataStreamType", { + get: function () { + return this.privActivityResponse.messageDataStreamType; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ActivityPayloadResponse.prototype, "messagePayload", { + get: function () { + return this.privActivityResponse.messagePayload; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ActivityPayloadResponse.prototype, "version", { + get: function () { + return this.privActivityResponse.version; + }, + enumerable: true, + configurable: true + }); + return ActivityPayloadResponse; +}()); +exports.ActivityPayloadResponse = ActivityPayloadResponse; +var MessageDataStreamType; +(function (MessageDataStreamType) { + MessageDataStreamType[MessageDataStreamType["None"] = 0] = "None"; + MessageDataStreamType[MessageDataStreamType["TextToSpeechAudio"] = 1] = "TextToSpeechAudio"; +})(MessageDataStreamType = exports.MessageDataStreamType || (exports.MessageDataStreamType = {})); + + + +/***/ }), +/* 155 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Represents the JSON used in the agent.config message sent to the speech service. + */ +var AgentConfig = /** @class */ (function () { + function AgentConfig() { + } + AgentConfig.prototype.toJsonString = function () { + return JSON.stringify(this.iPrivConfig); + }; + AgentConfig.prototype.get = function () { + return this.iPrivConfig; + }; + /** + * Setter for the agent.config object. + * @param value a JSON serializable object. + */ + AgentConfig.prototype.set = function (value) { + this.iPrivConfig = value; + }; + return AgentConfig; +}()); +exports.AgentConfig = AgentConfig; + + + +/***/ }), +/* 156 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var ConversationManager_1 = __webpack_require__(157); +exports.ConversationManager = ConversationManager_1.ConversationManager; +var ConversationTranslatorRecognizer_1 = __webpack_require__(161); +exports.ConversationTranslatorRecognizer = ConversationTranslatorRecognizer_1.ConversationTranslatorRecognizer; +var ConversationConnectionConfig_1 = __webpack_require__(158); +exports.ConversationConnectionConfig = ConversationConnectionConfig_1.ConversationConnectionConfig; +var ConversationTranslatorEventArgs_1 = __webpack_require__(167); +exports.ConversationReceivedTranslationEventArgs = ConversationTranslatorEventArgs_1.ConversationReceivedTranslationEventArgs; +exports.LockRoomEventArgs = ConversationTranslatorEventArgs_1.LockRoomEventArgs; +exports.MuteAllEventArgs = ConversationTranslatorEventArgs_1.MuteAllEventArgs; +exports.ParticipantAttributeEventArgs = ConversationTranslatorEventArgs_1.ParticipantAttributeEventArgs; +exports.ParticipantEventArgs = ConversationTranslatorEventArgs_1.ParticipantEventArgs; +exports.ParticipantsListEventArgs = ConversationTranslatorEventArgs_1.ParticipantsListEventArgs; +var ConversationTranslatorInterfaces_1 = __webpack_require__(168); +exports.ConversationTranslatorCommandTypes = ConversationTranslatorInterfaces_1.ConversationTranslatorCommandTypes; +exports.ConversationTranslatorMessageTypes = ConversationTranslatorInterfaces_1.ConversationTranslatorMessageTypes; +exports.InternalParticipants = ConversationTranslatorInterfaces_1.InternalParticipants; + + + +/***/ }), +/* 157 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Contracts_1 = __webpack_require__(33); +var Exports_1 = __webpack_require__(31); +var ConversationConnectionConfig_1 = __webpack_require__(158); +var ConversationUtils_1 = __webpack_require__(160); +var ConversationManager = /** @class */ (function () { + function ConversationManager() { + // + this.privRequestParams = ConversationConnectionConfig_1.ConversationConnectionConfig.configParams; + this.privErrors = ConversationConnectionConfig_1.ConversationConnectionConfig.restErrors; + this.privHost = ConversationConnectionConfig_1.ConversationConnectionConfig.host; + this.privApiVersion = ConversationConnectionConfig_1.ConversationConnectionConfig.apiVersion; + this.privRestPath = ConversationConnectionConfig_1.ConversationConnectionConfig.restPath; + } + /** + * Make a POST request to the Conversation Manager service endpoint to create or join a conversation. + * @param args + * @param conversationCode + * @param callback + * @param errorCallback + */ + ConversationManager.prototype.createOrJoin = function (args, conversationCode, cb, err) { + var _this = this; + try { + Contracts_1.Contracts.throwIfNullOrUndefined(args, "args"); + var languageCode = args.getProperty(Exports_1.PropertyId.SpeechServiceConnection_RecoLanguage, ConversationConnectionConfig_1.ConversationConnectionConfig.defaultLanguageCode); + var nickname = args.getProperty(Exports_1.PropertyId.ConversationTranslator_Name); + var endpointHost = args.getProperty(Exports_1.PropertyId.ConversationTranslator_Host, this.privHost); + var correlationId = args.getProperty(Exports_1.PropertyId.ConversationTranslator_CorrelationId); + var subscriptionKey = args.getProperty(Exports_1.PropertyId.SpeechServiceConnection_Key); + var subscriptionRegion = args.getProperty(Exports_1.PropertyId.SpeechServiceConnection_Region); + var authToken = args.getProperty(Exports_1.PropertyId.SpeechServiceAuthorization_Token); + Contracts_1.Contracts.throwIfNullOrWhitespace(languageCode, "languageCode"); + Contracts_1.Contracts.throwIfNullOrWhitespace(nickname, "nickname"); + Contracts_1.Contracts.throwIfNullOrWhitespace(endpointHost, "endpointHost"); + var queryParams = {}; + queryParams[this.privRequestParams.apiVersion] = this.privApiVersion; + queryParams[this.privRequestParams.languageCode] = languageCode; + queryParams[this.privRequestParams.nickname] = nickname; + var headers = {}; + if (correlationId) { + headers[this.privRequestParams.correlationId] = correlationId; + } + headers[this.privRequestParams.clientAppId] = ConversationConnectionConfig_1.ConversationConnectionConfig.clientAppId; + if (conversationCode !== undefined) { + queryParams[this.privRequestParams.roomId] = conversationCode; + } + else { + Contracts_1.Contracts.throwIfNullOrUndefined(subscriptionRegion, this.privErrors.authInvalidSubscriptionRegion); + headers[this.privRequestParams.subscriptionRegion] = subscriptionRegion; + if (subscriptionKey) { + headers[this.privRequestParams.subscriptionKey] = subscriptionKey; + } + else if (authToken) { + headers[this.privRequestParams.authorization] = "Bearer " + authToken; + } + else { + Contracts_1.Contracts.throwIfNullOrUndefined(subscriptionKey, this.privErrors.authInvalidSubscriptionKey); + } + } + var config = {}; + config.headers = headers; + var endpoint = "https://" + endpointHost + this.privRestPath; + // TODO: support a proxy and certificate validation + ConversationUtils_1.request("post", endpoint, queryParams, null, config, function (response) { + var requestId = ConversationUtils_1.extractHeaderValue(_this.privRequestParams.requestId, response.headers); + if (!response.ok) { + if (!!err) { + // get the error + var errorMessage = _this.privErrors.invalidCreateJoinConversationResponse.replace("{status}", response.status.toString()); + var errMessageRaw = void 0; + try { + errMessageRaw = JSON.parse(response.data); + errorMessage += " [" + errMessageRaw.error.code + ": " + errMessageRaw.error.message + "]"; + } + catch (e) { + errorMessage += " [" + response.data + "]"; + } + if (requestId) { + errorMessage += " " + requestId; + } + err(errorMessage); + } + return; + } + var conversation = JSON.parse(response.data); + if (conversation) { + conversation.requestId = requestId; + } + if (!!cb) { + try { + cb(conversation); + } + catch (e) { + if (!!err) { + err(e); + } + } + cb = undefined; + } + }); + } + catch (error) { + if (!!err) { + if (error instanceof Error) { + var typedError = error; + err(typedError.name + ": " + typedError.message); + } + else { + err(error); + } + } + } + }; + /** + * Make a DELETE request to the Conversation Manager service endpoint to leave the conversation. + * @param args + * @param sessionToken + * @param callback + */ + ConversationManager.prototype.leave = function (args, sessionToken, cb, err) { + try { + Contracts_1.Contracts.throwIfNullOrUndefined(args, this.privErrors.invalidArgs.replace("{arg}", "config")); + Contracts_1.Contracts.throwIfNullOrWhitespace(sessionToken, this.privErrors.invalidArgs.replace("{arg}", "token")); + var endpointHost = args.getProperty(Exports_1.PropertyId.ConversationTranslator_Host, this.privHost); + var correlationId = args.getProperty(Exports_1.PropertyId.ConversationTranslator_CorrelationId); + var queryParams = {}; + queryParams[this.privRequestParams.apiVersion] = this.privApiVersion; + queryParams[this.privRequestParams.sessionToken] = sessionToken; + var headers = {}; + if (correlationId) { + headers[this.privRequestParams.correlationId] = correlationId; + } + var config = {}; + config.headers = headers; + var endpoint = "https://" + endpointHost + this.privRestPath; + // TODO: support a proxy and certificate validation + ConversationUtils_1.request("delete", endpoint, queryParams, null, config, function (response) { + if (!response.ok) { + // ignore errors on delete + } + if (!!cb) { + try { + cb(); + } + catch (e) { + if (!!err) { + err(e); + } + } + cb = undefined; + } + }); + } + catch (error) { + if (!!err) { + if (error instanceof Error) { + var typedError = error; + err(typedError.name + ": " + typedError.message); + } + else { + err(error); + } + } + } + }; + return ConversationManager; +}()); +exports.ConversationManager = ConversationManager; + + + +/***/ }), +/* 158 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 RestConfigBase_1 = __webpack_require__(159); +var ConversationConnectionConfig = /** @class */ (function (_super) { + __extends(ConversationConnectionConfig, _super); + function ConversationConnectionConfig() { + return _super !== null && _super.apply(this, arguments) || this; + } + Object.defineProperty(ConversationConnectionConfig, "host", { + get: function () { + return ConversationConnectionConfig.privHost; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationConnectionConfig, "apiVersion", { + get: function () { + return ConversationConnectionConfig.privApiVersion; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationConnectionConfig, "clientAppId", { + get: function () { + return ConversationConnectionConfig.privClientAppId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationConnectionConfig, "defaultLanguageCode", { + get: function () { + return ConversationConnectionConfig.privDefaultLanguageCode; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationConnectionConfig, "restPath", { + get: function () { + return ConversationConnectionConfig.privRestPath; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationConnectionConfig, "webSocketPath", { + get: function () { + return ConversationConnectionConfig.privWebSocketPath; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationConnectionConfig, "speechHost", { + get: function () { + return ConversationConnectionConfig.privSpeechHost; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationConnectionConfig, "speechPath", { + get: function () { + return ConversationConnectionConfig.privSpeechPath; + }, + enumerable: true, + configurable: true + }); + ConversationConnectionConfig.privHost = "dev.microsofttranslator.com"; + ConversationConnectionConfig.privRestPath = "/capito/room"; + ConversationConnectionConfig.privApiVersion = "2.0"; + ConversationConnectionConfig.privDefaultLanguageCode = "en-US"; + ConversationConnectionConfig.privClientAppId = "FC539C22-1767-4F1F-84BC-B4D811114F15"; + ConversationConnectionConfig.privWebSocketPath = "/capito/translate"; + ConversationConnectionConfig.privSpeechHost = "{region}.s2s.speech.microsoft.com"; + ConversationConnectionConfig.privSpeechPath = "/speech/translation/cognitiveservices/v1"; + return ConversationConnectionConfig; +}(RestConfigBase_1.RestConfigBase)); +exports.ConversationConnectionConfig = ConversationConnectionConfig; + + + +/***/ }), +/* 159 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var RestConfigBase = /** @class */ (function () { + function RestConfigBase() { + } + Object.defineProperty(RestConfigBase, "requestOptions", { + get: function () { + return RestConfigBase.privDefaultRequestOptions; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RestConfigBase, "configParams", { + get: function () { + return RestConfigBase.privDefaultParams; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(RestConfigBase, "restErrors", { + get: function () { + return RestConfigBase.privRestErrors; + }, + enumerable: true, + configurable: true + }); + RestConfigBase.privDefaultRequestOptions = { + headers: { + Accept: "application/json", + }, + ignoreCache: false, + timeout: 10000, + }; + RestConfigBase.privRestErrors = { + authInvalidSubscriptionKey: "You must specify either an authentication token to use, or a Cognitive Speech subscription key.", + authInvalidSubscriptionRegion: "You must specify the Cognitive Speech region to use.", + invalidArgs: "Required input not found: {arg}.", + invalidCreateJoinConversationResponse: "Creating/Joining conversation failed with HTTP {status}.", + invalidParticipantRequest: "The requested participant was not found.", + permissionDeniedConnect: "Required credentials not found.", + permissionDeniedConversation: "Invalid operation: only the host can {command} the conversation.", + permissionDeniedParticipant: "Invalid operation: only the host can {command} a participant.", + permissionDeniedSend: "Invalid operation: the conversation is not in a connected state.", + permissionDeniedStart: "Invalid operation: there is already an active conversation.", + }; + RestConfigBase.privDefaultParams = { + apiVersion: "api-version", + authorization: "Authorization", + clientAppId: "X-ClientAppId", + contentTypeKey: "Content-Type", + correlationId: "X-CorrelationId", + languageCode: "language", + nickname: "nickname", + profanity: "profanity", + requestId: "X-RequestId", + roomId: "roomid", + sessionToken: "token", + subscriptionKey: "Ocp-Apim-Subscription-Key", + subscriptionRegion: "Ocp-Apim-Subscription-Region", + token: "X-CapitoToken", + }; + return RestConfigBase; +}()); +exports.RestConfigBase = RestConfigBase; + + + +/***/ }), +/* 160 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var RestConfigBase_1 = __webpack_require__(159); +/** + * Config settings for Conversation Translator + */ +/** + * Helpers for sending / receiving HTTPS requests / responses. + * @param params + */ +function queryParams(params) { + if (params === void 0) { params = {}; } + return Object.keys(params) + .map(function (k) { return encodeURIComponent(k) + "=" + encodeURIComponent(params[k]); }) + .join("&"); +} +function withQuery(url, params) { + if (params === void 0) { params = {}; } + var queryString = queryParams(params); + return queryString ? url + (url.indexOf("?") === -1 ? "?" : "&") + queryString : url; +} +function parseXHRResult(xhr) { + return { + data: xhr.responseText, + headers: xhr.getAllResponseHeaders(), + json: function () { return JSON.parse(xhr.responseText); }, + ok: xhr.status >= 200 && xhr.status < 300, + status: xhr.status, + statusText: xhr.statusText, + }; +} +function errorResponse(xhr, message) { + if (message === void 0) { message = null; } + return { + data: message || xhr.statusText, + headers: xhr.getAllResponseHeaders(), + json: function () { return JSON.parse(message || ("\"" + xhr.statusText + "\"")); }, + ok: false, + status: xhr.status, + statusText: xhr.statusText, + }; +} +function extractHeaderValue(headerKey, headers) { + var headerValue = ""; + try { + var arr = headers.trim().split(/[\r\n]+/); + var headerMap_1 = {}; + arr.forEach(function (line) { + var parts = line.split(": "); + var header = parts.shift().toLowerCase(); + var value = parts.join(": "); + headerMap_1[header] = value; + }); + headerValue = headerMap_1[headerKey.toLowerCase()]; + } + catch (e) { + // ignore the error + } + return headerValue; +} +exports.extractHeaderValue = extractHeaderValue; +function request(method, url, queryParams, body, options, callback) { + if (queryParams === void 0) { queryParams = {}; } + if (body === void 0) { body = null; } + if (options === void 0) { options = {}; } + var defaultRequestOptions = RestConfigBase_1.RestConfigBase.requestOptions; + var ignoreCache = options.ignoreCache || defaultRequestOptions.ignoreCache; + var headers = options.headers || defaultRequestOptions.headers; + var timeout = options.timeout || defaultRequestOptions.timeout; + var xhr = new XMLHttpRequest(); + xhr.open(method, withQuery(url, queryParams), true); + if (headers) { + Object.keys(headers).forEach(function (key) { return xhr.setRequestHeader(key, headers[key]); }); + } + if (ignoreCache) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + } + xhr.timeout = timeout; + xhr.onload = function (evt) { + callback(parseXHRResult(xhr)); + }; + xhr.onerror = function (evt) { + callback(errorResponse(xhr, "Failed to make request.")); + }; + xhr.ontimeout = function (evt) { + callback(errorResponse(xhr, "Request took longer than expected.")); + }; + if (method === "post" && body) { + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.send(JSON.stringify(body)); + } + else { + xhr.send(); + } +} +exports.request = request; +function PromiseToEmptyCallback(promise, cb, err) { + if (!!promise) { + promise.continueWith(function (antecedent) { + try { + if (antecedent.isError) { + if (!!err) { + err(antecedent.error); + } + } + else { + if (!!cb) { + cb(); + } + } + } + catch (e) { + if (!!err) { + err("'Unhandled error on promise callback: " + e + ". InnerError: " + antecedent.error + "'"); + } + } + }); + } + else { + if (!!err) { + err("Null promise"); + } + } +} +exports.PromiseToEmptyCallback = PromiseToEmptyCallback; + + + +/***/ }), +/* 161 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(26); +var Contracts_1 = __webpack_require__(33); +var Exports_2 = __webpack_require__(31); +var ConversationConnectionFactory_1 = __webpack_require__(162); +var ConversationServiceAdapter_1 = __webpack_require__(165); +var ConversationTranslatorInterfaces_1 = __webpack_require__(168); +var ConversationUtils_1 = __webpack_require__(160); +/** + * Sends messages to the Conversation Translator websocket and listens for incoming events containing websocket messages. + * Based off the recognizers in the SDK folder. + */ +var ConversationTranslatorRecognizer = /** @class */ (function (_super) { + __extends(ConversationTranslatorRecognizer, _super); + function ConversationTranslatorRecognizer(speechConfig, audioConfig) { + var _this = this; + var serviceConfigImpl = speechConfig; + Contracts_1.Contracts.throwIfNull(serviceConfigImpl, "speechConfig"); + _this = _super.call(this, audioConfig, serviceConfigImpl.properties, new ConversationConnectionFactory_1.ConversationConnectionFactory()) || this; + _this.privIsDisposed = false; + _this.privProperties = serviceConfigImpl.properties.clone(); + return _this; + } + Object.defineProperty(ConversationTranslatorRecognizer.prototype, "conversation", { + set: function (value) { + this.privRoom = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationTranslatorRecognizer.prototype, "speechRecognitionLanguage", { + /** + * Return the speech language used by the recognizer + */ + get: function () { + return this.privSpeechRecognitionLanguage; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationTranslatorRecognizer.prototype, "properties", { + /** + * Return the properties for the recognizer + */ + get: function () { + return this.privProperties; + }, + enumerable: true, + configurable: true + }); + ConversationTranslatorRecognizer.prototype.isDisposed = function () { + return this.privIsDisposed; + }; + /** + * Connect to the recognizer + * @param token + */ + ConversationTranslatorRecognizer.prototype.connect = function (token, cb, err) { + try { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + Contracts_1.Contracts.throwIfNullOrWhitespace(token, "token"); + this.privReco.conversationTranslatorToken = token; + this.privReco.connectAsync(cb, err); + } + catch (error) { + if (!!err) { + if (error instanceof Error) { + var typedError = error; + err(typedError.name + ": " + typedError.message); + } + else { + err(error); + } + } + } + }; + /** + * Disconnect from the recognizer + */ + ConversationTranslatorRecognizer.prototype.disconnect = function (cb, err) { + try { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + this.privRoom = undefined; + this.privReco.disconnectAsync(cb, err); + } + catch (error) { + if (!!err) { + if (error instanceof Error) { + var typedError = error; + err(typedError.name + ": " + typedError.message); + } + else { + err(error); + } + } + // Destroy the recognizer. + this.dispose(true); + } + }; + /** + * Send the text message command to the websocket + * @param conversationId + * @param participantId + * @param message + */ + ConversationTranslatorRecognizer.prototype.sendMessageRequest = function (message, cb, err) { + try { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + Contracts_1.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "conversationId"); + Contracts_1.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, "participantId"); + Contracts_1.Contracts.throwIfNullOrWhitespace(message, "message"); + var command = { + // tslint:disable-next-line: object-literal-shorthand + participantId: this.privRoom.participantId, + roomId: this.privRoom.roomId, + text: message, + type: ConversationTranslatorInterfaces_1.ConversationTranslatorMessageTypes.instantMessage + }; + this.sendMessage(JSON.stringify(command), cb, err); + } + catch (error) { + if (!!err) { + if (error instanceof Error) { + var typedError = error; + err(typedError.name + ": " + typedError.message); + } + else { + err(error); + } + } + // Destroy the recognizer. + this.dispose(true); + } + }; + /** + * Send the lock conversation command to the websocket + * @param conversationId + * @param participantId + * @param isLocked + */ + ConversationTranslatorRecognizer.prototype.sendLockRequest = function (isLocked, cb, err) { + try { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + Contracts_1.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "conversationId"); + Contracts_1.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, "participantId"); + Contracts_1.Contracts.throwIfNullOrUndefined(isLocked, "isLocked"); + var command = { + command: ConversationTranslatorInterfaces_1.ConversationTranslatorCommandTypes.setLockState, + // tslint:disable-next-line: object-literal-shorthand + participantId: this.privRoom.participantId, + roomid: this.privRoom.roomId, + type: ConversationTranslatorInterfaces_1.ConversationTranslatorMessageTypes.participantCommand, + value: isLocked + }; + this.sendMessage(JSON.stringify(command), cb, err); + } + catch (error) { + if (!!err) { + if (error instanceof Error) { + var typedError = error; + err(typedError.name + ": " + typedError.message); + } + else { + err(error); + } + } + // Destroy the recognizer. + this.dispose(true); + } + }; + /** + * Send the mute all participants command to the websocket + * @param conversationId + * @param participantId + * @param isMuted + */ + ConversationTranslatorRecognizer.prototype.sendMuteAllRequest = function (isMuted, cb, err) { + try { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + Contracts_1.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "conversationId"); + Contracts_1.Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, "participantId"); + Contracts_1.Contracts.throwIfNullOrUndefined(isMuted, "isMuted"); + var command = { + command: ConversationTranslatorInterfaces_1.ConversationTranslatorCommandTypes.setMuteAll, + // tslint:disable-next-line: object-literal-shorthand + participantId: this.privRoom.participantId, + roomid: this.privRoom.roomId, + type: ConversationTranslatorInterfaces_1.ConversationTranslatorMessageTypes.participantCommand, + value: isMuted + }; + this.sendMessage(JSON.stringify(command), cb, err); + } + catch (error) { + if (!!err) { + if (error instanceof Error) { + var typedError = error; + err(typedError.name + ": " + typedError.message); + } + else { + err(error); + } + } + // Destroy the recognizer. + this.dispose(true); + } + }; + /** + * Send the mute participant command to the websocket + * @param conversationId + * @param participantId + * @param isMuted + */ + ConversationTranslatorRecognizer.prototype.sendMuteRequest = function (participantId, isMuted, cb, err) { + try { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + Contracts_1.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "conversationId"); + Contracts_1.Contracts.throwIfNullOrWhitespace(participantId, "participantId"); + Contracts_1.Contracts.throwIfNullOrUndefined(isMuted, "isMuted"); + var command = { + command: ConversationTranslatorInterfaces_1.ConversationTranslatorCommandTypes.setMute, + // tslint:disable-next-line: object-literal-shorthand + participantId: participantId, + roomid: this.privRoom.roomId, + type: ConversationTranslatorInterfaces_1.ConversationTranslatorMessageTypes.participantCommand, + value: isMuted + }; + this.sendMessage(JSON.stringify(command), cb, err); + } + catch (error) { + if (!!err) { + if (error instanceof Error) { + var typedError = error; + err(typedError.name + ": " + typedError.message); + } + else { + err(error); + } + } + // Destroy the recognizer. + this.dispose(true); + } + }; + /** + * Send the eject participant command to the websocket + * @param conversationId + * @param participantId + */ + ConversationTranslatorRecognizer.prototype.sendEjectRequest = function (participantId, cb, err) { + try { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + Contracts_1.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "conversationId"); + Contracts_1.Contracts.throwIfNullOrWhitespace(participantId, "participantId"); + var command = { + command: ConversationTranslatorInterfaces_1.ConversationTranslatorCommandTypes.ejectParticipant, + // tslint:disable-next-line: object-literal-shorthand + participantId: participantId, + roomid: this.privRoom.roomId, + type: ConversationTranslatorInterfaces_1.ConversationTranslatorMessageTypes.participantCommand, + }; + this.sendMessage(JSON.stringify(command), cb, err); + if (!!cb) { + try { + cb(); + } + catch (e) { + if (!!err) { + err(e); + } + } + } + } + catch (error) { + if (!!err) { + if (error instanceof Error) { + var typedError = error; + err(typedError.name + ": " + typedError.message); + } + else { + err(error); + } + } + // Destroy the recognizer. + this.dispose(true); + } + }; + /** + * Send the mute participant command to the websocket + * @param conversationId + * @param participantId + * @param isMuted + */ + ConversationTranslatorRecognizer.prototype.sendChangeNicknameRequest = function (nickname, cb, err) { + try { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + Contracts_1.Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, "conversationId"); + Contracts_1.Contracts.throwIfNullOrWhitespace(nickname, "nickname"); + var command = { + command: ConversationTranslatorInterfaces_1.ConversationTranslatorCommandTypes.changeNickname, + nickname: nickname, + // tslint:disable-next-line: object-literal-shorthand + participantId: this.privRoom.participantId, + roomid: this.privRoom.roomId, + type: ConversationTranslatorInterfaces_1.ConversationTranslatorMessageTypes.participantCommand, + value: nickname + }; + this.sendMessage(JSON.stringify(command), cb, err); + } + catch (error) { + if (!!err) { + if (error instanceof Error) { + var typedError = error; + err(typedError.name + ": " + typedError.message); + } + else { + err(error); + } + } + // Destroy the recognizer. + this.dispose(true); + } + }; + /** + * Close and dispose the recognizer + */ + ConversationTranslatorRecognizer.prototype.close = function () { + Contracts_1.Contracts.throwIfDisposed(this.privIsDisposed); + this.dispose(true); + }; + /** + * Dispose the recognizer + * @param disposing + */ + ConversationTranslatorRecognizer.prototype.dispose = function (disposing) { + if (this.privIsDisposed) { + return; + } + if (disposing) { + this.privIsDisposed = true; + _super.prototype.dispose.call(this, disposing); + } + }; + /** + * Create the config for the recognizer + * @param speechConfig + */ + ConversationTranslatorRecognizer.prototype.createRecognizerConfig = function (speechConfig) { + return new Exports_1.RecognizerConfig(speechConfig, this.privProperties); + }; + /** + * Create the service recognizer. + * The audio source is redundnant here but is required by the implementation. + * @param authentication + * @param connectionFactory + * @param audioConfig + * @param recognizerConfig + */ + ConversationTranslatorRecognizer.prototype.createServiceRecognizer = function (authentication, connectionFactory, audioConfig, recognizerConfig) { + var audioSource = audioConfig; + return new ConversationServiceAdapter_1.ConversationServiceAdapter(authentication, connectionFactory, audioSource, recognizerConfig, this); + }; + ConversationTranslatorRecognizer.prototype.sendMessage = function (msg, cb, err) { + var withAsync = this.privReco; + ConversationUtils_1.PromiseToEmptyCallback(withAsync.sendMessageAsync(msg), cb, err); + }; + return ConversationTranslatorRecognizer; +}(Exports_2.Recognizer)); +exports.ConversationTranslatorRecognizer = ConversationTranslatorRecognizer; + + + +/***/ }), +/* 162 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(2); +var Exports_2 = __webpack_require__(4); +var Contracts_1 = __webpack_require__(33); +var Exports_3 = __webpack_require__(31); +var ConnectionFactoryBase_1 = __webpack_require__(72); +var ConversationConnectionConfig_1 = __webpack_require__(158); +var ConversationWebsocketMessageFormatter_1 = __webpack_require__(163); +/** + * Create a connection to the Conversation Translator websocket for sending instant messages and commands, and for receiving translated messages. + * The conversation must already have been started or joined. + */ +var ConversationConnectionFactory = /** @class */ (function (_super) { + __extends(ConversationConnectionFactory, _super); + function ConversationConnectionFactory() { + return _super !== null && _super.apply(this, arguments) || this; + } + ConversationConnectionFactory.prototype.create = function (config, authInfo, connectionId) { + var endpointHost = config.parameters.getProperty(Exports_3.PropertyId.ConversationTranslator_Host, ConversationConnectionConfig_1.ConversationConnectionConfig.host); + var correlationId = config.parameters.getProperty(Exports_3.PropertyId.ConversationTranslator_CorrelationId, Exports_2.createGuid()); + var endpoint = "wss://" + endpointHost + ConversationConnectionConfig_1.ConversationConnectionConfig.webSocketPath; + var token = config.parameters.getProperty(Exports_3.PropertyId.ConversationTranslator_Token, undefined); + Contracts_1.Contracts.throwIfNullOrUndefined(token, "token"); + var queryParams = {}; + queryParams[ConversationConnectionConfig_1.ConversationConnectionConfig.configParams.apiVersion] = ConversationConnectionConfig_1.ConversationConnectionConfig.apiVersion; + queryParams[ConversationConnectionConfig_1.ConversationConnectionConfig.configParams.token] = token; + queryParams[ConversationConnectionConfig_1.ConversationConnectionConfig.configParams.correlationId] = correlationId; + return new Exports_1.WebsocketConnection(endpoint, queryParams, {}, new ConversationWebsocketMessageFormatter_1.ConversationWebsocketMessageFormatter(), Exports_1.ProxyInfo.fromRecognizerConfig(config), connectionId); + }; + return ConversationConnectionFactory; +}(ConnectionFactoryBase_1.ConnectionFactoryBase)); +exports.ConversationConnectionFactory = ConversationConnectionFactory; + + + +/***/ }), +/* 163 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(4); +var ConversationConnectionMessage_1 = __webpack_require__(164); +/** + * Based off WebsocketMessageFormatter. The messages for Conversation Translator have some variations from the Speech messages. + */ +var ConversationWebsocketMessageFormatter = /** @class */ (function () { + function ConversationWebsocketMessageFormatter() { + /** + * Format incoming messages: text (speech partial/final, IM) or binary (tts) + */ + this.toConnectionMessage = function (message) { + var deferral = new Exports_1.Deferred(); + try { + if (message.messageType === Exports_1.MessageType.Text) { + var incomingMessage = new ConversationConnectionMessage_1.ConversationConnectionMessage(message.messageType, message.textContent, {}, message.id); + deferral.resolve(incomingMessage); + } + else if (message.messageType === Exports_1.MessageType.Binary) { + deferral.resolve(new ConversationConnectionMessage_1.ConversationConnectionMessage(message.messageType, message.binaryContent, undefined, message.id)); + } + } + catch (e) { + deferral.reject("Error formatting the message. Error: " + e); + } + return deferral.promise(); + }; + /** + * Format outgoing messages: text (commands or IM) + */ + this.fromConnectionMessage = function (message) { + var deferral = new Exports_1.Deferred(); + try { + if (message.messageType === Exports_1.MessageType.Text) { + var payload = "" + (message.textBody ? message.textBody : ""); + deferral.resolve(new Exports_1.RawWebsocketMessage(Exports_1.MessageType.Text, payload, message.id)); + } + } + catch (e) { + deferral.reject("Error formatting the message. " + e); + } + return deferral.promise(); + }; + } + return ConversationWebsocketMessageFormatter; +}()); +exports.ConversationWebsocketMessageFormatter = ConversationWebsocketMessageFormatter; + + + +/***/ }), +/* 164 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(4); +var ConversationConnectionMessage = /** @class */ (function (_super) { + __extends(ConversationConnectionMessage, _super); + function ConversationConnectionMessage(messageType, body, headers, id) { + var _this = _super.call(this, messageType, body, headers, id) || this; + var json = JSON.parse(_this.textBody); + if (json.type !== undefined) { + _this.privConversationMessageType = json.type; + } + return _this; + } + Object.defineProperty(ConversationConnectionMessage.prototype, "conversationMessageType", { + get: function () { + return this.privConversationMessageType; + }, + enumerable: true, + configurable: true + }); + return ConversationConnectionMessage; +}(Exports_1.ConnectionMessage)); +exports.ConversationConnectionMessage = ConversationConnectionMessage; + + + +/***/ }), +/* 165 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(4); +var Promise_1 = __webpack_require__(16); +var Exports_2 = __webpack_require__(31); +var Exports_3 = __webpack_require__(26); +var ConversationConnectionMessage_1 = __webpack_require__(164); +var ConversationRequestSession_1 = __webpack_require__(166); +var ConversationTranslatorEventArgs_1 = __webpack_require__(167); +var ConversationTranslatorInterfaces_1 = __webpack_require__(168); +var Exports_4 = __webpack_require__(169); +/*** + * The service adapter handles sending and receiving messages to the Conversation Translator websocket. + */ +var ConversationServiceAdapter = /** @class */ (function (_super) { + __extends(ConversationServiceAdapter, _super); + function ConversationServiceAdapter(authentication, connectionFactory, audioSource, recognizerConfig, conversationServiceConnector) { + var _this = _super.call(this, authentication, connectionFactory, audioSource, recognizerConfig, conversationServiceConnector) || this; + _this.privLastPartialUtteranceId = ""; + _this.sendMessageAsync = function (message) { + var sink = new Promise_1.Sink(); + _this.fetchConversationConnection().continueWith(function (antecedent) { + try { + if (antecedent.isError) { + sink.reject(antecedent.error); + } + else { + antecedent.result.send(new ConversationConnectionMessage_1.ConversationConnectionMessage(Exports_1.MessageType.Text, message)) + .continueWith(function (innerAntecedent) { + try { + if (innerAntecedent.isError) { + sink.reject(innerAntecedent.error); + } + else { + sink.resolve(innerAntecedent.result); + } + } + catch (e) { + sink.reject("Unhandled inner error: " + e); + } + }); + } + } + catch (e) { + sink.reject("Unhandled error: " + e); + } + }); + return new Exports_1.Promise(sink); + }; + _this.noOp = function () { + // operation not supported + }; + /** + * Process incoming websocket messages + */ + _this.receiveConversationMessageOverride = function (successCallback, errorCallBack) { + // we won't rely on the cascading promises of the connection since we want to continually be available to receive messages + var communicationCustodian = new Exports_1.Deferred(); + _this.fetchConversationConnection().on(function (connection) { + return connection.read().onSuccessContinueWithPromise(function (message) { + var isDisposed = _this.isDisposed(); + var terminateMessageLoop = (!_this.isDisposed() && _this.terminateMessageLoop); + var sessionId = _this.privConversationRequestSession.sessionId; + var sendFinal = false; + if (isDisposed || terminateMessageLoop) { + // We're done. + communicationCustodian.resolve(undefined); + return Exports_1.PromiseHelper.fromResult(undefined); + } + if (!message) { + return _this.receiveConversationMessageOverride(); + } + try { + switch (message.conversationMessageType.toLowerCase()) { + case "info": + case "participant_command": + case "command": + var commandPayload = Exports_4.CommandResponsePayload.fromJSON(message.textBody); + switch (commandPayload.command.toLowerCase()) { + /** + * 'ParticpantList' is the first message sent to the user after the websocket connection has opened. + * The consuming client must wait for this message to arrive + * before starting to send their own data. + */ + case "participantlist": + var participantsPayload = Exports_4.ParticipantsListPayloadResponse.fromJSON(message.textBody); + var participantsResult = participantsPayload.participants.map(function (p) { + var participant = { + avatar: p.avatar, + displayName: p.nickname, + id: p.participantId, + isHost: p.ishost, + isMuted: p.ismuted, + isUsingTts: p.usetts, + preferredLanguage: p.locale + }; + return participant; + }); + if (!!_this.privConversationServiceConnector.participantsListReceived) { + _this.privConversationServiceConnector.participantsListReceived(_this.privConversationServiceConnector, new ConversationTranslatorEventArgs_1.ParticipantsListEventArgs(participantsPayload.roomid, participantsPayload.token, participantsPayload.translateTo, participantsPayload.profanityFilter, participantsPayload.roomProfanityFilter, participantsPayload.roomLocked, participantsPayload.muteAll, participantsResult, sessionId)); + } + break; + /** + * 'SetTranslateToLanguages' represents the list of languages being used in the Conversation by all users(?). + * This is sent at the start of the Conversation + */ + case "settranslatetolanguages": + if (!!_this.privConversationServiceConnector.participantUpdateCommandReceived) { + _this.privConversationServiceConnector.participantUpdateCommandReceived(_this.privConversationServiceConnector, new ConversationTranslatorEventArgs_1.ParticipantAttributeEventArgs(commandPayload.participantId, ConversationTranslatorInterfaces_1.ConversationTranslatorCommandTypes.setTranslateToLanguages, commandPayload.value, sessionId)); + } + break; + /** + * 'SetProfanityFiltering' lets the client set the level of profanity filtering. + * If sent by the participant the setting will effect only their own profanity level. + * If sent by the host, the setting will effect all participants including the host. + * Note: the profanity filters differ from Speech Service (?): 'marked', 'raw', 'removed', 'tagged' + */ + case "setprofanityfiltering": + if (!!_this.privConversationServiceConnector.participantUpdateCommandReceived) { + _this.privConversationServiceConnector.participantUpdateCommandReceived(_this.privConversationServiceConnector, new ConversationTranslatorEventArgs_1.ParticipantAttributeEventArgs(commandPayload.participantId, ConversationTranslatorInterfaces_1.ConversationTranslatorCommandTypes.setProfanityFiltering, commandPayload.value, sessionId)); + } + break; + /** + * 'SetMute' is sent if the participant has been muted by the host. + * Check the 'participantId' to determine if the current user has been muted. + */ + case "setmute": + if (!!_this.privConversationServiceConnector.participantUpdateCommandReceived) { + _this.privConversationServiceConnector.participantUpdateCommandReceived(_this.privConversationServiceConnector, new ConversationTranslatorEventArgs_1.ParticipantAttributeEventArgs(commandPayload.participantId, ConversationTranslatorInterfaces_1.ConversationTranslatorCommandTypes.setMute, commandPayload.value, sessionId)); + } + break; + /** + * 'SetMuteAll' is sent if the Conversation has been muted by the host. + */ + case "setmuteall": + if (!!_this.privConversationServiceConnector.muteAllCommandReceived) { + _this.privConversationServiceConnector.muteAllCommandReceived(_this.privConversationServiceConnector, new ConversationTranslatorEventArgs_1.MuteAllEventArgs(commandPayload.value, sessionId)); + } + break; + /** + * 'RoomExpirationWarning' is sent towards the end of the Conversation session to give a timeout warning. + */ + case "roomexpirationwarning": + if (!!_this.privConversationServiceConnector.conversationExpiration) { + _this.privConversationServiceConnector.conversationExpiration(_this.privConversationServiceConnector, new Exports_2.ConversationExpirationEventArgs(commandPayload.value, _this.privConversationRequestSession.sessionId)); + } + break; + /** + * 'SetUseTts' is sent as a confirmation if the user requests TTS to be turned on or off. + */ + case "setusetts": + if (!!_this.privConversationServiceConnector.participantUpdateCommandReceived) { + _this.privConversationServiceConnector.participantUpdateCommandReceived(_this.privConversationServiceConnector, new ConversationTranslatorEventArgs_1.ParticipantAttributeEventArgs(commandPayload.participantId, ConversationTranslatorInterfaces_1.ConversationTranslatorCommandTypes.setUseTTS, commandPayload.value, sessionId)); + } + break; + /** + * 'SetLockState' is set if the host has locked or unlocked the Conversation. + */ + case "setlockstate": + if (!!_this.privConversationServiceConnector.lockRoomCommandReceived) { + _this.privConversationServiceConnector.lockRoomCommandReceived(_this.privConversationServiceConnector, new ConversationTranslatorEventArgs_1.LockRoomEventArgs(commandPayload.value, sessionId)); + } + break; + /** + * 'ChangeNickname' is received if a user changes their display name. + * Any cached particpiants list should be updated to reflect the display name. + */ + case "changenickname": + if (!!_this.privConversationServiceConnector.participantUpdateCommandReceived) { + _this.privConversationServiceConnector.participantUpdateCommandReceived(_this.privConversationServiceConnector, new ConversationTranslatorEventArgs_1.ParticipantAttributeEventArgs(commandPayload.participantId, ConversationTranslatorInterfaces_1.ConversationTranslatorCommandTypes.changeNickname, commandPayload.nickname, sessionId)); + } + break; + /** + * 'JoinSession' is sent when a user joins the Conversation. + */ + case "joinsession": + var joinParticipantPayload = Exports_4.ParticipantPayloadResponse.fromJSON(message.textBody); + var joiningParticipant = { + avatar: joinParticipantPayload.avatar, + displayName: joinParticipantPayload.nickname, + id: joinParticipantPayload.participantId, + isHost: joinParticipantPayload.ishost, + isMuted: joinParticipantPayload.ismuted, + isUsingTts: joinParticipantPayload.usetts, + preferredLanguage: joinParticipantPayload.locale, + }; + if (!!_this.privConversationServiceConnector.participantJoinCommandReceived) { + _this.privConversationServiceConnector.participantJoinCommandReceived(_this.privConversationServiceConnector, new ConversationTranslatorEventArgs_1.ParticipantEventArgs(joiningParticipant, sessionId)); + } + break; + /** + * 'LeaveSession' is sent when a user leaves the Conversation'. + */ + case "leavesession": + var leavingParticipant = { + id: commandPayload.participantId + }; + if (!!_this.privConversationServiceConnector.participantLeaveCommandReceived) { + _this.privConversationServiceConnector.participantLeaveCommandReceived(_this.privConversationServiceConnector, new ConversationTranslatorEventArgs_1.ParticipantEventArgs(leavingParticipant, sessionId)); + } + break; + /** + * 'DisconnectSession' is sent when a user is disconnected from the session (e.g. network problem). + * Check the 'ParticipantId' to check whether the message is for the current user. + */ + case "disconnectsession": + var disconnectParticipant = { + id: commandPayload.participantId + }; + break; + /** + * Message not recognized. + */ + default: + break; + } + break; + /** + * 'partial' (or 'hypothesis') represents a unfinalized speech message. + */ + case "partial": + /** + * 'final' (or 'phrase') represents a finalized speech message. + */ + case "final": + var speechPayload = Exports_4.SpeechResponsePayload.fromJSON(message.textBody); + var speechResult = new Exports_2.ConversationTranslationResult(speechPayload.participantId, _this.getTranslations(speechPayload.translations), speechPayload.language, undefined, undefined, speechPayload.recognition, undefined, undefined, message.textBody, undefined); + if (speechPayload.isFinal) { + // check the length, sometimes empty finals are returned + if (speechResult.text !== undefined && speechResult.text.length > 0) { + sendFinal = true; + } + else if (speechPayload.id === _this.privLastPartialUtteranceId) { + // send final as normal. We had a non-empty partial for this same utterance + // so sending the empty final is important + sendFinal = true; + } + else { + // suppress unneeded final + } + if (sendFinal) { + if (!!_this.privConversationServiceConnector.translationReceived) { + _this.privConversationServiceConnector.translationReceived(_this.privConversationServiceConnector, new ConversationTranslatorEventArgs_1.ConversationReceivedTranslationEventArgs(ConversationTranslatorInterfaces_1.ConversationTranslatorMessageTypes.final, speechResult, sessionId)); + } + } + } + else if (speechResult.text !== undefined) { + _this.privLastPartialUtteranceId = speechPayload.id; + if (!!_this.privConversationServiceConnector.translationReceived) { + _this.privConversationServiceConnector.translationReceived(_this.privConversationServiceConnector, new ConversationTranslatorEventArgs_1.ConversationReceivedTranslationEventArgs(ConversationTranslatorInterfaces_1.ConversationTranslatorMessageTypes.partial, speechResult, sessionId)); + } + } + break; + /** + * "translated_message" is a text message or instant message (IM). + */ + case "translated_message": + var textPayload = Exports_4.TextResponsePayload.fromJSON(message.textBody); + var textResult = new Exports_2.ConversationTranslationResult(textPayload.participantId, _this.getTranslations(textPayload.translations), textPayload.language, undefined, undefined, textPayload.originalText, undefined, undefined, undefined, message.textBody, undefined); + if (!!_this.privConversationServiceConnector.translationReceived) { + _this.privConversationServiceConnector.translationReceived(_this.privConversationServiceConnector, new ConversationTranslatorEventArgs_1.ConversationReceivedTranslationEventArgs(ConversationTranslatorInterfaces_1.ConversationTranslatorMessageTypes.instantMessage, textResult, sessionId)); + } + break; + default: + // ignore any unsupported message types + break; + } + } + catch (e) { + // continue + } + return _this.receiveConversationMessageOverride(); + }); + }, function (error) { + _this.terminateMessageLoop = true; + }); + return communicationCustodian.promise(); + }; + _this.fetchConversationConnection = function () { + return _this.configConnection(); + }; + _this.privConversationServiceConnector = conversationServiceConnector; + _this.privConversationAuthentication = authentication; + _this.receiveMessageOverride = _this.receiveConversationMessageOverride; + _this.recognizeOverride = _this.noOp; + _this.connectImplOverride = _this.conversationConnectImpl; + _this.configConnectionOverride = _this.configConnection; + _this.fetchConnectionOverride = _this.fetchConversationConnection; + _this.disconnectOverride = _this.privDisconnect; + _this.privConversationRequestSession = new ConversationRequestSession_1.ConversationRequestSession(Exports_1.createNoDashGuid()); + _this.privConversationConnectionFactory = connectionFactory; + _this.privConversationIsDisposed = false; + return _this; + } + ConversationServiceAdapter.prototype.isDisposed = function () { + return this.privConversationIsDisposed; + }; + ConversationServiceAdapter.prototype.dispose = function (reason) { + this.privConversationIsDisposed = true; + if (this.privConnectionConfigPromise) { + this.privConnectionConfigPromise.onSuccessContinueWith(function (connection) { + connection.dispose(reason); + }); + } + }; + ConversationServiceAdapter.prototype.sendMessage = function (message) { + this.fetchConversationConnection().onSuccessContinueWith(function (connection) { + connection.send(new ConversationConnectionMessage_1.ConversationConnectionMessage(Exports_1.MessageType.Text, message)); + }); + }; + ConversationServiceAdapter.prototype.privDisconnect = function () { + if (this.terminateMessageLoop) { + return; + } + this.cancelRecognition(this.privConversationRequestSession.sessionId, this.privConversationRequestSession.requestId, Exports_2.CancellationReason.Error, Exports_2.CancellationErrorCode.NoError, "Disconnecting"); + this.terminateMessageLoop = true; + if (this.privConversationConnectionPromise.result().isCompleted) { + if (!this.privConversationConnectionPromise.result().isError) { + this.privConversationConnectionPromise.result().result.dispose(); + this.privConversationConnectionPromise = null; + } + } + else { + this.privConversationConnectionPromise.onSuccessContinueWith(function (connection) { + connection.dispose(); + }); + } + }; + ConversationServiceAdapter.prototype.processTypeSpecificMessages = function (connectionMessage, successCallback, errorCallBack) { + return true; + }; + // Cancels recognition. + ConversationServiceAdapter.prototype.cancelRecognition = function (sessionId, requestId, cancellationReason, errorCode, error) { + this.terminateMessageLoop = true; + var cancelEvent = new Exports_2.ConversationTranslationCanceledEventArgs(cancellationReason, error, errorCode, undefined, sessionId); + try { + if (!!this.privConversationServiceConnector.canceled) { + this.privConversationServiceConnector.canceled(this.privConversationServiceConnector, cancelEvent); + } + } + catch (_a) { + // continue on error + } + }; + /** + * Establishes a websocket connection to the end point. + * @param isUnAuthorized + */ + ConversationServiceAdapter.prototype.conversationConnectImpl = function (isUnAuthorized) { + var _this = this; + if (isUnAuthorized === void 0) { isUnAuthorized = false; } + if (this.privConversationConnectionPromise) { + if (this.privConversationConnectionPromise.result().isCompleted && + (this.privConversationConnectionPromise.result().isError + || this.privConversationConnectionPromise.result().result.state() === Exports_1.ConnectionState.Disconnected)) { + this.privConnectionId = null; + this.privConversationConnectionPromise = null; + this.terminateMessageLoop = true; + return this.conversationConnectImpl(); + } + else { + return this.privConversationConnectionPromise; + } + } + this.privConversationAuthFetchEventId = Exports_1.createNoDashGuid(); + // keep the connectionId for reconnect events + if (this.privConnectionId === undefined) { + this.privConnectionId = Exports_1.createNoDashGuid(); + } + this.privConversationRequestSession.onPreConnectionStart(this.privConversationAuthFetchEventId, this.privConnectionId); + var authPromise = isUnAuthorized ? this.privConversationAuthentication.fetchOnExpiry(this.privConversationAuthFetchEventId) : this.privConversationAuthentication.fetch(this.privConversationAuthFetchEventId); + this.privConversationConnectionPromise = authPromise + .continueWithPromise(function (result) { + if (result.isError) { + _this.privConversationRequestSession.onAuthCompleted(true, result.error); + throw new Error(result.error); + } + else { + _this.privConversationRequestSession.onAuthCompleted(false); + } + var connection = _this.privConversationConnectionFactory.create(_this.privRecognizerConfig, result.result, _this.privConnectionId); + // Attach to the underlying event. No need to hold onto the detach pointers as in the event the connection goes away, + // it'll stop sending events. + connection.events.attach(function (event) { + _this.connectionEvents.onEvent(event); + }); + return connection.open().onSuccessContinueWithPromise(function (response) { + if (response.statusCode === 200) { + _this.privConversationRequestSession.onPreConnectionStart(_this.privConversationAuthFetchEventId, _this.privConnectionId); + _this.privConversationRequestSession.onConnectionEstablishCompleted(response.statusCode); + var sessionStartEventArgs = new Exports_2.SessionEventArgs(_this.privConversationRequestSession.sessionId); + if (!!_this.privConversationServiceConnector.connectionOpened) { + _this.privConversationServiceConnector.connectionOpened(_this.privConversationServiceConnector, sessionStartEventArgs); + } + return Exports_1.PromiseHelper.fromResult(connection); + } + else if (response.statusCode === 403 && !isUnAuthorized) { + return _this.conversationConnectImpl(true); + } + else { + _this.privConversationRequestSession.onConnectionEstablishCompleted(response.statusCode, response.reason); + return Exports_1.PromiseHelper.fromError("Unable to contact server. StatusCode: " + response.statusCode + ", " + _this.privRecognizerConfig.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_Endpoint) + " Reason: " + response.reason); + } + }); + }); + this.privConnectionLoop = this.startMessageLoop(); + return this.privConversationConnectionPromise; + }; + ConversationServiceAdapter.prototype.startMessageLoop = function () { + var _this = this; + this.terminateMessageLoop = false; + var messageRetrievalPromise = this.receiveConversationMessageOverride(); + return messageRetrievalPromise.on(function (r) { + return true; + }, function (error) { + _this.cancelRecognition(_this.privRequestSession ? _this.privRequestSession.sessionId : "", _this.privRequestSession ? _this.privRequestSession.requestId : "", Exports_2.CancellationReason.Error, Exports_2.CancellationErrorCode.RuntimeError, error); + }); + }; + // Takes an established websocket connection to the endpoint + ConversationServiceAdapter.prototype.configConnection = function () { + if (this.privConnectionConfigPromise) { + if (this.privConnectionConfigPromise.result().isCompleted && + (this.privConnectionConfigPromise.result().isError + || this.privConnectionConfigPromise.result().result.state() === Exports_1.ConnectionState.Disconnected)) { + this.privConnectionConfigPromise = null; + return this.configConnection(); + } + else { + return this.privConnectionConfigPromise; + } + } + if (this.terminateMessageLoop) { + return Exports_1.PromiseHelper.fromResult(undefined); + } + this.privConnectionConfigPromise = this.conversationConnectImpl() + .onSuccessContinueWith(function (connection) { + return connection; + }); + return this.privConnectionConfigPromise; + }; + ConversationServiceAdapter.prototype.getTranslations = function (serviceResultTranslations) { + var translations; + if (undefined !== serviceResultTranslations) { + translations = new Exports_2.Translations(); + for (var _i = 0, serviceResultTranslations_1 = serviceResultTranslations; _i < serviceResultTranslations_1.length; _i++) { + var translation = serviceResultTranslations_1[_i]; + translations.set(translation.lang, translation.translation); + } + } + return translations; + }; + return ConversationServiceAdapter; +}(Exports_3.ServiceRecognizerBase)); +exports.ConversationServiceAdapter = ConversationServiceAdapter; + + + +/***/ }), +/* 166 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(4); +/** + * Placeholder class for the Conversation Request Session. Based off RequestSession. + * TODO: define what telemetry is required. + */ +var ConversationRequestSession = /** @class */ (function () { + function ConversationRequestSession(sessionId) { + var _this = this; + this.privIsDisposed = false; + this.privDetachables = new Array(); + this.onPreConnectionStart = function (authFetchEventId, connectionId) { + _this.privSessionId = connectionId; + }; + this.onAuthCompleted = function (isError, error) { + if (isError) { + _this.onComplete(); + } + }; + this.onConnectionEstablishCompleted = function (statusCode, reason) { + if (statusCode === 200) { + return; + } + else if (statusCode === 403) { + _this.onComplete(); + } + }; + this.onServiceTurnEndResponse = function (continuousRecognition) { + if (!continuousRecognition) { + _this.onComplete(); + } + else { + _this.privRequestId = Exports_1.createNoDashGuid(); + } + }; + this.dispose = function (error) { + if (!_this.privIsDisposed) { + // we should have completed by now. If we did not its an unknown error. + _this.privIsDisposed = true; + for (var _i = 0, _a = _this.privDetachables; _i < _a.length; _i++) { + var detachable = _a[_i]; + detachable.detach(); + } + } + }; + this.onComplete = function () { + // + }; + this.privSessionId = sessionId; + this.privRequestId = Exports_1.createNoDashGuid(); + this.privRequestCompletionDeferral = new Exports_1.Deferred(); + } + Object.defineProperty(ConversationRequestSession.prototype, "sessionId", { + get: function () { + return this.privSessionId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationRequestSession.prototype, "requestId", { + get: function () { + return this.privRequestId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationRequestSession.prototype, "completionPromise", { + get: function () { + return this.privRequestCompletionDeferral.promise(); + }, + enumerable: true, + configurable: true + }); + return ConversationRequestSession; +}()); +exports.ConversationRequestSession = ConversationRequestSession; + + + +/***/ }), +/* 167 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +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 }); +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +var Exports_1 = __webpack_require__(31); +var MuteAllEventArgs = /** @class */ (function (_super) { + __extends(MuteAllEventArgs, _super); + function MuteAllEventArgs(isMuted, sessionId) { + var _this = _super.call(this, sessionId) || this; + _this.privIsMuted = isMuted; + return _this; + } + Object.defineProperty(MuteAllEventArgs.prototype, "isMuted", { + get: function () { + return this.privIsMuted; + }, + enumerable: true, + configurable: true + }); + return MuteAllEventArgs; +}(Exports_1.SessionEventArgs)); +exports.MuteAllEventArgs = MuteAllEventArgs; +// tslint:disable-next-line: max-classes-per-file +var LockRoomEventArgs = /** @class */ (function (_super) { + __extends(LockRoomEventArgs, _super); + function LockRoomEventArgs(isLocked, sessionId) { + var _this = _super.call(this, sessionId) || this; + _this.privIsLocked = isLocked; + return _this; + } + Object.defineProperty(LockRoomEventArgs.prototype, "isMuted", { + get: function () { + return this.privIsLocked; + }, + enumerable: true, + configurable: true + }); + return LockRoomEventArgs; +}(Exports_1.SessionEventArgs)); +exports.LockRoomEventArgs = LockRoomEventArgs; +// tslint:disable-next-line: max-classes-per-file +var ParticipantEventArgs = /** @class */ (function (_super) { + __extends(ParticipantEventArgs, _super); + function ParticipantEventArgs(participant, sessionId) { + var _this = _super.call(this, sessionId) || this; + _this.privParticipant = participant; + return _this; + } + Object.defineProperty(ParticipantEventArgs.prototype, "participant", { + get: function () { + return this.privParticipant; + }, + enumerable: true, + configurable: true + }); + return ParticipantEventArgs; +}(Exports_1.SessionEventArgs)); +exports.ParticipantEventArgs = ParticipantEventArgs; +// tslint:disable-next-line: max-classes-per-file +var ParticipantAttributeEventArgs = /** @class */ (function (_super) { + __extends(ParticipantAttributeEventArgs, _super); + function ParticipantAttributeEventArgs(participantId, key, value, sessionId) { + var _this = _super.call(this, sessionId) || this; + _this.privKey = key; + _this.privValue = value; + _this.privParticipantId = participantId; + return _this; + } + Object.defineProperty(ParticipantAttributeEventArgs.prototype, "value", { + get: function () { + return this.privValue; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantAttributeEventArgs.prototype, "key", { + get: function () { + return this.privKey; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantAttributeEventArgs.prototype, "id", { + get: function () { + return this.privParticipantId; + }, + enumerable: true, + configurable: true + }); + return ParticipantAttributeEventArgs; +}(Exports_1.SessionEventArgs)); +exports.ParticipantAttributeEventArgs = ParticipantAttributeEventArgs; +// tslint:disable-next-line: max-classes-per-file +var ParticipantsListEventArgs = /** @class */ (function (_super) { + __extends(ParticipantsListEventArgs, _super); + function ParticipantsListEventArgs(conversationId, token, translateTo, profanityFilter, roomProfanityFilter, isRoomLocked, isMuteAll, participants, sessionId) { + var _this = _super.call(this, sessionId) || this; + _this.privRoomId = conversationId; + _this.privSessionToken = token; + _this.privTranslateTo = translateTo; + _this.privProfanityFilter = profanityFilter; + _this.privRoomProfanityFilter = roomProfanityFilter; + _this.privIsRoomLocked = isRoomLocked; + _this.privIsRoomLocked = isMuteAll; + _this.privParticipants = participants; + return _this; + } + Object.defineProperty(ParticipantsListEventArgs.prototype, "sessionToken", { + get: function () { + return this.privSessionToken; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantsListEventArgs.prototype, "conversationId", { + get: function () { + return this.privRoomId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantsListEventArgs.prototype, "translateTo", { + get: function () { + return this.privTranslateTo; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantsListEventArgs.prototype, "profanityFilter", { + get: function () { + return this.privProfanityFilter; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantsListEventArgs.prototype, "roomProfanityFilter", { + get: function () { + return this.privRoomProfanityFilter; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantsListEventArgs.prototype, "isRoomLocked", { + get: function () { + return this.privIsRoomLocked; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantsListEventArgs.prototype, "isMuteAll", { + get: function () { + return this.privIsMuteAll; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantsListEventArgs.prototype, "participants", { + get: function () { + return this.privParticipants; + }, + enumerable: true, + configurable: true + }); + return ParticipantsListEventArgs; +}(Exports_1.SessionEventArgs)); +exports.ParticipantsListEventArgs = ParticipantsListEventArgs; +// tslint:disable-next-line: max-classes-per-file +var ConversationReceivedTranslationEventArgs = /** @class */ (function () { + function ConversationReceivedTranslationEventArgs(command, payload, sessionId) { + this.privPayload = payload; + this.privCommand = command; + this.privSessionId = sessionId; + } + Object.defineProperty(ConversationReceivedTranslationEventArgs.prototype, "payload", { + get: function () { + return this.privPayload; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationReceivedTranslationEventArgs.prototype, "command", { + get: function () { + return this.privCommand; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ConversationReceivedTranslationEventArgs.prototype, "sessionId", { + get: function () { + return this.privSessionId; + }, + enumerable: true, + configurable: true + }); + return ConversationReceivedTranslationEventArgs; +}()); +exports.ConversationReceivedTranslationEventArgs = ConversationReceivedTranslationEventArgs; + + + +/***/ }), +/* 168 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** Users participating in the conversation */ +var InternalParticipants = /** @class */ (function () { + function InternalParticipants(participants, meId) { + if (participants === void 0) { participants = []; } + this.participants = participants; + this.meId = meId; + } + /** + * Add or update a participant + * @param value + */ + InternalParticipants.prototype.addOrUpdateParticipant = function (value) { + if (value === undefined) { + return; + } + var exists = this.getParticipantIndex(value.id); + if (exists > -1) { + this.participants.splice(exists, 1, value); + } + else { + this.participants.push(value); + } + // ensure it was added ok + return this.getParticipant(value.id); + }; + /** + * Find the participant's position in the participants list. + * @param id + */ + InternalParticipants.prototype.getParticipantIndex = function (id) { + return this.participants.findIndex(function (p) { return p.id === id; }); + }; + /** + * Find the participant by id. + * @param id + */ + InternalParticipants.prototype.getParticipant = function (id) { + return this.participants.find(function (p) { return p.id === id; }); + }; + /*** + * Remove a participant from the participants list. + */ + InternalParticipants.prototype.deleteParticipant = function (id) { + this.participants = this.participants.filter(function (p) { return p.id !== id; }); + }; + Object.defineProperty(InternalParticipants.prototype, "host", { + /*** + * Helper to return the conversation host. + */ + get: function () { + return this.participants.find(function (p) { return p.isHost === true; }); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(InternalParticipants.prototype, "me", { + /** + * Helper to return the current user. + */ + get: function () { + return this.getParticipant(this.meId); + }, + enumerable: true, + configurable: true + }); + return InternalParticipants; +}()); +exports.InternalParticipants = InternalParticipants; +/** + * List of command message types + */ +exports.ConversationTranslatorMessageTypes = { + command: "command", + final: "final", + info: "info", + instantMessage: "instant_message", + partial: "partial", + participantCommand: "participant_command", + translatedMessage: "translated_message" +}; +/** + * List of command types + */ +exports.ConversationTranslatorCommandTypes = { + changeNickname: "ChangeNickname", + disconnectSession: "DisconnectSession", + ejectParticipant: "EjectParticipant", + instant_message: "instant_message", + joinSession: "JoinSession", + leaveSession: "LeaveSession", + participantList: "ParticipantList", + roomExpirationWarning: "RoomExpirationWarning", + setLockState: "SetLockState", + setMute: "SetMute", + setMuteAll: "SetMuteAll", + setProfanityFiltering: "SetProfanityFiltering", + setTranslateToLanguages: "SetTranslateToLanguages", + setUseTTS: "SetUseTTS" +}; + + + +/***/ }), +/* 169 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var CommandResponsePayload_1 = __webpack_require__(170); +exports.CommandResponsePayload = CommandResponsePayload_1.CommandResponsePayload; +var ParticipantResponsePayload_1 = __webpack_require__(171); +exports.ParticipantsListPayloadResponse = ParticipantResponsePayload_1.ParticipantsListPayloadResponse; +exports.ParticipantPayloadResponse = ParticipantResponsePayload_1.ParticipantPayloadResponse; +var TranslationResponsePayload_1 = __webpack_require__(172); +exports.SpeechResponsePayload = TranslationResponsePayload_1.SpeechResponsePayload; +exports.TextResponsePayload = TranslationResponsePayload_1.TextResponsePayload; + + + +/***/ }), +/* 170 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var CommandResponsePayload = /** @class */ (function () { + function CommandResponsePayload(json) { + this.privCommandResponse = JSON.parse(json); + } + CommandResponsePayload.fromJSON = function (json) { + return new CommandResponsePayload(json); + }; + Object.defineProperty(CommandResponsePayload.prototype, "type", { + get: function () { + return this.privCommandResponse.type; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CommandResponsePayload.prototype, "command", { + get: function () { + return this.privCommandResponse.command; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CommandResponsePayload.prototype, "id", { + get: function () { + return this.privCommandResponse.id; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CommandResponsePayload.prototype, "nickname", { + get: function () { + return this.privCommandResponse.nickname; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CommandResponsePayload.prototype, "participantId", { + get: function () { + return this.privCommandResponse.participantId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CommandResponsePayload.prototype, "roomid", { + get: function () { + return this.privCommandResponse.roomid; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CommandResponsePayload.prototype, "value", { + get: function () { + return this.privCommandResponse.value; + }, + enumerable: true, + configurable: true + }); + return CommandResponsePayload; +}()); +exports.CommandResponsePayload = CommandResponsePayload; + + + +/***/ }), +/* 171 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var ParticipantsListPayloadResponse = /** @class */ (function () { + function ParticipantsListPayloadResponse(json) { + this.privParticipantsPayloadResponse = JSON.parse(json); + } + ParticipantsListPayloadResponse.fromJSON = function (json) { + return new ParticipantsListPayloadResponse(json); + }; + Object.defineProperty(ParticipantsListPayloadResponse.prototype, "roomid", { + get: function () { + return this.privParticipantsPayloadResponse.roomid; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantsListPayloadResponse.prototype, "id", { + get: function () { + return this.privParticipantsPayloadResponse.id; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantsListPayloadResponse.prototype, "command", { + get: function () { + return this.privParticipantsPayloadResponse.command; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantsListPayloadResponse.prototype, "participants", { + get: function () { + return this.privParticipantsPayloadResponse.participants; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantsListPayloadResponse.prototype, "token", { + get: function () { + return this.privParticipantsPayloadResponse.token; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantsListPayloadResponse.prototype, "translateTo", { + get: function () { + return this.privParticipantsPayloadResponse.translateTo; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantsListPayloadResponse.prototype, "profanityFilter", { + get: function () { + return this.privParticipantsPayloadResponse.profanityFilter; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantsListPayloadResponse.prototype, "roomProfanityFilter", { + get: function () { + return this.privParticipantsPayloadResponse.roomProfanityFilter; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantsListPayloadResponse.prototype, "roomLocked", { + get: function () { + return this.privParticipantsPayloadResponse.roomLocked; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantsListPayloadResponse.prototype, "muteAll", { + get: function () { + return this.privParticipantsPayloadResponse.muteAll; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantsListPayloadResponse.prototype, "type", { + get: function () { + return this.privParticipantsPayloadResponse.type; + }, + enumerable: true, + configurable: true + }); + return ParticipantsListPayloadResponse; +}()); +exports.ParticipantsListPayloadResponse = ParticipantsListPayloadResponse; +// tslint:disable-next-line: max-classes-per-file +var ParticipantPayloadResponse = /** @class */ (function () { + function ParticipantPayloadResponse(json) { + this.privParticipantPayloadResponse = JSON.parse(json); + } + ParticipantPayloadResponse.fromJSON = function (json) { + return new ParticipantPayloadResponse(json); + }; + Object.defineProperty(ParticipantPayloadResponse.prototype, "nickname", { + get: function () { + return this.privParticipantPayloadResponse.nickname; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantPayloadResponse.prototype, "locale", { + get: function () { + return this.privParticipantPayloadResponse.locale; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantPayloadResponse.prototype, "usetts", { + get: function () { + return this.privParticipantPayloadResponse.usetts; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantPayloadResponse.prototype, "ismuted", { + get: function () { + return this.privParticipantPayloadResponse.ismuted; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantPayloadResponse.prototype, "ishost", { + get: function () { + return this.privParticipantPayloadResponse.ishost; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantPayloadResponse.prototype, "participantId", { + get: function () { + return this.privParticipantPayloadResponse.participantId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ParticipantPayloadResponse.prototype, "avatar", { + get: function () { + return this.privParticipantPayloadResponse.avatar; + }, + enumerable: true, + configurable: true + }); + return ParticipantPayloadResponse; +}()); +exports.ParticipantPayloadResponse = ParticipantPayloadResponse; + + + +/***/ }), +/* 172 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var SpeechResponsePayload = /** @class */ (function () { + function SpeechResponsePayload(json) { + this.privSpeechResponse = JSON.parse(json); + } + SpeechResponsePayload.fromJSON = function (json) { + return new SpeechResponsePayload(json); + }; + Object.defineProperty(SpeechResponsePayload.prototype, "recognition", { + get: function () { + return this.privSpeechResponse.recognition; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechResponsePayload.prototype, "translations", { + get: function () { + return this.privSpeechResponse.translations; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechResponsePayload.prototype, "id", { + get: function () { + return this.privSpeechResponse.id; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechResponsePayload.prototype, "language", { + get: function () { + return this.privSpeechResponse.language; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechResponsePayload.prototype, "nickname", { + get: function () { + return this.privSpeechResponse.nickname; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechResponsePayload.prototype, "participantId", { + get: function () { + return this.privSpeechResponse.participantId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechResponsePayload.prototype, "roomid", { + get: function () { + return this.privSpeechResponse.roomid; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechResponsePayload.prototype, "timestamp", { + get: function () { + return this.privSpeechResponse.timestamp; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechResponsePayload.prototype, "type", { + get: function () { + return this.privSpeechResponse.type; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeechResponsePayload.prototype, "isFinal", { + get: function () { + return this.privSpeechResponse.type === "final"; + }, + enumerable: true, + configurable: true + }); + return SpeechResponsePayload; +}()); +exports.SpeechResponsePayload = SpeechResponsePayload; +// tslint:disable-next-line: max-classes-per-file +var TextResponsePayload = /** @class */ (function () { + function TextResponsePayload(json) { + this.privTextResponse = JSON.parse(json); + } + TextResponsePayload.fromJSON = function (json) { + return new TextResponsePayload(json); + }; + Object.defineProperty(TextResponsePayload.prototype, "originalText", { + get: function () { + return this.privTextResponse.originalText; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TextResponsePayload.prototype, "translations", { + get: function () { + return this.privTextResponse.translations; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TextResponsePayload.prototype, "id", { + get: function () { + return this.privTextResponse.id; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TextResponsePayload.prototype, "language", { + get: function () { + return this.privTextResponse.language; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TextResponsePayload.prototype, "nickname", { + get: function () { + return this.privTextResponse.nickname; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TextResponsePayload.prototype, "participantId", { + get: function () { + return this.privTextResponse.participantId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TextResponsePayload.prototype, "roomid", { + get: function () { + return this.privTextResponse.roomid; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TextResponsePayload.prototype, "timestamp", { + get: function () { + return this.privTextResponse.timestamp; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TextResponsePayload.prototype, "type", { + get: function () { + return this.privTextResponse.type; + }, + enumerable: true, + configurable: true + }); + return TextResponsePayload; +}()); +exports.TextResponsePayload = TextResponsePayload; + + + +/***/ }), +/* 173 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var SynthesisAudioMetadata = /** @class */ (function () { + function SynthesisAudioMetadata(json) { + this.privSynthesisAudioMetadata = JSON.parse(json); + } + SynthesisAudioMetadata.fromJSON = function (json) { + return new SynthesisAudioMetadata(json); + }; + Object.defineProperty(SynthesisAudioMetadata.prototype, "Metadata", { + get: function () { + return this.privSynthesisAudioMetadata.Metadata; + }, + enumerable: true, + configurable: true + }); + return SynthesisAudioMetadata; +}()); +exports.SynthesisAudioMetadata = SynthesisAudioMetadata; + + + +/***/ }), +/* 174 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(4); +var AudioOutputStream_1 = __webpack_require__(43); +var SynthesisAdapterBase_1 = __webpack_require__(175); +var SynthesisEvents_1 = __webpack_require__(176); +var SynthesisTurn = /** @class */ (function () { + function SynthesisTurn() { + var _this = this; + this.privIsDisposed = false; + this.privIsSynthesizing = false; + this.privIsSynthesisEnded = false; + this.privBytesReceived = 0; + this.privTextOffset = 0; + this.privNextSearchTextIndex = 0; + this.onPreConnectionStart = function (authFetchEventId, connectionId) { + _this.privAuthFetchEventId = authFetchEventId; + _this.onEvent(new SynthesisEvents_1.ConnectingToSynthesisServiceEvent(_this.privRequestId, _this.privAuthFetchEventId)); + }; + this.onAuthCompleted = function (isError, error) { + if (isError) { + _this.onComplete(); + } + }; + this.onConnectionEstablishCompleted = function (statusCode, reason) { + if (statusCode === 200) { + _this.onEvent(new SynthesisEvents_1.SynthesisStartedEvent(_this.requestId, _this.privAuthFetchEventId)); + _this.privBytesReceived = 0; + return; + } + else if (statusCode === 403) { + _this.onComplete(); + } + }; + this.onServiceResponseMessage = function (responseJson) { + var response = JSON.parse(responseJson); + _this.streamId = response.audio.streamId; + }; + this.onServiceTurnEndResponse = function () { + _this.privTurnDeferral.resolve(true); + _this.onComplete(); + }; + this.onServiceTurnStartResponse = function () { + if (_this.privTurnDeferral.state() === Exports_1.PromiseState.None) { + // What? How are we starting a turn with another not done? + _this.privTurnDeferral.reject("Another turn started before current completed."); + } + _this.privTurnDeferral = new Exports_1.Deferred(); + }; + this.dispose = function (error) { + if (!_this.privIsDisposed) { + // we should have completed by now. If we did not its an unknown error. + _this.privIsDisposed = true; + } + }; + this.onEvent = function (event) { + Exports_1.Events.instance.onEvent(event); + }; + this.onComplete = function () { + if (_this.privIsSynthesizing) { + _this.privIsSynthesizing = false; + _this.privIsSynthesisEnded = true; + _this.privAudioOutputStream.close(); + if (_this.privTurnAudioDestination !== undefined) { + _this.privTurnAudioDestination.close(); + _this.privTurnAudioDestination = undefined; + } + } + }; + this.privRequestId = Exports_1.createNoDashGuid(); + this.privTurnDeferral = new Exports_1.Deferred(); + // We're not in a turn, so resolve. + this.privTurnDeferral.resolve(true); + } + Object.defineProperty(SynthesisTurn.prototype, "requestId", { + get: function () { + return this.privRequestId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SynthesisTurn.prototype, "streamId", { + get: function () { + return this.privStreamId; + }, + set: function (value) { + this.privStreamId = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SynthesisTurn.prototype, "audioOutputFormat", { + get: function () { + return this.privAudioOutputFormat; + }, + set: function (format) { + this.privAudioOutputFormat = format; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SynthesisTurn.prototype, "turnCompletionPromise", { + get: function () { + return this.privTurnDeferral.promise(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SynthesisTurn.prototype, "isSynthesisEnded", { + get: function () { + return this.privIsSynthesisEnded; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SynthesisTurn.prototype, "isSynthesizing", { + get: function () { + return this.privIsSynthesizing; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SynthesisTurn.prototype, "currentTextOffset", { + get: function () { + return this.privTextOffset; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SynthesisTurn.prototype, "bytesReceived", { + // The number of bytes received for current turn + get: function () { + return this.privBytesReceived; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SynthesisTurn.prototype, "allReceivedAudio", { + get: function () { + if (!!this.privReceivedAudio) { + return this.privReceivedAudio; + } + if (!this.privIsSynthesisEnded) { + return null; + } + this.readAllAudioFromStream(); + return this.allReceivedAudio; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SynthesisTurn.prototype, "allReceivedAudioWithHeader", { + get: function () { + if (!!this.privReceivedAudioWithHeader) { + return this.privReceivedAudioWithHeader; + } + if (!this.privIsSynthesisEnded) { + return null; + } + if (this.audioOutputFormat.hasHeader) { + this.privReceivedAudioWithHeader = SynthesisAdapterBase_1.SynthesisAdapterBase.addHeader(this.allReceivedAudio, this.audioOutputFormat); + return this.allReceivedAudioWithHeader; + } + else { + return this.allReceivedAudio; + } + }, + enumerable: true, + configurable: true + }); + SynthesisTurn.prototype.startNewSynthesis = function (requestId, rawText, isSSML, audioDestination) { + this.privIsSynthesisEnded = false; + this.privIsSynthesizing = true; + this.privRequestId = requestId; + this.privRawText = rawText; + this.privIsSSML = isSSML; + this.privAudioOutputStream = new AudioOutputStream_1.PullAudioOutputStreamImpl(); + this.privAudioOutputStream.format = this.privAudioOutputFormat; + this.privReceivedAudio = null; + this.privReceivedAudioWithHeader = null; + this.privBytesReceived = 0; + this.privTextOffset = 0; + this.privNextSearchTextIndex = 0; + if (audioDestination !== undefined) { + this.privTurnAudioDestination = audioDestination; + this.privTurnAudioDestination.format = this.privAudioOutputFormat; + } + this.onEvent(new SynthesisEvents_1.SynthesisTriggeredEvent(this.requestId, undefined, audioDestination === undefined ? undefined : audioDestination.id())); + }; + SynthesisTurn.prototype.onAudioChunkReceived = function (data) { + if (this.isSynthesizing) { + this.privAudioOutputStream.write(data); + this.privBytesReceived += data.byteLength; + if (this.privTurnAudioDestination !== undefined) { + this.privTurnAudioDestination.write(data); + } + } + }; + SynthesisTurn.prototype.onWordBoundaryEvent = function (text) { + this.updateTextOffset(text); + }; + SynthesisTurn.prototype.onStopSynthesizing = function () { + this.onComplete(); + }; + SynthesisTurn.prototype.updateTextOffset = function (text) { + if (this.privTextOffset >= 0) { + this.privTextOffset = this.privRawText.indexOf(text, this.privNextSearchTextIndex); + if (this.privTextOffset >= 0) { + this.privNextSearchTextIndex = this.privTextOffset + text.length; + } + if (this.privIsSSML) { + if (this.privRawText.indexOf("<", this.privTextOffset + 1) > this.privRawText.indexOf(">", this.privTextOffset + 1)) { + this.updateTextOffset(text); + } + } + } + }; + SynthesisTurn.prototype.readAllAudioFromStream = function () { + if (this.privIsSynthesisEnded) { + this.privReceivedAudio = new ArrayBuffer(this.bytesReceived); + try { + this.privAudioOutputStream.read(this.privReceivedAudio); + } + catch (e) { + this.privReceivedAudio = new ArrayBuffer(0); + } + } + }; + return SynthesisTurn; +}()); +exports.SynthesisTurn = SynthesisTurn; + + + +/***/ }), +/* 175 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(4); +var Exports_2 = __webpack_require__(31); +var Exports_3 = __webpack_require__(26); +var SpeechConnectionMessage_Internal_1 = __webpack_require__(128); +var SynthesisAdapterBase = /** @class */ (function () { + function SynthesisAdapterBase(authentication, connectionFactory, synthesizerConfig, speechSynthesizer, audioDestination) { + var _this = this; + this.speakOverride = undefined; + this.receiveMessageOverride = undefined; + this.connectImplOverride = undefined; + this.configConnectionOverride = undefined; + this.fetchConnectionOverride = undefined; + this.receiveMessage = function () { + return _this.fetchConnection().on(function (connection) { + return connection.read() + .onSuccessContinueWithPromise(function (message) { + if (_this.receiveMessageOverride !== undefined) { + return _this.receiveMessageOverride(); + } + if (_this.privIsDisposed) { + // We're done. + return Exports_1.PromiseHelper.fromResult(undefined); + } + // indicates we are draining the queue and it came with no message; + if (!message) { + if (!_this.privSynthesisTurn.isSynthesizing) { + return Exports_1.PromiseHelper.fromResult(true); + } + else { + return _this.receiveMessage(); + } + } + _this.privServiceHasSentMessage = true; + var connectionMessage = SpeechConnectionMessage_Internal_1.SpeechConnectionMessage.fromConnectionMessage(message); + if (connectionMessage.requestId.toLowerCase() === _this.privSynthesisTurn.requestId.toLowerCase()) { + switch (connectionMessage.path.toLowerCase()) { + case "turn.start": + _this.privSynthesisTurn.onServiceTurnStartResponse(); + break; + case "response": + _this.privSynthesisTurn.onServiceResponseMessage(connectionMessage.textBody); + break; + case "audio": + if (_this.privSynthesisTurn.streamId.toLowerCase() === connectionMessage.streamId.toLowerCase() + && !!connectionMessage.binaryBody) { + _this.privSynthesisTurn.onAudioChunkReceived(connectionMessage.binaryBody); + if (!!_this.privSpeechSynthesizer.synthesizing) { + try { + var audioWithHeader = SynthesisAdapterBase.addHeader(connectionMessage.binaryBody, _this.privSynthesisTurn.audioOutputFormat); + var ev = new Exports_2.SpeechSynthesisEventArgs(new Exports_2.SpeechSynthesisResult(_this.privSynthesisTurn.requestId, Exports_2.ResultReason.SynthesizingAudio, audioWithHeader)); + _this.privSpeechSynthesizer.synthesizing(_this.privSpeechSynthesizer, ev); + } + catch (error) { + // Not going to let errors in the event handler + // trip things up. + } + } + if (_this.privSessionAudioDestination !== undefined) { + _this.privSessionAudioDestination.write(connectionMessage.binaryBody); + } + } + break; + case "audio.metadata": + var metadataList = Exports_3.SynthesisAudioMetadata.fromJSON(connectionMessage.textBody).Metadata; + for (var _i = 0, metadataList_1 = metadataList; _i < metadataList_1.length; _i++) { + var metadata = metadataList_1[_i]; + if (metadata.Type.toLowerCase() === "WordBoundary".toLowerCase()) { + _this.privSynthesisTurn.onWordBoundaryEvent(metadata.Data.text.Text); + var ev = new Exports_2.SpeechSynthesisWordBoundaryEventArgs(metadata.Data.Offset, metadata.Data.text.Text, metadata.Data.text.Length, _this.privSynthesisTurn.currentTextOffset); + if (!!_this.privSpeechSynthesizer.wordBoundary) { + try { + _this.privSpeechSynthesizer.wordBoundary(_this.privSpeechSynthesizer, ev); + } + catch (error) { + // Not going to let errors in the event handler + // trip things up. + } + } + } + } + break; + case "turn.end": + _this.privSynthesisTurn.onServiceTurnEndResponse(); + var result = void 0; + try { + result = new Exports_2.SpeechSynthesisResult(_this.privSynthesisTurn.requestId, Exports_2.ResultReason.SynthesizingAudioCompleted, _this.privSynthesisTurn.allReceivedAudioWithHeader); + if (!!_this.privSuccessCallback) { + _this.privSuccessCallback(result); + } + } + catch (error) { + if (!!_this.privErrorCallback) { + _this.privErrorCallback(error); + } + } + if (_this.privSpeechSynthesizer.synthesisCompleted) { + try { + _this.privSpeechSynthesizer.synthesisCompleted(_this.privSpeechSynthesizer, new Exports_2.SpeechSynthesisEventArgs(result)); + } + catch (e) { + // Not going to let errors in the event handler + // trip things up. + } + } + break; + default: + if (!_this.processTypeSpecificMessages(connectionMessage)) { + // here are some messages that the derived class has not processed, dispatch them to connect class + if (!!_this.privServiceEvents) { + _this.serviceEvents.onEvent(new Exports_1.ServiceEvent(connectionMessage.path.toLowerCase(), connectionMessage.textBody)); + } + } + } + } + return _this.receiveMessage(); + }); + }, function (error) { + }); + }; + this.sendSynthesisContext = function (connection) { + var synthesisContextJson = _this.synthesisContext.toJSON(); + if (synthesisContextJson) { + return connection.send(new SpeechConnectionMessage_Internal_1.SpeechConnectionMessage(Exports_1.MessageType.Text, "synthesis.context", _this.privSynthesisTurn.requestId, "application/json", synthesisContextJson)); + } + return Exports_1.PromiseHelper.fromResult(true); + }; + this.sendSpeechServiceConfig = function (connection, SpeechServiceConfigJson) { + if (SpeechServiceConfigJson) { + return connection.send(new SpeechConnectionMessage_Internal_1.SpeechConnectionMessage(Exports_1.MessageType.Text, "speech.config", _this.privSynthesisTurn.requestId, "application/json", SpeechServiceConfigJson)); + } + return Exports_1.PromiseHelper.fromResult(true); + }; + this.sendSsmlMessage = function (connection, ssml, requestId) { + return connection.send(new SpeechConnectionMessage_Internal_1.SpeechConnectionMessage(Exports_1.MessageType.Text, "ssml", requestId, "application/ssml+xml", ssml)); + }; + this.fetchConnection = function () { + if (_this.fetchConnectionOverride !== undefined) { + return _this.fetchConnectionOverride(); + } + return _this.configureConnection(); + }; + if (!authentication) { + throw new Exports_1.ArgumentNullError("authentication"); + } + if (!connectionFactory) { + throw new Exports_1.ArgumentNullError("connectionFactory"); + } + if (!synthesizerConfig) { + throw new Exports_1.ArgumentNullError("synthesizerConfig"); + } + this.privAuthentication = authentication; + this.privConnectionFactory = connectionFactory; + this.privSynthesizerConfig = synthesizerConfig; + this.privIsDisposed = false; + this.privSpeechSynthesizer = speechSynthesizer; + this.privSessionAudioDestination = audioDestination; + this.privSynthesisTurn = new Exports_3.SynthesisTurn(); + this.privConnectionEvents = new Exports_1.EventSource(); + this.privServiceEvents = new Exports_1.EventSource(); + this.privSynthesisContext = new Exports_3.SynthesisContext(this.privSpeechSynthesizer); + this.privAgentConfig = new Exports_3.AgentConfig(); + this.connectionEvents.attach(function (connectionEvent) { + if (connectionEvent.name === "ConnectionClosedEvent") { + var connectionClosedEvent = connectionEvent; + _this.cancelSynthesisLocal(Exports_2.CancellationReason.Error, connectionClosedEvent.statusCode === 1007 ? Exports_2.CancellationErrorCode.BadRequestParameters : Exports_2.CancellationErrorCode.ConnectionFailure, connectionClosedEvent.reason + " websocket error code: " + connectionClosedEvent.statusCode); + } + }); + } + Object.defineProperty(SynthesisAdapterBase.prototype, "synthesisContext", { + get: function () { + return this.privSynthesisContext; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SynthesisAdapterBase.prototype, "agentConfig", { + get: function () { + return this.privAgentConfig; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SynthesisAdapterBase.prototype, "connectionEvents", { + get: function () { + return this.privConnectionEvents; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SynthesisAdapterBase.prototype, "serviceEvents", { + get: function () { + return this.privServiceEvents; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SynthesisAdapterBase.prototype, "activityTemplate", { + get: function () { return this.privActivityTemplate; }, + set: function (messagePayload) { this.privActivityTemplate = messagePayload; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SynthesisAdapterBase.prototype, "audioOutputFormat", { + set: function (format) { + this.privAudioOutputFormat = format; + this.privSynthesisTurn.audioOutputFormat = format; + if (this.privSessionAudioDestination !== undefined) { + this.privSessionAudioDestination.format = format; + } + if (this.synthesisContext !== undefined) { + this.synthesisContext.audioOutputFormat = format; + } + }, + enumerable: true, + configurable: true + }); + SynthesisAdapterBase.addHeader = function (audio, format) { + if (!format.hasHeader) { + return audio; + } + format.updateHeader(audio.byteLength); + var tmp = new Uint8Array(audio.byteLength + format.header.byteLength); + tmp.set(new Uint8Array(format.header), 0); + tmp.set(new Uint8Array(audio), format.header.byteLength); + return tmp.buffer; + }; + SynthesisAdapterBase.prototype.isDisposed = function () { + return this.privIsDisposed; + }; + SynthesisAdapterBase.prototype.dispose = function (reason) { + this.privIsDisposed = true; + if (this.privSessionAudioDestination !== undefined) { + this.privSessionAudioDestination.close(); + } + if (this.privConnectionConfigurationPromise) { + this.privConnectionConfigurationPromise.onSuccessContinueWith(function (connection) { + connection.dispose(reason); + }); + } + }; + SynthesisAdapterBase.prototype.connect = function () { + this.connectImpl().result(); + }; + SynthesisAdapterBase.prototype.connectAsync = function (cb, err) { + this.connectImpl().continueWith(function (promiseResult) { + try { + if (promiseResult.isError) { + if (!!err) { + err(promiseResult.error); + } + } + else if (promiseResult.isCompleted) { + if (!!cb) { + cb(); + } + } + } + catch (e) { + if (!!err) { + err(e); + } + } + }); + }; + SynthesisAdapterBase.prototype.sendNetworkMessage = function (path, payload, success, err) { + var _this = this; + var type = typeof payload === "string" ? Exports_1.MessageType.Text : Exports_1.MessageType.Binary; + var contentType = typeof payload === "string" ? "application/json" : ""; + this.fetchConnection().on(function (connection) { + connection.send(new SpeechConnectionMessage_Internal_1.SpeechConnectionMessage(type, path, _this.privSynthesisTurn.requestId, contentType, payload)).on(function () { + if (!!success) { + success(); + } + }, function (error) { + if (!!err) { + err(error); + } + }); + }, function (error) { + if (!!err) { + err(error); + } + }); + }; + SynthesisAdapterBase.prototype.Speak = function (text, isSSML, requestId, successCallback, errorCallBack, audioDestination) { + var _this = this; + var ssml; + if (isSSML) { + ssml = text; + } + else { + ssml = this.privSpeechSynthesizer.buildSsml(text); + } + if (this.speakOverride !== undefined) { + return this.speakOverride(ssml, requestId, successCallback, errorCallBack); + } + this.privSuccessCallback = successCallback; + this.privErrorCallback = errorCallBack; + this.privSynthesisTurn.startNewSynthesis(requestId, text, isSSML, audioDestination); + return this.fetchConnection().continueWithPromise(function (connection) { + if (connection.isError) { + _this.cancelSynthesisLocal(Exports_2.CancellationReason.Error, Exports_2.CancellationErrorCode.ConnectionFailure, connection.error); + return Exports_1.PromiseHelper.fromError(connection.error); + } + return _this.sendSynthesisContext(connection.result).continueWithPromise(function (result) { + if (result.isError) { + _this.cancelSynthesisLocal(Exports_2.CancellationReason.Error, Exports_2.CancellationErrorCode.ConnectionFailure, result.error); + return Exports_1.PromiseHelper.fromError(result.error); + } + return _this.sendSsmlMessage(connection.result, ssml, requestId).continueWithPromise(function (result) { + if (result.isError) { + _this.cancelSynthesisLocal(Exports_2.CancellationReason.Error, Exports_2.CancellationErrorCode.ConnectionFailure, result.error); + return Exports_1.PromiseHelper.fromError(result.error); + } + var synthesisStartEventArgs = new Exports_2.SpeechSynthesisEventArgs(new Exports_2.SpeechSynthesisResult(requestId, Exports_2.ResultReason.SynthesizingAudioStarted)); + if (!!_this.privSpeechSynthesizer.synthesisStarted) { + _this.privSpeechSynthesizer.synthesisStarted(_this.privSpeechSynthesizer, synthesisStartEventArgs); + } + var messageRetrievalPromise = _this.receiveMessage(); + return Exports_1.PromiseHelper.fromResult(true); + }); + }); + }); + }; + // Cancels synthesis. + SynthesisAdapterBase.prototype.cancelSynthesis = function (requestId, cancellationReason, errorCode, error) { + var properties = new Exports_2.PropertyCollection(); + properties.setProperty(Exports_3.CancellationErrorCodePropertyName, Exports_2.CancellationErrorCode[errorCode]); + var result = new Exports_2.SpeechSynthesisResult(requestId, Exports_2.ResultReason.Canceled, undefined, error, properties); + if (!!this.privSpeechSynthesizer.SynthesisCanceled) { + var cancelEvent = new Exports_2.SpeechSynthesisEventArgs(result); + try { + this.privSpeechSynthesizer.SynthesisCanceled(this.privSpeechSynthesizer, cancelEvent); + /* tslint:disable:no-empty */ + } + catch (_a) { } + } + if (!!this.privSuccessCallback) { + try { + this.privSuccessCallback(result); + /* tslint:disable:no-empty */ + } + catch (_b) { } + } + }; + // Cancels synthesis. + SynthesisAdapterBase.prototype.cancelSynthesisLocal = function (cancellationReason, errorCode, error) { + if (!!this.privSynthesisTurn.isSynthesizing) { + this.privSynthesisTurn.onStopSynthesizing(); + this.cancelSynthesis(this.privSynthesisTurn.requestId, cancellationReason, errorCode, error); + } + }; + SynthesisAdapterBase.prototype.processTypeSpecificMessages = function (connectionMessage, successCallback, errorCallBack) { + return true; + }; + // Establishes a websocket connection to the end point. + SynthesisAdapterBase.prototype.connectImpl = function (isUnAuthorized) { + var _this = this; + if (isUnAuthorized === void 0) { isUnAuthorized = false; } + if (this.connectImplOverride !== undefined) { + return this.connectImplOverride(isUnAuthorized); + } + if (this.privConnectionPromise) { + if (this.privConnectionPromise.result().isCompleted && + (this.privConnectionPromise.result().isError + || this.privConnectionPromise.result().result.state() === Exports_1.ConnectionState.Disconnected) && + this.privServiceHasSentMessage === true) { + this.privConnectionId = null; + this.privConnectionPromise = null; + this.privServiceHasSentMessage = false; + return this.connectImpl(); + } + else { + return this.privConnectionPromise; + } + } + this.privAuthFetchEventId = Exports_1.createNoDashGuid(); + this.privConnectionId = Exports_1.createNoDashGuid(); + this.privSynthesisTurn.onPreConnectionStart(this.privAuthFetchEventId, this.privConnectionId); + var authPromise = isUnAuthorized ? this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId) : this.privAuthentication.fetch(this.privAuthFetchEventId); + this.privConnectionPromise = authPromise + .continueWithPromise(function (result) { + if (result.isError) { + _this.privSynthesisTurn.onAuthCompleted(true, result.error); + throw new Error(result.error); + } + else { + _this.privSynthesisTurn.onAuthCompleted(false); + } + var connection = _this.privConnectionFactory.create(_this.privSynthesizerConfig, result.result, _this.privConnectionId); + // Attach to the underlying event. No need to hold onto the detach pointers as in the event the connection goes away, + // it'll stop sending events. + connection.events.attach(function (event) { + _this.connectionEvents.onEvent(event); + }); + return connection.open().onSuccessContinueWithPromise(function (response) { + if (response.statusCode === 200) { + _this.privSynthesisTurn.onPreConnectionStart(_this.privAuthFetchEventId, _this.privConnectionId); + _this.privSynthesisTurn.onConnectionEstablishCompleted(response.statusCode); + return Exports_1.PromiseHelper.fromResult(connection); + } + else if (response.statusCode === 403 && !isUnAuthorized) { + return _this.connectImpl(true); + } + else { + _this.privSynthesisTurn.onConnectionEstablishCompleted(response.statusCode, response.reason); + return Exports_1.PromiseHelper.fromError("Unable to contact server. StatusCode: " + response.statusCode + ", " + _this.privSynthesizerConfig.parameters.getProperty(Exports_2.PropertyId.SpeechServiceConnection_Endpoint) + " Reason: " + response.reason); + } + }); + }); + return this.privConnectionPromise; + }; + // Takes an established websocket connection to the endpoint and sends speech configuration information. + SynthesisAdapterBase.prototype.configureConnection = function () { + var _this = this; + if (this.configConnectionOverride !== undefined) { + return this.configConnectionOverride(); + } + if (this.privConnectionConfigurationPromise) { + if (this.privConnectionConfigurationPromise.result().isCompleted && + (this.privConnectionConfigurationPromise.result().isError + || this.privConnectionConfigurationPromise.result().result.state() === Exports_1.ConnectionState.Disconnected)) { + this.privConnectionConfigurationPromise = null; + return this.configureConnection(); + } + else { + return this.privConnectionConfigurationPromise; + } + } + this.privConnectionConfigurationPromise = this.connectImpl().onSuccessContinueWithPromise(function (connection) { + return _this.sendSpeechServiceConfig(connection, _this.privSynthesizerConfig.SpeechServiceConfig.serialize()) + .onSuccessContinueWith(function (_) { + return connection; + }); + }); + return this.privConnectionConfigurationPromise; + }; + SynthesisAdapterBase.telemetryDataEnabled = true; + return SynthesisAdapterBase; +}()); +exports.SynthesisAdapterBase = SynthesisAdapterBase; + + + +/***/ }), +/* 176 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// 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 Exports_1 = __webpack_require__(4); +var SpeechSynthesisEvent = /** @class */ (function (_super) { + __extends(SpeechSynthesisEvent, _super); + function SpeechSynthesisEvent(eventName, requestId, eventType) { + if (eventType === void 0) { eventType = Exports_1.EventType.Info; } + var _this = _super.call(this, eventName, eventType) || this; + _this.privRequestId = requestId; + return _this; + } + Object.defineProperty(SpeechSynthesisEvent.prototype, "requestId", { + get: function () { + return this.privRequestId; + }, + enumerable: true, + configurable: true + }); + return SpeechSynthesisEvent; +}(Exports_1.PlatformEvent)); +exports.SpeechSynthesisEvent = SpeechSynthesisEvent; +// tslint:disable-next-line:max-classes-per-file +var SynthesisTriggeredEvent = /** @class */ (function (_super) { + __extends(SynthesisTriggeredEvent, _super); + function SynthesisTriggeredEvent(requestId, sessionAudioDestinationId, turnAudioDestinationId) { + var _this = _super.call(this, "SynthesisTriggeredEvent", requestId) || this; + _this.privSessionAudioDestinationId = sessionAudioDestinationId; + _this.privTurnAudioDestinationId = turnAudioDestinationId; + return _this; + } + Object.defineProperty(SynthesisTriggeredEvent.prototype, "audioSessionDestinationId", { + get: function () { + return this.privSessionAudioDestinationId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SynthesisTriggeredEvent.prototype, "audioTurnDestinationId", { + get: function () { + return this.privTurnAudioDestinationId; + }, + enumerable: true, + configurable: true + }); + return SynthesisTriggeredEvent; +}(SpeechSynthesisEvent)); +exports.SynthesisTriggeredEvent = SynthesisTriggeredEvent; +// tslint:disable-next-line:max-classes-per-file +var ConnectingToSynthesisServiceEvent = /** @class */ (function (_super) { + __extends(ConnectingToSynthesisServiceEvent, _super); + function ConnectingToSynthesisServiceEvent(requestId, authFetchEventId) { + var _this = _super.call(this, "ConnectingToSynthesisServiceEvent", requestId) || this; + _this.privAuthFetchEventId = authFetchEventId; + return _this; + } + Object.defineProperty(ConnectingToSynthesisServiceEvent.prototype, "authFetchEventId", { + get: function () { + return this.privAuthFetchEventId; + }, + enumerable: true, + configurable: true + }); + return ConnectingToSynthesisServiceEvent; +}(SpeechSynthesisEvent)); +exports.ConnectingToSynthesisServiceEvent = ConnectingToSynthesisServiceEvent; +// tslint:disable-next-line:max-classes-per-file +var SynthesisStartedEvent = /** @class */ (function (_super) { + __extends(SynthesisStartedEvent, _super); + function SynthesisStartedEvent(requestId, authFetchEventId) { + var _this = _super.call(this, "SynthesisStartedEvent", requestId) || this; + _this.privAuthFetchEventId = authFetchEventId; + return _this; + } + Object.defineProperty(SynthesisStartedEvent.prototype, "authFetchEventId", { + get: function () { + return this.privAuthFetchEventId; + }, + enumerable: true, + configurable: true + }); + return SynthesisStartedEvent; +}(SpeechSynthesisEvent)); +exports.SynthesisStartedEvent = SynthesisStartedEvent; + + + +/***/ }), +/* 177 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var SynthesisServiceType; +(function (SynthesisServiceType) { + SynthesisServiceType[SynthesisServiceType["Standard"] = 0] = "Standard"; + SynthesisServiceType[SynthesisServiceType["Custom"] = 1] = "Custom"; +})(SynthesisServiceType = exports.SynthesisServiceType || (exports.SynthesisServiceType = {})); +var SynthesizerConfig = /** @class */ (function () { + function SynthesizerConfig(speechServiceConfig, parameters) { + this.privSynthesisServiceType = SynthesisServiceType.Standard; + this.privSpeechServiceConfig = speechServiceConfig ? speechServiceConfig : new Exports_1.SpeechServiceConfig(new Exports_1.Context(null)); + this.privParameters = parameters; + } + Object.defineProperty(SynthesizerConfig.prototype, "parameters", { + get: function () { + return this.privParameters; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SynthesizerConfig.prototype, "synthesisServiceType", { + get: function () { + return this.privSynthesisServiceType; + }, + set: function (value) { + this.privSynthesisServiceType = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SynthesizerConfig.prototype, "SpeechServiceConfig", { + get: function () { + return this.privSpeechServiceConfig; + }, + enumerable: true, + configurable: true + }); + return SynthesizerConfig; +}()); +exports.SynthesizerConfig = SynthesizerConfig; + + + +/***/ }), +/* 178 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Represents the JSON used in the synthesis.context message sent to the speech service. + * The dynamic grammar is always refreshed from the encapsulated dynamic grammar object. + */ +var SynthesisContext = /** @class */ (function () { + function SynthesisContext(speechSynthesizer) { + this.privContext = {}; + this.privSpeechSynthesizer = speechSynthesizer; + } + /** + * Adds a section to the synthesis.context object. + * @param sectionName Name of the section to add. + * @param value JSON serializable object that represents the value. + */ + SynthesisContext.prototype.setSection = function (sectionName, value) { + this.privContext[sectionName] = value; + }; + Object.defineProperty(SynthesisContext.prototype, "audioOutputFormat", { + /** + * Sets the audio output format for synthesis context generation. + * @param format {AudioOutputFormatImpl} the output format + */ + set: function (format) { + this.privAudioOutputFormat = format; + }, + enumerable: true, + configurable: true + }); + SynthesisContext.prototype.toJSON = function () { + var synthesisSection = this.buildSynthesisContext(); + this.setSection("synthesis", synthesisSection); + return JSON.stringify(this.privContext); + }; + SynthesisContext.prototype.buildSynthesisContext = function () { + return { + audio: { + metadataOptions: { + sentenceBoundaryEnabled: false, + wordBoundaryEnabled: (!!this.privSpeechSynthesizer.wordBoundary), + }, + outputFormat: this.privAudioOutputFormat.requestAudioFormatString, + }, + language: { + autoDetection: this.privSpeechSynthesizer.autoDetectSourceLanguage + } + }; + }; + return SynthesisContext; +}()); +exports.SynthesisContext = SynthesisContext; + + + +/***/ }), +/* 179 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var SpeakerRecognitionConfig = /** @class */ (function () { + function SpeakerRecognitionConfig(context, parameters) { + this.privContext = context ? context : new Exports_1.Context(null); + this.privParameters = parameters; + } + Object.defineProperty(SpeakerRecognitionConfig.prototype, "parameters", { + get: function () { + return this.privParameters; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SpeakerRecognitionConfig.prototype, "Context", { + get: function () { + return this.privContext; + }, + enumerable: true, + configurable: true + }); + return SpeakerRecognitionConfig; +}()); +exports.SpeakerRecognitionConfig = SpeakerRecognitionConfig; + + + +/***/ }), +/* 180 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(2); +var Exports_2 = __webpack_require__(4); +var Exports_3 = __webpack_require__(31); +/** + * Implements methods for speaker recognition classes, sending requests to endpoint + * and parsing response into expected format + * @class SpeakerIdMessageAdapter + */ +var SpeakerIdMessageAdapter = /** @class */ (function () { + function SpeakerIdMessageAdapter(config) { + var endpoint = config.parameters.getProperty(Exports_3.PropertyId.SpeechServiceConnection_Endpoint, undefined); + if (!endpoint) { + var region = config.parameters.getProperty(Exports_3.PropertyId.SpeechServiceConnection_Region, "westus"); + var hostSuffix = (region && region.toLowerCase().startsWith("china")) ? ".azure.cn" : ".microsoft.com"; + var host = config.parameters.getProperty(Exports_3.PropertyId.SpeechServiceConnection_Host, "https://" + region + ".api.cognitive" + hostSuffix + "/speaker/{mode}/v2.0/{dependency}"); + endpoint = host + "/profiles"; + } + this.privUri = endpoint; + var options = Exports_1.RestConfigBase.requestOptions; + options.headers[Exports_1.RestConfigBase.configParams.subscriptionKey] = config.parameters.getProperty(Exports_3.PropertyId.SpeechServiceConnection_Key, undefined); + this.privRestAdapter = new Exports_1.RestMessageAdapter(options); + } + /** + * Sends create profile request to endpoint. + * @function + * @param {VoiceProfileType} profileType - type of voice profile to create. + * @param {string} lang - language/locale of voice profile + * @public + * @returns {Promise} promised rest response containing id of created profile. + */ + SpeakerIdMessageAdapter.prototype.createProfile = function (profileType, lang) { + var uri = this.getOperationUri(profileType); + this.privRestAdapter.setHeaders(Exports_1.RestConfigBase.configParams.contentTypeKey, "application/json"); + return this.privRestAdapter.request(Exports_1.RestRequestType.Post, uri, {}, { locale: lang }); + }; + /** + * Sends create enrollment request to endpoint. + * @function + * @param {VoiceProfile} profileType - voice profile for which to create new enrollment. + * @param {IAudioSource} audioSource - audioSource from which to pull data to send + * @public + * @returns {Promise} rest response to enrollment request. + */ + SpeakerIdMessageAdapter.prototype.createEnrollment = function (profile, audioSource) { + var _this = this; + this.privRestAdapter.setHeaders(Exports_1.RestConfigBase.configParams.contentTypeKey, "multipart/form-data"); + var uri = this.getOperationUri(profile.profileType) + "/" + profile.profileId + "/enrollments"; + return audioSource.blob.onSuccessContinueWithPromise(function (result) { + return _this.privRestAdapter.request(Exports_1.RestRequestType.File, uri, { ignoreMinLength: "true" }, null, result); + }); + }; + /** + * Sends verification request to endpoint. + * @function + * @param {SpeakerVerificationModel} model - voice model to verify against. + * @param {IAudioSource} audioSource - audioSource from which to pull data to send + * @public + * @returns {Promise} rest response to enrollment request. + */ + SpeakerIdMessageAdapter.prototype.verifySpeaker = function (model, audioSource) { + var _this = this; + this.privRestAdapter.setHeaders(Exports_1.RestConfigBase.configParams.contentTypeKey, "multipart/form-data"); + var uri = this.getOperationUri(model.voiceProfile.profileType) + "/" + model.voiceProfile.profileId + "/verify"; + return audioSource.blob.continueWithPromise(function (result) { + if (result.isError) { + var response = new Exports_2.Deferred(); + response.resolve({ data: result.error }); + return response.promise(); + } + return _this.privRestAdapter.request(Exports_1.RestRequestType.File, uri, { ignoreMinLength: "true" }, null, result.result); + }); + }; + /** + * Sends identification request to endpoint. + * @function + * @param {SpeakerIdentificationModel} model - voice profiles against which to identify. + * @param {IAudioSource} audioSource - audioSource from which to pull data to send + * @public + * @returns {Promise} rest response to enrollment request. + */ + SpeakerIdMessageAdapter.prototype.identifySpeaker = function (model, audioSource) { + var _this = this; + this.privRestAdapter.setHeaders(Exports_1.RestConfigBase.configParams.contentTypeKey, "multipart/form-data"); + var uri = this.getOperationUri(Exports_3.VoiceProfileType.TextIndependentIdentification) + "/identifySingleSpeaker"; + return audioSource.blob.continueWithPromise(function (result) { + if (result.isError) { + var response = new Exports_2.Deferred(); + response.resolve({ data: result.error }); + return response.promise(); + } + return _this.privRestAdapter.request(Exports_1.RestRequestType.File, uri, { profileIds: model.voiceProfileIds, ignoreMinLength: "true" }, null, result.result); + }); + }; + /** + * Sends delete profile request to endpoint. + * @function + * @param {VoiceProfile} profile - voice profile to delete. + * @public + * @returns {Promise} rest response to deletion request + */ + SpeakerIdMessageAdapter.prototype.deleteProfile = function (profile) { + var uri = this.getOperationUri(profile.profileType) + "/" + profile.profileId; + return this.privRestAdapter.request(Exports_1.RestRequestType.Delete, uri, {}); + }; + /** + * Sends reset profile request to endpoint. + * @function + * @param {VoiceProfile} profile - voice profile to reset enrollments for. + * @public + * @returns {Promise} rest response to reset request + */ + SpeakerIdMessageAdapter.prototype.resetProfile = function (profile) { + var uri = this.getOperationUri(profile.profileType) + "/" + profile.profileId + "/reset"; + return this.privRestAdapter.request(Exports_1.RestRequestType.Post, uri, {}); + }; + SpeakerIdMessageAdapter.prototype.getOperationUri = function (profileType) { + var mode = profileType === Exports_3.VoiceProfileType.TextIndependentIdentification ? "identification" : "verification"; + var dependency = profileType === Exports_3.VoiceProfileType.TextDependentVerification ? "text-dependent" : "text-independent"; + return this.privUri.replace("{mode}", mode).replace("{dependency}", dependency); + }; + return SpeakerIdMessageAdapter; +}()); +exports.SpeakerIdMessageAdapter = SpeakerIdMessageAdapter; + + + +/***/ }), +/* 181 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(26); +var Exports_2 = __webpack_require__(4); +var AudioStreamFormat_1 = __webpack_require__(42); +var FileAudioSource = /** @class */ (function () { + function FileAudioSource(file, audioSourceId) { + var _this = this; + this.privStreams = {}; + this.turnOn = function () { + if (typeof FileReader === "undefined") { + var errorMsg = "Browser does not support FileReader."; + _this.onEvent(new Exports_2.AudioSourceErrorEvent(errorMsg, "")); // initialization error - no streamid at this point + return Exports_2.PromiseHelper.fromError(errorMsg); + } + else if (_this.privFile.name.lastIndexOf(".wav") !== _this.privFile.name.length - 4) { + var errorMsg = _this.privFile.name + " is not supported. Only WAVE files are allowed at the moment."; + _this.onEvent(new Exports_2.AudioSourceErrorEvent(errorMsg, "")); + return Exports_2.PromiseHelper.fromError(errorMsg); + } + _this.onEvent(new Exports_2.AudioSourceInitializingEvent(_this.privId)); // no stream id + _this.onEvent(new Exports_2.AudioSourceReadyEvent(_this.privId)); + return Exports_2.PromiseHelper.fromResult(true); + }; + this.id = function () { + return _this.privId; + }; + this.attach = function (audioNodeId) { + _this.onEvent(new Exports_2.AudioStreamNodeAttachingEvent(_this.privId, audioNodeId)); + return _this.upload(audioNodeId).onSuccessContinueWith(function (stream) { + _this.onEvent(new Exports_2.AudioStreamNodeAttachedEvent(_this.privId, audioNodeId)); + return { + detach: function () { + stream.readEnded(); + delete _this.privStreams[audioNodeId]; + _this.onEvent(new Exports_2.AudioStreamNodeDetachedEvent(_this.privId, audioNodeId)); + _this.turnOff(); + }, + id: function () { + return audioNodeId; + }, + read: function () { + return stream.read(); + }, + }; + }); + }; + this.detach = function (audioNodeId) { + if (audioNodeId && _this.privStreams[audioNodeId]) { + _this.privStreams[audioNodeId].close(); + delete _this.privStreams[audioNodeId]; + _this.onEvent(new Exports_2.AudioStreamNodeDetachedEvent(_this.privId, audioNodeId)); + } + }; + this.turnOff = function () { + for (var streamId in _this.privStreams) { + if (streamId) { + var stream = _this.privStreams[streamId]; + if (stream && !stream.isClosed) { + stream.close(); + } + } + } + _this.onEvent(new Exports_2.AudioSourceOffEvent(_this.privId)); // no stream now + return Exports_2.PromiseHelper.fromResult(true); + }; + this.readHeader = function () { + // Read the wave header. + var header = _this.privFile.slice(0, 44); + var headerReader = new FileReader(); + var headerResult = new Exports_2.Deferred(); + var processHeader = function (event) { + var header = event.target.result; + var view = new DataView(header); + // RIFF 4 bytes. + var riff = String.fromCharCode(view.getUint8(0), view.getUint8(1), view.getUint8(2), view.getUint8(3)); + if ("RIFF" !== riff) { + headerResult.reject("Invalid WAV header in file, RIFF was not found"); + } + // length, 4 bytes + // RIFF Type & fmt 8 bytes + var type = String.fromCharCode(view.getUint8(8), view.getUint8(9), view.getUint8(10), view.getUint8(11), view.getUint8(12), view.getUint8(13), view.getUint8(14)); + if ("WAVEfmt" !== type) { + headerResult.reject("Invalid WAV header in file, WAVEfmt was not found"); + } + var channelCount = view.getUint16(22, true); + var sampleRate = view.getUint32(24, true); + var bitsPerSample = view.getUint16(34, true); + headerResult.resolve(AudioStreamFormat_1.AudioStreamFormat.getWaveFormatPCM(sampleRate, bitsPerSample, channelCount)); + }; + headerReader.onload = processHeader; + headerReader.readAsArrayBuffer(header); + return headerResult.promise(); + }; + this.upload = function (audioNodeId) { + return _this.turnOn() + .onSuccessContinueWithPromise(function (_) { + return _this.privAudioFormatPromise.onSuccessContinueWith(function (format) { + var fileStream = new Exports_2.ChunkedArrayBufferStream(3200); + var reader = new FileReader(); + var stream = new Exports_2.ChunkedArrayBufferStream(format.avgBytesPerSec / 10, audioNodeId); + _this.privStreams[audioNodeId] = stream; + var processFile = function (event) { + if (stream.isClosed) { + return; // output stream was closed (somebody called TurnOff). We're done here. + } + stream.writeStreamChunk({ + buffer: reader.result, + isEnd: false, + timeReceived: Date.now(), + }); + stream.close(); + }; + reader.onload = processFile; + reader.onerror = function (event) { + var errorMsg = "Error occurred while processing '" + _this.privFile.name + "'. " + event; + _this.onEvent(new Exports_2.AudioStreamNodeErrorEvent(_this.privId, audioNodeId, errorMsg)); + throw new Error(errorMsg); + }; + var chunk = _this.privFile.slice(44); + reader.readAsArrayBuffer(chunk); + return stream; + }); + }); + }; + this.onEvent = function (event) { + _this.privEvents.onEvent(event); + Exports_2.Events.instance.onEvent(event); + }; + this.privId = audioSourceId ? audioSourceId : Exports_2.createNoDashGuid(); + this.privEvents = new Exports_2.EventSource(); + this.privFile = file; + // Read the header. + this.privAudioFormatPromise = this.readHeader(); + } + Object.defineProperty(FileAudioSource.prototype, "format", { + get: function () { + return this.privAudioFormatPromise; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(FileAudioSource.prototype, "blob", { + get: function () { + return Exports_2.PromiseHelper.fromResult(this.privFile); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(FileAudioSource.prototype, "events", { + get: function () { + return this.privEvents; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(FileAudioSource.prototype, "deviceInfo", { + get: function () { + return this.privAudioFormatPromise.onSuccessContinueWithPromise(function (result) { + return Exports_2.PromiseHelper.fromResult({ + bitspersample: result.bitsPerSample, + channelcount: result.channels, + connectivity: Exports_1.connectivity.Unknown, + manufacturer: "Speech SDK", + model: "File", + samplerate: result.samplesPerSec, + type: Exports_1.type.File, + }); + }); + }, + enumerable: true, + configurable: true + }); + return FileAudioSource; +}()); +exports.FileAudioSource = FileAudioSource; + + + +/***/ }), +/* 182 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(4); +var PcmRecorder = /** @class */ (function () { + function PcmRecorder() { + var _this = this; + this.record = function (context, mediaStream, outputStream) { + var desiredSampleRate = 16000; + var scriptNode = (function () { + var bufferSize = 0; + try { + return context.createScriptProcessor(bufferSize, 1, 1); + } + catch (error) { + // Webkit (<= version 31) requires a valid bufferSize. + bufferSize = 2048; + var audioSampleRate = context.sampleRate; + while (bufferSize < 16384 && audioSampleRate >= (2 * desiredSampleRate)) { + bufferSize <<= 1; + audioSampleRate >>= 1; + } + return context.createScriptProcessor(bufferSize, 1, 1); + } + })(); + var waveStreamEncoder = new Exports_1.RiffPcmEncoder(context.sampleRate, desiredSampleRate); + var needHeader = true; + var that = _this; + scriptNode.onaudioprocess = function (event) { + var inputFrame = event.inputBuffer.getChannelData(0); + if (outputStream && !outputStream.isClosed) { + var waveFrame = waveStreamEncoder.encode(inputFrame); + if (!!waveFrame) { + outputStream.writeStreamChunk({ + buffer: waveFrame, + isEnd: false, + timeReceived: Date.now(), + }); + needHeader = false; + } + } + }; + var micInput = context.createMediaStreamSource(mediaStream); + // https://webaudio.github.io/web-audio-api/#audioworklet + // Using AudioWorklet to improve audio quality and avoid audio glitches due to blocking the UI thread + if (!!_this.privSpeechProcessorScript && !!context.audioWorklet) { + context.audioWorklet + .addModule(_this.privSpeechProcessorScript) + .then(function () { + var workletNode = new AudioWorkletNode(context, "speech-processor"); + workletNode.port.onmessage = function (ev) { + var inputFrame = ev.data; + if (outputStream && !outputStream.isClosed) { + var waveFrame = waveStreamEncoder.encode(inputFrame); + if (!!waveFrame) { + outputStream.writeStreamChunk({ + buffer: waveFrame, + isEnd: false, + timeReceived: Date.now(), + }); + needHeader = false; + } + } + }; + micInput.connect(workletNode); + workletNode.connect(context.destination); + _this.privMediaResources = { + scriptProcessorNode: workletNode, + source: micInput, + stream: mediaStream, + }; + }) + .catch(function () { + micInput.connect(scriptNode); + scriptNode.connect(context.destination); + _this.privMediaResources = { + scriptProcessorNode: scriptNode, + source: micInput, + stream: mediaStream, + }; + }); + } + else { + micInput.connect(scriptNode); + scriptNode.connect(context.destination); + _this.privMediaResources = { + scriptProcessorNode: scriptNode, + source: micInput, + stream: mediaStream, + }; + } + }; + this.releaseMediaResources = function (context) { + if (_this.privMediaResources) { + if (_this.privMediaResources.scriptProcessorNode) { + _this.privMediaResources.scriptProcessorNode.disconnect(context.destination); + _this.privMediaResources.scriptProcessorNode = null; + } + if (_this.privMediaResources.source) { + _this.privMediaResources.source.disconnect(); + _this.privMediaResources.stream.getTracks().forEach(function (track) { return track.stop(); }); + _this.privMediaResources.source = null; + } + } + }; + } + PcmRecorder.prototype.setWorkletUrl = function (url) { + this.privSpeechProcessorScript = url; + }; + return PcmRecorder; +}()); +exports.PcmRecorder = PcmRecorder; + + + +/***/ }), +/* 183 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(4); +var WebsocketMessageAdapter_1 = __webpack_require__(184); +var WebsocketConnection = /** @class */ (function () { + function WebsocketConnection(uri, queryParameters, headers, messageFormatter, proxyInfo, connectionId) { + var _this = this; + this.privIsDisposed = false; + this.dispose = function () { + _this.privIsDisposed = true; + if (_this.privConnectionMessageAdapter) { + _this.privConnectionMessageAdapter.close(); + } + }; + this.isDisposed = function () { + return _this.privIsDisposed; + }; + this.state = function () { + return _this.privConnectionMessageAdapter.state; + }; + this.open = function () { + return _this.privConnectionMessageAdapter.open(); + }; + this.send = function (message) { + return _this.privConnectionMessageAdapter.send(message); + }; + this.read = function () { + return _this.privConnectionMessageAdapter.read(); + }; + if (!uri) { + throw new Exports_1.ArgumentNullError("uri"); + } + if (!messageFormatter) { + throw new Exports_1.ArgumentNullError("messageFormatter"); + } + this.privMessageFormatter = messageFormatter; + var queryParams = ""; + var i = 0; + if (queryParameters) { + for (var paramName in queryParameters) { + if (paramName) { + queryParams += ((i === 0) && (uri.indexOf("?") === -1)) ? "?" : "&"; + var val = encodeURIComponent(queryParameters[paramName]); + queryParams += paramName + "=" + val; + i++; + } + } + } + if (headers) { + for (var headerName in headers) { + if (headerName) { + queryParams += ((i === 0) && (uri.indexOf("?") === -1)) ? "?" : "&"; + var val = encodeURIComponent(headers[headerName]); + queryParams += headerName + "=" + val; + i++; + } + } + } + this.privUri = uri + queryParams; + this.privId = connectionId ? connectionId : Exports_1.createNoDashGuid(); + this.privConnectionMessageAdapter = new WebsocketMessageAdapter_1.WebsocketMessageAdapter(this.privUri, this.id, this.privMessageFormatter, proxyInfo, headers); + } + Object.defineProperty(WebsocketConnection.prototype, "id", { + get: function () { + return this.privId; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(WebsocketConnection.prototype, "events", { + get: function () { + return this.privConnectionMessageAdapter.events; + }, + enumerable: true, + configurable: true + }); + return WebsocketConnection; +}()); +exports.WebsocketConnection = WebsocketConnection; + + + +/***/ }), +/* 184 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(4); +// Node.JS specific web socket / browser support. +var ws_1 = __importDefault(__webpack_require__(185)); +var CertChecks_1 = __webpack_require__(186); +var WebsocketMessageAdapter = /** @class */ (function () { + function WebsocketMessageAdapter(uri, connectionId, messageFormatter, proxyInfo, headers) { + var _this = this; + this.open = function () { + if (_this.privConnectionState === Exports_1.ConnectionState.Disconnected) { + return Exports_1.PromiseHelper.fromError("Cannot open a connection that is in " + _this.privConnectionState + " state"); + } + if (_this.privConnectionEstablishDeferral) { + return _this.privConnectionEstablishDeferral.promise(); + } + _this.privConnectionEstablishDeferral = new Exports_1.Deferred(); + _this.privCertificateValidatedDeferral = new Exports_1.Deferred(); + _this.privConnectionState = Exports_1.ConnectionState.Connecting; + try { + if (typeof WebSocket !== "undefined" && !WebsocketMessageAdapter.forceNpmWebSocket) { + // Browser handles cert checks. + _this.privCertificateValidatedDeferral.resolve(true); + _this.privWebsocketClient = new WebSocket(_this.privUri); + } + else { + var options = { headers: _this.privHeaders }; + // The ocsp library will handle validation for us and fail the connection if needed. + _this.privCertificateValidatedDeferral.resolve(true); + var checkAgent = new CertChecks_1.CertCheckAgent(_this.proxyInfo); + options.agent = checkAgent.GetAgent(); + _this.privWebsocketClient = new ws_1.default(_this.privUri, options); + } + _this.privWebsocketClient.binaryType = "arraybuffer"; + _this.privReceivingMessageQueue = new Exports_1.Queue(); + _this.privDisconnectDeferral = new Exports_1.Deferred(); + _this.privSendMessageQueue = new Exports_1.Queue(); + _this.processSendQueue(); + } + catch (error) { + _this.privConnectionEstablishDeferral.resolve(new Exports_1.ConnectionOpenResponse(500, error)); + return _this.privConnectionEstablishDeferral.promise(); + } + _this.onEvent(new Exports_1.ConnectionStartEvent(_this.privConnectionId, _this.privUri)); + _this.privWebsocketClient.onopen = function (e) { + _this.privCertificateValidatedDeferral.promise().on(function () { + _this.privConnectionState = Exports_1.ConnectionState.Connected; + _this.onEvent(new Exports_1.ConnectionEstablishedEvent(_this.privConnectionId)); + _this.privConnectionEstablishDeferral.resolve(new Exports_1.ConnectionOpenResponse(200, "")); + }, function (error) { + _this.privConnectionEstablishDeferral.reject(error); + }); + }; + _this.privWebsocketClient.onerror = function (e) { + _this.onEvent(new Exports_1.ConnectionErrorEvent(_this.privConnectionId, e.message, e.type)); + _this.privLastErrorReceived = e.message; + }; + _this.privWebsocketClient.onclose = function (e) { + if (_this.privConnectionState === Exports_1.ConnectionState.Connecting) { + _this.privConnectionState = Exports_1.ConnectionState.Disconnected; + // this.onEvent(new ConnectionEstablishErrorEvent(this.connectionId, e.code, e.reason)); + _this.privConnectionEstablishDeferral.resolve(new Exports_1.ConnectionOpenResponse(e.code, e.reason + " " + _this.privLastErrorReceived)); + } + else { + _this.privConnectionState = Exports_1.ConnectionState.Disconnected; + _this.onEvent(new Exports_1.ConnectionClosedEvent(_this.privConnectionId, e.code, e.reason)); + } + _this.onClose(e.code, e.reason); + }; + _this.privWebsocketClient.onmessage = function (e) { + var networkReceivedTime = new Date().toISOString(); + if (_this.privConnectionState === Exports_1.ConnectionState.Connected) { + var deferred_1 = new Exports_1.Deferred(); + // let id = ++this.idCounter; + _this.privReceivingMessageQueue.enqueueFromPromise(deferred_1.promise()); + if (e.data instanceof ArrayBuffer) { + var rawMessage = new Exports_1.RawWebsocketMessage(Exports_1.MessageType.Binary, e.data); + _this.privMessageFormatter + .toConnectionMessage(rawMessage) + .on(function (connectionMessage) { + _this.onEvent(new Exports_1.ConnectionMessageReceivedEvent(_this.privConnectionId, networkReceivedTime, connectionMessage)); + deferred_1.resolve(connectionMessage); + }, function (error) { + // TODO: Events for these ? + deferred_1.reject("Invalid binary message format. Error: " + error); + }); + } + else { + var rawMessage = new Exports_1.RawWebsocketMessage(Exports_1.MessageType.Text, e.data); + _this.privMessageFormatter + .toConnectionMessage(rawMessage) + .on(function (connectionMessage) { + _this.onEvent(new Exports_1.ConnectionMessageReceivedEvent(_this.privConnectionId, networkReceivedTime, connectionMessage)); + deferred_1.resolve(connectionMessage); + }, function (error) { + // TODO: Events for these ? + deferred_1.reject("Invalid text message format. Error: " + error); + }); + } + } + }; + return _this.privConnectionEstablishDeferral.promise(); + }; + this.send = function (message) { + if (_this.privConnectionState !== Exports_1.ConnectionState.Connected) { + return Exports_1.PromiseHelper.fromError("Cannot send on connection that is in " + _this.privConnectionState + " state"); + } + var messageSendStatusDeferral = new Exports_1.Deferred(); + var messageSendDeferral = new Exports_1.Deferred(); + _this.privSendMessageQueue.enqueueFromPromise(messageSendDeferral.promise()); + _this.privMessageFormatter + .fromConnectionMessage(message) + .on(function (rawMessage) { + messageSendDeferral.resolve({ + Message: message, + RawWebsocketMessage: rawMessage, + sendStatusDeferral: messageSendStatusDeferral, + }); + }, function (error) { + messageSendDeferral.reject("Error formatting the message. " + error); + }); + return messageSendStatusDeferral.promise(); + }; + this.read = function () { + if (_this.privConnectionState !== Exports_1.ConnectionState.Connected) { + return Exports_1.PromiseHelper.fromError("Cannot read on connection that is in " + _this.privConnectionState + " state"); + } + return _this.privReceivingMessageQueue.dequeue(); + }; + this.close = function (reason) { + if (_this.privWebsocketClient) { + if (_this.privConnectionState !== Exports_1.ConnectionState.Disconnected) { + _this.privWebsocketClient.close(1000, reason ? reason : "Normal closure by client"); + } + } + else { + var deferral = new Exports_1.Deferred(); + deferral.resolve(true); + return deferral.promise(); + } + return _this.privDisconnectDeferral.promise(); + }; + this.sendRawMessage = function (sendItem) { + try { + // indicates we are draining the queue and it came with no message; + if (!sendItem) { + return Exports_1.PromiseHelper.fromResult(true); + } + _this.onEvent(new Exports_1.ConnectionMessageSentEvent(_this.privConnectionId, new Date().toISOString(), sendItem.Message)); + // add a check for the ws readystate in order to stop the red console error 'WebSocket is already in CLOSING or CLOSED state' appearing + if (_this.isWebsocketOpen) { + _this.privWebsocketClient.send(sendItem.RawWebsocketMessage.payload); + } + else { + return Exports_1.PromiseHelper.fromError("websocket send error: Websocket not ready"); + } + return Exports_1.PromiseHelper.fromResult(true); + } + catch (e) { + return Exports_1.PromiseHelper.fromError("websocket send error: " + e); + } + }; + this.onClose = function (code, reason) { + var closeReason = "Connection closed. " + code + ": " + reason; + _this.privConnectionState = Exports_1.ConnectionState.Disconnected; + _this.privDisconnectDeferral.resolve(true); + _this.privReceivingMessageQueue.dispose(reason); + _this.privReceivingMessageQueue.drainAndDispose(function (pendingReceiveItem) { + // TODO: Events for these ? + // Logger.instance.onEvent(new LoggingEvent(LogType.Warning, null, `Failed to process received message. Reason: ${closeReason}, Message: ${JSON.stringify(pendingReceiveItem)}`)); + }, closeReason); + _this.privSendMessageQueue.drainAndDispose(function (pendingSendItem) { + pendingSendItem.sendStatusDeferral.reject(closeReason); + }, closeReason); + }; + this.processSendQueue = function () { + _this.privSendMessageQueue + .dequeue() + .on(function (sendItem) { + // indicates we are draining the queue and it came with no message; + if (!sendItem) { + return; + } + _this.sendRawMessage(sendItem) + .on(function (result) { + sendItem.sendStatusDeferral.resolve(result); + _this.processSendQueue(); + }, function (sendError) { + sendItem.sendStatusDeferral.reject(sendError); + _this.processSendQueue(); + }); + }, function (error) { + // do nothing + }); + }; + this.onEvent = function (event) { + _this.privConnectionEvents.onEvent(event); + Exports_1.Events.instance.onEvent(event); + }; + if (!uri) { + throw new Exports_1.ArgumentNullError("uri"); + } + if (!messageFormatter) { + throw new Exports_1.ArgumentNullError("messageFormatter"); + } + this.proxyInfo = proxyInfo; + this.privConnectionEvents = new Exports_1.EventSource(); + this.privConnectionId = connectionId; + this.privMessageFormatter = messageFormatter; + this.privConnectionState = Exports_1.ConnectionState.None; + this.privUri = uri; + this.privHeaders = headers; + // Add the connection ID to the headers + this.privHeaders["X-ConnectionId"] = this.privConnectionId; + this.privLastErrorReceived = ""; + } + Object.defineProperty(WebsocketMessageAdapter.prototype, "state", { + get: function () { + return this.privConnectionState; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(WebsocketMessageAdapter.prototype, "events", { + get: function () { + return this.privConnectionEvents; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(WebsocketMessageAdapter.prototype, "isWebsocketOpen", { + get: function () { + return this.privWebsocketClient && this.privWebsocketClient.readyState === this.privWebsocketClient.OPEN; + }, + enumerable: true, + configurable: true + }); + WebsocketMessageAdapter.forceNpmWebSocket = false; + return WebsocketMessageAdapter; +}()); +exports.WebsocketMessageAdapter = WebsocketMessageAdapter; + + + +/***/ }), +/* 185 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 186 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(process, Buffer) { +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var tls = __importStar(__webpack_require__(188)); +var url = __importStar(__webpack_require__(189)); +var ocsp = __importStar(__webpack_require__(196)); +var Exports_1 = __webpack_require__(4); +var agent_base_1 = __importDefault(__webpack_require__(197)); +// @ts-ignore +var async_disk_cache_1 = __importDefault(__webpack_require__(198)); +var https_proxy_agent_1 = __importDefault(__webpack_require__(199)); +var OCSPEvents_1 = __webpack_require__(24); +var CertCheckAgent = /** @class */ (function () { + function CertCheckAgent(proxyInfo) { + if (!!proxyInfo) { + this.privProxyInfo = proxyInfo; + } + // Initialize this here to allow tests to set the env variable before the cache is constructed. + if (!CertCheckAgent.privDiskCache) { + CertCheckAgent.privDiskCache = new async_disk_cache_1.default("microsoft-cognitiveservices-speech-sdk-cache", { supportBuffer: true, location: (typeof process !== "undefined" && !!process.env.SPEECH_OCSP_CACHE_ROOT) ? process.env.SPEECH_OCSP_CACHE_ROOT : undefined }); + } + } + // Test hook to force the disk cache to be recreated. + CertCheckAgent.forceReinitDiskCache = function () { + CertCheckAgent.privDiskCache = undefined; + CertCheckAgent.privMemCache = {}; + }; + CertCheckAgent.prototype.GetAgent = function (disableStapling) { + var agent = new agent_base_1.default.Agent(this.CreateConnection); + if (this.privProxyInfo !== undefined && + this.privProxyInfo.HostName !== undefined && + this.privProxyInfo.Port > 0) { + var proxyName = "privProxyInfo"; + agent[proxyName] = this.privProxyInfo; + } + return agent; + }; + CertCheckAgent.GetProxyAgent = function (proxyInfo) { + var httpProxyOptions = { + host: proxyInfo.HostName, + port: proxyInfo.Port, + }; + if (!!proxyInfo.UserName) { + httpProxyOptions.headers = { + "Proxy-Authentication": "Basic " + new Buffer(proxyInfo.UserName + ":" + (proxyInfo.Password === undefined) ? "" : proxyInfo.Password).toString("base64"), + }; + } + else { + httpProxyOptions.headers = {}; + } + httpProxyOptions.headers.requestOCSP = "true"; + var httpProxyAgent = new https_proxy_agent_1.default(httpProxyOptions); + return httpProxyAgent; + }; + CertCheckAgent.OCSPCheck = function (socketPromise, proxyInfo) { + return __awaiter(this, void 0, void 0, function () { + var ocspRequest, stapling, resolved, socket, tlsSocket; + var _this = this; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + resolved = false; + return [4 /*yield*/, socketPromise]; + case 1: + socket = _a.sent(); + socket.cork(); + tlsSocket = socket; + return [2 /*return*/, new Promise(function (resolve, reject) { + socket.on("OCSPResponse", function (data) { + if (!!data) { + _this.onEvent(new Exports_1.OCSPStapleReceivedEvent()); + stapling = data; + } + }); + socket.on("error", function (error) { + if (!resolved) { + resolved = true; + socket.destroy(); + reject(error); + } + }); + tlsSocket.on("secure", function () { return __awaiter(_this, void 0, void 0, function () { + var peer, issuer, sig, cacheEntry, e_1; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + peer = tlsSocket.getPeerCertificate(true); + _a.label = 1; + case 1: + _a.trys.push([1, 6, , 7]); + return [4 /*yield*/, this.GetIssuer(peer)]; + case 2: + issuer = _a.sent(); + // We always need a request to verify the response. + ocspRequest = ocsp.request.generate(peer.raw, issuer.raw); + sig = ocspRequest.id.toString("hex"); + if (!!stapling) return [3 /*break*/, 4]; + return [4 /*yield*/, CertCheckAgent.GetResponseFromCache(sig, ocspRequest, proxyInfo)]; + case 3: + cacheEntry = _a.sent(); + stapling = cacheEntry; + _a.label = 4; + case 4: return [4 /*yield*/, this.VerifyOCSPResponse(stapling, ocspRequest, proxyInfo)]; + case 5: + _a.sent(); + socket.uncork(); + resolved = true; + resolve(socket); + return [3 /*break*/, 7]; + case 6: + e_1 = _a.sent(); + socket.destroy(); + resolved = true; + reject(e_1); + return [3 /*break*/, 7]; + case 7: return [2 /*return*/]; + } + }); + }); }); + })]; + } + }); + }); + }; + CertCheckAgent.GetIssuer = function (peer) { + if (peer.issuerCertificate) { + return Promise.resolve(peer.issuerCertificate); + } + return new Promise(function (resolve, reject) { + var ocspAgent = new ocsp.Agent({}); + ocspAgent.fetchIssuer(peer, null, function (error, value) { + if (!!error) { + reject(error); + return; + } + resolve(value); + }); + }); + }; + CertCheckAgent.GetResponseFromCache = function (signature, ocspRequest, proxyInfo) { + return __awaiter(this, void 0, void 0, function () { + var cachedResponse, diskCacheResponse, error_1, cachedOcspResponse, tbsData, cachedStartTime, cachedNextTime, minUpdate; + var _this = this; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + cachedResponse = CertCheckAgent.privMemCache[signature]; + if (!!cachedResponse) { + this.onEvent(new Exports_1.OCSPMemoryCacheHitEvent(signature)); + } + if (!!cachedResponse) return [3 /*break*/, 4]; + _a.label = 1; + case 1: + _a.trys.push([1, 3, , 4]); + return [4 /*yield*/, CertCheckAgent.privDiskCache.get(signature)]; + case 2: + diskCacheResponse = _a.sent(); + if (!!diskCacheResponse.isCached) { + CertCheckAgent.onEvent(new Exports_1.OCSPDiskCacheHitEvent(signature)); + CertCheckAgent.StoreMemoryCacheEntry(signature, diskCacheResponse.value); + cachedResponse = diskCacheResponse.value; + } + return [3 /*break*/, 4]; + case 3: + error_1 = _a.sent(); + cachedResponse = null; + return [3 /*break*/, 4]; + case 4: + if (!cachedResponse) { + return [2 /*return*/, cachedResponse]; + } + try { + cachedOcspResponse = ocsp.utils.parseResponse(cachedResponse); + tbsData = cachedOcspResponse.value.tbsResponseData; + if (tbsData.responses.length < 1) { + this.onEvent(new Exports_1.OCSPCacheFetchErrorEvent(signature, "Not enough data in cached response")); + return [2 /*return*/]; + } + cachedStartTime = tbsData.responses[0].thisUpdate; + cachedNextTime = tbsData.responses[0].nextUpdate; + if (cachedNextTime < (Date.now() + this.testTimeOffset - 60000)) { + // Cached entry has expired. + this.onEvent(new Exports_1.OCSPCacheEntryExpiredEvent(signature, cachedNextTime)); + cachedResponse = null; + } + else { + minUpdate = Math.min(24 * 60 * 60 * 1000, (cachedNextTime - cachedStartTime) / 2); + if ((cachedNextTime - (Date.now() + this.testTimeOffset)) < minUpdate) { + this.onEvent(new Exports_1.OCSPCacheEntryNeedsRefreshEvent(signature, cachedStartTime, cachedNextTime)); + this.UpdateCache(ocspRequest, proxyInfo).catch(function (error) { + // Well, not much we can do here. + _this.onEvent(new OCSPEvents_1.OCSPCacheUpdateErrorEvent(signature, error.toString())); + }); + } + else { + this.onEvent(new Exports_1.OCSPCacheHitEvent(signature, cachedStartTime, cachedNextTime)); + } + } + } + catch (error) { + this.onEvent(new Exports_1.OCSPCacheFetchErrorEvent(signature, error)); + cachedResponse = null; + } + if (!cachedResponse) { + this.onEvent(new Exports_1.OCSPCacheMissEvent(signature)); + } + return [2 /*return*/, cachedResponse]; + } + }); + }); + }; + CertCheckAgent.VerifyOCSPResponse = function (cacheValue, ocspRequest, proxyInfo) { + return __awaiter(this, void 0, void 0, function () { + var ocspResponse, sig; + var _this = this; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + ocspResponse = cacheValue; + sig = ocspRequest.certID.toString("hex"); + if (!!ocspResponse) return [3 /*break*/, 2]; + return [4 /*yield*/, CertCheckAgent.GetOCSPResponse(ocspRequest, proxyInfo)]; + case 1: + ocspResponse = _a.sent(); + _a.label = 2; + case 2: return [2 /*return*/, new Promise(function (resolve, reject) { + ocsp.verify({ request: ocspRequest, response: ocspResponse }, function (error, result) { + if (!!error) { + CertCheckAgent.onEvent(new Exports_1.OCSPVerificationFailedEvent(ocspRequest.id.toString("hex"), error)); + // Bad Cached Value? One more try without the cache. + if (!!cacheValue) { + _this.VerifyOCSPResponse(null, ocspRequest, proxyInfo).then(function () { + resolve(); + }, function (error) { + reject(error); + }); + } + else { + reject(error); + } + } + else { + if (!cacheValue) { + CertCheckAgent.StoreCacheEntry(ocspRequest.id.toString("hex"), ocspResponse); + } + resolve(); + } + }); + })]; + } + }); + }); + }; + CertCheckAgent.UpdateCache = function (req, proxyInfo) { + return __awaiter(this, void 0, void 0, function () { + var signature, rawResponse; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + signature = req.id.toString("hex"); + this.onEvent(new Exports_1.OCSPCacheUpdateNeededEvent(signature)); + return [4 /*yield*/, this.GetOCSPResponse(req, proxyInfo)]; + case 1: + rawResponse = _a.sent(); + this.StoreCacheEntry(signature, rawResponse); + this.onEvent(new Exports_1.OCSPCacheUpdatehCompleteEvent(req.id.toString("hex"))); + return [2 /*return*/]; + } + }); + }); + }; + CertCheckAgent.StoreCacheEntry = function (sig, rawResponse) { + this.StoreMemoryCacheEntry(sig, rawResponse); + this.StoreDiskCacheEntry(sig, rawResponse); + }; + CertCheckAgent.StoreMemoryCacheEntry = function (sig, rawResponse) { + this.privMemCache[sig] = rawResponse; + this.onEvent(new Exports_1.OCSPMemoryCacheStoreEvent(sig)); + }; + CertCheckAgent.StoreDiskCacheEntry = function (sig, rawResponse) { + var _this = this; + this.privDiskCache.set(sig, rawResponse).then(function () { + _this.onEvent(new Exports_1.OCSPDiskCacheStoreEvent(sig)); + }); + }; + CertCheckAgent.GetOCSPResponse = function (req, proxyInfo) { + var _this = this; + var ocspMethod = "1.3.6.1.5.5.7.48.1"; + var options = {}; + if (!!proxyInfo) { + var agent = CertCheckAgent.GetProxyAgent(proxyInfo); + options.agent = agent; + } + return new Promise(function (resolve, reject) { + ocsp.utils.getAuthorityInfo(req.cert, ocspMethod, function (error, uri) { + if (error) { + reject(error); + return; + } + var parsedUri = url.parse(uri); + options = __assign(__assign({}, options), parsedUri); + ocsp.utils.getResponse(options, req.data, function (error, raw) { + if (error) { + reject(error); + return; + } + _this.onEvent(new Exports_1.OCSPResponseRetrievedEvent(req.certID.toString("hex"))); + resolve(raw); + }); + }); + }); + }; + CertCheckAgent.prototype.CreateConnection = function (request, options) { + var enableOCSP = (typeof process !== "undefined" && process.env.NODE_TLS_REJECT_UNAUTHORIZED !== "0" && process.env.SPEECH_CONDUCT_OCSP_CHECK !== "0") && options.secureEndpoint; + var socketPromise; + options = __assign(__assign({}, options), { + requestOCSP: !CertCheckAgent.forceDisableOCSPStapling, + servername: options.host + }); + if (!!this.privProxyInfo) { + var httpProxyAgent = CertCheckAgent.GetProxyAgent(this.privProxyInfo); + var baseAgent_1 = httpProxyAgent; + socketPromise = new Promise(function (resolve, reject) { + baseAgent_1.callback(request, options, function (error, socket) { + if (!!error) { + reject(error); + } + else { + resolve(socket); + } + }); + }); + } + else { + socketPromise = Promise.resolve(tls.connect(options)); + } + if (!!enableOCSP) { + return CertCheckAgent.OCSPCheck(socketPromise, this.privProxyInfo); + } + else { + return socketPromise; + } + }; + // Test hook to enable forcing expiration / refresh to happen. + CertCheckAgent.testTimeOffset = 0; + // Test hook to disable stapling for cache testing. + CertCheckAgent.forceDisableOCSPStapling = false; + // An in memory cache for recived responses. + CertCheckAgent.privMemCache = {}; + CertCheckAgent.onEvent = function (event) { + Exports_1.Events.instance.onEvent(event); + }; + return CertCheckAgent; +}()); +exports.CertCheckAgent = CertCheckAgent; + + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(187), __webpack_require__(37).Buffer)) + +/***/ }), +/* 187 */ +/***/ (function(module, exports) { + +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + + +/***/ }), +/* 188 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 189 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + + + +var punycode = __webpack_require__(190); +var util = __webpack_require__(192); + +exports.parse = urlParse; +exports.resolve = urlResolve; +exports.resolveObject = urlResolveObject; +exports.format = urlFormat; + +exports.Url = Url; + +function Url() { + this.protocol = null; + this.slashes = null; + this.auth = null; + this.host = null; + this.port = null; + this.hostname = null; + this.hash = null; + this.search = null; + this.query = null; + this.pathname = null; + this.path = null; + this.href = null; +} + +// Reference: RFC 3986, RFC 1808, RFC 2396 + +// define these here so at least they only have to be +// compiled once on the first module load. +var protocolPattern = /^([a-z0-9.+-]+:)/i, + portPattern = /:[0-9]*$/, + + // Special case for a simple path URL + simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/, + + // RFC 2396: characters reserved for delimiting URLs. + // We actually just auto-escape these. + delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'], + + // RFC 2396: characters not allowed for various reasons. + unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims), + + // Allowed by RFCs, but cause of XSS attacks. Always escape these. + autoEscape = ['\''].concat(unwise), + // Characters that are never ever allowed in a hostname. + // Note that any invalid chars are also handled, but these + // are the ones that are *expected* to be seen, so we fast-path + // them. + nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape), + hostEndingChars = ['/', '?', '#'], + hostnameMaxLen = 255, + hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/, + hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/, + // protocols that can allow "unsafe" and "unwise" chars. + unsafeProtocol = { + 'javascript': true, + 'javascript:': true + }, + // protocols that never have a hostname. + hostlessProtocol = { + 'javascript': true, + 'javascript:': true + }, + // protocols that always contain a // bit. + slashedProtocol = { + 'http': true, + 'https': true, + 'ftp': true, + 'gopher': true, + 'file': true, + 'http:': true, + 'https:': true, + 'ftp:': true, + 'gopher:': true, + 'file:': true + }, + querystring = __webpack_require__(193); + +function urlParse(url, parseQueryString, slashesDenoteHost) { + if (url && util.isObject(url) && url instanceof Url) return url; + + var u = new Url; + u.parse(url, parseQueryString, slashesDenoteHost); + return u; +} + +Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { + if (!util.isString(url)) { + throw new TypeError("Parameter 'url' must be a string, not " + typeof url); + } + + // Copy chrome, IE, opera backslash-handling behavior. + // Back slashes before the query string get converted to forward slashes + // See: https://code.google.com/p/chromium/issues/detail?id=25916 + var queryIndex = url.indexOf('?'), + splitter = + (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#', + uSplit = url.split(splitter), + slashRegex = /\\/g; + uSplit[0] = uSplit[0].replace(slashRegex, '/'); + url = uSplit.join(splitter); + + var rest = url; + + // trim before proceeding. + // This is to support parse stuff like " http://foo.com \n" + rest = rest.trim(); + + if (!slashesDenoteHost && url.split('#').length === 1) { + // Try fast path regexp + var simplePath = simplePathPattern.exec(rest); + if (simplePath) { + this.path = rest; + this.href = rest; + this.pathname = simplePath[1]; + if (simplePath[2]) { + this.search = simplePath[2]; + if (parseQueryString) { + this.query = querystring.parse(this.search.substr(1)); + } else { + this.query = this.search.substr(1); + } + } else if (parseQueryString) { + this.search = ''; + this.query = {}; + } + return this; + } + } + + var proto = protocolPattern.exec(rest); + if (proto) { + proto = proto[0]; + var lowerProto = proto.toLowerCase(); + this.protocol = lowerProto; + rest = rest.substr(proto.length); + } + + // figure out if it's got a host + // user@server is *always* interpreted as a hostname, and url + // resolution will treat //foo/bar as host=foo,path=bar because that's + // how the browser resolves relative URLs. + if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) { + var slashes = rest.substr(0, 2) === '//'; + if (slashes && !(proto && hostlessProtocol[proto])) { + rest = rest.substr(2); + this.slashes = true; + } + } + + if (!hostlessProtocol[proto] && + (slashes || (proto && !slashedProtocol[proto]))) { + + // there's a hostname. + // the first instance of /, ?, ;, or # ends the host. + // + // If there is an @ in the hostname, then non-host chars *are* allowed + // to the left of the last @ sign, unless some host-ending character + // comes *before* the @-sign. + // URLs are obnoxious. + // + // ex: + // http://a@b@c/ => user:a@b host:c + // http://a@b?@c => user:a host:c path:/?@c + + // v0.12 TODO(isaacs): This is not quite how Chrome does things. + // Review our test case against browsers more comprehensively. + + // find the first instance of any hostEndingChars + var hostEnd = -1; + for (var i = 0; i < hostEndingChars.length; i++) { + var hec = rest.indexOf(hostEndingChars[i]); + if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) + hostEnd = hec; + } + + // at this point, either we have an explicit point where the + // auth portion cannot go past, or the last @ char is the decider. + var auth, atSign; + if (hostEnd === -1) { + // atSign can be anywhere. + atSign = rest.lastIndexOf('@'); + } else { + // atSign must be in auth portion. + // http://a@b/c@d => host:b auth:a path:/c@d + atSign = rest.lastIndexOf('@', hostEnd); + } + + // Now we have a portion which is definitely the auth. + // Pull that off. + if (atSign !== -1) { + auth = rest.slice(0, atSign); + rest = rest.slice(atSign + 1); + this.auth = decodeURIComponent(auth); + } + + // the host is the remaining to the left of the first non-host char + hostEnd = -1; + for (var i = 0; i < nonHostChars.length; i++) { + var hec = rest.indexOf(nonHostChars[i]); + if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) + hostEnd = hec; + } + // if we still have not hit it, then the entire thing is a host. + if (hostEnd === -1) + hostEnd = rest.length; + + this.host = rest.slice(0, hostEnd); + rest = rest.slice(hostEnd); + + // pull out port. + this.parseHost(); + + // we've indicated that there is a hostname, + // so even if it's empty, it has to be present. + this.hostname = this.hostname || ''; + + // if hostname begins with [ and ends with ] + // assume that it's an IPv6 address. + var ipv6Hostname = this.hostname[0] === '[' && + this.hostname[this.hostname.length - 1] === ']'; + + // validate a little. + if (!ipv6Hostname) { + var hostparts = this.hostname.split(/\./); + for (var i = 0, l = hostparts.length; i < l; i++) { + var part = hostparts[i]; + if (!part) continue; + if (!part.match(hostnamePartPattern)) { + var newpart = ''; + for (var j = 0, k = part.length; j < k; j++) { + if (part.charCodeAt(j) > 127) { + // we replace non-ASCII char with a temporary placeholder + // we need this to make sure size of hostname is not + // broken by replacing non-ASCII by nothing + newpart += 'x'; + } else { + newpart += part[j]; + } + } + // we test again with ASCII char only + if (!newpart.match(hostnamePartPattern)) { + var validParts = hostparts.slice(0, i); + var notHost = hostparts.slice(i + 1); + var bit = part.match(hostnamePartStart); + if (bit) { + validParts.push(bit[1]); + notHost.unshift(bit[2]); + } + if (notHost.length) { + rest = '/' + notHost.join('.') + rest; + } + this.hostname = validParts.join('.'); + break; + } + } + } + } + + if (this.hostname.length > hostnameMaxLen) { + this.hostname = ''; + } else { + // hostnames are always lower case. + this.hostname = this.hostname.toLowerCase(); + } + + if (!ipv6Hostname) { + // IDNA Support: Returns a punycoded representation of "domain". + // It only converts parts of the domain name that + // have non-ASCII characters, i.e. it doesn't matter if + // you call it with a domain that already is ASCII-only. + this.hostname = punycode.toASCII(this.hostname); + } + + var p = this.port ? ':' + this.port : ''; + var h = this.hostname || ''; + this.host = h + p; + this.href += this.host; + + // strip [ and ] from the hostname + // the host field still retains them, though + if (ipv6Hostname) { + this.hostname = this.hostname.substr(1, this.hostname.length - 2); + if (rest[0] !== '/') { + rest = '/' + rest; + } + } + } + + // now rest is set to the post-host stuff. + // chop off any delim chars. + if (!unsafeProtocol[lowerProto]) { + + // First, make 100% sure that any "autoEscape" chars get + // escaped, even if encodeURIComponent doesn't think they + // need to be. + for (var i = 0, l = autoEscape.length; i < l; i++) { + var ae = autoEscape[i]; + if (rest.indexOf(ae) === -1) + continue; + var esc = encodeURIComponent(ae); + if (esc === ae) { + esc = escape(ae); + } + rest = rest.split(ae).join(esc); + } + } + + + // chop off from the tail first. + var hash = rest.indexOf('#'); + if (hash !== -1) { + // got a fragment string. + this.hash = rest.substr(hash); + rest = rest.slice(0, hash); + } + var qm = rest.indexOf('?'); + if (qm !== -1) { + this.search = rest.substr(qm); + this.query = rest.substr(qm + 1); + if (parseQueryString) { + this.query = querystring.parse(this.query); + } + rest = rest.slice(0, qm); + } else if (parseQueryString) { + // no query string, but parseQueryString still requested + this.search = ''; + this.query = {}; + } + if (rest) this.pathname = rest; + if (slashedProtocol[lowerProto] && + this.hostname && !this.pathname) { + this.pathname = '/'; + } + + //to support http.request + if (this.pathname || this.search) { + var p = this.pathname || ''; + var s = this.search || ''; + this.path = p + s; + } + + // finally, reconstruct the href based on what has been validated. + this.href = this.format(); + return this; +}; + +// format a parsed object into a url string +function urlFormat(obj) { + // ensure it's an object, and not a string url. + // If it's an obj, this is a no-op. + // this way, you can call url_format() on strings + // to clean up potentially wonky urls. + if (util.isString(obj)) obj = urlParse(obj); + if (!(obj instanceof Url)) return Url.prototype.format.call(obj); + return obj.format(); +} + +Url.prototype.format = function() { + var auth = this.auth || ''; + if (auth) { + auth = encodeURIComponent(auth); + auth = auth.replace(/%3A/i, ':'); + auth += '@'; + } + + var protocol = this.protocol || '', + pathname = this.pathname || '', + hash = this.hash || '', + host = false, + query = ''; + + if (this.host) { + host = auth + this.host; + } else if (this.hostname) { + host = auth + (this.hostname.indexOf(':') === -1 ? + this.hostname : + '[' + this.hostname + ']'); + if (this.port) { + host += ':' + this.port; + } + } + + if (this.query && + util.isObject(this.query) && + Object.keys(this.query).length) { + query = querystring.stringify(this.query); + } + + var search = this.search || (query && ('?' + query)) || ''; + + if (protocol && protocol.substr(-1) !== ':') protocol += ':'; + + // only the slashedProtocols get the //. Not mailto:, xmpp:, etc. + // unless they had them to begin with. + if (this.slashes || + (!protocol || slashedProtocol[protocol]) && host !== false) { + host = '//' + (host || ''); + if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname; + } else if (!host) { + host = ''; + } + + if (hash && hash.charAt(0) !== '#') hash = '#' + hash; + if (search && search.charAt(0) !== '?') search = '?' + search; + + pathname = pathname.replace(/[?#]/g, function(match) { + return encodeURIComponent(match); + }); + search = search.replace('#', '%23'); + + return protocol + host + pathname + search + hash; +}; + +function urlResolve(source, relative) { + return urlParse(source, false, true).resolve(relative); +} + +Url.prototype.resolve = function(relative) { + return this.resolveObject(urlParse(relative, false, true)).format(); +}; + +function urlResolveObject(source, relative) { + if (!source) return relative; + return urlParse(source, false, true).resolveObject(relative); +} + +Url.prototype.resolveObject = function(relative) { + if (util.isString(relative)) { + var rel = new Url(); + rel.parse(relative, false, true); + relative = rel; + } + + var result = new Url(); + var tkeys = Object.keys(this); + for (var tk = 0; tk < tkeys.length; tk++) { + var tkey = tkeys[tk]; + result[tkey] = this[tkey]; + } + + // hash is always overridden, no matter what. + // even href="" will remove it. + result.hash = relative.hash; + + // if the relative url is empty, then there's nothing left to do here. + if (relative.href === '') { + result.href = result.format(); + return result; + } + + // hrefs like //foo/bar always cut to the protocol. + if (relative.slashes && !relative.protocol) { + // take everything except the protocol from relative + var rkeys = Object.keys(relative); + for (var rk = 0; rk < rkeys.length; rk++) { + var rkey = rkeys[rk]; + if (rkey !== 'protocol') + result[rkey] = relative[rkey]; + } + + //urlParse appends trailing / to urls like http://www.example.com + if (slashedProtocol[result.protocol] && + result.hostname && !result.pathname) { + result.path = result.pathname = '/'; + } + + result.href = result.format(); + return result; + } + + if (relative.protocol && relative.protocol !== result.protocol) { + // if it's a known url protocol, then changing + // the protocol does weird things + // first, if it's not file:, then we MUST have a host, + // and if there was a path + // to begin with, then we MUST have a path. + // if it is file:, then the host is dropped, + // because that's known to be hostless. + // anything else is assumed to be absolute. + if (!slashedProtocol[relative.protocol]) { + var keys = Object.keys(relative); + for (var v = 0; v < keys.length; v++) { + var k = keys[v]; + result[k] = relative[k]; + } + result.href = result.format(); + return result; + } + + result.protocol = relative.protocol; + if (!relative.host && !hostlessProtocol[relative.protocol]) { + var relPath = (relative.pathname || '').split('/'); + while (relPath.length && !(relative.host = relPath.shift())); + if (!relative.host) relative.host = ''; + if (!relative.hostname) relative.hostname = ''; + if (relPath[0] !== '') relPath.unshift(''); + if (relPath.length < 2) relPath.unshift(''); + result.pathname = relPath.join('/'); + } else { + result.pathname = relative.pathname; + } + result.search = relative.search; + result.query = relative.query; + result.host = relative.host || ''; + result.auth = relative.auth; + result.hostname = relative.hostname || relative.host; + result.port = relative.port; + // to support http.request + if (result.pathname || result.search) { + var p = result.pathname || ''; + var s = result.search || ''; + result.path = p + s; + } + result.slashes = result.slashes || relative.slashes; + result.href = result.format(); + return result; + } + + var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'), + isRelAbs = ( + relative.host || + relative.pathname && relative.pathname.charAt(0) === '/' + ), + mustEndAbs = (isRelAbs || isSourceAbs || + (result.host && relative.pathname)), + removeAllDots = mustEndAbs, + srcPath = result.pathname && result.pathname.split('/') || [], + relPath = relative.pathname && relative.pathname.split('/') || [], + psychotic = result.protocol && !slashedProtocol[result.protocol]; + + // if the url is a non-slashed url, then relative + // links like ../.. should be able + // to crawl up to the hostname, as well. This is strange. + // result.protocol has already been set by now. + // Later on, put the first path part into the host field. + if (psychotic) { + result.hostname = ''; + result.port = null; + if (result.host) { + if (srcPath[0] === '') srcPath[0] = result.host; + else srcPath.unshift(result.host); + } + result.host = ''; + if (relative.protocol) { + relative.hostname = null; + relative.port = null; + if (relative.host) { + if (relPath[0] === '') relPath[0] = relative.host; + else relPath.unshift(relative.host); + } + relative.host = null; + } + mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === ''); + } + + if (isRelAbs) { + // it's absolute. + result.host = (relative.host || relative.host === '') ? + relative.host : result.host; + result.hostname = (relative.hostname || relative.hostname === '') ? + relative.hostname : result.hostname; + result.search = relative.search; + result.query = relative.query; + srcPath = relPath; + // fall through to the dot-handling below. + } else if (relPath.length) { + // it's relative + // throw away the existing file, and take the new path instead. + if (!srcPath) srcPath = []; + srcPath.pop(); + srcPath = srcPath.concat(relPath); + result.search = relative.search; + result.query = relative.query; + } else if (!util.isNullOrUndefined(relative.search)) { + // just pull out the search. + // like href='?foo'. + // Put this after the other two cases because it simplifies the booleans + if (psychotic) { + result.hostname = result.host = srcPath.shift(); + //occationaly the auth can get stuck only in host + //this especially happens in cases like + //url.resolveObject('mailto:local1@domain1', 'local2@domain2') + var authInHost = result.host && result.host.indexOf('@') > 0 ? + result.host.split('@') : false; + if (authInHost) { + result.auth = authInHost.shift(); + result.host = result.hostname = authInHost.shift(); + } + } + result.search = relative.search; + result.query = relative.query; + //to support http.request + if (!util.isNull(result.pathname) || !util.isNull(result.search)) { + result.path = (result.pathname ? result.pathname : '') + + (result.search ? result.search : ''); + } + result.href = result.format(); + return result; + } + + if (!srcPath.length) { + // no path at all. easy. + // we've already handled the other stuff above. + result.pathname = null; + //to support http.request + if (result.search) { + result.path = '/' + result.search; + } else { + result.path = null; + } + result.href = result.format(); + return result; + } + + // if a url ENDs in . or .., then it must get a trailing slash. + // however, if it ends in anything else non-slashy, + // then it must NOT get a trailing slash. + var last = srcPath.slice(-1)[0]; + var hasTrailingSlash = ( + (result.host || relative.host || srcPath.length > 1) && + (last === '.' || last === '..') || last === ''); + + // strip single dots, resolve double dots to parent dir + // if the path tries to go above the root, `up` ends up > 0 + var up = 0; + for (var i = srcPath.length; i >= 0; i--) { + last = srcPath[i]; + if (last === '.') { + srcPath.splice(i, 1); + } else if (last === '..') { + srcPath.splice(i, 1); + up++; + } else if (up) { + srcPath.splice(i, 1); + up--; + } + } + + // if the path is allowed to go above the root, restore leading ..s + if (!mustEndAbs && !removeAllDots) { + for (; up--; up) { + srcPath.unshift('..'); + } + } + + if (mustEndAbs && srcPath[0] !== '' && + (!srcPath[0] || srcPath[0].charAt(0) !== '/')) { + srcPath.unshift(''); + } + + if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { + srcPath.push(''); + } + + var isAbsolute = srcPath[0] === '' || + (srcPath[0] && srcPath[0].charAt(0) === '/'); + + // put the host back + if (psychotic) { + result.hostname = result.host = isAbsolute ? '' : + srcPath.length ? srcPath.shift() : ''; + //occationaly the auth can get stuck only in host + //this especially happens in cases like + //url.resolveObject('mailto:local1@domain1', 'local2@domain2') + var authInHost = result.host && result.host.indexOf('@') > 0 ? + result.host.split('@') : false; + if (authInHost) { + result.auth = authInHost.shift(); + result.host = result.hostname = authInHost.shift(); + } + } + + mustEndAbs = mustEndAbs || (result.host && srcPath.length); + + if (mustEndAbs && !isAbsolute) { + srcPath.unshift(''); + } + + if (!srcPath.length) { + result.pathname = null; + result.path = null; + } else { + result.pathname = srcPath.join('/'); + } + + //to support request.http + if (!util.isNull(result.pathname) || !util.isNull(result.search)) { + result.path = (result.pathname ? result.pathname : '') + + (result.search ? result.search : ''); + } + result.auth = relative.auth || result.auth; + result.slashes = result.slashes || relative.slashes; + result.href = result.format(); + return result; +}; + +Url.prototype.parseHost = function() { + var host = this.host; + var port = portPattern.exec(host); + if (port) { + port = port[0]; + if (port !== ':') { + this.port = port.substr(1); + } + host = host.substr(0, host.length - port.length); + } + if (host) this.hostname = host; +}; + + +/***/ }), +/* 190 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(module, global) {var __WEBPACK_AMD_DEFINE_RESULT__;/*! https://mths.be/punycode v1.4.1 by @mathias */ +;(function(root) { + + /** Detect free variables */ + var freeExports = true && exports && + !exports.nodeType && exports; + var freeModule = true && module && + !module.nodeType && module; + var freeGlobal = typeof global == 'object' && global; + if ( + freeGlobal.global === freeGlobal || + freeGlobal.window === freeGlobal || + freeGlobal.self === freeGlobal + ) { + root = freeGlobal; + } + + /** + * The `punycode` object. + * @name punycode + * @type Object + */ + var punycode, + + /** Highest positive signed 32-bit float value */ + maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 + + /** Bootstring parameters */ + base = 36, + tMin = 1, + tMax = 26, + skew = 38, + damp = 700, + initialBias = 72, + initialN = 128, // 0x80 + delimiter = '-', // '\x2D' + + /** Regular expressions */ + regexPunycode = /^xn--/, + regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars + regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators + + /** Error messages */ + errors = { + 'overflow': 'Overflow: input needs wider integers to process', + 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', + 'invalid-input': 'Invalid input' + }, + + /** Convenience shortcuts */ + baseMinusTMin = base - tMin, + floor = Math.floor, + stringFromCharCode = String.fromCharCode, + + /** Temporary variable */ + key; + + /*--------------------------------------------------------------------------*/ + + /** + * A generic error utility function. + * @private + * @param {String} type The error type. + * @returns {Error} Throws a `RangeError` with the applicable error message. + */ + function error(type) { + throw new RangeError(errors[type]); + } + + /** + * A generic `Array#map` utility function. + * @private + * @param {Array} array The array to iterate over. + * @param {Function} callback The function that gets called for every array + * item. + * @returns {Array} A new array of values returned by the callback function. + */ + function map(array, fn) { + var length = array.length; + var result = []; + while (length--) { + result[length] = fn(array[length]); + } + return result; + } + + /** + * A simple `Array#map`-like wrapper to work with domain name strings or email + * addresses. + * @private + * @param {String} domain The domain name or email address. + * @param {Function} callback The function that gets called for every + * character. + * @returns {Array} A new string of characters returned by the callback + * function. + */ + function mapDomain(string, fn) { + var parts = string.split('@'); + var result = ''; + if (parts.length > 1) { + // In email addresses, only the domain name should be punycoded. Leave + // the local part (i.e. everything up to `@`) intact. + result = parts[0] + '@'; + string = parts[1]; + } + // Avoid `split(regex)` for IE8 compatibility. See #17. + string = string.replace(regexSeparators, '\x2E'); + var labels = string.split('.'); + var encoded = map(labels, fn).join('.'); + return result + encoded; + } + + /** + * Creates an array containing the numeric code points of each Unicode + * character in the string. While JavaScript uses UCS-2 internally, + * this function will convert a pair of surrogate halves (each of which + * UCS-2 exposes as separate characters) into a single code point, + * matching UTF-16. + * @see `punycode.ucs2.encode` + * @see + * @memberOf punycode.ucs2 + * @name decode + * @param {String} string The Unicode input string (UCS-2). + * @returns {Array} The new array of code points. + */ + function ucs2decode(string) { + var output = [], + counter = 0, + length = string.length, + value, + extra; + while (counter < length) { + value = string.charCodeAt(counter++); + if (value >= 0xD800 && value <= 0xDBFF && counter < length) { + // high surrogate, and there is a next character + extra = string.charCodeAt(counter++); + if ((extra & 0xFC00) == 0xDC00) { // low surrogate + output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); + } else { + // unmatched surrogate; only append this code unit, in case the next + // code unit is the high surrogate of a surrogate pair + output.push(value); + counter--; + } + } else { + output.push(value); + } + } + return output; + } + + /** + * Creates a string based on an array of numeric code points. + * @see `punycode.ucs2.decode` + * @memberOf punycode.ucs2 + * @name encode + * @param {Array} codePoints The array of numeric code points. + * @returns {String} The new Unicode string (UCS-2). + */ + function ucs2encode(array) { + return map(array, function(value) { + var output = ''; + if (value > 0xFFFF) { + value -= 0x10000; + output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); + value = 0xDC00 | value & 0x3FF; + } + output += stringFromCharCode(value); + return output; + }).join(''); + } + + /** + * Converts a basic code point into a digit/integer. + * @see `digitToBasic()` + * @private + * @param {Number} codePoint The basic numeric code point value. + * @returns {Number} The numeric value of a basic code point (for use in + * representing integers) in the range `0` to `base - 1`, or `base` if + * the code point does not represent a value. + */ + function basicToDigit(codePoint) { + if (codePoint - 48 < 10) { + return codePoint - 22; + } + if (codePoint - 65 < 26) { + return codePoint - 65; + } + if (codePoint - 97 < 26) { + return codePoint - 97; + } + return base; + } + + /** + * Converts a digit/integer into a basic code point. + * @see `basicToDigit()` + * @private + * @param {Number} digit The numeric value of a basic code point. + * @returns {Number} The basic code point whose value (when used for + * representing integers) is `digit`, which needs to be in the range + * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is + * used; else, the lowercase form is used. The behavior is undefined + * if `flag` is non-zero and `digit` has no uppercase form. + */ + function digitToBasic(digit, flag) { + // 0..25 map to ASCII a..z or A..Z + // 26..35 map to ASCII 0..9 + return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); + } + + /** + * Bias adaptation function as per section 3.4 of RFC 3492. + * https://tools.ietf.org/html/rfc3492#section-3.4 + * @private + */ + function adapt(delta, numPoints, firstTime) { + var k = 0; + delta = firstTime ? floor(delta / damp) : delta >> 1; + delta += floor(delta / numPoints); + for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { + delta = floor(delta / baseMinusTMin); + } + return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); + } + + /** + * Converts a Punycode string of ASCII-only symbols to a string of Unicode + * symbols. + * @memberOf punycode + * @param {String} input The Punycode string of ASCII-only symbols. + * @returns {String} The resulting string of Unicode symbols. + */ + function decode(input) { + // Don't use UCS-2 + var output = [], + inputLength = input.length, + out, + i = 0, + n = initialN, + bias = initialBias, + basic, + j, + index, + oldi, + w, + k, + digit, + t, + /** Cached calculation results */ + baseMinusT; + + // Handle the basic code points: let `basic` be the number of input code + // points before the last delimiter, or `0` if there is none, then copy + // the first basic code points to the output. + + basic = input.lastIndexOf(delimiter); + if (basic < 0) { + basic = 0; + } + + for (j = 0; j < basic; ++j) { + // if it's not a basic code point + if (input.charCodeAt(j) >= 0x80) { + error('not-basic'); + } + output.push(input.charCodeAt(j)); + } + + // Main decoding loop: start just after the last delimiter if any basic code + // points were copied; start at the beginning otherwise. + + for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { + + // `index` is the index of the next character to be consumed. + // Decode a generalized variable-length integer into `delta`, + // which gets added to `i`. The overflow checking is easier + // if we increase `i` as we go, then subtract off its starting + // value at the end to obtain `delta`. + for (oldi = i, w = 1, k = base; /* no condition */; k += base) { + + if (index >= inputLength) { + error('invalid-input'); + } + + digit = basicToDigit(input.charCodeAt(index++)); + + if (digit >= base || digit > floor((maxInt - i) / w)) { + error('overflow'); + } + + i += digit * w; + t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); + + if (digit < t) { + break; + } + + baseMinusT = base - t; + if (w > floor(maxInt / baseMinusT)) { + error('overflow'); + } + + w *= baseMinusT; + + } + + out = output.length + 1; + bias = adapt(i - oldi, out, oldi == 0); + + // `i` was supposed to wrap around from `out` to `0`, + // incrementing `n` each time, so we'll fix that now: + if (floor(i / out) > maxInt - n) { + error('overflow'); + } + + n += floor(i / out); + i %= out; + + // Insert `n` at position `i` of the output + output.splice(i++, 0, n); + + } + + return ucs2encode(output); + } + + /** + * Converts a string of Unicode symbols (e.g. a domain name label) to a + * Punycode string of ASCII-only symbols. + * @memberOf punycode + * @param {String} input The string of Unicode symbols. + * @returns {String} The resulting Punycode string of ASCII-only symbols. + */ + function encode(input) { + var n, + delta, + handledCPCount, + basicLength, + bias, + j, + m, + q, + k, + t, + currentValue, + output = [], + /** `inputLength` will hold the number of code points in `input`. */ + inputLength, + /** Cached calculation results */ + handledCPCountPlusOne, + baseMinusT, + qMinusT; + + // Convert the input in UCS-2 to Unicode + input = ucs2decode(input); + + // Cache the length + inputLength = input.length; + + // Initialize the state + n = initialN; + delta = 0; + bias = initialBias; + + // Handle the basic code points + for (j = 0; j < inputLength; ++j) { + currentValue = input[j]; + if (currentValue < 0x80) { + output.push(stringFromCharCode(currentValue)); + } + } + + handledCPCount = basicLength = output.length; + + // `handledCPCount` is the number of code points that have been handled; + // `basicLength` is the number of basic code points. + + // Finish the basic string - if it is not empty - with a delimiter + if (basicLength) { + output.push(delimiter); + } + + // Main encoding loop: + while (handledCPCount < inputLength) { + + // All non-basic code points < n have been handled already. Find the next + // larger one: + for (m = maxInt, j = 0; j < inputLength; ++j) { + currentValue = input[j]; + if (currentValue >= n && currentValue < m) { + m = currentValue; + } + } + + // Increase `delta` enough to advance the decoder's state to , + // but guard against overflow + handledCPCountPlusOne = handledCPCount + 1; + if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { + error('overflow'); + } + + delta += (m - n) * handledCPCountPlusOne; + n = m; + + for (j = 0; j < inputLength; ++j) { + currentValue = input[j]; + + if (currentValue < n && ++delta > maxInt) { + error('overflow'); + } + + if (currentValue == n) { + // Represent delta as a generalized variable-length integer + for (q = delta, k = base; /* no condition */; k += base) { + t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); + if (q < t) { + break; + } + qMinusT = q - t; + baseMinusT = base - t; + output.push( + stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) + ); + q = floor(qMinusT / baseMinusT); + } + + output.push(stringFromCharCode(digitToBasic(q, 0))); + bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); + delta = 0; + ++handledCPCount; + } + } + + ++delta; + ++n; + + } + return output.join(''); + } + + /** + * Converts a Punycode string representing a domain name or an email address + * to Unicode. Only the Punycoded parts of the input will be converted, i.e. + * it doesn't matter if you call it on a string that has already been + * converted to Unicode. + * @memberOf punycode + * @param {String} input The Punycoded domain name or email address to + * convert to Unicode. + * @returns {String} The Unicode representation of the given Punycode + * string. + */ + function toUnicode(input) { + return mapDomain(input, function(string) { + return regexPunycode.test(string) + ? decode(string.slice(4).toLowerCase()) + : string; + }); + } + + /** + * Converts a Unicode string representing a domain name or an email address to + * Punycode. Only the non-ASCII parts of the domain name will be converted, + * i.e. it doesn't matter if you call it with a domain that's already in + * ASCII. + * @memberOf punycode + * @param {String} input The domain name or email address to convert, as a + * Unicode string. + * @returns {String} The Punycode representation of the given domain name or + * email address. + */ + function toASCII(input) { + return mapDomain(input, function(string) { + return regexNonASCII.test(string) + ? 'xn--' + encode(string) + : string; + }); + } + + /*--------------------------------------------------------------------------*/ + + /** Define the public API */ + punycode = { + /** + * A string representing the current Punycode.js version number. + * @memberOf punycode + * @type String + */ + 'version': '1.4.1', + /** + * An object of methods to convert from JavaScript's internal character + * representation (UCS-2) to Unicode code points, and back. + * @see + * @memberOf punycode + * @type Object + */ + 'ucs2': { + 'decode': ucs2decode, + 'encode': ucs2encode + }, + 'decode': decode, + 'encode': encode, + 'toASCII': toASCII, + 'toUnicode': toUnicode + }; + + /** Expose `punycode` */ + // Some AMD build optimizers, like r.js, check for specific condition patterns + // like the following: + if ( + true + ) { + !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { + return punycode; + }).call(exports, __webpack_require__, exports, module), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else {} + +}(this)); + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(191)(module), __webpack_require__(38))) + +/***/ }), +/* 191 */ +/***/ (function(module, exports) { + +module.exports = function(module) { + if (!module.webpackPolyfill) { + module.deprecate = function() {}; + module.paths = []; + // module.parent = undefined by default + if (!module.children) module.children = []; + Object.defineProperty(module, "loaded", { + enumerable: true, + get: function() { + return module.l; + } + }); + Object.defineProperty(module, "id", { + enumerable: true, + get: function() { + return module.i; + } + }); + module.webpackPolyfill = 1; + } + return module; +}; + + +/***/ }), +/* 192 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +module.exports = { + isString: function(arg) { + return typeof(arg) === 'string'; + }, + isObject: function(arg) { + return typeof(arg) === 'object' && arg !== null; + }, + isNull: function(arg) { + return arg === null; + }, + isNullOrUndefined: function(arg) { + return arg == null; + } +}; + + +/***/ }), +/* 193 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.decode = exports.parse = __webpack_require__(194); +exports.encode = exports.stringify = __webpack_require__(195); + + +/***/ }), +/* 194 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + + + +// If obj.hasOwnProperty has been overridden, then calling +// obj.hasOwnProperty(prop) will break. +// See: https://github.com/joyent/node/issues/1707 +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + +module.exports = function(qs, sep, eq, options) { + sep = sep || '&'; + eq = eq || '='; + var obj = {}; + + if (typeof qs !== 'string' || qs.length === 0) { + return obj; + } + + var regexp = /\+/g; + qs = qs.split(sep); + + var maxKeys = 1000; + if (options && typeof options.maxKeys === 'number') { + maxKeys = options.maxKeys; + } + + var len = qs.length; + // maxKeys <= 0 means that we should not limit keys count + if (maxKeys > 0 && len > maxKeys) { + len = maxKeys; + } + + for (var i = 0; i < len; ++i) { + var x = qs[i].replace(regexp, '%20'), + idx = x.indexOf(eq), + kstr, vstr, k, v; + + if (idx >= 0) { + kstr = x.substr(0, idx); + vstr = x.substr(idx + 1); + } else { + kstr = x; + vstr = ''; + } + + k = decodeURIComponent(kstr); + v = decodeURIComponent(vstr); + + if (!hasOwnProperty(obj, k)) { + obj[k] = v; + } else if (isArray(obj[k])) { + obj[k].push(v); + } else { + obj[k] = [obj[k], v]; + } + } + + return obj; +}; + +var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; +}; + + +/***/ }), +/* 195 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + + + +var stringifyPrimitive = function(v) { + switch (typeof v) { + case 'string': + return v; + + case 'boolean': + return v ? 'true' : 'false'; + + case 'number': + return isFinite(v) ? v : ''; + + default: + return ''; + } +}; + +module.exports = function(obj, sep, eq, name) { + sep = sep || '&'; + eq = eq || '='; + if (obj === null) { + obj = undefined; + } + + if (typeof obj === 'object') { + return map(objectKeys(obj), function(k) { + var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; + if (isArray(obj[k])) { + return map(obj[k], function(v) { + return ks + encodeURIComponent(stringifyPrimitive(v)); + }).join(sep); + } else { + return ks + encodeURIComponent(stringifyPrimitive(obj[k])); + } + }).join(sep); + + } + + if (!name) return ''; + return encodeURIComponent(stringifyPrimitive(name)) + eq + + encodeURIComponent(stringifyPrimitive(obj)); +}; + +var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; +}; + +function map (xs, f) { + if (xs.map) return xs.map(f); + var res = []; + for (var i = 0; i < xs.length; i++) { + res.push(f(xs[i], i)); + } + return res; +} + +var objectKeys = Object.keys || function (obj) { + var res = []; + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key); + } + return res; +}; + + +/***/ }), +/* 196 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 197 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 198 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 199 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 200 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(4); +var ReplayableAudioNode = /** @class */ (function () { + function ReplayableAudioNode(audioSource, bytesPerSecond) { + var _this = this; + this.privBuffers = []; + this.privReplayOffset = 0; + this.privLastShrinkOffset = 0; + this.privBufferStartOffset = 0; + this.privBufferSerial = 0; + this.privBufferedBytes = 0; + this.privReplay = false; + this.privLastChunkAcquiredTime = 0; + this.id = function () { + return _this.privAudioNode.id(); + }; + this.privAudioNode = audioSource; + this.privBytesPerSecond = bytesPerSecond; + } + // Reads and returns the next chunk of audio buffer. + // If replay of existing buffers are needed, read() will first seek and replay + // existing content, and upoin completion it will read new content from the underlying + // audio node, saving that content into the replayable buffers. + ReplayableAudioNode.prototype.read = function () { + var _this = this; + // if there is a replay request to honor. + if (!!this.privReplay && this.privBuffers.length !== 0) { + // Find the start point in the buffers. + // Offsets are in 100ns increments. + // So how many bytes do we need to seek to get the right offset? + var offsetToSeek = this.privReplayOffset - this.privBufferStartOffset; + var bytesToSeek = Math.round(offsetToSeek * this.privBytesPerSecond * 1e-7); + if (0 !== (bytesToSeek % 2)) { + bytesToSeek++; + } + var i = 0; + while (i < this.privBuffers.length && bytesToSeek >= this.privBuffers[i].chunk.buffer.byteLength) { + bytesToSeek -= this.privBuffers[i++].chunk.buffer.byteLength; + } + var retVal = this.privBuffers[i].chunk.buffer.slice(bytesToSeek); + this.privReplayOffset += (retVal.byteLength / this.privBytesPerSecond) * 1e+7; + // If we've reached the end of the buffers, stop replaying. + if (i === this.privBuffers.length - 1) { + this.privReplay = false; + } + return Exports_1.PromiseHelper.fromResult({ + buffer: retVal, + isEnd: false, + timeReceived: this.privBuffers[i].chunk.timeReceived, + }); + } + return this.privAudioNode.read() + .onSuccessContinueWith(function (result) { + if (result && result.buffer) { + _this.privBuffers.push(new BufferEntry(result, _this.privBufferSerial++, _this.privBufferedBytes)); + _this.privBufferedBytes += result.buffer.byteLength; + } + return result; + }); + }; + ReplayableAudioNode.prototype.detach = function () { + this.privAudioNode.detach(); + this.privBuffers = undefined; + }; + ReplayableAudioNode.prototype.replay = function () { + if (this.privBuffers && 0 !== this.privBuffers.length) { + this.privReplay = true; + this.privReplayOffset = this.privLastShrinkOffset; + } + }; + // Shrinks the existing audio buffers to start at the new offset, or at the + // beginning of the buffer closest to the requested offset. + // A replay request will start from the last shrink point. + ReplayableAudioNode.prototype.shrinkBuffers = function (offset) { + if (this.privBuffers === undefined) { + return; + } + this.privLastShrinkOffset = offset; + // Find the start point in the buffers. + // Offsets are in 100ns increments. + // So how many bytes do we need to seek to get the right offset? + var offsetToSeek = offset - this.privBufferStartOffset; + var bytesToSeek = Math.round(offsetToSeek * this.privBytesPerSecond * 1e-7); + var i = 0; + while (i < this.privBuffers.length && bytesToSeek >= this.privBuffers[i].chunk.buffer.byteLength) { + bytesToSeek -= this.privBuffers[i++].chunk.buffer.byteLength; + } + this.privBufferStartOffset = Math.round(offset - ((bytesToSeek / this.privBytesPerSecond) * 1e+7)); + this.privBuffers = this.privBuffers.slice(i); + }; + // Finds the time a buffer of audio was first seen by offset. + ReplayableAudioNode.prototype.findTimeAtOffset = function (offset) { + if (offset < this.privBufferStartOffset || this.privBuffers === undefined) { + return 0; + } + for (var _i = 0, _a = this.privBuffers; _i < _a.length; _i++) { + var value = _a[_i]; + var startOffset = (value.byteOffset / this.privBytesPerSecond) * 1e7; + var endOffset = startOffset + ((value.chunk.buffer.byteLength / this.privBytesPerSecond) * 1e7); + if (offset >= startOffset && offset <= endOffset) { + return value.chunk.timeReceived; + } + } + return 0; + }; + return ReplayableAudioNode; +}()); +exports.ReplayableAudioNode = ReplayableAudioNode; +// Primary use of this class is to help debugging problems with the replay +// code. If the memory cost of alloc / dealloc gets too much, drop it and just use +// the ArrayBuffer directly. +// tslint:disable-next-line:max-classes-per-file +var BufferEntry = /** @class */ (function () { + function BufferEntry(chunk, serial, byteOffset) { + this.chunk = chunk; + this.serial = serial; + this.byteOffset = byteOffset; + } + return BufferEntry; +}()); + + + +/***/ }), +/* 201 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(31); +var ProxyInfo = /** @class */ (function () { + function ProxyInfo(proxyHostName, proxyPort, proxyUserName, proxyPassword) { + this.privProxyHostName = proxyHostName; + this.privProxyPort = proxyPort; + this.privProxyUserName = proxyUserName; + this.privProxyPassword = proxyPassword; + } + ProxyInfo.fromParameters = function (parameters) { + return new ProxyInfo(parameters.getProperty(Exports_1.PropertyId.SpeechServiceConnection_ProxyHostName), parseInt(parameters.getProperty(Exports_1.PropertyId.SpeechServiceConnection_ProxyPort), 10), parameters.getProperty(Exports_1.PropertyId.SpeechServiceConnection_ProxyUserName), parameters.getProperty(Exports_1.PropertyId.SpeechServiceConnection_ProxyPassword)); + }; + ProxyInfo.fromRecognizerConfig = function (config) { + return this.fromParameters(config.parameters); + }; + Object.defineProperty(ProxyInfo.prototype, "HostName", { + get: function () { + return this.privProxyHostName; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ProxyInfo.prototype, "Port", { + get: function () { + return this.privProxyPort; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ProxyInfo.prototype, "UserName", { + get: function () { + return this.privProxyUserName; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ProxyInfo.prototype, "Password", { + get: function () { + return this.privProxyPassword; + }, + enumerable: true, + configurable: true + }); + return ProxyInfo; +}()); +exports.ProxyInfo = ProxyInfo; + + + +/***/ }), +/* 202 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var Exports_1 = __webpack_require__(4); +// Node.JS specific xmlhttprequest / browser support. +var XHR = __importStar(__webpack_require__(203)); +var RestRequestType; +(function (RestRequestType) { + RestRequestType["Get"] = "get"; + RestRequestType["Post"] = "post"; + RestRequestType["Delete"] = "delete"; + RestRequestType["File"] = "file"; +})(RestRequestType = exports.RestRequestType || (exports.RestRequestType = {})); +// accept rest operations via request method and return abstracted objects from server response +var RestMessageAdapter = /** @class */ (function () { + function RestMessageAdapter(configParams, connectionId) { + if (!configParams) { + throw new Exports_1.ArgumentNullError("configParams"); + } + this.privHeaders = configParams.headers; + this.privTimeout = configParams.timeout; + this.privIgnoreCache = configParams.ignoreCache; + } + RestMessageAdapter.prototype.setHeaders = function (key, value) { + this.privHeaders[key] = value; + }; + RestMessageAdapter.prototype.request = function (method, uri, queryParams, body, binaryBody) { + var _this = this; + if (queryParams === void 0) { queryParams = {}; } + if (body === void 0) { body = null; } + if (binaryBody === void 0) { binaryBody = null; } + var responseReceivedDeferral = new Exports_1.Deferred(); + var xhr; + if (typeof (XMLHttpRequest) === "undefined") { + xhr = new XHR.XMLHttpRequest(); + } + else { + xhr = new XMLHttpRequest(); + } + var requestCommand = method === RestRequestType.File ? "post" : method; + xhr.open(requestCommand, this.withQuery(uri, queryParams), true); + if (this.privHeaders) { + Object.keys(this.privHeaders).forEach(function (key) { return xhr.setRequestHeader(key, _this.privHeaders[key]); }); + } + if (this.privIgnoreCache) { + xhr.setRequestHeader("Cache-Control", "no-cache"); + } + xhr.timeout = this.privTimeout; + xhr.onload = function () { + responseReceivedDeferral.resolve(_this.parseXHRResult(xhr)); + }; + xhr.onerror = function () { + responseReceivedDeferral.resolve(_this.errorResponse(xhr, "Failed to make request.")); + }; + xhr.ontimeout = function () { + responseReceivedDeferral.resolve(_this.errorResponse(xhr, "Request took longer than expected.")); + }; + if (method === RestRequestType.File && binaryBody) { + xhr.setRequestHeader("Content-Type", "multipart/form-data"); + xhr.send(binaryBody); + } + else if (method === RestRequestType.Post && body) { + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.send(JSON.stringify(body)); + } + else { + xhr.send(); + } + return responseReceivedDeferral.promise(); + }; + RestMessageAdapter.prototype.parseXHRResult = function (xhr) { + return { + data: xhr.responseText, + headers: xhr.getAllResponseHeaders(), + json: function () { return JSON.parse(xhr.responseText); }, + ok: xhr.status >= 200 && xhr.status < 300, + status: xhr.status, + statusText: xhr.statusText, + }; + }; + RestMessageAdapter.prototype.errorResponse = function (xhr, message) { + if (message === void 0) { message = null; } + return { + data: message || xhr.statusText, + headers: xhr.getAllResponseHeaders(), + json: function () { return JSON.parse(message || ("\"" + xhr.statusText + "\"")); }, + ok: false, + status: xhr.status, + statusText: xhr.statusText, + }; + }; + RestMessageAdapter.prototype.withQuery = function (url, params) { + if (params === void 0) { params = {}; } + var queryString = this.queryParams(params); + return queryString ? url + (url.indexOf("?") === -1 ? "?" : "&") + queryString : url; + }; + RestMessageAdapter.prototype.queryParams = function (params) { + if (params === void 0) { params = {}; } + return Object.keys(params) + .map(function (k) { return encodeURIComponent(k) + "=" + encodeURIComponent(params[k]); }) + .join("&"); + }; + return RestMessageAdapter; +}()); +exports.RestMessageAdapter = RestMessageAdapter; + + + +/***/ }), +/* 203 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }) +/******/ ]); +//# sourceMappingURL=microsoft.cognitiveservices.speech.sdk.bundle.js.map \ No newline at end of file diff --git a/microsoft.cognitiveservices.speech.sdk.bundle.js.map b/microsoft.cognitiveservices.speech.sdk.bundle.js.map new file mode 100644 index 0000000..e5ef313 --- /dev/null +++ b/microsoft.cognitiveservices.speech.sdk.bundle.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./bundleApp.js","webpack:///microsoft.cognitiveservices.speech.sdk.ts","webpack:///src/common.browser/Exports.ts","webpack:///src/common.browser/ConsoleLoggingListener.ts","webpack:///src/common/Exports.ts","webpack:///src/common/AudioSourceEvents.ts","webpack:///src/common/PlatformEvent.ts","webpack:///src/common/Guid.ts","webpack:///src/common/ConnectionEvents.ts","webpack:///src/common/ConnectionMessage.ts","webpack:///src/common/Error.ts","webpack:///src/common/ConnectionOpenResponse.ts","webpack:///src/common/Events.ts","webpack:///src/common/EventSource.ts","webpack:///src/common/IConnection.ts","webpack:///src/common/List.ts","webpack:///src/common/Promise.ts","webpack:///src/common/Queue.ts","webpack:///src/common/RawWebsocketMessage.ts","webpack:///src/common/RiffPcmEncoder.ts","webpack:///src/common/Stream.ts","webpack:///src/common.speech/TranslationStatus.ts","webpack:///src/common/ChunkedArrayBufferStream.ts","webpack:///src/common/Timeout.ts","webpack:///src/common/OCSPEvents.ts","webpack:///src/common.browser/MicAudioSource.ts","webpack:///src/common.speech/Exports.ts","webpack:///src/common.speech/CognitiveSubscriptionKeyAuthentication.ts","webpack:///src/common.speech/IAuthentication.ts","webpack:///src/common.speech/CognitiveTokenAuthentication.ts","webpack:///src/common.speech/IntentConnectionFactory.ts","webpack:///src/sdk/Exports.ts","webpack:///src/sdk/Audio/AudioConfig.ts","webpack:///src/sdk/Contracts.ts","webpack:///src/sdk/Audio/AudioFileWriter.ts","webpack:///fs (ignored)","webpack:///src/sdk/Audio/AudioInputStream.ts","webpack:///./node_modules/buffer/index.js","webpack:///(webpack)/buildin/global.js","webpack:///./node_modules/base64-js/index.js","webpack:///./node_modules/ieee754/index.js","webpack:///./node_modules/isarray/index.js","webpack:///src/sdk/Audio/AudioStreamFormat.ts","webpack:///src/sdk/Audio/AudioOutputStream.ts","webpack:///src/sdk/Audio/AudioOutputFormat.ts","webpack:///src/sdk/SpeechSynthesisOutputFormat.ts","webpack:///src/sdk/CancellationReason.ts","webpack:///src/sdk/Audio/PullAudioInputStreamCallback.ts","webpack:///src/sdk/Audio/PushAudioOutputStreamCallback.ts","webpack:///src/sdk/KeywordRecognitionModel.ts","webpack:///src/sdk/SessionEventArgs.ts","webpack:///src/sdk/RecognitionEventArgs.ts","webpack:///src/sdk/OutputFormat.ts","webpack:///src/sdk/IntentRecognitionEventArgs.ts","webpack:///src/sdk/RecognitionResult.ts","webpack:///src/sdk/SpeechRecognitionResult.ts","webpack:///src/sdk/IntentRecognitionResult.ts","webpack:///src/sdk/LanguageUnderstandingModel.ts","webpack:///src/sdk/SpeechRecognitionEventArgs.ts","webpack:///src/sdk/SpeechRecognitionCanceledEventArgs.ts","webpack:///src/sdk/TranslationRecognitionEventArgs.ts","webpack:///src/sdk/TranslationSynthesisEventArgs.ts","webpack:///src/sdk/TranslationRecognitionResult.ts","webpack:///src/sdk/TranslationSynthesisResult.ts","webpack:///src/sdk/ResultReason.ts","webpack:///src/sdk/SpeechConfig.ts","webpack:///src/sdk/SpeechTranslationConfig.ts","webpack:///src/sdk/PropertyCollection.ts","webpack:///src/sdk/PropertyId.ts","webpack:///src/sdk/Recognizer.ts","webpack:///src/sdk/SpeechRecognizer.ts","webpack:///src/common.speech/SpeechConnectionFactory.ts","webpack:///src/common.speech/ConnectionFactoryBase.ts","webpack:///src/common.speech/QueryParameterNames.ts","webpack:///src/sdk/IntentRecognizer.ts","webpack:///src/sdk/VoiceProfileType.ts","webpack:///src/sdk/TranslationRecognizer.ts","webpack:///src/sdk/Translations.ts","webpack:///src/sdk/NoMatchReason.ts","webpack:///src/sdk/NoMatchDetails.ts","webpack:///src/sdk/TranslationRecognitionCanceledEventArgs.ts","webpack:///src/sdk/IntentRecognitionCanceledEventArgs.ts","webpack:///src/sdk/CancellationDetailsBase.ts","webpack:///src/sdk/CancellationDetails.ts","webpack:///src/sdk/CancellationErrorCodes.ts","webpack:///src/sdk/ConnectionEventArgs.ts","webpack:///src/sdk/ServiceEventArgs.ts","webpack:///src/sdk/Connection.ts","webpack:///src/sdk/ConnectionMessage.ts","webpack:///src/sdk/PhraseListGrammar.ts","webpack:///src/sdk/DialogServiceConfig.ts","webpack:///src/sdk/BotFrameworkConfig.ts","webpack:///src/sdk/CustomCommandsConfig.ts","webpack:///src/sdk/DialogServiceConnector.ts","webpack:///src/common.speech/DialogConnectorFactory.ts","webpack:///src/sdk/ActivityReceivedEventArgs.ts","webpack:///src/sdk/ServicePropertyChannel.ts","webpack:///src/sdk/ProfanityOption.ts","webpack:///src/sdk/Audio/BaseAudioPlayer.ts","webpack:///src/sdk/ConnectionMessageEventArgs.ts","webpack:///src/sdk/VoiceProfile.ts","webpack:///src/sdk/VoiceProfileEnrollmentResult.ts","webpack:///src/sdk/VoiceProfileResult.ts","webpack:///src/sdk/VoiceProfileClient.ts","webpack:///src/sdk/SpeakerRecognizer.ts","webpack:///src/sdk/SpeakerIdentificationModel.ts","webpack:///src/sdk/SpeakerVerificationModel.ts","webpack:///src/sdk/AutoDetectSourceLanguageConfig.ts","webpack:///src/sdk/AutoDetectSourceLanguageResult.ts","webpack:///src/sdk/SourceLanguageConfig.ts","webpack:///src/sdk/SpeakerRecognitionResult.ts","webpack:///src/sdk/Transcription/Exports.ts","webpack:///src/sdk/Transcription/Conversation.ts","webpack:///src/sdk/Transcription/ConversationExpirationEventArgs.ts","webpack:///src/sdk/Transcription/ConversationParticipantsChangedEventArgs.ts","webpack:///src/sdk/Transcription/ConversationTranslationCanceledEventArgs.ts","webpack:///src/sdk/Transcription/ConversationTranslationEventArgs.ts","webpack:///src/sdk/Transcription/ConversationTranslationResult.ts","webpack:///src/sdk/Transcription/ConversationTranslator.ts","webpack:///src/sdk/Transcription/IParticipant.ts","webpack:///src/sdk/Transcription/ParticipantChangedReason.ts","webpack:///src/sdk/SpeechSynthesizer.ts","webpack:///src/sdk/SpeechSynthesisResult.ts","webpack:///src/sdk/SpeechSynthesisEventArgs.ts","webpack:///src/sdk/SpeechSynthesisWordBoundaryEventArgs.ts","webpack:///src/sdk/Audio/SpeakerAudioDestination.ts","webpack:///src/common.speech/RecognitionEvents.ts","webpack:///src/common.speech/ServiceRecognizerBase.ts","webpack:///src/common.speech/SpeechConnectionMessage.Internal.ts","webpack:///src/common.speech/RecognizerConfig.ts","webpack:///src/common.speech/WebsocketMessageFormatter.ts","webpack:///src/common.speech/TranslationConnectionFactory.ts","webpack:///src/common.speech/SpeechSynthesisConnectionFactory.ts","webpack:///src/common.speech/EnumTranslation.ts","webpack:///src/common.speech/ServiceMessages/Enums.ts","webpack:///src/common.speech/ServiceMessages/TranslationSynthesisEnd.ts","webpack:///src/common.speech/ServiceMessages/TranslationHypothesis.ts","webpack:///src/common.speech/ServiceMessages/TranslationPhrase.ts","webpack:///src/common.speech/TranslationServiceRecognizer.ts","webpack:///src/common.speech/ServiceMessages/SpeechDetected.ts","webpack:///src/common.speech/ServiceMessages/SpeechHypothesis.ts","webpack:///src/common.speech/SpeechServiceRecognizer.ts","webpack:///src/common.speech/ServiceMessages/DetailedSpeechPhrase.ts","webpack:///src/common.speech/ServiceMessages/SimpleSpeechPhrase.ts","webpack:///src/common.speech/AddedLmIntent.ts","webpack:///src/common.speech/IntentServiceRecognizer.ts","webpack:///src/common.speech/ServiceMessages/IntentResponse.ts","webpack:///src/common.speech/RequestSession.ts","webpack:///src/common.speech/ServiceTelemetryListener.Internal.ts","webpack:///src/common.speech/SpeechContext.ts","webpack:///src/common.speech/DynamicGrammarBuilder.ts","webpack:///src/common.speech/DialogServiceAdapter.ts","webpack:///src/common.speech/DialogServiceTurnStateManager.ts","webpack:///src/common.speech/DialogServiceTurnState.ts","webpack:///src/common.speech/ServiceMessages/ActivityResponsePayload.ts","webpack:///src/common.speech/AgentConfig.ts","webpack:///src/common.speech/Transcription/Exports.ts","webpack:///src/common.speech/Transcription/ConversationManager.ts","webpack:///src/common.speech/Transcription/ConversationConnectionConfig.ts","webpack:///src/common.browser/RestConfigBase.ts","webpack:///src/common.speech/Transcription/ConversationUtils.ts","webpack:///src/common.speech/Transcription/ConversationTranslatorRecognizer.ts","webpack:///src/common.speech/Transcription/ConversationConnectionFactory.ts","webpack:///src/common.speech/Transcription/ConversationWebsocketMessageFormatter.ts","webpack:///src/common.speech/Transcription/ConversationConnectionMessage.ts","webpack:///src/common.speech/Transcription/ConversationServiceAdapter.ts","webpack:///src/common.speech/Transcription/ConversationRequestSession.ts","webpack:///src/common.speech/Transcription/ConversationTranslatorEventArgs.ts","webpack:///src/common.speech/Transcription/ConversationTranslatorInterfaces.ts","webpack:///src/common.speech/Transcription/ServiceMessages/Exports.ts","webpack:///src/common.speech/Transcription/ServiceMessages/CommandResponsePayload.ts","webpack:///src/common.speech/Transcription/ServiceMessages/ParticipantResponsePayload.ts","webpack:///src/common.speech/Transcription/ServiceMessages/TranslationResponsePayload.ts","webpack:///src/common.speech/ServiceMessages/SynthesisAudioMetadata.ts","webpack:///src/common.speech/SynthesisTurn.ts","webpack:///src/common.speech/SynthesisAdapterBase.ts","webpack:///src/common.speech/SynthesisEvents.ts","webpack:///src/common.speech/SynthesizerConfig.ts","webpack:///src/common.speech/SynthesisContext.ts","webpack:///src/common.speech/SpeakerRecognitionConfig.ts","webpack:///src/common.speech/SpeakerIdMessageAdapter.ts","webpack:///src/common.browser/FileAudioSource.ts","webpack:///src/common.browser/PCMRecorder.ts","webpack:///src/common.browser/WebsocketConnection.ts","webpack:///src/common.browser/WebsocketMessageAdapter.ts","webpack:///ws (ignored)","webpack:///src/common.browser/CertChecks.ts","webpack:///./node_modules/process/browser.js","webpack:///tls (ignored)","webpack:///./node_modules/url/url.js","webpack:///./node_modules/node-libs-browser/node_modules/punycode/punycode.js","webpack:///(webpack)/buildin/module.js","webpack:///./node_modules/url/util.js","webpack:///./node_modules/querystring-es3/index.js","webpack:///./node_modules/querystring-es3/decode.js","webpack:///./node_modules/querystring-es3/encode.js","webpack:///../../external/ocsp/ocsp (ignored)","webpack:///agent-base (ignored)","webpack:///async-disk-cache (ignored)","webpack:///https-proxy-agent (ignored)","webpack:///src/common.browser/ReplayableAudioNode.ts","webpack:///src/common.browser/ProxyInfo.ts","webpack:///src/common.browser/RestMessageAdapter.ts","webpack:///xmlhttprequest-ts (ignored)"],"names":[],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;AClFA;AACA;;AAEA,mBAAmB,mBAAO,CAAC,CAAyD;;;;;;;;;;;;;;ACHpF,4DAA4D;AAC5D,kCAAkC;AAClC,uCAAsE;AACtE,uCAA8C;AAE9C,qEAAqE;AACrE,yEAAyE;AACzE,gBAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,gCAAsB,EAAE,CAAC,CAAC;AAE7D,iBAAiB;AACjB,kCAAkC;;;;;;;;;;ACVlC,4DAA4D;AAC5D,kCAAkC;;;;;AAElC,iCAAyC;AAEzC,kCAAiC;AACjC,mCAAkC;AAClC,mCAA8B;AAC9B,mCAAsC;AACtC,mCAA0C;AAC1C,mCAAsC;AACtC,mCAA4B;AAC5B,mCAAqC;AACrC,mCAAiC;;;;;;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Aa;gBACzC,IAAI,EAAE,cAAI,CAAC,MAAM;aACpB,CAAC,CAAC;QACP,CAAC;;;OAAA;IAML,+BAAC;AAAD,CAAC,CApJ6C,oBAAoB,GAoJjE;AApJY,4DAAwB;;;;;;;;;;AC1UrC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEY;;AAEZ,aAAa,mBAAO,CAAC,EAAW;AAChC,cAAc,mBAAO,CAAC,EAAS;AAC/B,cAAc,mBAAO,CAAC,EAAS;;AAE/B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,qBAAqB,mDAAmD;AACxE;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB,UAAU;AAC7B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,YAAY;AAC7B;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA,uCAAuC,SAAS;AAChD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe,iBAAiB;AAChC;AACA;AACA;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,gDAAgD,EAAE;AAClD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA,iBAAiB,SAAS;AAC1B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC;AACzC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA,wBAAwB,eAAe;AACvC;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,wBAAwB,QAAQ;AAChC;AACA,qBAAqB,eAAe;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,YAAY;AAC7B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB,SAAS;AAC9B;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,qBAAqB,SAAS;AAC9B;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,qBAAqB,SAAS;AAC9B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,kBAAkB;AACnC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,mBAAmB,cAAc;AACjC;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uDAAuD,OAAO;AAC9D;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA,uDAAuD,OAAO;AAC9D;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAkB;AAClB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,qBAAqB,QAAQ;AAC7B;AACA;AACA,GAAG;AACH;AACA,eAAe,SAAS;AACxB;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA,mBAAmB,SAAS;AAC5B;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,eAAe,iBAAiB;AAChC;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,iBAAiB,YAAY;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,iBAAiB,gBAAgB;AACjC;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,iBAAiB,YAAY;AAC7B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;;;;;;AC5vDA;;AAEA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;;AAEA;AACA;AACA,4CAA4C;;AAE5C;;;;;;;;ACnBY;;AAEZ;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,kCAAkC,SAAS;AAC3C;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,SAAS;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,qBAAqB,SAAS;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,0CAA0C,UAAU;AACpD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,G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A;AAnVY,wCAAc;;;;;;;;;ACrC3B;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;;;;AAIA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,uBAAuB,sBAAsB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,qCAAqC;;AAErC;AACA;AACA;;AAEA,2BAA2B;AAC3B;AACA;AACA;AACA,4BAA4B,UAAU;;;;;;;ACvLtC,e;;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEa;;AAEb,eAAe,mBAAO,CAAC,GAAU;AACjC,WAAW,mBAAO,CAAC,GAAQ;;AAE3B;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,gBAAgB,KAAK;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC;AACrC;AACA;AACA,2CAA2C,KAAK;AAChD,0CAA0C,KAAK;AAC/C;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,kBAAkB,mBAAO,CAAC,GAAa;;AAEvC;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,oCAAoC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,mBAAmB,4BAA4B;AAC/C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,mBAAmB,yBAAyB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,2CAA2C,OAAO;AAClD;AACA;AACA;AACA;AACA,0CAA0C,OAAO;AACjD;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,0CAA0C,OAAO;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;AACH;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,kBAAkB,mBAAmB;AACrC;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,oBAAoB,mBAAmB;AACvC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,iBAAiB;AACtC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,8BAA8B,QAAQ;AACtC;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA,UAAU,MAAM;AAChB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;AC3tBA;AACA,CAAC;;AAED;AACA,mBAAmB,KAA0B;AAC7C;AACA,kBAAkB,KAAyB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,YAAY,OAAO;AACnB,cAAc,MAAM;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAY,MAAM;AAClB,YAAY,SAAS;AACrB;AACA,cAAc,MAAM;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB,YAAY,SAAS;AACrB;AACA,cAAc,MAAM;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB,cAAc,MAAM;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC;AACrC;AACA,KAAK;AACL,4BAA4B;AAC5B;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,YAAY,MAAM;AAClB,cAAc,OAAO;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB,cAAc,OAAO;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB,cAAc,OAAO;AACrB;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,mCAAmC;AAClE;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB,cAAc,OAAO;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,aAAa,WAAW;AACxB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,wBAAwB;;AAExB,yCAAyC,qBAAqB;;AAE9D;AACA;AACA;AACA;AACA;AACA,kCAAkC,oBAAoB;;AAEtD;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB,cAAc,OAAO;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,aAAa,iBAAiB;AAC9B;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,0BAA0B,iBAAiB;AAC3C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,cAAc,iBAAiB;AAC/B;;AAEA;AACA;AACA;;AAEA;AACA;AACA,8BAA8B,oBAAoB;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB;AACA,cAAc,OAAO;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB;AACA,cAAc,OAAO;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,EAAE,IAEU;AACZ;AACA,EAAE,mCAAmB;AACrB;AACA,GAAG;AAAA,oGAAC;AACJ,EAAE,MAAM,EAaN;;AAEF,CAAC;;;;;;;;ACphBD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;;;;;;;ACrBa;;AAEb;AACA;AACA;AACA,GAAG;AACH;AACA;AACA,GAAG;AACH;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;;;;;;;;ACfa;;AAEb,iCAAiC,mBAAO,CAAC,GAAU;AACnD,qCAAqC,mBAAO,CAAC,GAAU;;;;;;;;ACHvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEa;;AAEb;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,iBAAiB,SAAS;AAC1B;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;;;;;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;A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AC,CAAC,CAAC,GAAG,CAAC;IACzF,CAAC;IAEO,wCAAW,GAAnB,UAAoB,MAAgB;QAAhB,oCAAgB;QAChC,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;aACrB,GAAG,CAAC,UAAC,CAAM,IAAK,yBAAkB,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAA3D,CAA2D,CAAC;aAC5E,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IACL,yBAAC;AAAD,CAAC;AA9GY,gDAAkB;;;;;;;;AC9B/B,e","file":"microsoft.cognitiveservices.speech.sdk.bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nwindow.SpeechSDK = require('./distrib/lib/microsoft.cognitiveservices.speech.sdk.js');\r\n\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\nimport { ConsoleLoggingListener } from \"./src/common.browser/Exports\";\r\nimport { Events } from \"./src/common/Exports\";\r\n\r\n// Common.Storage.SetLocalStorage(new Common.Browser.LocalStorage());\r\n// Common.Storage.SetSessionStorage(new Common.Browser.SessionStorage());\r\nEvents.instance.attachListener(new ConsoleLoggingListener());\r\n\r\n// Speech SDK API\r\nexport * from \"./src/sdk/Exports\";\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nexport * from \"./ConsoleLoggingListener\";\r\nexport * from \"./IRecorder\";\r\nexport * from \"./MicAudioSource\";\r\nexport * from \"./FileAudioSource\";\r\nexport * from \"./PCMRecorder\";\r\nexport * from \"./WebsocketConnection\";\r\nexport * from \"./WebsocketMessageAdapter\";\r\nexport * from \"./ReplayableAudioNode\";\r\nexport * from \"./ProxyInfo\";\r\nexport * from \"./RestMessageAdapter\";\r\nexport * from \"./RestConfigBase\";\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { EventType, IEventListener, PlatformEvent } from \"../common/Exports\";\r\n\r\nexport class ConsoleLoggingListener implements IEventListener {\r\n private privLogLevelFilter: EventType;\r\n\r\n public constructor(logLevelFilter: EventType = EventType.Warning) {\r\n this.privLogLevelFilter = logLevelFilter;\r\n }\r\n\r\n public onEvent = (event: PlatformEvent): void => {\r\n if (event.eventType >= this.privLogLevelFilter) {\r\n const log = this.toString(event);\r\n\r\n switch (event.eventType) {\r\n case EventType.Debug:\r\n // tslint:disable-next-line:no-console\r\n console.debug(log);\r\n break;\r\n case EventType.Info:\r\n // tslint:disable-next-line:no-console\r\n console.info(log);\r\n break;\r\n case EventType.Warning:\r\n // tslint:disable-next-line:no-console\r\n console.warn(log);\r\n break;\r\n case EventType.Error:\r\n // tslint:disable-next-line:no-console\r\n console.error(log);\r\n break;\r\n default:\r\n // tslint:disable-next-line:no-console\r\n console.log(log);\r\n break;\r\n }\r\n }\r\n }\r\n\r\n private toString = (event: any): string => {\r\n const logFragments = [\r\n `${event.EventTime}`,\r\n `${event.Name}`,\r\n ];\r\n\r\n for (const prop in event) {\r\n if (prop && event.hasOwnProperty(prop) &&\r\n prop !== \"eventTime\" && prop !== \"eventType\" &&\r\n prop !== \"eventId\" && prop !== \"name\" &&\r\n prop !== \"constructor\") {\r\n const value = event[prop];\r\n let valueToLog = \"\";\r\n if (value !== undefined && value !== null) {\r\n if (typeof (value) === \"number\" || typeof (value) === \"string\") {\r\n valueToLog = value.toString();\r\n } else {\r\n valueToLog = JSON.stringify(value);\r\n }\r\n }\r\n\r\n logFragments.push(`${prop}: ${valueToLog}`);\r\n }\r\n\r\n }\r\n\r\n return logFragments.join(\" | \");\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nexport * from \"./AudioSourceEvents\";\r\nexport * from \"./ConnectionEvents\";\r\nexport * from \"./ConnectionMessage\";\r\nexport * from \"./ConnectionOpenResponse\";\r\nexport * from \"./Error\";\r\nexport * from \"./Events\";\r\nexport * from \"./EventSource\";\r\nexport * from \"./Guid\";\r\nexport * from \"./IAudioSource\";\r\nexport * from \"./IConnection\";\r\nexport * from \"./IDetachable\";\r\nexport * from \"./IDictionary\";\r\nexport * from \"./IDisposable\";\r\nexport * from \"./IEventSource\";\r\nexport * from \"./IErrorMessages\";\r\nexport * from \"./ITimer\";\r\nexport * from \"./IWebsocketMessageFormatter\";\r\nexport * from \"./List\";\r\nexport * from \"./PlatformEvent\";\r\nexport * from \"./Promise\";\r\nexport * from \"./Queue\";\r\nexport * from \"./RawWebsocketMessage\";\r\nexport * from \"./RiffPcmEncoder\";\r\nexport * from \"./Stream\";\r\nexport { TranslationStatus } from \"../common.speech/TranslationStatus\";\r\nexport * from \"./ChunkedArrayBufferStream\";\r\nexport * from \"./IAudioDestination\";\r\nexport * from \"./Timeout\";\r\nexport * from \"./OCSPEvents\";\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { EventType, PlatformEvent } from \"./PlatformEvent\";\r\n\r\nexport class AudioSourceEvent extends PlatformEvent {\r\n private privAudioSourceId: string;\r\n\r\n constructor(eventName: string, audioSourceId: string, eventType: EventType = EventType.Info) {\r\n super(eventName, eventType);\r\n this.privAudioSourceId = audioSourceId;\r\n }\r\n\r\n public get audioSourceId(): string {\r\n return this.privAudioSourceId;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class AudioSourceInitializingEvent extends AudioSourceEvent {\r\n constructor(audioSourceId: string) {\r\n super(\"AudioSourceInitializingEvent\", audioSourceId);\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class AudioSourceReadyEvent extends AudioSourceEvent {\r\n constructor(audioSourceId: string) {\r\n super(\"AudioSourceReadyEvent\", audioSourceId);\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class AudioSourceOffEvent extends AudioSourceEvent {\r\n constructor(audioSourceId: string) {\r\n super(\"AudioSourceOffEvent\", audioSourceId);\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class AudioSourceErrorEvent extends AudioSourceEvent {\r\n private privError: string;\r\n\r\n constructor(audioSourceId: string, error: string) {\r\n super(\"AudioSourceErrorEvent\", audioSourceId, EventType.Error);\r\n this.privError = error;\r\n }\r\n\r\n public get error(): string {\r\n return this.privError;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class AudioStreamNodeEvent extends AudioSourceEvent {\r\n private privAudioNodeId: string;\r\n\r\n constructor(eventName: string, audioSourceId: string, audioNodeId: string) {\r\n super(eventName, audioSourceId);\r\n this.privAudioNodeId = audioNodeId;\r\n }\r\n\r\n public get audioNodeId(): string {\r\n return this.privAudioNodeId;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class AudioStreamNodeAttachingEvent extends AudioStreamNodeEvent {\r\n constructor(audioSourceId: string, audioNodeId: string) {\r\n super(\"AudioStreamNodeAttachingEvent\", audioSourceId, audioNodeId);\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class AudioStreamNodeAttachedEvent extends AudioStreamNodeEvent {\r\n constructor(audioSourceId: string, audioNodeId: string) {\r\n super(\"AudioStreamNodeAttachedEvent\", audioSourceId, audioNodeId);\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class AudioStreamNodeDetachedEvent extends AudioStreamNodeEvent {\r\n constructor(audioSourceId: string, audioNodeId: string) {\r\n super(\"AudioStreamNodeDetachedEvent\", audioSourceId, audioNodeId);\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class AudioStreamNodeErrorEvent extends AudioStreamNodeEvent {\r\n private privError: string;\r\n\r\n constructor(audioSourceId: string, audioNodeId: string, error: string) {\r\n super(\"AudioStreamNodeErrorEvent\", audioSourceId, audioNodeId);\r\n this.privError = error;\r\n }\r\n\r\n public get error(): string {\r\n return this.privError;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { createNoDashGuid } from \"./Guid\";\r\nimport { IStringDictionary } from \"./IDictionary\";\r\n\r\nexport enum EventType {\r\n Debug,\r\n Info,\r\n Warning,\r\n Error,\r\n}\r\n\r\nexport class PlatformEvent {\r\n private privName: string;\r\n private privEventId: string;\r\n private privEventTime: string;\r\n private privEventType: EventType;\r\n private privMetadata: IStringDictionary;\r\n\r\n constructor(eventName: string, eventType: EventType) {\r\n this.privName = eventName;\r\n this.privEventId = createNoDashGuid();\r\n this.privEventTime = new Date().toISOString();\r\n this.privEventType = eventType;\r\n this.privMetadata = { };\r\n }\r\n\r\n public get name(): string {\r\n return this.privName;\r\n }\r\n\r\n public get eventId(): string {\r\n return this.privEventId;\r\n }\r\n\r\n public get eventTime(): string {\r\n return this.privEventTime;\r\n }\r\n\r\n public get eventType(): EventType {\r\n return this.privEventType;\r\n }\r\n\r\n public get metadata(): IStringDictionary {\r\n return this.privMetadata;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nconst createGuid: () => string = (): string => {\r\n let d = new Date().getTime();\r\n const guid = \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, (c: string) => {\r\n const r = (d + Math.random() * 16) % 16 | 0;\r\n d = Math.floor(d / 16);\r\n return (c === \"x\" ? r : (r & 0x3 | 0x8)).toString(16);\r\n });\r\n\r\n return guid;\r\n};\r\n\r\nconst createNoDashGuid: () => string = (): string => {\r\n return createGuid().replace(new RegExp(\"-\", \"g\"), \"\").toUpperCase();\r\n};\r\n\r\nexport { createGuid, createNoDashGuid };\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ConnectionMessage } from \"./ConnectionMessage\";\r\nimport { IStringDictionary } from \"./IDictionary\";\r\nimport { EventType, PlatformEvent } from \"./PlatformEvent\";\r\n\r\nexport class ServiceEvent extends PlatformEvent {\r\n private privJsonResult: string;\r\n\r\n constructor(eventName: string, jsonstring: string, eventType: EventType = EventType.Info) {\r\n super(eventName, eventType);\r\n this.privJsonResult = jsonstring;\r\n }\r\n\r\n public get jsonString(): string {\r\n return this.privJsonResult;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class ConnectionEvent extends PlatformEvent {\r\n private privConnectionId: string;\r\n\r\n constructor(eventName: string, connectionId: string, eventType: EventType = EventType.Info) {\r\n super(eventName, eventType);\r\n this.privConnectionId = connectionId;\r\n }\r\n\r\n public get connectionId(): string {\r\n return this.privConnectionId;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class ConnectionStartEvent extends ConnectionEvent {\r\n private privUri: string;\r\n private privHeaders: IStringDictionary;\r\n\r\n constructor(connectionId: string, uri: string, headers?: IStringDictionary) {\r\n super(\"ConnectionStartEvent\", connectionId);\r\n this.privUri = uri;\r\n this.privHeaders = headers;\r\n }\r\n\r\n public get uri(): string {\r\n return this.privUri;\r\n }\r\n\r\n public get headers(): IStringDictionary {\r\n return this.privHeaders;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class ConnectionEstablishedEvent extends ConnectionEvent {\r\n constructor(connectionId: string, metadata?: IStringDictionary) {\r\n super(\"ConnectionEstablishedEvent\", connectionId);\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class ConnectionClosedEvent extends ConnectionEvent {\r\n private privRreason: string;\r\n private privStatusCode: number;\r\n\r\n constructor(connectionId: string, statusCode: number, reason: string) {\r\n super(\"ConnectionClosedEvent\", connectionId, EventType.Debug);\r\n this.privRreason = reason;\r\n this.privStatusCode = statusCode;\r\n }\r\n\r\n public get reason(): string {\r\n return this.privRreason;\r\n }\r\n\r\n public get statusCode(): number {\r\n return this.privStatusCode;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class ConnectionErrorEvent extends ConnectionEvent {\r\n private readonly privMessage: string;\r\n private readonly privType: string;\r\n\r\n constructor(connectionId: string, message: string, type: string) {\r\n super(\"ConnectionErrorEvent\", connectionId, EventType.Debug);\r\n this.privMessage = message;\r\n this.privType = type;\r\n }\r\n\r\n public get message(): string {\r\n return this.privMessage;\r\n }\r\n\r\n public get type(): string {\r\n return this.privType;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class ConnectionEstablishErrorEvent extends ConnectionEvent {\r\n private privStatusCode: number;\r\n private privReason: string;\r\n\r\n constructor(connectionId: string, statuscode: number, reason: string) {\r\n super(\"ConnectionEstablishErrorEvent\", connectionId, EventType.Error);\r\n this.privStatusCode = statuscode;\r\n this.privReason = reason;\r\n }\r\n\r\n public get reason(): string {\r\n return this.privReason;\r\n }\r\n\r\n public get statusCode(): number {\r\n return this.privStatusCode;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class ConnectionMessageReceivedEvent extends ConnectionEvent {\r\n private privNetworkReceivedTime: string;\r\n private privMessage: ConnectionMessage;\r\n\r\n constructor(connectionId: string, networkReceivedTimeISO: string, message: ConnectionMessage) {\r\n super(\"ConnectionMessageReceivedEvent\", connectionId);\r\n this.privNetworkReceivedTime = networkReceivedTimeISO;\r\n this.privMessage = message;\r\n }\r\n\r\n public get networkReceivedTime(): string {\r\n return this.privNetworkReceivedTime;\r\n }\r\n\r\n public get message(): ConnectionMessage {\r\n return this.privMessage;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class ConnectionMessageSentEvent extends ConnectionEvent {\r\n private privNetworkSentTime: string;\r\n private privMessage: ConnectionMessage;\r\n\r\n constructor(connectionId: string, networkSentTimeISO: string, message: ConnectionMessage) {\r\n super(\"ConnectionMessageSentEvent\", connectionId);\r\n this.privNetworkSentTime = networkSentTimeISO;\r\n this.privMessage = message;\r\n }\r\n\r\n public get networkSentTime(): string {\r\n return this.privNetworkSentTime;\r\n }\r\n\r\n public get message(): ConnectionMessage {\r\n return this.privMessage;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { InvalidOperationError } from \"./Error\";\r\nimport { createNoDashGuid } from \"./Guid\";\r\nimport { IStringDictionary } from \"./IDictionary\";\r\n\r\nexport enum MessageType {\r\n Text,\r\n Binary,\r\n}\r\n\r\nexport class ConnectionMessage {\r\n\r\n private privMessageType: MessageType;\r\n private privHeaders: IStringDictionary;\r\n private privBody: any = null;\r\n private privSize: number;\r\n\r\n private privId: string;\r\n\r\n public constructor(\r\n messageType: MessageType,\r\n body: any,\r\n headers?: IStringDictionary,\r\n id?: string) {\r\n\r\n if (messageType === MessageType.Text && body && !(typeof (body) === \"string\")) {\r\n throw new InvalidOperationError(\"Payload must be a string\");\r\n }\r\n\r\n if (messageType === MessageType.Binary && body && !(body instanceof ArrayBuffer)) {\r\n throw new InvalidOperationError(\"Payload must be ArrayBuffer\");\r\n }\r\n\r\n this.privMessageType = messageType;\r\n this.privBody = body;\r\n this.privHeaders = headers ? headers : {};\r\n this.privId = id ? id : createNoDashGuid();\r\n switch (this.messageType) {\r\n case MessageType.Binary:\r\n this.privSize = this.binaryBody !== null ? this.binaryBody.byteLength : 0;\r\n break;\r\n case MessageType.Text:\r\n this.privSize = this.textBody.length;\r\n }\r\n }\r\n\r\n public get messageType(): MessageType {\r\n return this.privMessageType;\r\n }\r\n\r\n public get headers(): IStringDictionary {\r\n return this.privHeaders;\r\n }\r\n\r\n public get body(): any {\r\n return this.privBody;\r\n }\r\n\r\n public get textBody(): string {\r\n if (this.privMessageType === MessageType.Binary) {\r\n throw new InvalidOperationError(\"Not supported for binary message\");\r\n }\r\n\r\n return this.privBody as string;\r\n }\r\n\r\n public get binaryBody(): ArrayBuffer {\r\n if (this.privMessageType === MessageType.Text) {\r\n throw new InvalidOperationError(\"Not supported for text message\");\r\n }\r\n\r\n return this.privBody;\r\n }\r\n\r\n public get id(): string {\r\n return this.privId;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * The error that is thrown when an argument passed in is null.\r\n *\r\n * @export\r\n * @class ArgumentNullError\r\n * @extends {Error}\r\n */\r\nexport class ArgumentNullError extends Error {\r\n\r\n /**\r\n * Creates an instance of ArgumentNullError.\r\n *\r\n * @param {string} argumentName - Name of the argument that is null\r\n *\r\n * @memberOf ArgumentNullError\r\n */\r\n public constructor(argumentName: string) {\r\n super(argumentName);\r\n this.name = \"ArgumentNull\";\r\n this.message = argumentName;\r\n }\r\n}\r\n\r\n/**\r\n * The error that is thrown when an invalid operation is performed in the code.\r\n *\r\n * @export\r\n * @class InvalidOperationError\r\n * @extends {Error}\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class InvalidOperationError extends Error {\r\n\r\n /**\r\n * Creates an instance of InvalidOperationError.\r\n *\r\n * @param {string} error - The error\r\n *\r\n * @memberOf InvalidOperationError\r\n */\r\n public constructor(error: string) {\r\n super(error);\r\n this.name = \"InvalidOperation\";\r\n this.message = error;\r\n }\r\n}\r\n\r\n/**\r\n * The error that is thrown when an object is disposed.\r\n *\r\n * @export\r\n * @class ObjectDisposedError\r\n * @extends {Error}\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class ObjectDisposedError extends Error {\r\n\r\n /**\r\n * Creates an instance of ObjectDisposedError.\r\n *\r\n * @param {string} objectName - The object that is disposed\r\n * @param {string} error - The error\r\n *\r\n * @memberOf ObjectDisposedError\r\n */\r\n public constructor(objectName: string, error?: string) {\r\n super(error);\r\n this.name = objectName + \"ObjectDisposed\";\r\n this.message = error;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nexport class ConnectionOpenResponse {\r\n private privStatusCode: number;\r\n private privReason: string;\r\n\r\n constructor(statusCode: number, reason: string) {\r\n this.privStatusCode = statusCode;\r\n this.privReason = reason;\r\n }\r\n\r\n public get statusCode(): number {\r\n return this.privStatusCode;\r\n }\r\n\r\n public get reason(): string {\r\n return this.privReason;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ArgumentNullError } from \"./Error\";\r\nimport { EventSource } from \"./EventSource\";\r\nimport { IEventSource } from \"./IEventSource\";\r\nimport { PlatformEvent } from \"./PlatformEvent\";\r\n\r\nexport class Events {\r\n private static privInstance: IEventSource = new EventSource();\r\n\r\n public static setEventSource = (eventSource: IEventSource): void => {\r\n if (!eventSource) {\r\n throw new ArgumentNullError(\"eventSource\");\r\n }\r\n\r\n Events.privInstance = eventSource;\r\n }\r\n\r\n public static get instance(): IEventSource {\r\n return Events.privInstance;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ObjectDisposedError } from \"./Error\";\r\nimport { createNoDashGuid } from \"./Guid\";\r\nimport { IDetachable } from \"./IDetachable\";\r\nimport { IStringDictionary } from \"./IDictionary\";\r\nimport { IEventListener, IEventSource } from \"./IEventSource\";\r\nimport { PlatformEvent } from \"./PlatformEvent\";\r\n\r\nexport class EventSource implements IEventSource {\r\n private privEventListeners: IStringDictionary<(event: TEvent) => void> = {};\r\n private privMetadata: IStringDictionary;\r\n private privIsDisposed: boolean = false;\r\n\r\n constructor(metadata?: IStringDictionary) {\r\n this.privMetadata = metadata;\r\n }\r\n\r\n public onEvent = (event: TEvent): void => {\r\n if (this.isDisposed()) {\r\n throw (new ObjectDisposedError(\"EventSource\"));\r\n }\r\n\r\n if (this.metadata) {\r\n for (const paramName in this.metadata) {\r\n if (paramName) {\r\n if (event.metadata) {\r\n if (!event.metadata[paramName]) {\r\n event.metadata[paramName] = this.metadata[paramName];\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n for (const eventId in this.privEventListeners) {\r\n if (eventId && this.privEventListeners[eventId]) {\r\n this.privEventListeners[eventId](event);\r\n }\r\n }\r\n }\r\n\r\n public attach = (onEventCallback: (event: TEvent) => void): IDetachable => {\r\n const id = createNoDashGuid();\r\n this.privEventListeners[id] = onEventCallback;\r\n return {\r\n detach: () => {\r\n delete this.privEventListeners[id];\r\n },\r\n };\r\n }\r\n\r\n public attachListener = (listener: IEventListener): IDetachable => {\r\n return this.attach(listener.onEvent);\r\n }\r\n\r\n public isDisposed = (): boolean => {\r\n return this.privIsDisposed;\r\n }\r\n\r\n public dispose = (): void => {\r\n this.privEventListeners = null;\r\n this.privIsDisposed = true;\r\n }\r\n\r\n public get metadata(): IStringDictionary {\r\n return this.privMetadata;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ConnectionEvent } from \"./ConnectionEvents\";\r\nimport { ConnectionMessage } from \"./ConnectionMessage\";\r\nimport { ConnectionOpenResponse } from \"./ConnectionOpenResponse\";\r\nimport { EventSource } from \"./EventSource\";\r\nimport { IDisposable } from \"./IDisposable\";\r\nimport { Promise } from \"./Promise\";\r\n\r\nexport enum ConnectionState {\r\n None,\r\n Connected,\r\n Connecting,\r\n Disconnected,\r\n}\r\n\r\nexport interface IConnection extends IDisposable {\r\n id: string;\r\n state(): ConnectionState;\r\n open(): Promise;\r\n send(message: ConnectionMessage): Promise;\r\n read(): Promise;\r\n events: EventSource;\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ObjectDisposedError } from \"./Error\";\r\nimport { IDetachable } from \"./IDetachable\";\r\nimport { IStringDictionary } from \"./IDictionary\";\r\nimport { IDisposable } from \"./IDisposable\";\r\n\r\nexport interface IList extends IDisposable {\r\n get(itemIndex: number): TItem;\r\n first(): TItem;\r\n last(): TItem;\r\n\r\n add(item: TItem): void;\r\n insertAt(index: number, item: TItem): void;\r\n\r\n removeFirst(): TItem;\r\n removeLast(): TItem;\r\n removeAt(index: number): TItem;\r\n remove(index: number, count: number): TItem[];\r\n clear(): void;\r\n\r\n length(): number;\r\n\r\n onAdded(addedCallback: () => void): IDetachable;\r\n onRemoved(removedCallback: () => void): IDetachable;\r\n onDisposed(disposedCallback: () => void): IDetachable;\r\n\r\n join(seperator?: string): string;\r\n\r\n toArray(): TItem[];\r\n\r\n any(callback?: (item: TItem, index: number) => boolean): boolean;\r\n all(callback: (item: TItem) => boolean): boolean;\r\n forEach(callback: (item: TItem, index: number) => void): void;\r\n select(callback: (item: TItem, index: number) => T2): List;\r\n where(callback: (item: TItem, index: number) => boolean): List;\r\n orderBy(compareFn: (a: TItem, b: TItem) => number): List;\r\n orderByDesc(compareFn: (a: TItem, b: TItem) => number): List;\r\n clone(): List;\r\n concat(list: List): List;\r\n concatArray(array: TItem[]): List;\r\n}\r\n\r\nexport class List implements IList {\r\n private privList: TItem[];\r\n private privSubscriptionIdCounter: number = 0;\r\n private privAddSubscriptions: IStringDictionary<() => void> = {};\r\n private privRemoveSubscriptions: IStringDictionary<() => void> = {};\r\n private privDisposedSubscriptions: IStringDictionary<() => void> = {};\r\n private privDisposeReason: string = null;\r\n\r\n public constructor(list?: TItem[]) {\r\n this.privList = [];\r\n // copy the list rather than taking as is.\r\n if (list) {\r\n for (const item of list) {\r\n this.privList.push(item);\r\n }\r\n }\r\n }\r\n\r\n public get = (itemIndex: number): TItem => {\r\n this.throwIfDisposed();\r\n return this.privList[itemIndex];\r\n }\r\n\r\n public first = (): TItem => {\r\n return this.get(0);\r\n }\r\n\r\n public last = (): TItem => {\r\n return this.get(this.length() - 1);\r\n }\r\n\r\n public add = (item: TItem): void => {\r\n this.throwIfDisposed();\r\n this.insertAt(this.privList.length, item);\r\n }\r\n\r\n public insertAt = (index: number, item: TItem): void => {\r\n this.throwIfDisposed();\r\n if (index === 0) {\r\n this.privList.unshift(item);\r\n } else if (index === this.privList.length) {\r\n this.privList.push(item);\r\n } else {\r\n this.privList.splice(index, 0, item);\r\n }\r\n this.triggerSubscriptions(this.privAddSubscriptions);\r\n }\r\n\r\n public removeFirst = (): TItem => {\r\n this.throwIfDisposed();\r\n return this.removeAt(0);\r\n }\r\n\r\n public removeLast = (): TItem => {\r\n this.throwIfDisposed();\r\n return this.removeAt(this.length() - 1);\r\n }\r\n\r\n public removeAt = (index: number): TItem => {\r\n this.throwIfDisposed();\r\n return this.remove(index, 1)[0];\r\n }\r\n\r\n public remove = (index: number, count: number): TItem[] => {\r\n this.throwIfDisposed();\r\n const removedElements = this.privList.splice(index, count);\r\n this.triggerSubscriptions(this.privRemoveSubscriptions);\r\n return removedElements;\r\n }\r\n\r\n public clear = (): void => {\r\n this.throwIfDisposed();\r\n this.remove(0, this.length());\r\n }\r\n\r\n public length = (): number => {\r\n this.throwIfDisposed();\r\n return this.privList.length;\r\n }\r\n\r\n public onAdded = (addedCallback: () => void): IDetachable => {\r\n this.throwIfDisposed();\r\n const subscriptionId = this.privSubscriptionIdCounter++;\r\n\r\n this.privAddSubscriptions[subscriptionId] = addedCallback;\r\n\r\n return {\r\n detach: () => {\r\n delete this.privAddSubscriptions[subscriptionId];\r\n },\r\n };\r\n }\r\n\r\n public onRemoved = (removedCallback: () => void): IDetachable => {\r\n this.throwIfDisposed();\r\n const subscriptionId = this.privSubscriptionIdCounter++;\r\n\r\n this.privRemoveSubscriptions[subscriptionId] = removedCallback;\r\n\r\n return {\r\n detach: () => {\r\n delete this.privRemoveSubscriptions[subscriptionId];\r\n },\r\n };\r\n }\r\n\r\n public onDisposed = (disposedCallback: () => void): IDetachable => {\r\n this.throwIfDisposed();\r\n const subscriptionId = this.privSubscriptionIdCounter++;\r\n\r\n this.privDisposedSubscriptions[subscriptionId] = disposedCallback;\r\n\r\n return {\r\n detach: () => {\r\n delete this.privDisposedSubscriptions[subscriptionId];\r\n },\r\n };\r\n }\r\n\r\n public join = (seperator?: string): string => {\r\n this.throwIfDisposed();\r\n return this.privList.join(seperator);\r\n }\r\n\r\n public toArray = (): TItem[] => {\r\n const cloneCopy = Array();\r\n this.privList.forEach((val: TItem) => {\r\n cloneCopy.push(val);\r\n });\r\n return cloneCopy;\r\n }\r\n\r\n public any = (callback?: (item: TItem, index: number) => boolean): boolean => {\r\n this.throwIfDisposed();\r\n if (callback) {\r\n return this.where(callback).length() > 0;\r\n } else {\r\n return this.length() > 0;\r\n }\r\n }\r\n\r\n public all = (callback: (item: TItem) => boolean): boolean => {\r\n this.throwIfDisposed();\r\n return this.where(callback).length() === this.length();\r\n }\r\n\r\n public forEach = (callback: (item: TItem, index: number) => void): void => {\r\n this.throwIfDisposed();\r\n for (let i = 0; i < this.length(); i++) {\r\n callback(this.privList[i], i);\r\n }\r\n }\r\n\r\n public select = (callback: (item: TItem, index: number) => T2): List => {\r\n this.throwIfDisposed();\r\n const selectList: T2[] = [];\r\n for (let i = 0; i < this.privList.length; i++) {\r\n selectList.push(callback(this.privList[i], i));\r\n }\r\n\r\n return new List(selectList);\r\n }\r\n\r\n public where = (callback: (item: TItem, index: number) => boolean): List => {\r\n this.throwIfDisposed();\r\n const filteredList = new List();\r\n for (let i = 0; i < this.privList.length; i++) {\r\n if (callback(this.privList[i], i)) {\r\n filteredList.add(this.privList[i]);\r\n }\r\n }\r\n return filteredList;\r\n }\r\n\r\n public orderBy = (compareFn: (a: TItem, b: TItem) => number): List => {\r\n this.throwIfDisposed();\r\n const clonedArray = this.toArray();\r\n const orderedArray = clonedArray.sort(compareFn);\r\n return new List(orderedArray);\r\n }\r\n\r\n public orderByDesc = (compareFn: (a: TItem, b: TItem) => number): List => {\r\n this.throwIfDisposed();\r\n return this.orderBy((a: TItem, b: TItem) => compareFn(b, a));\r\n }\r\n\r\n public clone = (): List => {\r\n this.throwIfDisposed();\r\n return new List(this.toArray());\r\n }\r\n\r\n public concat = (list: List): List => {\r\n this.throwIfDisposed();\r\n return new List(this.privList.concat(list.toArray()));\r\n }\r\n\r\n public concatArray = (array: TItem[]): List => {\r\n this.throwIfDisposed();\r\n return new List(this.privList.concat(array));\r\n }\r\n\r\n public isDisposed = (): boolean => {\r\n return this.privList == null;\r\n }\r\n\r\n public dispose = (reason?: string): void => {\r\n if (!this.isDisposed()) {\r\n this.privDisposeReason = reason;\r\n this.privList = null;\r\n this.privAddSubscriptions = null;\r\n this.privRemoveSubscriptions = null;\r\n this.triggerSubscriptions(this.privDisposedSubscriptions);\r\n }\r\n }\r\n\r\n private throwIfDisposed = (): void => {\r\n if (this.isDisposed()) {\r\n throw new ObjectDisposedError(\"List\", this.privDisposeReason);\r\n }\r\n }\r\n\r\n private triggerSubscriptions = (subscriptions: IStringDictionary<() => void>): void => {\r\n if (subscriptions) {\r\n for (const subscriptionId in subscriptions) {\r\n if (subscriptionId) {\r\n subscriptions[subscriptionId]();\r\n }\r\n }\r\n }\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ArgumentNullError } from \"./Error\";\r\n\r\nexport enum PromiseState {\r\n None,\r\n Resolved,\r\n Rejected,\r\n}\r\n\r\nexport interface IPromise {\r\n result(): PromiseResult;\r\n\r\n continueWith(\r\n continuationCallback: (promiseResult: PromiseResult) => TContinuationResult): IPromise;\r\n\r\n continueWithPromise(\r\n continuationCallback: (promiseResult: PromiseResult) => IPromise): IPromise;\r\n\r\n onSuccessContinueWith(\r\n continuationCallback: (result: T) => TContinuationResult): IPromise;\r\n\r\n onSuccessContinueWithPromise(\r\n continuationCallback: (result: T) => IPromise): IPromise;\r\n\r\n on(successCallback: (result: T) => void, errorCallback: (error: string) => void): IPromise;\r\n\r\n finally(callback: () => void): IPromise;\r\n}\r\n\r\nexport interface IDeferred {\r\n state(): PromiseState;\r\n\r\n promise(): IPromise;\r\n\r\n resolve(result: T): IDeferred;\r\n\r\n reject(error: string): IDeferred;\r\n}\r\n\r\nexport class PromiseResult {\r\n protected privIsCompleted: boolean;\r\n protected privIsError: boolean;\r\n protected privError: string;\r\n protected privResult: T;\r\n\r\n public constructor(promiseResultEventSource: PromiseResultEventSource) {\r\n promiseResultEventSource.on((result: T) => {\r\n if (!this.privIsCompleted) {\r\n this.privIsCompleted = true;\r\n this.privIsError = false;\r\n this.privResult = result;\r\n }\r\n }, (error: string) => {\r\n if (!this.privIsCompleted) {\r\n this.privIsCompleted = true;\r\n this.privIsError = true;\r\n this.privError = error;\r\n }\r\n });\r\n }\r\n\r\n public get isCompleted(): boolean {\r\n return this.privIsCompleted;\r\n }\r\n\r\n public get isError(): boolean {\r\n return this.privIsError;\r\n }\r\n\r\n public get error(): string {\r\n return this.privError;\r\n }\r\n\r\n public get result(): T {\r\n return this.privResult;\r\n }\r\n\r\n public throwIfError = (): void => {\r\n if (this.isError) {\r\n throw this.error;\r\n }\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class PromiseResultEventSource {\r\n\r\n private privOnSetResult: (result: T) => void;\r\n private privOnSetError: (error: string) => void;\r\n\r\n public setResult = (result: T): void => {\r\n this.privOnSetResult(result);\r\n }\r\n\r\n public setError = (error: string): void => {\r\n this.privOnSetError(error);\r\n }\r\n\r\n public on = (onSetResult: (result: T) => void, onSetError: (error: string) => void): void => {\r\n this.privOnSetResult = onSetResult;\r\n this.privOnSetError = onSetError;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class PromiseHelper {\r\n public static whenAll = (promises: Array>): Promise => {\r\n if (!promises || promises.length === 0) {\r\n throw new ArgumentNullError(\"promises\");\r\n }\r\n\r\n const deferred = new Deferred();\r\n const errors: string[] = [];\r\n let completedPromises: number = 0;\r\n\r\n const checkForCompletion = () => {\r\n completedPromises++;\r\n if (completedPromises === promises.length) {\r\n if (errors.length === 0) {\r\n deferred.resolve(true);\r\n } else {\r\n deferred.reject(errors.join(\", \"));\r\n }\r\n }\r\n };\r\n\r\n for (const promise of promises) {\r\n promise.on((r: any) => {\r\n checkForCompletion();\r\n }, (e: string) => {\r\n errors.push(e);\r\n checkForCompletion();\r\n });\r\n }\r\n\r\n return deferred.promise();\r\n }\r\n\r\n public static fromResult = (result: TResult): Promise => {\r\n const deferred = new Deferred();\r\n deferred.resolve(result);\r\n return deferred.promise();\r\n }\r\n\r\n public static fromError = (error: string): Promise => {\r\n const deferred = new Deferred();\r\n deferred.reject(error);\r\n return deferred.promise();\r\n }\r\n}\r\n\r\n// TODO: replace with ES6 promises\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class Promise implements IPromise {\r\n private privSink: Sink;\r\n\r\n public constructor(sink: Sink) {\r\n this.privSink = sink;\r\n }\r\n\r\n public result = (): PromiseResult => {\r\n return this.privSink.result;\r\n }\r\n\r\n public continueWith = (\r\n continuationCallback: (promiseResult: PromiseResult) => TContinuationResult): Promise => {\r\n\r\n if (!continuationCallback) {\r\n throw new ArgumentNullError(\"continuationCallback\");\r\n }\r\n\r\n const continuationDeferral = new Deferred();\r\n\r\n this.privSink.on(\r\n (r: T) => {\r\n try {\r\n const continuationResult: TContinuationResult = continuationCallback(this.privSink.result);\r\n continuationDeferral.resolve(continuationResult);\r\n } catch (e) {\r\n continuationDeferral.reject(e);\r\n }\r\n },\r\n (error: string) => {\r\n try {\r\n const continuationResult: TContinuationResult = continuationCallback(this.privSink.result);\r\n continuationDeferral.resolve(continuationResult);\r\n } catch (e) {\r\n continuationDeferral.reject(`'Error handler for error ${error} threw error ${e}'`);\r\n }\r\n },\r\n );\r\n\r\n return continuationDeferral.promise();\r\n }\r\n\r\n public onSuccessContinueWith = (\r\n continuationCallback: (result: T) => TContinuationResult): Promise => {\r\n\r\n if (!continuationCallback) {\r\n throw new ArgumentNullError(\"continuationCallback\");\r\n }\r\n\r\n const continuationDeferral = new Deferred();\r\n\r\n this.privSink.on(\r\n (r: T) => {\r\n try {\r\n const continuationResult: TContinuationResult = continuationCallback(r);\r\n continuationDeferral.resolve(continuationResult);\r\n } catch (e) {\r\n continuationDeferral.reject(e);\r\n }\r\n },\r\n (error: string) => {\r\n continuationDeferral.reject(error);\r\n },\r\n );\r\n\r\n return continuationDeferral.promise();\r\n }\r\n\r\n public continueWithPromise = (\r\n continuationCallback: (promiseResult: PromiseResult) => Promise): Promise => {\r\n\r\n if (!continuationCallback) {\r\n throw new ArgumentNullError(\"continuationCallback\");\r\n }\r\n\r\n const continuationDeferral = new Deferred();\r\n\r\n this.privSink.on(\r\n (r: T) => {\r\n try {\r\n const continuationPromise: Promise = continuationCallback(this.privSink.result);\r\n if (!continuationPromise) {\r\n throw new Error(\"'Continuation callback did not return promise'\");\r\n }\r\n continuationPromise.on((continuationResult: TContinuationResult) => {\r\n continuationDeferral.resolve(continuationResult);\r\n }, (e: string) => {\r\n continuationDeferral.reject(e);\r\n });\r\n } catch (e) {\r\n continuationDeferral.reject(e);\r\n }\r\n },\r\n (error: string) => {\r\n try {\r\n const continuationPromise: Promise = continuationCallback(this.privSink.result);\r\n if (!continuationPromise) {\r\n throw new Error(\"Continuation callback did not return promise\");\r\n }\r\n continuationPromise.on((continuationResult: TContinuationResult) => {\r\n continuationDeferral.resolve(continuationResult);\r\n }, (e: string) => {\r\n continuationDeferral.reject(e);\r\n });\r\n } catch (e) {\r\n continuationDeferral.reject(`'Error handler for error ${error} threw error ${e}'`);\r\n }\r\n },\r\n );\r\n\r\n return continuationDeferral.promise();\r\n }\r\n\r\n public onSuccessContinueWithPromise = (\r\n continuationCallback: (result: T) => Promise): Promise => {\r\n\r\n if (!continuationCallback) {\r\n throw new ArgumentNullError(\"continuationCallback\");\r\n }\r\n\r\n const continuationDeferral = new Deferred();\r\n\r\n this.privSink.on(\r\n (r: T) => {\r\n try {\r\n const continuationPromise: Promise = continuationCallback(r);\r\n if (!continuationPromise) {\r\n throw new Error(\"Continuation callback did not return promise\");\r\n }\r\n continuationPromise.on((continuationResult: TContinuationResult) => {\r\n continuationDeferral.resolve(continuationResult);\r\n }, (e: string) => {\r\n continuationDeferral.reject(e);\r\n });\r\n } catch (e) {\r\n continuationDeferral.reject(e);\r\n }\r\n },\r\n (error: string) => {\r\n continuationDeferral.reject(error);\r\n },\r\n );\r\n\r\n return continuationDeferral.promise();\r\n }\r\n\r\n public on = (\r\n successCallback: (result: T) => void,\r\n errorCallback: (error: string) => void): Promise => {\r\n if (!successCallback) {\r\n throw new ArgumentNullError(\"successCallback\");\r\n }\r\n\r\n if (!errorCallback) {\r\n throw new ArgumentNullError(\"errorCallback\");\r\n }\r\n\r\n this.privSink.on(successCallback, errorCallback);\r\n return this;\r\n }\r\n\r\n public finally = (callback: () => void): Promise => {\r\n if (!callback) {\r\n throw new ArgumentNullError(\"callback\");\r\n }\r\n\r\n const callbackWrapper = (_: any) => {\r\n callback();\r\n };\r\n\r\n return this.on(callbackWrapper, callbackWrapper);\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class Deferred implements IDeferred {\r\n private privPromise: Promise;\r\n private privSink: Sink;\r\n\r\n public constructor() {\r\n this.privSink = new Sink();\r\n this.privPromise = new Promise(this.privSink);\r\n }\r\n\r\n public state = (): PromiseState => {\r\n return this.privSink.state;\r\n }\r\n\r\n public promise = (): Promise => {\r\n return this.privPromise;\r\n }\r\n\r\n public resolve = (result: T): Deferred => {\r\n this.privSink.resolve(result);\r\n return this;\r\n }\r\n\r\n public reject = (error: string): Deferred => {\r\n this.privSink.reject(error);\r\n return this;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class Sink {\r\n private privState: PromiseState = PromiseState.None;\r\n private privPromiseResult: PromiseResult = null;\r\n private privPromiseResultEvents: PromiseResultEventSource = null;\r\n\r\n private privSuccessHandlers: Array<((result: T) => void)> = [];\r\n private privErrorHandlers: Array<(e: string) => void> = [];\r\n\r\n public constructor() {\r\n this.privPromiseResultEvents = new PromiseResultEventSource();\r\n this.privPromiseResult = new PromiseResult(this.privPromiseResultEvents);\r\n }\r\n\r\n public get state(): PromiseState {\r\n return this.privState;\r\n }\r\n\r\n public get result(): PromiseResult {\r\n return this.privPromiseResult;\r\n }\r\n\r\n public resolve = (result: T): void => {\r\n if (this.privState !== PromiseState.None) {\r\n throw new Error(\"'Cannot resolve a completed promise'\");\r\n }\r\n\r\n this.privState = PromiseState.Resolved;\r\n this.privPromiseResultEvents.setResult(result);\r\n\r\n for (let i = 0; i < this.privSuccessHandlers.length; i++) {\r\n this.executeSuccessCallback(result, this.privSuccessHandlers[i], this.privErrorHandlers[i]);\r\n }\r\n\r\n this.detachHandlers();\r\n }\r\n\r\n public reject = (error: string): void => {\r\n if (this.privState !== PromiseState.None) {\r\n throw new Error(\"'Cannot reject a completed promise'\");\r\n }\r\n\r\n this.privState = PromiseState.Rejected;\r\n this.privPromiseResultEvents.setError(error);\r\n\r\n for (const errorHandler of this.privErrorHandlers) {\r\n this.executeErrorCallback(error, errorHandler);\r\n }\r\n\r\n this.detachHandlers();\r\n }\r\n\r\n public on = (\r\n successCallback: (result: T) => void,\r\n errorCallback: (error: string) => void): void => {\r\n\r\n if (successCallback == null) {\r\n successCallback = (r: T) => { return; };\r\n }\r\n\r\n if (this.privState === PromiseState.None) {\r\n this.privSuccessHandlers.push(successCallback);\r\n this.privErrorHandlers.push(errorCallback);\r\n } else {\r\n if (this.privState === PromiseState.Resolved) {\r\n this.executeSuccessCallback(this.privPromiseResult.result, successCallback, errorCallback);\r\n } else if (this.privState === PromiseState.Rejected) {\r\n this.executeErrorCallback(this.privPromiseResult.error, errorCallback);\r\n }\r\n\r\n this.detachHandlers();\r\n }\r\n }\r\n\r\n private executeSuccessCallback = (result: T, successCallback: (result: T) => void, errorCallback: (error: string) => void): void => {\r\n try {\r\n successCallback(result);\r\n } catch (e) {\r\n this.executeErrorCallback(`'Unhandled callback error: ${e}'`, errorCallback);\r\n }\r\n }\r\n\r\n private executeErrorCallback = (error: string, errorCallback: (error: string) => void): void => {\r\n if (errorCallback) {\r\n try {\r\n errorCallback(error);\r\n } catch (e) {\r\n throw new Error(`'Unhandled callback error: ${e}. InnerError: ${error}'`);\r\n }\r\n } else {\r\n throw new Error(`'Unhandled error: ${error}'`);\r\n }\r\n }\r\n\r\n private detachHandlers = (): void => {\r\n this.privErrorHandlers = [];\r\n this.privSuccessHandlers = [];\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { InvalidOperationError, ObjectDisposedError } from \"./Error\";\r\nimport { IDetachable } from \"./IDetachable\";\r\nimport { IDisposable } from \"./IDisposable\";\r\nimport { List } from \"./List\";\r\nimport { Deferred, Promise, PromiseHelper } from \"./Promise\";\r\n\r\nexport interface IQueue extends IDisposable {\r\n enqueue(item: TItem): void;\r\n enqueueFromPromise(promise: Promise): void;\r\n dequeue(): Promise;\r\n peek(): Promise;\r\n length(): number;\r\n}\r\n\r\nenum SubscriberType {\r\n Dequeue,\r\n Peek,\r\n}\r\n\r\nexport class Queue implements IQueue {\r\n private privPromiseStore: List> = new List>();\r\n private privList: List;\r\n private privDetachables: IDetachable[];\r\n private privSubscribers: List<{ type: SubscriberType, deferral: Deferred }>;\r\n private privIsDrainInProgress: boolean = false;\r\n private privIsDisposing: boolean = false;\r\n private privDisposeReason: string = null;\r\n\r\n public constructor(list?: List) {\r\n this.privList = list ? list : new List();\r\n this.privDetachables = [];\r\n this.privSubscribers = new List<{ type: SubscriberType, deferral: Deferred }>();\r\n this.privDetachables.push(this.privList.onAdded(this.drain));\r\n }\r\n\r\n public enqueue = (item: TItem): void => {\r\n this.throwIfDispose();\r\n this.enqueueFromPromise(PromiseHelper.fromResult(item));\r\n }\r\n\r\n public enqueueFromPromise = (promise: Promise): void => {\r\n this.throwIfDispose();\r\n this.privPromiseStore.add(promise);\r\n promise.finally(() => {\r\n while (this.privPromiseStore.length() > 0) {\r\n if (!this.privPromiseStore.first().result().isCompleted) {\r\n break;\r\n } else {\r\n const p = this.privPromiseStore.removeFirst();\r\n if (!p.result().isError) {\r\n this.privList.add(p.result().result);\r\n } else {\r\n // TODO: Log as warning.\r\n }\r\n }\r\n }\r\n });\r\n }\r\n\r\n public dequeue = (): Promise => {\r\n this.throwIfDispose();\r\n const deferredSubscriber = new Deferred();\r\n\r\n if (this.privSubscribers) {\r\n this.privSubscribers.add({ deferral: deferredSubscriber, type: SubscriberType.Dequeue });\r\n this.drain();\r\n }\r\n\r\n return deferredSubscriber.promise();\r\n }\r\n\r\n public peek = (): Promise => {\r\n this.throwIfDispose();\r\n const deferredSubscriber = new Deferred();\r\n\r\n const subs = this.privSubscribers;\r\n if (subs) {\r\n this.privSubscribers.add({ deferral: deferredSubscriber, type: SubscriberType.Peek });\r\n this.drain();\r\n }\r\n\r\n return deferredSubscriber.promise();\r\n }\r\n\r\n public length = (): number => {\r\n this.throwIfDispose();\r\n return this.privList.length();\r\n }\r\n\r\n public isDisposed = (): boolean => {\r\n return this.privSubscribers == null;\r\n }\r\n\r\n public drainAndDispose = (pendingItemProcessor: (pendingItemInQueue: TItem) => void, reason?: string): Promise => {\r\n if (!this.isDisposed() && !this.privIsDisposing) {\r\n this.privDisposeReason = reason;\r\n this.privIsDisposing = true;\r\n\r\n const subs = this.privSubscribers;\r\n if (subs) {\r\n while (subs.length() > 0) {\r\n const subscriber = subs.removeFirst();\r\n // TODO: this needs work (Resolve(null) instead?).\r\n subscriber.deferral.resolve(undefined);\r\n // subscriber.deferral.reject(\"Disposed\");\r\n }\r\n\r\n // note: this block assumes cooperative multitasking, i.e.,\r\n // between the if-statement and the assignment there are no\r\n // thread switches.\r\n // Reason is that between the initial const = this.; and this\r\n // point there is the derral.resolve() operation that might have\r\n // caused recursive calls to the Queue, especially, calling\r\n // Dispose() on the queue alredy (which would reset the var\r\n // here to null!).\r\n // That should generally hold true for javascript...\r\n if (this.privSubscribers === subs) {\r\n this.privSubscribers = subs;\r\n }\r\n }\r\n\r\n for (const detachable of this.privDetachables) {\r\n detachable.detach();\r\n }\r\n\r\n if (this.privPromiseStore.length() > 0 && pendingItemProcessor) {\r\n return PromiseHelper\r\n .whenAll(this.privPromiseStore.toArray())\r\n .continueWith(() => {\r\n this.privSubscribers = null;\r\n this.privList.forEach((item: TItem, index: number): void => {\r\n pendingItemProcessor(item);\r\n });\r\n this.privList = null;\r\n return true;\r\n });\r\n } else {\r\n this.privSubscribers = null;\r\n this.privList = null;\r\n }\r\n }\r\n\r\n return PromiseHelper.fromResult(true);\r\n }\r\n\r\n public dispose = (reason?: string): void => {\r\n this.drainAndDispose(null, reason);\r\n }\r\n\r\n private drain = (): void => {\r\n if (!this.privIsDrainInProgress && !this.privIsDisposing) {\r\n this.privIsDrainInProgress = true;\r\n\r\n const subs = this.privSubscribers;\r\n const lists = this.privList;\r\n if (subs && lists) {\r\n while (lists.length() > 0 && subs.length() > 0 && !this.privIsDisposing) {\r\n const subscriber = subs.removeFirst();\r\n if (subscriber.type === SubscriberType.Peek) {\r\n subscriber.deferral.resolve(lists.first());\r\n } else {\r\n const dequeuedItem = lists.removeFirst();\r\n subscriber.deferral.resolve(dequeuedItem);\r\n }\r\n }\r\n\r\n // note: this block assumes cooperative multitasking, i.e.,\r\n // between the if-statement and the assignment there are no\r\n // thread switches.\r\n // Reason is that between the initial const = this.; and this\r\n // point there is the derral.resolve() operation that might have\r\n // caused recursive calls to the Queue, especially, calling\r\n // Dispose() on the queue alredy (which would reset the var\r\n // here to null!).\r\n // That should generally hold true for javascript...\r\n if (this.privSubscribers === subs) {\r\n this.privSubscribers = subs;\r\n }\r\n\r\n // note: this block assumes cooperative multitasking, i.e.,\r\n // between the if-statement and the assignment there are no\r\n // thread switches.\r\n // Reason is that between the initial const = this.; and this\r\n // point there is the derral.resolve() operation that might have\r\n // caused recursive calls to the Queue, especially, calling\r\n // Dispose() on the queue alredy (which would reset the var\r\n // here to null!).\r\n // That should generally hold true for javascript...\r\n if (this.privList === lists) {\r\n this.privList = lists;\r\n }\r\n }\r\n\r\n this.privIsDrainInProgress = false;\r\n }\r\n }\r\n\r\n private throwIfDispose = (): void => {\r\n if (this.isDisposed()) {\r\n if (this.privDisposeReason) {\r\n throw new InvalidOperationError(this.privDisposeReason);\r\n }\r\n\r\n throw new ObjectDisposedError(\"Queue\");\r\n } else if (this.privIsDisposing) {\r\n throw new InvalidOperationError(\"Queue disposing\");\r\n }\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { MessageType } from \"./ConnectionMessage\";\r\nimport { ArgumentNullError, InvalidOperationError } from \"./Error\";\r\nimport { createNoDashGuid } from \"./Guid\";\r\n\r\nexport class RawWebsocketMessage {\r\n private privMessageType: MessageType;\r\n private privPayload: any = null;\r\n private privId: string;\r\n\r\n public constructor(messageType: MessageType, payload: any, id?: string) {\r\n if (!payload) {\r\n throw new ArgumentNullError(\"payload\");\r\n }\r\n\r\n if (messageType === MessageType.Binary && !(payload instanceof ArrayBuffer)) {\r\n throw new InvalidOperationError(\"Payload must be ArrayBuffer\");\r\n }\r\n\r\n if (messageType === MessageType.Text && !(typeof (payload) === \"string\")) {\r\n throw new InvalidOperationError(\"Payload must be a string\");\r\n }\r\n\r\n this.privMessageType = messageType;\r\n this.privPayload = payload;\r\n this.privId = id ? id : createNoDashGuid();\r\n }\r\n\r\n public get messageType(): MessageType {\r\n return this.privMessageType;\r\n }\r\n\r\n public get payload(): any {\r\n return this.privPayload;\r\n }\r\n\r\n public get textContent(): string {\r\n if (this.privMessageType === MessageType.Binary) {\r\n throw new InvalidOperationError(\"Not supported for binary message\");\r\n }\r\n\r\n return this.privPayload as string;\r\n }\r\n\r\n public get binaryContent(): ArrayBuffer {\r\n if (this.privMessageType === MessageType.Text) {\r\n throw new InvalidOperationError(\"Not supported for text message\");\r\n }\r\n\r\n return this.privPayload;\r\n }\r\n\r\n public get id(): string {\r\n return this.privId;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nexport class RiffPcmEncoder {\r\n\r\n private privActualSampleRate: number;\r\n private privDesiredSampleRate: number;\r\n\r\n public constructor(actualSampleRate: number, desiredSampleRate: number) {\r\n this.privActualSampleRate = actualSampleRate;\r\n this.privDesiredSampleRate = desiredSampleRate;\r\n }\r\n\r\n public encode = (\r\n actualAudioFrame: Float32Array): ArrayBuffer => {\r\n\r\n const audioFrame = this.downSampleAudioFrame(actualAudioFrame, this.privActualSampleRate, this.privDesiredSampleRate);\r\n\r\n if (!audioFrame) {\r\n return null;\r\n }\r\n\r\n const audioLength = audioFrame.length * 2;\r\n\r\n const buffer = new ArrayBuffer(audioLength);\r\n const view = new DataView(buffer);\r\n this.floatTo16BitPCM(view, 0, audioFrame);\r\n\r\n return buffer;\r\n }\r\n\r\n private setString = (view: DataView, offset: number, str: string): void => {\r\n for (let i = 0; i < str.length; i++) {\r\n view.setUint8(offset + i, str.charCodeAt(i));\r\n }\r\n }\r\n\r\n private floatTo16BitPCM = (view: DataView, offset: number, input: Float32Array): void => {\r\n for (let i = 0; i < input.length; i++ , offset += 2) {\r\n const s = Math.max(-1, Math.min(1, input[i]));\r\n view.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7FFF, true);\r\n }\r\n }\r\n\r\n private downSampleAudioFrame = (\r\n srcFrame: Float32Array,\r\n srcRate: number,\r\n dstRate: number): Float32Array => {\r\n\r\n if (dstRate === srcRate || dstRate > srcRate) {\r\n return srcFrame;\r\n }\r\n\r\n const ratio = srcRate / dstRate;\r\n const dstLength = Math.round(srcFrame.length / ratio);\r\n const dstFrame = new Float32Array(dstLength);\r\n let srcOffset = 0;\r\n let dstOffset = 0;\r\n while (dstOffset < dstLength) {\r\n const nextSrcOffset = Math.round((dstOffset + 1) * ratio);\r\n let accum = 0;\r\n let count = 0;\r\n while (srcOffset < nextSrcOffset && srcOffset < srcFrame.length) {\r\n accum += srcFrame[srcOffset++];\r\n count++;\r\n }\r\n dstFrame[dstOffset++] = accum / count;\r\n }\r\n\r\n return dstFrame;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { InvalidOperationError } from \"./Error\";\r\nimport { createNoDashGuid } from \"./Guid\";\r\nimport { Promise } from \"./Promise\";\r\nimport { Queue } from \"./Queue\";\r\n\r\nexport interface IStreamChunk {\r\n isEnd: boolean;\r\n buffer: TBuffer;\r\n timeReceived: number;\r\n}\r\n\r\nexport class Stream {\r\n private privId: string;\r\n private privIsWriteEnded: boolean = false;\r\n private privIsReadEnded: boolean = false;\r\n private privReaderQueue: Queue>;\r\n\r\n public constructor(streamId?: string) {\r\n this.privId = streamId ? streamId : createNoDashGuid();\r\n this.privReaderQueue = new Queue>();\r\n }\r\n\r\n public get isClosed(): boolean {\r\n return this.privIsWriteEnded;\r\n }\r\n\r\n public get isReadEnded(): boolean {\r\n return this.privIsReadEnded;\r\n }\r\n\r\n public get id(): string {\r\n return this.privId;\r\n }\r\n\r\n public close(): void {\r\n if (!this.privIsWriteEnded) {\r\n this.writeStreamChunk({\r\n buffer: null,\r\n isEnd: true,\r\n timeReceived: Date.now(),\r\n });\r\n this.privIsWriteEnded = true;\r\n }\r\n }\r\n\r\n public writeStreamChunk(streamChunk: IStreamChunk): void {\r\n this.throwIfClosed();\r\n if (!this.privReaderQueue.isDisposed()) {\r\n try {\r\n this.privReaderQueue.enqueue(streamChunk);\r\n } catch (e) {\r\n // Do nothing\r\n }\r\n }\r\n }\r\n\r\n public read = (): Promise> => {\r\n if (this.privIsReadEnded) {\r\n throw new InvalidOperationError(\"Stream read has already finished\");\r\n }\r\n\r\n return this.privReaderQueue\r\n .dequeue()\r\n .onSuccessContinueWith((streamChunk: IStreamChunk) => {\r\n if (streamChunk === undefined || streamChunk.isEnd) {\r\n this.privReaderQueue.dispose(\"End of stream reached\");\r\n }\r\n\r\n return streamChunk;\r\n });\r\n }\r\n\r\n public readEnded = (): void => {\r\n if (!this.privIsReadEnded) {\r\n this.privIsReadEnded = true;\r\n this.privReaderQueue = new Queue>();\r\n }\r\n }\r\n\r\n private throwIfClosed = (): void => {\r\n if (this.privIsWriteEnded) {\r\n throw new InvalidOperationError(\"Stream closed\");\r\n }\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * Defines translation status.\r\n * @class TranslationStatus\r\n */\r\nexport enum TranslationStatus {\r\n /**\r\n * @member TranslationStatus.Success\r\n */\r\n Success = 0,\r\n\r\n /**\r\n * @member TranslationStatus.Error\r\n */\r\n Error,\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { IStreamChunk, Stream } from \"./Exports\";\r\n\r\nexport class ChunkedArrayBufferStream extends Stream {\r\n private privTargetChunkSize: number;\r\n private privNextBufferToWrite: ArrayBuffer;\r\n private privNextBufferStartTime: number;\r\n private privNextBufferReadyBytes: number;\r\n\r\n constructor(targetChunkSize: number, streamId?: string) {\r\n super(streamId);\r\n this.privTargetChunkSize = targetChunkSize;\r\n this.privNextBufferReadyBytes = 0;\r\n }\r\n\r\n public writeStreamChunk(chunk: IStreamChunk): void {\r\n // No pending write, and the buffer is the right size so write it.\r\n if (chunk.isEnd ||\r\n (0 === this.privNextBufferReadyBytes && chunk.buffer.byteLength === this.privTargetChunkSize)) {\r\n super.writeStreamChunk(chunk);\r\n return;\r\n }\r\n\r\n let bytesCopiedFromBuffer: number = 0;\r\n\r\n while (bytesCopiedFromBuffer < chunk.buffer.byteLength) {\r\n // Fill the next buffer.\r\n if (undefined === this.privNextBufferToWrite) {\r\n this.privNextBufferToWrite = new ArrayBuffer(this.privTargetChunkSize);\r\n this.privNextBufferStartTime = chunk.timeReceived;\r\n }\r\n\r\n // Find out how many bytes we can copy into the read buffer.\r\n const bytesToCopy: number = Math.min(chunk.buffer.byteLength - bytesCopiedFromBuffer, this.privTargetChunkSize - this.privNextBufferReadyBytes);\r\n const targetView: Uint8Array = new Uint8Array(this.privNextBufferToWrite);\r\n const sourceView: Uint8Array = new Uint8Array(chunk.buffer.slice(bytesCopiedFromBuffer, bytesToCopy + bytesCopiedFromBuffer));\r\n\r\n targetView.set(sourceView, this.privNextBufferReadyBytes);\r\n this.privNextBufferReadyBytes += bytesToCopy;\r\n bytesCopiedFromBuffer += bytesToCopy;\r\n\r\n // Are we ready to write?\r\n if (this.privNextBufferReadyBytes === this.privTargetChunkSize) {\r\n super.writeStreamChunk({\r\n buffer: this.privNextBufferToWrite,\r\n isEnd: false,\r\n timeReceived: this.privNextBufferStartTime,\r\n });\r\n this.privNextBufferReadyBytes = 0;\r\n this.privNextBufferToWrite = undefined;\r\n }\r\n }\r\n }\r\n\r\n public close(): void {\r\n // Send whatever is pending, then close the base class.\r\n if (0 !== this.privNextBufferReadyBytes && !this.isClosed) {\r\n super.writeStreamChunk({\r\n buffer: this.privNextBufferToWrite.slice(0, this.privNextBufferReadyBytes),\r\n isEnd: false,\r\n timeReceived: this.privNextBufferStartTime,\r\n });\r\n }\r\n\r\n super.close();\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\ntype TWorkerMessage = ICallNotification | IClearResponse | IErrorNotification | IErrorResponse;\r\n\r\ninterface IClearResponse {\r\n error: null;\r\n id: number;\r\n}\r\n\r\ninterface IErrorNotification {\r\n error: {\r\n message: string;\r\n };\r\n id: null;\r\n result: null;\r\n}\r\n\r\ninterface IErrorResponse {\r\n error: {\r\n message: string;\r\n };\r\n id: number;\r\n result: null;\r\n}\r\n\r\ninterface ICallNotification {\r\n id: null;\r\n method: \"call\";\r\n params: {\r\n timerId: number;\r\n };\r\n}\r\n\r\ninterface ISetNotification {\r\n id: null;\r\n method: \"set\";\r\n params: {\r\n delay: number;\r\n now: number;\r\n timerId: number;\r\n };\r\n}\r\n\r\ninterface IClearRequest {\r\n id: number;\r\n method: \"clear\";\r\n params: {\r\n timerId: number;\r\n };\r\n}\r\n\r\ninterface IWorkerEvent extends Event {\r\n data: TWorkerMessage;\r\n}\r\n\r\ninterface IWorkerTimers {\r\n clearTimeout: (timerId: number) => void;\r\n setTimeout: (func: () => any, delay: number) => number;\r\n}\r\n\r\ndeclare type Func = () => any;\r\n\r\nexport class Timeout {\r\n\r\n private static workerTimers: null | IWorkerTimers = null;\r\n\r\n public static clearTimeout: IWorkerTimers[\"clearTimeout\"] = (timerId) => Timeout.timers().clearTimeout(timerId);\r\n\r\n public static setTimeout: IWorkerTimers[\"setTimeout\"] = (func, delay) => Timeout.timers().setTimeout(func, delay);\r\n\r\n public static load = (url: string) => {\r\n // Prefilling the Maps with a function indexed by zero is necessary to be compliant with the specification.\r\n const scheduledTimeoutFunctions: Map = new Map([[0, () => { }]]); // tslint:disable-line no-empty\r\n const unhandledRequests: Map = new Map();\r\n\r\n const worker = new Worker(url);\r\n\r\n worker.addEventListener(\"message\", ({ data }: IWorkerEvent) => {\r\n if (Timeout.isCallNotification(data)) {\r\n const {\r\n params: { timerId }\r\n } = data;\r\n\r\n const idOrFunc = scheduledTimeoutFunctions.get(timerId);\r\n\r\n if (typeof idOrFunc === \"number\") {\r\n const unhandledTimerId = unhandledRequests.get(idOrFunc);\r\n\r\n if (\r\n unhandledTimerId === undefined ||\r\n unhandledTimerId !== timerId\r\n ) {\r\n throw new Error(\"The timer is in an undefined state.\");\r\n }\r\n } else if (typeof idOrFunc !== \"undefined\") {\r\n idOrFunc();\r\n\r\n // A timeout can be safely deleted because it is only called once.\r\n scheduledTimeoutFunctions.delete(timerId);\r\n } else {\r\n throw new Error(\"The timer is in an undefined state.\");\r\n }\r\n } else if (Timeout.isClearResponse(data)) {\r\n const { id } = data;\r\n\r\n const unhandledTimerId = unhandledRequests.get(id);\r\n\r\n if (unhandledTimerId === undefined) {\r\n throw new Error(\"The timer is in an undefined state.\");\r\n }\r\n\r\n unhandledRequests.delete(id);\r\n\r\n scheduledTimeoutFunctions.delete(unhandledTimerId);\r\n } else {\r\n const {\r\n error: { message }\r\n } = data;\r\n\r\n throw new Error(message);\r\n }\r\n });\r\n\r\n const clearTimeout = (timerId: number) => {\r\n const id = Math.random();\r\n\r\n unhandledRequests.set(id, timerId);\r\n scheduledTimeoutFunctions.set(timerId, id);\r\n\r\n worker.postMessage({\r\n id,\r\n method: \"clear\",\r\n params: { timerId }\r\n } as IClearRequest);\r\n };\r\n\r\n const setTimeout = (func: () => void, delay: number) => {\r\n const timerId = Math.random();\r\n\r\n scheduledTimeoutFunctions.set(timerId, func);\r\n\r\n worker.postMessage({\r\n id: null,\r\n method: \"set\",\r\n params: {\r\n delay,\r\n now: performance.now(),\r\n timerId\r\n }\r\n } as ISetNotification);\r\n\r\n return timerId;\r\n };\r\n\r\n return {\r\n clearTimeout,\r\n setTimeout\r\n };\r\n }\r\n\r\n private static loadWorkerTimers = () => {\r\n const worker = `!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&\"object\"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,\"default\",{enumerable:!0,value:e}),2&t&&\"string\"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,\"a\",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=\"\",n(n.s=14)}([function(e,t,n){\"use strict\";n.d(t,\"a\",(function(){return i})),n.d(t,\"b\",(function(){return u})),n.d(t,\"c\",(function(){return a})),n.d(t,\"d\",(function(){return d}));const r=new Map,o=new Map,i=e=>{const t=r.get(e);if(void 0===t)throw new Error('There is no interval scheduled with the given id \"'.concat(e,'\".'));clearTimeout(t),r.delete(e)},u=e=>{const t=o.get(e);if(void 0===t)throw new Error('There is no timeout scheduled with the given id \"'.concat(e,'\".'));clearTimeout(t),o.delete(e)},f=(e,t)=>{let n,r;if(\"performance\"in self){const o=performance.now();n=o,r=e-Math.max(0,o-t)}else n=Date.now(),r=e;return{expected:n+r,remainingDelay:r}},c=(e,t,n,r)=>{const o=\"performance\"in self?performance.now():Date.now();o>n?postMessage({id:null,method:\"call\",params:{timerId:t}}):e.set(t,setTimeout(c,n-o,e,t,n))},a=(e,t,n)=>{const{expected:o,remainingDelay:i}=f(e,n);r.set(t,setTimeout(c,i,r,t,o))},d=(e,t,n)=>{const{expected:r,remainingDelay:i}=f(e,n);o.set(t,setTimeout(c,i,o,t,r))}},function(e,t,n){\"use strict\";n.r(t);var r=n(2);for(var o in r)\"default\"!==o&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(3);for(var o in i)\"default\"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var u=n(4);for(var o in u)\"default\"!==o&&function(e){n.d(t,e,(function(){return u[e]}))}(o);var f=n(5);for(var o in f)\"default\"!==o&&function(e){n.d(t,e,(function(){return f[e]}))}(o);var c=n(6);for(var o in c)\"default\"!==o&&function(e){n.d(t,e,(function(){return c[e]}))}(o);var a=n(7);for(var o in a)\"default\"!==o&&function(e){n.d(t,e,(function(){return a[e]}))}(o);var d=n(8);for(var o in d)\"default\"!==o&&function(e){n.d(t,e,(function(){return d[e]}))}(o);var s=n(9);for(var o in s)\"default\"!==o&&function(e){n.d(t,e,(function(){return s[e]}))}(o)},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){\"use strict\";n.r(t);var r=n(11);for(var o in r)\"default\"!==o&&function(e){n.d(t,e,(function(){return r[e]}))}(o);var i=n(12);for(var o in i)\"default\"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);var u=n(13);for(var o in u)\"default\"!==o&&function(e){n.d(t,e,(function(){return u[e]}))}(o)},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){\"use strict\";n.r(t);var r=n(0),o=n(1);for(var i in o)\"default\"!==i&&function(e){n.d(t,e,(function(){return o[e]}))}(i);var u=n(10);for(var i in u)\"default\"!==i&&function(e){n.d(t,e,(function(){return u[e]}))}(i);addEventListener(\"message\",({data:e})=>{try{if(\"clear\"===e.method){const{id:t,params:{timerId:n}}=e;Object(r.b)(n),postMessage({error:null,id:t})}else{if(\"set\"!==e.method)throw new Error('The given method \"'.concat(e.method,'\" is not supported'));{const{params:{delay:t,now:n,timerId:o}}=e;Object(r.d)(t,o,n)}}}catch(t){postMessage({error:{message:t.message},id:e.id,result:null})}})}]);`; // tslint:disable-line:max-line-length\r\n return () => {\r\n if (Timeout.workerTimers !== null) {\r\n return Timeout.workerTimers;\r\n }\r\n\r\n const blob = new Blob([worker], { type: \"application/javascript; charset=utf-8\" });\r\n const url = URL.createObjectURL(blob);\r\n\r\n Timeout.workerTimers = Timeout.load(url);\r\n\r\n // Edge doesn't like the URL to be revoked directly.\r\n Timeout.workerTimers.setTimeout(() => URL.revokeObjectURL(url), 0);\r\n\r\n return Timeout.workerTimers as IWorkerTimers;\r\n };\r\n }\r\n\r\n public static timers: () => IWorkerTimers = Timeout.loadWorkerTimers();\r\n\r\n private static isCallNotification = (message: TWorkerMessage): message is ICallNotification => {\r\n return (message as ICallNotification).method !== undefined && (message as ICallNotification).method === \"call\";\r\n }\r\n\r\n private static isClearResponse = (message: TWorkerMessage): message is IClearResponse => {\r\n return (message as IClearResponse).error === null && typeof message.id === \"number\";\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { EventType, PlatformEvent } from \"./PlatformEvent\";\r\n\r\nexport class OCSPEvent extends PlatformEvent {\r\n private privSignature: string;\r\n\r\n constructor(eventName: string, eventType: EventType, signature: string) {\r\n super(eventName, eventType);\r\n\r\n this.privSignature = signature;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class OCSPMemoryCacheHitEvent extends OCSPEvent {\r\n constructor(signature: string) {\r\n super(\"OCSPMemoryCacheHitEvent\", EventType.Debug, signature);\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class OCSPCacheMissEvent extends OCSPEvent {\r\n constructor(signature: string) {\r\n super(\"OCSPCacheMissEvent\", EventType.Debug, signature);\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class OCSPDiskCacheHitEvent extends OCSPEvent {\r\n constructor(signature: string) {\r\n super(\"OCSPDiskCacheHitEvent\", EventType.Debug, signature);\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class OCSPCacheUpdateNeededEvent extends OCSPEvent {\r\n constructor(signature: string) {\r\n super(\"OCSPCacheUpdateNeededEvent\", EventType.Debug, signature);\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class OCSPMemoryCacheStoreEvent extends OCSPEvent {\r\n constructor(signature: string) {\r\n super(\"OCSPMemoryCacheStoreEvent\", EventType.Debug, signature);\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class OCSPDiskCacheStoreEvent extends OCSPEvent {\r\n constructor(signature: string) {\r\n super(\"OCSPDiskCacheStoreEvent\", EventType.Debug, signature);\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class OCSPCacheUpdatehCompleteEvent extends OCSPEvent {\r\n constructor(signature: string) {\r\n super(\"OCSPCacheUpdatehCompleteEvent\", EventType.Debug, signature);\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class OCSPStapleReceivedEvent extends OCSPEvent {\r\n constructor() {\r\n super(\"OCSPStapleReceivedEvent\", EventType.Debug, \"\");\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class OCSPWSUpgradeStartedEvent extends OCSPEvent {\r\n constructor(serialNumber: string) {\r\n super(\"OCSPWSUpgradeStartedEvent\", EventType.Debug, serialNumber);\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class OCSPCacheEntryExpiredEvent extends OCSPEvent {\r\n private privExpireTime: number;\r\n\r\n constructor(serialNumber: string, expireTime: number) {\r\n super(\"OCSPCacheEntryExpiredEvent\", EventType.Debug, serialNumber);\r\n this.privExpireTime = expireTime;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class OCSPCacheEntryNeedsRefreshEvent extends OCSPEvent {\r\n private privExpireTime: number;\r\n private privStartTime: number;\r\n\r\n constructor(serialNumber: string, startTime: number, expireTime: number) {\r\n super(\"OCSPCacheEntryNeedsRefreshEvent\", EventType.Debug, serialNumber);\r\n this.privExpireTime = expireTime;\r\n this.privStartTime = startTime;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class OCSPCacheHitEvent extends OCSPEvent {\r\n private privExpireTime: number;\r\n private privStartTime: number;\r\n private privExpireTimeString: string;\r\n private privStartTimeString: string;\r\n\r\n constructor(serialNumber: string, startTime: number, expireTime: number) {\r\n super(\"OCSPCacheHitEvent\", EventType.Debug, serialNumber);\r\n this.privExpireTime = expireTime;\r\n this.privExpireTimeString = new Date(expireTime).toLocaleDateString();\r\n this.privStartTime = startTime;\r\n this.privStartTimeString = new Date(startTime).toLocaleTimeString();\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class OCSPVerificationFailedEvent extends OCSPEvent {\r\n private privError: string;\r\n\r\n constructor(serialNumber: string, error: string) {\r\n super(\"OCSPVerificationFailedEvent\", EventType.Debug, serialNumber);\r\n this.privError = error;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class OCSPCacheFetchErrorEvent extends OCSPEvent {\r\n private privError: string;\r\n\r\n constructor(serialNumber: string, error: string) {\r\n super(\"OCSPCacheFetchErrorEvent\", EventType.Debug, serialNumber);\r\n this.privError = error;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class OCSPResponseRetrievedEvent extends OCSPEvent {\r\n constructor(serialNumber: string) {\r\n super(\"OCSPResponseRetrievedEvent\", EventType.Debug, serialNumber);\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class OCSPCacheUpdateErrorEvent extends OCSPEvent {\r\n private privError: string;\r\n\r\n constructor(serialNumber: string, error: string) {\r\n super(\"OCSPCacheUpdateErrorEvent\", EventType.Debug, serialNumber);\r\n this.privError = error;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n connectivity,\r\n ISpeechConfigAudioDevice,\r\n type\r\n} from \"../common.speech/Exports\";\r\nimport {\r\n AudioSourceErrorEvent,\r\n AudioSourceEvent,\r\n AudioSourceInitializingEvent,\r\n AudioSourceOffEvent,\r\n AudioSourceReadyEvent,\r\n AudioStreamNodeAttachedEvent,\r\n AudioStreamNodeAttachingEvent,\r\n AudioStreamNodeDetachedEvent,\r\n AudioStreamNodeErrorEvent,\r\n ChunkedArrayBufferStream,\r\n createNoDashGuid,\r\n Deferred,\r\n Events,\r\n EventSource,\r\n IAudioSource,\r\n IAudioStreamNode,\r\n IStringDictionary,\r\n Promise,\r\n PromiseHelper,\r\n Stream,\r\n} from \"../common/Exports\";\r\nimport {\r\n AudioStreamFormat,\r\n AudioStreamFormatImpl,\r\n} from \"../sdk/Audio/AudioStreamFormat\";\r\nimport { IRecorder } from \"./IRecorder\";\r\n\r\n// Extending the default definition with browser specific definitions for backward compatibility\r\ninterface INavigator extends Navigator {\r\n webkitGetUserMedia?: (constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback) => void;\r\n mozGetUserMedia?: (constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback) => void;\r\n msGetUserMedia?: (constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback) => void;\r\n}\r\n\r\nexport const AudioWorkletSourceURLPropertyName = \"MICROPHONE-WorkletSourceUrl\";\r\n\r\nexport class MicAudioSource implements IAudioSource {\r\n\r\n private static readonly AUDIOFORMAT: AudioStreamFormatImpl = AudioStreamFormat.getDefaultInputFormat() as AudioStreamFormatImpl;\r\n\r\n private privStreams: IStringDictionary> = {};\r\n\r\n private privId: string;\r\n\r\n private privEvents: EventSource;\r\n\r\n private privInitializeDeferral: Deferred;\r\n\r\n private privMediaStream: MediaStream;\r\n\r\n private privContext: AudioContext;\r\n\r\n private privMicrophoneLabel: string;\r\n\r\n private privOutputChunkSize: number;\r\n\r\n public constructor(\r\n private readonly privRecorder: IRecorder,\r\n private readonly deviceId?: string,\r\n audioSourceId?: string) {\r\n\r\n this.privOutputChunkSize = MicAudioSource.AUDIOFORMAT.avgBytesPerSec / 10;\r\n this.privId = audioSourceId ? audioSourceId : createNoDashGuid();\r\n this.privEvents = new EventSource();\r\n }\r\n\r\n public get format(): Promise {\r\n return PromiseHelper.fromResult(MicAudioSource.AUDIOFORMAT);\r\n }\r\n\r\n public get blob(): Promise {\r\n return PromiseHelper.fromError(\"Not implemented for Mic input\");\r\n }\r\n\r\n public turnOn = (): Promise => {\r\n if (this.privInitializeDeferral) {\r\n return this.privInitializeDeferral.promise();\r\n }\r\n\r\n this.privInitializeDeferral = new Deferred();\r\n\r\n try {\r\n this.createAudioContext();\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n this.privInitializeDeferral.reject(typedError.name + \": \" + typedError.message);\r\n } else {\r\n this.privInitializeDeferral.reject(error);\r\n }\r\n return this.privInitializeDeferral.promise();\r\n }\r\n\r\n const nav = window.navigator as INavigator;\r\n\r\n let getUserMedia = (\r\n nav.getUserMedia ||\r\n nav.webkitGetUserMedia ||\r\n nav.mozGetUserMedia ||\r\n nav.msGetUserMedia\r\n );\r\n\r\n if (!!nav.mediaDevices) {\r\n getUserMedia = (constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void => {\r\n nav.mediaDevices\r\n .getUserMedia(constraints)\r\n .then(successCallback)\r\n .catch(errorCallback);\r\n };\r\n }\r\n\r\n if (!getUserMedia) {\r\n const errorMsg = \"Browser does not support getUserMedia.\";\r\n this.privInitializeDeferral.reject(errorMsg);\r\n this.onEvent(new AudioSourceErrorEvent(errorMsg, \"\")); // mic initialized error - no streamid at this point\r\n } else {\r\n const next = () => {\r\n this.onEvent(new AudioSourceInitializingEvent(this.privId)); // no stream id\r\n getUserMedia(\r\n { audio: this.deviceId ? { deviceId: this.deviceId } : true, video: false },\r\n (mediaStream: MediaStream) => {\r\n this.privMediaStream = mediaStream;\r\n this.onEvent(new AudioSourceReadyEvent(this.privId));\r\n this.privInitializeDeferral.resolve(true);\r\n }, (error: MediaStreamError) => {\r\n const errorMsg = `Error occurred during microphone initialization: ${error}`;\r\n const tmp = this.privInitializeDeferral;\r\n // HACK: this should be handled through onError callbacks of all promises up the stack.\r\n // Unfortunately, the current implementation does not provide an easy way to reject promises\r\n // without a lot of code replication.\r\n // TODO: fix promise implementation, allow for a graceful reject chaining.\r\n this.privInitializeDeferral = null;\r\n tmp.reject(errorMsg); // this will bubble up through the whole chain of promises,\r\n // with each new level adding extra \"Unhandled callback error\" prefix to the error message.\r\n // The following line is not guaranteed to be executed.\r\n this.onEvent(new AudioSourceErrorEvent(this.privId, errorMsg));\r\n });\r\n };\r\n\r\n if (this.privContext.state === \"suspended\") {\r\n // NOTE: On iOS, the Web Audio API requires sounds to be triggered from an explicit user action.\r\n // https://github.com/WebAudio/web-audio-api/issues/790\r\n this.privContext.resume().then(next, (reason: any) => {\r\n this.privInitializeDeferral.reject(`Failed to initialize audio context: ${reason}`);\r\n });\r\n } else {\r\n next();\r\n }\r\n }\r\n\r\n return this.privInitializeDeferral.promise();\r\n }\r\n\r\n public id = (): string => {\r\n return this.privId;\r\n }\r\n\r\n public attach = (audioNodeId: string): Promise => {\r\n this.onEvent(new AudioStreamNodeAttachingEvent(this.privId, audioNodeId));\r\n\r\n return this.listen(audioNodeId).onSuccessContinueWith(\r\n (stream: Stream) => {\r\n this.onEvent(new AudioStreamNodeAttachedEvent(this.privId, audioNodeId));\r\n return {\r\n detach: () => {\r\n stream.readEnded();\r\n this.turnOff();\r\n delete this.privStreams[audioNodeId];\r\n this.onEvent(new AudioStreamNodeDetachedEvent(this.privId, audioNodeId));\r\n },\r\n id: () => {\r\n return audioNodeId;\r\n },\r\n read: () => {\r\n return stream.read();\r\n },\r\n };\r\n });\r\n }\r\n\r\n public detach = (audioNodeId: string): void => {\r\n if (audioNodeId && this.privStreams[audioNodeId]) {\r\n this.privStreams[audioNodeId].close();\r\n delete this.privStreams[audioNodeId];\r\n this.onEvent(new AudioStreamNodeDetachedEvent(this.privId, audioNodeId));\r\n }\r\n }\r\n\r\n public turnOff = (): Promise => {\r\n for (const streamId in this.privStreams) {\r\n if (streamId) {\r\n const stream = this.privStreams[streamId];\r\n if (stream) {\r\n stream.close();\r\n }\r\n }\r\n }\r\n\r\n this.onEvent(new AudioSourceOffEvent(this.privId)); // no stream now\r\n this.privInitializeDeferral = null;\r\n\r\n this.destroyAudioContext();\r\n\r\n return PromiseHelper.fromResult(true);\r\n }\r\n\r\n public get events(): EventSource {\r\n return this.privEvents;\r\n }\r\n\r\n public get deviceInfo(): Promise {\r\n return this.getMicrophoneLabel().onSuccessContinueWith((label: string) => {\r\n return {\r\n bitspersample: MicAudioSource.AUDIOFORMAT.bitsPerSample,\r\n channelcount: MicAudioSource.AUDIOFORMAT.channels,\r\n connectivity: connectivity.Unknown,\r\n manufacturer: \"Speech SDK\",\r\n model: label,\r\n samplerate: MicAudioSource.AUDIOFORMAT.samplesPerSec,\r\n type: type.Microphones,\r\n };\r\n });\r\n }\r\n\r\n public setProperty(name: string, value: string): void {\r\n if (name === AudioWorkletSourceURLPropertyName) {\r\n this.privRecorder.setWorkletUrl(value);\r\n } else {\r\n throw new Error(\"Property '\" + name + \"' is not supported on Microphone.\");\r\n }\r\n }\r\n\r\n private getMicrophoneLabel(): Promise {\r\n const defaultMicrophoneName: string = \"microphone\";\r\n\r\n // If we did this already, return the value.\r\n if (this.privMicrophoneLabel !== undefined) {\r\n return PromiseHelper.fromResult(this.privMicrophoneLabel);\r\n }\r\n\r\n // If the stream isn't currently running, we can't query devices because security.\r\n if (this.privMediaStream === undefined || !this.privMediaStream.active) {\r\n return PromiseHelper.fromResult(defaultMicrophoneName);\r\n }\r\n\r\n // Setup a default\r\n this.privMicrophoneLabel = defaultMicrophoneName;\r\n\r\n // Get the id of the device running the audio track.\r\n const microphoneDeviceId: string = this.privMediaStream.getTracks()[0].getSettings().deviceId;\r\n\r\n // If the browser doesn't support getting the device ID, set a default and return.\r\n if (undefined === microphoneDeviceId) {\r\n return PromiseHelper.fromResult(this.privMicrophoneLabel);\r\n }\r\n\r\n const deferred: Deferred = new Deferred();\r\n\r\n // Enumerate the media devices.\r\n navigator.mediaDevices.enumerateDevices().then((devices: MediaDeviceInfo[]) => {\r\n for (const device of devices) {\r\n if (device.deviceId === microphoneDeviceId) {\r\n // Found the device\r\n this.privMicrophoneLabel = device.label;\r\n break;\r\n }\r\n }\r\n deferred.resolve(this.privMicrophoneLabel);\r\n }, () => deferred.resolve(this.privMicrophoneLabel));\r\n\r\n return deferred.promise();\r\n }\r\n\r\n private listen = (audioNodeId: string): Promise> => {\r\n return this.turnOn()\r\n .onSuccessContinueWith>((_: boolean) => {\r\n const stream = new ChunkedArrayBufferStream(this.privOutputChunkSize, audioNodeId);\r\n this.privStreams[audioNodeId] = stream;\r\n\r\n try {\r\n this.privRecorder.record(this.privContext, this.privMediaStream, stream);\r\n } catch (error) {\r\n this.onEvent(new AudioStreamNodeErrorEvent(this.privId, audioNodeId, error));\r\n throw error;\r\n }\r\n\r\n return stream;\r\n });\r\n }\r\n\r\n private onEvent = (event: AudioSourceEvent): void => {\r\n this.privEvents.onEvent(event);\r\n Events.instance.onEvent(event);\r\n }\r\n\r\n private createAudioContext = (): void => {\r\n if (!!this.privContext) {\r\n return;\r\n }\r\n\r\n // https://developer.mozilla.org/en-US/docs/Web/API/AudioContext\r\n if (typeof (AudioContext) === \"undefined\") {\r\n throw new Error(\"Browser does not support Web Audio API (AudioContext is not available).\");\r\n }\r\n\r\n // Browsers without sampleRate constraint support can't connect nodes with different sample rates\r\n if (navigator.mediaDevices.getSupportedConstraints().sampleRate) {\r\n this.privContext = new AudioContext({ sampleRate: MicAudioSource.AUDIOFORMAT.samplesPerSec });\r\n } else {\r\n this.privContext = new AudioContext();\r\n }\r\n }\r\n\r\n private destroyAudioContext = (): void => {\r\n if (!this.privContext) {\r\n return;\r\n }\r\n\r\n this.privRecorder.releaseMediaResources(this.privContext);\r\n\r\n // This pattern brought to you by a bug in the TypeScript compiler where it\r\n // confuses the (\"close\" in this.privContext) with this.privContext always being null as the alternate.\r\n // https://github.com/Microsoft/TypeScript/issues/11498\r\n let hasClose: boolean = false;\r\n if (\"close\" in this.privContext) {\r\n hasClose = true;\r\n }\r\n\r\n if (hasClose) {\r\n this.privContext.close();\r\n this.privContext = null;\r\n } else if (null !== this.privContext && this.privContext.state === \"running\") {\r\n // Suspend actually takes a callback, but analogous to the\r\n // resume method, it'll be only fired if suspend is called\r\n // in a direct response to a user action. The later is not always\r\n // the case, as TurnOff is also called, when we receive an\r\n // end-of-speech message from the service. So, doing a best effort\r\n // fire-and-forget here.\r\n this.privContext.suspend();\r\n }\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n// Make sure not to export internal modules.\r\n//\r\nexport * from \"./CognitiveSubscriptionKeyAuthentication\";\r\nexport * from \"./CognitiveTokenAuthentication\";\r\nexport * from \"./IAuthentication\";\r\nexport * from \"./IConnectionFactory\";\r\nexport * from \"./ISynthesisConnectionFactory\";\r\nexport * from \"./IntentConnectionFactory\";\r\nexport * from \"./RecognitionEvents\";\r\nexport * from \"./ServiceRecognizerBase\";\r\nexport * from \"./RecognizerConfig\";\r\nexport * from \"./SpeechServiceInterfaces\";\r\nexport * from \"./WebsocketMessageFormatter\";\r\nexport * from \"./SpeechConnectionFactory\";\r\nexport * from \"./TranslationConnectionFactory\";\r\nexport * from \"./SpeechSynthesisConnectionFactory\";\r\nexport * from \"./EnumTranslation\";\r\nexport * from \"./ServiceMessages/Enums\";\r\nexport * from \"./ServiceMessages/TranslationSynthesisEnd\";\r\nexport * from \"./ServiceMessages/TranslationHypothesis\";\r\nexport * from \"./ServiceMessages/TranslationPhrase\";\r\nexport * from \"./TranslationServiceRecognizer\";\r\nexport * from \"./ServiceMessages/SpeechDetected\";\r\nexport * from \"./ServiceMessages/SpeechHypothesis\";\r\nexport * from \"./SpeechServiceRecognizer\";\r\nexport * from \"./ServiceMessages/DetailedSpeechPhrase\";\r\nexport * from \"./ServiceMessages/SimpleSpeechPhrase\";\r\nexport * from \"./AddedLmIntent\";\r\nexport * from \"./IntentServiceRecognizer\";\r\nexport * from \"./ServiceMessages/IntentResponse\";\r\nexport * from \"./RequestSession\";\r\nexport * from \"./SpeechContext\";\r\nexport * from \"./DynamicGrammarBuilder\";\r\nexport * from \"./DynamicGrammarInterfaces\";\r\nexport * from \"./DialogServiceAdapter\";\r\nexport * from \"./AgentConfig\";\r\nexport * from \"./Transcription/Exports\";\r\nexport * from \"./ServiceMessages/SynthesisAudioMetadata\";\r\nexport * from \"./SynthesisTurn\";\r\nexport * from \"./SynthesisAdapterBase\";\r\nexport * from \"./SynthesizerConfig\";\r\nexport * from \"./SynthesisContext\";\r\nexport * from \"./SpeakerRecognitionConfig\";\r\nexport * from \"./SpeakerIdMessageAdapter\";\r\n\r\nexport const OutputFormatPropertyName: string = \"OutputFormat\";\r\nexport const CancellationErrorCodePropertyName: string = \"CancellationErrorCode\";\r\nexport const ServicePropertiesPropertyName: string = \"ServiceProperties\";\r\nexport const ForceDictationPropertyName: string = \"ForceDication\";\r\nexport const AutoDetectSourceLanguagesOpenRangeOptionName: string = \"OpenRange\";\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ArgumentNullError, Promise, PromiseHelper } from \"../common/Exports\";\r\nimport { AuthInfo, IAuthentication } from \"./IAuthentication\";\r\n\r\nconst AuthHeader: string = \"Ocp-Apim-Subscription-Key\";\r\n\r\n/**\r\n * @class\r\n */\r\nexport class CognitiveSubscriptionKeyAuthentication implements IAuthentication {\r\n private privAuthInfo: AuthInfo;\r\n\r\n /**\r\n * Creates and initializes an instance of the CognitiveSubscriptionKeyAuthentication class.\r\n * @constructor\r\n * @param {string} subscriptionKey - The subscription key\r\n */\r\n constructor(subscriptionKey: string) {\r\n if (!subscriptionKey) {\r\n throw new ArgumentNullError(\"subscriptionKey\");\r\n }\r\n\r\n this.privAuthInfo = new AuthInfo(AuthHeader, subscriptionKey);\r\n }\r\n\r\n /**\r\n * Fetches the subscription key.\r\n * @member\r\n * @function\r\n * @public\r\n * @param {string} authFetchEventId - The id to fetch.\r\n */\r\n public fetch = (authFetchEventId: string): Promise => {\r\n return PromiseHelper.fromResult(this.privAuthInfo);\r\n }\r\n\r\n /**\r\n * Fetches the subscription key.\r\n * @member\r\n * @function\r\n * @public\r\n * @param {string} authFetchEventId - The id to fetch.\r\n */\r\n public fetchOnExpiry = (authFetchEventId: string): Promise => {\r\n return PromiseHelper.fromResult(this.privAuthInfo);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { Promise } from \"../common/Exports\";\r\n\r\nexport interface IAuthentication {\r\n fetch(authFetchEventId: string): Promise;\r\n fetchOnExpiry(authFetchEventId: string): Promise;\r\n}\r\n\r\nexport class AuthInfo {\r\n private privHeaderName: string;\r\n private privToken: string;\r\n\r\n public constructor(headerName: string, token: string) {\r\n this.privHeaderName = headerName;\r\n this.privToken = token;\r\n }\r\n\r\n public get headerName(): string {\r\n return this.privHeaderName;\r\n }\r\n\r\n public get token(): string {\r\n return this.privToken;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ArgumentNullError, Promise } from \"../common/Exports\";\r\nimport { AuthInfo, IAuthentication } from \"./IAuthentication\";\r\n\r\nconst AuthHeader: string = \"Authorization\";\r\n\r\nexport class CognitiveTokenAuthentication implements IAuthentication {\r\n private privFetchCallback: (authFetchEventId: string) => Promise;\r\n private privFetchOnExpiryCallback: (authFetchEventId: string) => Promise;\r\n\r\n constructor(fetchCallback: (authFetchEventId: string) => Promise, fetchOnExpiryCallback: (authFetchEventId: string) => Promise) {\r\n if (!fetchCallback) {\r\n throw new ArgumentNullError(\"fetchCallback\");\r\n }\r\n\r\n if (!fetchOnExpiryCallback) {\r\n throw new ArgumentNullError(\"fetchOnExpiryCallback\");\r\n }\r\n\r\n this.privFetchCallback = fetchCallback;\r\n this.privFetchOnExpiryCallback = fetchOnExpiryCallback;\r\n }\r\n\r\n public fetch = (authFetchEventId: string): Promise => {\r\n return this.privFetchCallback(authFetchEventId).onSuccessContinueWith((token: string) => new AuthInfo(AuthHeader, token));\r\n }\r\n\r\n public fetchOnExpiry = (authFetchEventId: string): Promise => {\r\n return this.privFetchOnExpiryCallback(authFetchEventId).onSuccessContinueWith((token: string) => new AuthInfo(AuthHeader, token));\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n ProxyInfo,\r\n WebsocketConnection,\r\n} from \"../common.browser/Exports\";\r\nimport {\r\n IConnection,\r\n IStringDictionary\r\n} from \"../common/Exports\";\r\nimport {\r\n PropertyId\r\n} from \"../sdk/Exports\";\r\nimport {\r\n ConnectionFactoryBase\r\n} from \"./ConnectionFactoryBase\";\r\nimport {\r\n AuthInfo,\r\n IConnectionFactory,\r\n RecognizerConfig,\r\n WebsocketMessageFormatter,\r\n} from \"./Exports\";\r\n\r\nconst TestHooksParamName: string = \"testhooks\";\r\nconst ConnectionIdHeader: string = \"X-ConnectionId\";\r\n\r\nexport class IntentConnectionFactory extends ConnectionFactoryBase {\r\n\r\n public create = (\r\n config: RecognizerConfig,\r\n authInfo: AuthInfo,\r\n connectionId?: string): IConnection => {\r\n\r\n let endpoint: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint);\r\n if (!endpoint) {\r\n const region: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_IntentRegion);\r\n const hostSuffix = (region && region.toLowerCase().startsWith(\"china\")) ? \".azure.cn\" : \".microsoft.com\";\r\n const host: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, \"wss://\" + region + \".sr.speech\" + hostSuffix);\r\n endpoint = host + \"/speech/recognition/interactive/cognitiveservices/v1\";\r\n }\r\n\r\n const queryParams: IStringDictionary = {\r\n format: \"simple\",\r\n language: config.parameters.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage),\r\n };\r\n\r\n this.setCommonUrlParams(config, queryParams, endpoint);\r\n\r\n const headers: IStringDictionary = {};\r\n if (authInfo.token !== undefined && authInfo.token !== \"\") {\r\n headers[authInfo.headerName] = authInfo.token;\r\n }\r\n headers[ConnectionIdHeader] = connectionId;\r\n\r\n config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, endpoint);\r\n\r\n return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), connectionId);\r\n }\r\n\r\n private getSpeechRegionFromIntentRegion(intentRegion: string): string {\r\n switch (intentRegion) {\r\n case \"West US\":\r\n case \"US West\":\r\n case \"westus\":\r\n return \"uswest\";\r\n case \"West US 2\":\r\n case \"US West 2\":\r\n case \"westus2\":\r\n return \"uswest2\";\r\n case \"South Central US\":\r\n case \"US South Central\":\r\n case \"southcentralus\":\r\n return \"ussouthcentral\";\r\n case \"West Central US\":\r\n case \"US West Central\":\r\n case \"westcentralus\":\r\n return \"uswestcentral\";\r\n case \"East US\":\r\n case \"US East\":\r\n case \"eastus\":\r\n return \"useast\";\r\n case \"East US 2\":\r\n case \"US East 2\":\r\n case \"eastus2\":\r\n return \"useast2\";\r\n case \"West Europe\":\r\n case \"Europe West\":\r\n case \"westeurope\":\r\n return \"europewest\";\r\n case \"North Europe\":\r\n case \"Europe North\":\r\n case \"northeurope\":\r\n return \"europenorth\";\r\n case \"Brazil South\":\r\n case \"South Brazil\":\r\n case \"southbrazil\":\r\n return \"brazilsouth\";\r\n case \"Australia East\":\r\n case \"East Australia\":\r\n case \"eastaustralia\":\r\n return \"australiaeast\";\r\n case \"Southeast Asia\":\r\n case \"Asia Southeast\":\r\n case \"southeastasia\":\r\n return \"asiasoutheast\";\r\n case \"East Asia\":\r\n case \"Asia East\":\r\n case \"eastasia\":\r\n return \"asiaeast\";\r\n default:\r\n return intentRegion;\r\n }\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nexport { AudioConfig } from \"./Audio/AudioConfig\";\r\nexport { AudioStreamFormat } from \"./Audio/AudioStreamFormat\";\r\nexport { AudioInputStream, PullAudioInputStream, PushAudioInputStream } from \"./Audio/AudioInputStream\";\r\nexport { AudioOutputStream, PullAudioOutputStream, PushAudioOutputStream} from \"./Audio/AudioOutputStream\";\r\nexport { CancellationReason } from \"./CancellationReason\";\r\nexport { PullAudioInputStreamCallback } from \"./Audio/PullAudioInputStreamCallback\";\r\nexport { PushAudioOutputStreamCallback } from \"./Audio/PushAudioOutputStreamCallback\";\r\nexport { KeywordRecognitionModel } from \"./KeywordRecognitionModel\";\r\nexport { SessionEventArgs } from \"./SessionEventArgs\";\r\nexport { RecognitionEventArgs } from \"./RecognitionEventArgs\";\r\nexport { OutputFormat } from \"./OutputFormat\";\r\nexport { IntentRecognitionEventArgs } from \"./IntentRecognitionEventArgs\";\r\nexport { RecognitionResult } from \"./RecognitionResult\";\r\nexport { SpeechRecognitionResult } from \"./SpeechRecognitionResult\";\r\nexport { IntentRecognitionResult } from \"./IntentRecognitionResult\";\r\nexport { LanguageUnderstandingModel } from \"./LanguageUnderstandingModel\";\r\nexport { SpeechRecognitionEventArgs } from \"./SpeechRecognitionEventArgs\";\r\nexport { SpeechRecognitionCanceledEventArgs } from \"./SpeechRecognitionCanceledEventArgs\";\r\nexport { TranslationRecognitionEventArgs } from \"./TranslationRecognitionEventArgs\";\r\nexport { TranslationSynthesisEventArgs } from \"./TranslationSynthesisEventArgs\";\r\nexport { TranslationRecognitionResult } from \"./TranslationRecognitionResult\";\r\nexport { TranslationSynthesisResult } from \"./TranslationSynthesisResult\";\r\nexport { ResultReason } from \"./ResultReason\";\r\nexport { SpeechConfig, SpeechConfigImpl } from \"./SpeechConfig\";\r\nexport { SpeechTranslationConfig } from \"./SpeechTranslationConfig\";\r\nexport { PropertyCollection } from \"./PropertyCollection\";\r\nexport { PropertyId } from \"./PropertyId\";\r\nexport { Recognizer } from \"./Recognizer\";\r\nexport { SpeechRecognizer } from \"./SpeechRecognizer\";\r\nexport { IntentRecognizer } from \"./IntentRecognizer\";\r\nexport { VoiceProfileType } from \"./VoiceProfileType\";\r\nexport { TranslationRecognizer } from \"./TranslationRecognizer\";\r\nexport { Translations } from \"./Translations\";\r\nexport { NoMatchReason } from \"./NoMatchReason\";\r\nexport { NoMatchDetails } from \"./NoMatchDetails\";\r\nexport { TranslationRecognitionCanceledEventArgs } from \"./TranslationRecognitionCanceledEventArgs\";\r\nexport { IntentRecognitionCanceledEventArgs } from \"./IntentRecognitionCanceledEventArgs\";\r\nexport { CancellationDetailsBase } from \"./CancellationDetailsBase\";\r\nexport { CancellationDetails } from \"./CancellationDetails\";\r\nexport { CancellationErrorCode } from \"./CancellationErrorCodes\";\r\nexport { ConnectionEventArgs } from \"./ConnectionEventArgs\";\r\nexport { ServiceEventArgs } from \"./ServiceEventArgs\";\r\nexport { Connection } from \"./Connection\";\r\nexport { PhraseListGrammar } from \"./PhraseListGrammar\";\r\nexport { DialogServiceConfig } from \"./DialogServiceConfig\";\r\nexport { BotFrameworkConfig } from \"./BotFrameworkConfig\";\r\nexport { CustomCommandsConfig } from \"./CustomCommandsConfig\";\r\nexport { DialogServiceConnector } from \"./DialogServiceConnector\";\r\nexport { ActivityReceivedEventArgs } from \"./ActivityReceivedEventArgs\";\r\nexport { ServicePropertyChannel } from \"./ServicePropertyChannel\";\r\nexport { ProfanityOption } from \"./ProfanityOption\";\r\nexport { BaseAudioPlayer } from \"./Audio/BaseAudioPlayer\";\r\nexport { ConnectionMessageEventArgs } from \"./ConnectionMessageEventArgs\";\r\nexport { ConnectionMessage } from \"./ConnectionMessage\";\r\nexport { VoiceProfile } from \"./VoiceProfile\";\r\nexport { VoiceProfileEnrollmentResult, VoiceProfileEnrollmentCancellationDetails } from \"./VoiceProfileEnrollmentResult\";\r\nexport { VoiceProfileResult, VoiceProfileCancellationDetails } from \"./VoiceProfileResult\";\r\nexport { VoiceProfileClient } from \"./VoiceProfileClient\";\r\nexport { SpeakerRecognizer } from \"./SpeakerRecognizer\";\r\nexport { SpeakerIdentificationModel } from \"./SpeakerIdentificationModel\";\r\nexport { SpeakerVerificationModel } from \"./SpeakerVerificationModel\";\r\nexport { AutoDetectSourceLanguageConfig } from \"./AutoDetectSourceLanguageConfig\";\r\nexport { AutoDetectSourceLanguageResult } from \"./AutoDetectSourceLanguageResult\";\r\nexport { SourceLanguageConfig } from \"./SourceLanguageConfig\";\r\nexport { SpeakerRecognitionResult, SpeakerRecognitionResultType, SpeakerRecognitionCancellationDetails } from \"./SpeakerRecognitionResult\";\r\nexport { Conversation,\r\n ConversationExpirationEventArgs,\r\n ConversationParticipantsChangedEventArgs,\r\n ConversationTranslationCanceledEventArgs,\r\n ConversationTranslationEventArgs,\r\n ConversationTranslationResult,\r\n ConversationTranslator,\r\n Participant,\r\n ParticipantChangedReason,\r\n User\r\n } from \"./Transcription/Exports\";\r\nexport { SpeechSynthesisOutputFormat } from \"./SpeechSynthesisOutputFormat\";\r\nexport { SpeechSynthesizer } from \"./SpeechSynthesizer\";\r\nexport { SpeechSynthesisResult } from \"./SpeechSynthesisResult\";\r\nexport { SpeechSynthesisEventArgs } from \"./SpeechSynthesisEventArgs\";\r\nexport { SpeechSynthesisWordBoundaryEventArgs} from \"./SpeechSynthesisWordBoundaryEventArgs\";\r\nexport { IPlayer } from \"./Audio/IPlayer\";\r\nexport { SpeakerAudioDestination } from \"./Audio/SpeakerAudioDestination\";\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { PathLike } from \"fs\";\r\nimport {\r\n FileAudioSource,\r\n MicAudioSource,\r\n PcmRecorder,\r\n} from \"../../common.browser/Exports\";\r\nimport { ISpeechConfigAudioDevice } from \"../../common.speech/Exports\";\r\nimport {\r\n AudioSourceEvent,\r\n Deferred,\r\n EventSource,\r\n IAudioDestination,\r\n IAudioSource,\r\n IAudioStreamNode,\r\n Promise\r\n} from \"../../common/Exports\";\r\nimport { Contracts } from \"../Contracts\";\r\nimport {\r\n AudioInputStream,\r\n AudioOutputStream,\r\n AudioStreamFormat,\r\n IPlayer,\r\n PropertyCollection,\r\n PropertyId,\r\n PullAudioInputStreamCallback,\r\n PullAudioOutputStream,\r\n PushAudioOutputStream,\r\n PushAudioOutputStreamCallback,\r\n SpeakerAudioDestination\r\n} from \"../Exports\";\r\nimport { AudioFileWriter } from \"./AudioFileWriter\";\r\nimport { PullAudioInputStreamImpl, PushAudioInputStreamImpl } from \"./AudioInputStream\";\r\nimport { PullAudioOutputStreamImpl, PushAudioOutputStreamImpl } from \"./AudioOutputStream\";\r\nimport { AudioStreamFormatImpl } from \"./AudioStreamFormat\";\r\n\r\n/**\r\n * Represents audio input configuration used for specifying what type of input to use (microphone, file, stream).\r\n * @class AudioConfig\r\n * Updated in version 1.11.0\r\n */\r\nexport abstract class AudioConfig {\r\n /**\r\n * Creates an AudioConfig object representing the default microphone on the system.\r\n * @member AudioConfig.fromDefaultMicrophoneInput\r\n * @function\r\n * @public\r\n * @returns {AudioConfig} The audio input configuration being created.\r\n */\r\n public static fromDefaultMicrophoneInput(): AudioConfig {\r\n const pcmRecorder = new PcmRecorder();\r\n return new AudioConfigImpl(new MicAudioSource(pcmRecorder));\r\n }\r\n\r\n /**\r\n * Creates an AudioConfig object representing a microphone with the specified device ID.\r\n * @member AudioConfig.fromMicrophoneInput\r\n * @function\r\n * @public\r\n * @param {string | undefined} deviceId - Specifies the device ID of the microphone to be used.\r\n * Default microphone is used the value is omitted.\r\n * @returns {AudioConfig} The audio input configuration being created.\r\n */\r\n public static fromMicrophoneInput(deviceId?: string): AudioConfig {\r\n const pcmRecorder = new PcmRecorder();\r\n return new AudioConfigImpl(new MicAudioSource(pcmRecorder, deviceId));\r\n }\r\n\r\n /**\r\n * Creates an AudioConfig object representing the specified file.\r\n * @member AudioConfig.fromWavFileInput\r\n * @function\r\n * @public\r\n * @param {File} fileName - Specifies the audio input file. Currently, only WAV / PCM is supported.\r\n * @returns {AudioConfig} The audio input configuration being created.\r\n */\r\n public static fromWavFileInput(file: File): AudioConfig {\r\n return new AudioConfigImpl(new FileAudioSource(file));\r\n }\r\n\r\n /**\r\n * Creates an AudioConfig object representing the specified stream.\r\n * @member AudioConfig.fromStreamInput\r\n * @function\r\n * @public\r\n * @param {AudioInputStream | PullAudioInputStreamCallback} audioStream - Specifies the custom audio input\r\n * stream. Currently, only WAV / PCM is supported.\r\n * @returns {AudioConfig} The audio input configuration being created.\r\n */\r\n public static fromStreamInput(audioStream: AudioInputStream | PullAudioInputStreamCallback): AudioConfig {\r\n if (audioStream instanceof PullAudioInputStreamCallback) {\r\n return new AudioConfigImpl(new PullAudioInputStreamImpl(audioStream as PullAudioInputStreamCallback));\r\n }\r\n\r\n if (audioStream instanceof AudioInputStream) {\r\n return new AudioConfigImpl(audioStream as PushAudioInputStreamImpl);\r\n }\r\n\r\n throw new Error(\"Not Supported Type\");\r\n }\r\n\r\n /**\r\n * Creates an AudioConfig object representing the default speaker.\r\n * @member AudioConfig.fromDefaultSpeakerOutput\r\n * @function\r\n * @public\r\n * @returns {AudioConfig} The audio output configuration being created.\r\n * Added in version 1.11.0\r\n */\r\n public static fromDefaultSpeakerOutput(): AudioConfig {\r\n return new AudioOutputConfigImpl(new SpeakerAudioDestination());\r\n }\r\n\r\n /**\r\n * Creates an AudioConfig object representing the custom IPlayer object.\r\n * You can use the IPlayer object to control pause, resume, etc.\r\n * @member AudioConfig.fromSpeakerOutput\r\n * @function\r\n * @public\r\n * @param {IPlayer} player - the IPlayer object for playback.\r\n * @returns {AudioConfig} The audio output configuration being created.\r\n * Added in version 1.12.0\r\n */\r\n public static fromSpeakerOutput(player?: IPlayer): AudioConfig {\r\n if (player === undefined) {\r\n return AudioConfig.fromDefaultSpeakerOutput();\r\n }\r\n if (player instanceof SpeakerAudioDestination) {\r\n return new AudioOutputConfigImpl(player as SpeakerAudioDestination);\r\n }\r\n\r\n throw new Error(\"Not Supported Type\");\r\n }\r\n\r\n /**\r\n * Creates an AudioConfig object representing a specified output audio file\r\n * @member AudioConfig.fromAudioFileOutput\r\n * @function\r\n * @public\r\n * @param {PathLike} filename - the filename of the output audio file\r\n * @returns {AudioConfig} The audio output configuration being created.\r\n * Added in version 1.11.0\r\n */\r\n public static fromAudioFileOutput(filename: PathLike): AudioConfig {\r\n return new AudioOutputConfigImpl(new AudioFileWriter(filename));\r\n }\r\n\r\n /**\r\n * Creates an AudioConfig object representing a specified audio output stream\r\n * @member AudioConfig.fromStreamOutput\r\n * @function\r\n * @public\r\n * @param {AudioOutputStream | PushAudioOutputStreamCallback} audioStream - Specifies the custom audio output\r\n * stream.\r\n * @returns {AudioConfig} The audio output configuration being created.\r\n * Added in version 1.11.0\r\n */\r\n public static fromStreamOutput(audioStream: AudioOutputStream | PushAudioOutputStreamCallback): AudioConfig {\r\n if (audioStream instanceof PushAudioOutputStreamCallback) {\r\n return new AudioOutputConfigImpl(new PushAudioOutputStreamImpl(audioStream as PushAudioOutputStreamCallback));\r\n }\r\n\r\n if (audioStream instanceof PushAudioOutputStream) {\r\n return new AudioOutputConfigImpl(audioStream as PushAudioOutputStreamImpl);\r\n }\r\n\r\n if (audioStream instanceof PullAudioOutputStream) {\r\n return new AudioOutputConfigImpl(audioStream as PullAudioOutputStreamImpl);\r\n }\r\n\r\n throw new Error(\"Not Supported Type\");\r\n }\r\n\r\n /**\r\n * Explicitly frees any external resource attached to the object\r\n * @member AudioConfig.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public abstract close(): void;\r\n\r\n /**\r\n * Sets an arbitrary property.\r\n * @member SpeechConfig.prototype.setProperty\r\n * @function\r\n * @public\r\n * @param {string} name - The name of the property to set.\r\n * @param {string} value - The new value of the property.\r\n */\r\n public abstract setProperty(name: string, value: string): void;\r\n\r\n /**\r\n * Returns the current value of an arbitrary property.\r\n * @member SpeechConfig.prototype.getProperty\r\n * @function\r\n * @public\r\n * @param {string} name - The name of the property to query.\r\n * @param {string} def - The value to return in case the property is not known.\r\n * @returns {string} The current value, or provided default, of the given property.\r\n */\r\n public abstract getProperty(name: string, def?: string): string;\r\n\r\n}\r\n\r\n/**\r\n * Represents audio input stream used for custom audio input configurations.\r\n * @private\r\n * @class AudioConfigImpl\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class AudioConfigImpl extends AudioConfig implements IAudioSource {\r\n private privSource: IAudioSource;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {IAudioSource} source - An audio source.\r\n */\r\n public constructor(source: IAudioSource) {\r\n super();\r\n this.privSource = source;\r\n }\r\n\r\n /**\r\n * Format information for the audio\r\n */\r\n public get format(): Promise {\r\n return this.privSource.format;\r\n }\r\n\r\n /**\r\n * @member AudioConfigImpl.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(): void {\r\n this.privSource.turnOff();\r\n }\r\n\r\n /**\r\n * @member AudioConfigImpl.prototype.id\r\n * @function\r\n * @public\r\n */\r\n public id(): string {\r\n return this.privSource.id();\r\n }\r\n\r\n /**\r\n * @member AudioConfigImpl.prototype.blob\r\n * @function\r\n * @public\r\n */\r\n public get blob(): Promise {\r\n return this.privSource.blob;\r\n }\r\n\r\n /**\r\n * @member AudioConfigImpl.prototype.turnOn\r\n * @function\r\n * @public\r\n * @returns {Promise} A promise.\r\n */\r\n public turnOn(): Promise {\r\n return this.privSource.turnOn();\r\n }\r\n\r\n /**\r\n * @member AudioConfigImpl.prototype.attach\r\n * @function\r\n * @public\r\n * @param {string} audioNodeId - The audio node id.\r\n * @returns {Promise} A promise.\r\n */\r\n public attach(audioNodeId: string): Promise {\r\n return this.privSource.attach(audioNodeId);\r\n }\r\n\r\n /**\r\n * @member AudioConfigImpl.prototype.detach\r\n * @function\r\n * @public\r\n * @param {string} audioNodeId - The audio node id.\r\n */\r\n public detach(audioNodeId: string): void {\r\n return this.privSource.detach(audioNodeId);\r\n }\r\n\r\n /**\r\n * @member AudioConfigImpl.prototype.turnOff\r\n * @function\r\n * @public\r\n * @returns {Promise} A promise.\r\n */\r\n public turnOff(): Promise {\r\n return this.privSource.turnOff();\r\n }\r\n\r\n /**\r\n * @member AudioConfigImpl.prototype.events\r\n * @function\r\n * @public\r\n * @returns {EventSource} An event source for audio events.\r\n */\r\n public get events(): EventSource {\r\n return this.privSource.events;\r\n }\r\n\r\n public setProperty(name: string, value: string): void {\r\n Contracts.throwIfNull(value, \"value\");\r\n\r\n if (undefined !== this.privSource.setProperty) {\r\n this.privSource.setProperty(name, value);\r\n } else {\r\n throw new Error(\"This AudioConfig instance does not support setting properties.\");\r\n }\r\n\r\n }\r\n\r\n public getProperty(name: string, def?: string): string {\r\n if (undefined !== this.privSource.getProperty) {\r\n return this.privSource.getProperty(name, def);\r\n } else {\r\n throw new Error(\"This AudioConfig instance does not support getting properties.\");\r\n }\r\n\r\n return def;\r\n }\r\n\r\n public get deviceInfo(): Promise {\r\n return this.privSource.deviceInfo;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class AudioOutputConfigImpl extends AudioConfig implements IAudioDestination {\r\n private privDestination: IAudioDestination;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {IAudioDestination} destination - An audio destination.\r\n */\r\n public constructor(destination: IAudioDestination) {\r\n super();\r\n this.privDestination = destination;\r\n }\r\n\r\n public set format(format: AudioStreamFormat) {\r\n this.privDestination.format = format;\r\n }\r\n\r\n public write(buffer: ArrayBuffer): void {\r\n this.privDestination.write(buffer);\r\n }\r\n\r\n public close(): void {\r\n this.privDestination.close();\r\n }\r\n\r\n public id(): string {\r\n return this.privDestination.id();\r\n }\r\n\r\n public setProperty(name: string, value: string): void {\r\n throw new Error(\"This AudioConfig instance does not support setting properties.\");\r\n }\r\n\r\n public getProperty(name: string, def?: string): string {\r\n throw new Error(\"This AudioConfig instance does not support getting properties.\");\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * @class Contracts\r\n * @private\r\n */\r\nexport class Contracts {\r\n public static throwIfNullOrUndefined(param: any, name: string): void {\r\n if (param === undefined || param === null) {\r\n throw new Error(\"throwIfNullOrUndefined:\" + name);\r\n }\r\n }\r\n\r\n public static throwIfNull(param: any, name: string): void {\r\n if (param === null) {\r\n throw new Error(\"throwIfNull:\" + name);\r\n }\r\n }\r\n\r\n public static throwIfNullOrWhitespace(param: string, name: string): void {\r\n Contracts.throwIfNullOrUndefined(param, name);\r\n\r\n if ((\"\" + param).trim().length < 1) {\r\n throw new Error(\"throwIfNullOrWhitespace:\" + name);\r\n }\r\n }\r\n\r\n public static throwIfDisposed(isDisposed: boolean): void {\r\n if (isDisposed) {\r\n throw new Error(\"the object is already disposed\");\r\n }\r\n }\r\n\r\n public static throwIfArrayEmptyOrWhitespace(array: string[], name: string): void {\r\n Contracts.throwIfNullOrUndefined(array, name);\r\n\r\n if (array.length === 0) {\r\n throw new Error(\"throwIfArrayEmptyOrWhitespace:\" + name);\r\n }\r\n\r\n for (const item of array) {\r\n Contracts.throwIfNullOrWhitespace(item, name);\r\n }\r\n }\r\n\r\n public static throwIfFileDoesNotExist(param: any, name: string): void {\r\n Contracts.throwIfNullOrWhitespace(param, name);\r\n\r\n // TODO check for file existence.\r\n }\r\n\r\n public static throwIfNotUndefined(param: any, name: string): void {\r\n if (param !== undefined) {\r\n throw new Error(\"throwIfNotUndefined:\" + name);\r\n }\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport * as fs from \"fs\";\r\nimport { IAudioDestination } from \"../../common/Exports\";\r\nimport { Contracts } from \"../Contracts\";\r\nimport { AudioStreamFormat } from \"../Exports\";\r\nimport { AudioOutputFormatImpl } from \"./AudioOutputFormat\";\r\n\r\nexport class AudioFileWriter implements IAudioDestination {\r\n private privAudioFormat: AudioOutputFormatImpl;\r\n private privFd: number;\r\n private privId: string;\r\n private privWriteStream: fs.WriteStream;\r\n\r\n public constructor(filename: fs.PathLike) {\r\n this.privFd = fs.openSync(filename, \"w\");\r\n }\r\n\r\n public set format(format: AudioStreamFormat) {\r\n Contracts.throwIfNotUndefined(this.privAudioFormat, \"format is already set\");\r\n this.privAudioFormat = format as AudioOutputFormatImpl;\r\n let headerOffset: number = 0;\r\n if (this.privAudioFormat.hasHeader) {\r\n headerOffset = this.privAudioFormat.header.byteLength;\r\n }\r\n if (this.privFd !== undefined) {\r\n this.privWriteStream = fs.createWriteStream(\"\", {fd: this.privFd, start: headerOffset, autoClose: false});\r\n }\r\n }\r\n\r\n public write(buffer: ArrayBuffer): void {\r\n Contracts.throwIfNullOrUndefined(this.privAudioFormat, \"must set format before writing.\");\r\n if (this.privWriteStream !== undefined) {\r\n this.privWriteStream.write(new Uint8Array(buffer.slice(0)));\r\n }\r\n }\r\n\r\n public close(): void {\r\n if (this.privFd !== undefined) {\r\n this.privWriteStream.on(\"finish\", () => {\r\n if (this.privAudioFormat.hasHeader) {\r\n this.privAudioFormat.updateHeader(this.privWriteStream.bytesWritten);\r\n fs.writeSync(this.privFd,\r\n new Int8Array(this.privAudioFormat.header),\r\n 0,\r\n this.privAudioFormat.header.byteLength,\r\n 0);\r\n }\r\n fs.closeSync(this.privFd);\r\n this.privFd = undefined;\r\n });\r\n this.privWriteStream.end();\r\n }\r\n }\r\n\r\n public id = (): string => {\r\n return this.privId;\r\n }\r\n}\r\n","/* (ignored) */","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n connectivity,\r\n ISpeechConfigAudioDevice,\r\n type,\r\n} from \"../../common.speech/Exports\";\r\nimport {\r\n AudioSourceEvent,\r\n AudioSourceInitializingEvent,\r\n AudioSourceReadyEvent,\r\n AudioStreamNodeAttachedEvent,\r\n AudioStreamNodeAttachingEvent,\r\n AudioStreamNodeDetachedEvent,\r\n ChunkedArrayBufferStream,\r\n Deferred,\r\n Events,\r\n EventSource,\r\n IAudioSource,\r\n IAudioStreamNode,\r\n IStreamChunk,\r\n Promise,\r\n PromiseHelper,\r\n PromiseResult,\r\n Stream,\r\n} from \"../../common/Exports\";\r\nimport { createNoDashGuid } from \"../../common/Guid\";\r\nimport { AudioStreamFormat, PullAudioInputStreamCallback } from \"../Exports\";\r\nimport { AudioStreamFormatImpl } from \"./AudioStreamFormat\";\r\n\r\n/**\r\n * Represents audio input stream used for custom audio input configurations.\r\n * @class AudioInputStream\r\n */\r\nexport abstract class AudioInputStream {\r\n\r\n /**\r\n * Creates and initializes an instance.\r\n * @constructor\r\n */\r\n protected constructor() { }\r\n\r\n /**\r\n * Creates a memory backed PushAudioInputStream with the specified audio format.\r\n * @member AudioInputStream.createPushStream\r\n * @function\r\n * @public\r\n * @param {AudioStreamFormat} format - The audio data format in which audio will be\r\n * written to the push audio stream's write() method (Required if format is not 16 kHz 16bit mono PCM).\r\n * @returns {PushAudioInputStream} The audio input stream being created.\r\n */\r\n public static createPushStream(format?: AudioStreamFormat): PushAudioInputStream {\r\n return PushAudioInputStream.create(format);\r\n }\r\n\r\n /**\r\n * Creates a PullAudioInputStream that delegates to the specified callback interface for read()\r\n * and close() methods.\r\n * @member AudioInputStream.createPullStream\r\n * @function\r\n * @public\r\n * @param {PullAudioInputStreamCallback} callback - The custom audio input object, derived from\r\n * PullAudioInputStreamCallback\r\n * @param {AudioStreamFormat} format - The audio data format in which audio will be returned from\r\n * the callback's read() method (Required if format is not 16 kHz 16bit mono PCM).\r\n * @returns {PullAudioInputStream} The audio input stream being created.\r\n */\r\n public static createPullStream(callback: PullAudioInputStreamCallback, format?: AudioStreamFormat): PullAudioInputStream {\r\n return PullAudioInputStream.create(callback, format);\r\n // throw new Error(\"Oops\");\r\n }\r\n\r\n /**\r\n * Explicitly frees any external resource attached to the object\r\n * @member AudioInputStream.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public abstract close(): void;\r\n}\r\n\r\n/**\r\n * Represents memory backed push audio input stream used for custom audio input configurations.\r\n * @class PushAudioInputStream\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport abstract class PushAudioInputStream extends AudioInputStream {\r\n\r\n /**\r\n * Creates a memory backed PushAudioInputStream with the specified audio format.\r\n * @member PushAudioInputStream.create\r\n * @function\r\n * @public\r\n * @param {AudioStreamFormat} format - The audio data format in which audio will be written to the\r\n * push audio stream's write() method (Required if format is not 16 kHz 16bit mono PCM).\r\n * @returns {PushAudioInputStream} The push audio input stream being created.\r\n */\r\n public static create(format?: AudioStreamFormat): PushAudioInputStream {\r\n return new PushAudioInputStreamImpl(format);\r\n }\r\n\r\n /**\r\n * Writes the audio data specified by making an internal copy of the data.\r\n * @member PushAudioInputStream.prototype.write\r\n * @function\r\n * @public\r\n * @param {ArrayBuffer} dataBuffer - The audio buffer of which this function will make a copy.\r\n */\r\n public abstract write(dataBuffer: ArrayBuffer): void;\r\n\r\n /**\r\n * Closes the stream.\r\n * @member PushAudioInputStream.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public abstract close(): void;\r\n}\r\n\r\n/**\r\n * Represents memory backed push audio input stream used for custom audio input configurations.\r\n * @private\r\n * @class PushAudioInputStreamImpl\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class PushAudioInputStreamImpl extends PushAudioInputStream implements IAudioSource {\r\n\r\n private privFormat: AudioStreamFormatImpl;\r\n private privId: string;\r\n private privEvents: EventSource;\r\n private privStream: Stream;\r\n\r\n /**\r\n * Creates and initalizes an instance with the given values.\r\n * @constructor\r\n * @param {AudioStreamFormat} format - The audio stream format.\r\n */\r\n public constructor(format?: AudioStreamFormat) {\r\n super();\r\n if (format === undefined) {\r\n this.privFormat = AudioStreamFormatImpl.getDefaultInputFormat();\r\n } else {\r\n this.privFormat = format as AudioStreamFormatImpl;\r\n }\r\n this.privEvents = new EventSource();\r\n this.privId = createNoDashGuid();\r\n this.privStream = new ChunkedArrayBufferStream(this.privFormat.avgBytesPerSec / 10);\r\n }\r\n\r\n /**\r\n * Format information for the audio\r\n */\r\n public get format(): Promise {\r\n return PromiseHelper.fromResult(this.privFormat);\r\n }\r\n\r\n /**\r\n * Writes the audio data specified by making an internal copy of the data.\r\n * @member PushAudioInputStreamImpl.prototype.write\r\n * @function\r\n * @public\r\n * @param {ArrayBuffer} dataBuffer - The audio buffer of which this function will make a copy.\r\n */\r\n public write(dataBuffer: ArrayBuffer): void {\r\n this.privStream.writeStreamChunk({\r\n buffer: dataBuffer,\r\n isEnd: false,\r\n timeReceived: Date.now()\r\n });\r\n }\r\n\r\n /**\r\n * Closes the stream.\r\n * @member PushAudioInputStreamImpl.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(): void {\r\n this.privStream.close();\r\n }\r\n\r\n public id(): string {\r\n return this.privId;\r\n }\r\n\r\n public get blob(): Promise {\r\n return this.attach(\"id\").onSuccessContinueWithPromise((audioNode: IAudioStreamNode) => {\r\n const data: ArrayBuffer[] = [];\r\n let bufferData = Buffer.from(\"\");\r\n const readCycle = (): Promise => {\r\n return audioNode.read().onSuccessContinueWithPromise((audioStreamChunk: IStreamChunk) => {\r\n if (!audioStreamChunk || audioStreamChunk.isEnd) {\r\n if (typeof (XMLHttpRequest) !== \"undefined\") {\r\n return PromiseHelper.fromResult(new Blob(data));\r\n } else {\r\n return PromiseHelper.fromResult(Buffer.from(bufferData));\r\n }\r\n } else {\r\n if (typeof (Blob) !== \"undefined\") {\r\n data.push(audioStreamChunk.buffer);\r\n } else {\r\n bufferData = Buffer.concat([bufferData, this.toBuffer(audioStreamChunk.buffer)]);\r\n }\r\n return readCycle();\r\n }\r\n });\r\n };\r\n return readCycle();\r\n });\r\n }\r\n\r\n public turnOn(): Promise {\r\n this.onEvent(new AudioSourceInitializingEvent(this.privId)); // no stream id\r\n this.onEvent(new AudioSourceReadyEvent(this.privId));\r\n return PromiseHelper.fromResult(true);\r\n }\r\n\r\n public attach(audioNodeId: string): Promise {\r\n this.onEvent(new AudioStreamNodeAttachingEvent(this.privId, audioNodeId));\r\n\r\n return this.turnOn()\r\n .onSuccessContinueWith>((_: boolean) => {\r\n // For now we support a single parallel reader of the pushed stream.\r\n // So we can simiply hand the stream to the recognizer and let it recognize.\r\n\r\n return this.privStream;\r\n })\r\n .onSuccessContinueWith((stream: Stream) => {\r\n this.onEvent(new AudioStreamNodeAttachedEvent(this.privId, audioNodeId));\r\n\r\n return {\r\n detach: () => {\r\n stream.readEnded();\r\n this.onEvent(new AudioStreamNodeDetachedEvent(this.privId, audioNodeId));\r\n this.turnOff();\r\n },\r\n id: () => {\r\n return audioNodeId;\r\n },\r\n read: () => {\r\n return stream.read();\r\n },\r\n };\r\n });\r\n }\r\n\r\n public detach(audioNodeId: string): void {\r\n this.onEvent(new AudioStreamNodeDetachedEvent(this.privId, audioNodeId));\r\n }\r\n\r\n public turnOff(): Promise {\r\n return PromiseHelper.fromResult(false);\r\n }\r\n\r\n public get events(): EventSource {\r\n return this.privEvents;\r\n }\r\n\r\n public get deviceInfo(): Promise {\r\n return PromiseHelper.fromResult({\r\n bitspersample: this.privFormat.bitsPerSample,\r\n channelcount: this.privFormat.channels,\r\n connectivity: connectivity.Unknown,\r\n manufacturer: \"Speech SDK\",\r\n model: \"PushStream\",\r\n samplerate: this.privFormat.samplesPerSec,\r\n type: type.Stream,\r\n });\r\n }\r\n\r\n private onEvent = (event: AudioSourceEvent): void => {\r\n this.privEvents.onEvent(event);\r\n Events.instance.onEvent(event);\r\n }\r\n\r\n private toBuffer(arrayBuffer: ArrayBuffer): Buffer {\r\n const buf: Buffer = Buffer.alloc(arrayBuffer.byteLength);\r\n const view: Uint8Array = new Uint8Array(arrayBuffer);\r\n for (let i = 0; i < buf.length; ++i) {\r\n buf[i] = view[i];\r\n }\r\n return buf;\r\n }\r\n}\r\n\r\n/*\r\n * Represents audio input stream used for custom audio input configurations.\r\n * @class PullAudioInputStream\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport abstract class PullAudioInputStream extends AudioInputStream {\r\n /**\r\n * Creates and initializes and instance.\r\n * @constructor\r\n */\r\n protected constructor() { super(); }\r\n\r\n /**\r\n * Creates a PullAudioInputStream that delegates to the specified callback interface for\r\n * read() and close() methods, using the default format (16 kHz 16bit mono PCM).\r\n * @member PullAudioInputStream.create\r\n * @function\r\n * @public\r\n * @param {PullAudioInputStreamCallback} callback - The custom audio input object,\r\n * derived from PullAudioInputStreamCustomCallback\r\n * @param {AudioStreamFormat} format - The audio data format in which audio will be\r\n * returned from the callback's read() method (Required if format is not 16 kHz 16bit mono PCM).\r\n * @returns {PullAudioInputStream} The push audio input stream being created.\r\n */\r\n public static create(callback: PullAudioInputStreamCallback, format?: AudioStreamFormat): PullAudioInputStream {\r\n return new PullAudioInputStreamImpl(callback, format as AudioStreamFormatImpl);\r\n }\r\n\r\n /**\r\n * Explicitly frees any external resource attached to the object\r\n * @member PullAudioInputStream.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public abstract close(): void;\r\n\r\n}\r\n\r\n/**\r\n * Represents audio input stream used for custom audio input configurations.\r\n * @private\r\n * @class PullAudioInputStreamImpl\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class PullAudioInputStreamImpl extends PullAudioInputStream implements IAudioSource {\r\n\r\n private privCallback: PullAudioInputStreamCallback;\r\n private privFormat: AudioStreamFormatImpl;\r\n private privId: string;\r\n private privEvents: EventSource;\r\n private privIsClosed: boolean;\r\n private privBufferSize: number;\r\n\r\n /**\r\n * Creates a PullAudioInputStream that delegates to the specified callback interface for\r\n * read() and close() methods, using the default format (16 kHz 16bit mono PCM).\r\n * @constructor\r\n * @param {PullAudioInputStreamCallback} callback - The custom audio input object,\r\n * derived from PullAudioInputStreamCustomCallback\r\n * @param {AudioStreamFormat} format - The audio data format in which audio will be\r\n * returned from the callback's read() method (Required if format is not 16 kHz 16bit mono PCM).\r\n */\r\n public constructor(callback: PullAudioInputStreamCallback, format?: AudioStreamFormatImpl) {\r\n super();\r\n if (undefined === format) {\r\n this.privFormat = AudioStreamFormat.getDefaultInputFormat() as AudioStreamFormatImpl;\r\n } else {\r\n this.privFormat = format;\r\n }\r\n this.privEvents = new EventSource();\r\n this.privId = createNoDashGuid();\r\n this.privCallback = callback;\r\n this.privIsClosed = false;\r\n this.privBufferSize = this.privFormat.avgBytesPerSec / 10;\r\n }\r\n\r\n /**\r\n * Format information for the audio\r\n */\r\n public get format(): Promise {\r\n return PromiseHelper.fromResult(this.privFormat);\r\n }\r\n\r\n /**\r\n * Closes the stream.\r\n * @member PullAudioInputStreamImpl.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(): void {\r\n this.privIsClosed = true;\r\n this.privCallback.close();\r\n }\r\n\r\n public id(): string {\r\n return this.privId;\r\n }\r\n\r\n public get blob(): Promise {\r\n return PromiseHelper.fromError(\"Not implemented\");\r\n }\r\n\r\n public turnOn(): Promise {\r\n this.onEvent(new AudioSourceInitializingEvent(this.privId)); // no stream id\r\n this.onEvent(new AudioSourceReadyEvent(this.privId));\r\n return PromiseHelper.fromResult(true);\r\n }\r\n\r\n public attach(audioNodeId: string): Promise {\r\n this.onEvent(new AudioStreamNodeAttachingEvent(this.privId, audioNodeId));\r\n\r\n return this.turnOn()\r\n .onSuccessContinueWith((result: boolean) => {\r\n this.onEvent(new AudioStreamNodeAttachedEvent(this.privId, audioNodeId));\r\n\r\n return {\r\n detach: () => {\r\n this.privCallback.close();\r\n this.onEvent(new AudioStreamNodeDetachedEvent(this.privId, audioNodeId));\r\n this.turnOff();\r\n },\r\n id: () => {\r\n return audioNodeId;\r\n },\r\n read: (): Promise> => {\r\n let totalBytes: number = 0;\r\n let transmitBuff: ArrayBuffer;\r\n\r\n // Until we have the minimum number of bytes to send in a transmission, keep asking for more.\r\n while (totalBytes < this.privBufferSize) {\r\n // Sizing the read buffer to the delta between the perfect size and what's left means we won't ever get too much\r\n // data back.\r\n const readBuff: ArrayBuffer = new ArrayBuffer(this.privBufferSize - totalBytes);\r\n const pulledBytes: number = this.privCallback.read(readBuff);\r\n\r\n // If there is no return buffer yet defined, set the return buffer to the that was just populated.\r\n // This was, if we have enough data there's no copy penalty, but if we don't we have a buffer that's the\r\n // preferred size allocated.\r\n if (undefined === transmitBuff) {\r\n transmitBuff = readBuff;\r\n } else {\r\n // Not the first bite at the apple, so fill the return buffer with the data we got back.\r\n const intView: Int8Array = new Int8Array(transmitBuff);\r\n intView.set(new Int8Array(readBuff), totalBytes);\r\n }\r\n\r\n // If there are no bytes to read, just break out and be done.\r\n if (0 === pulledBytes) {\r\n break;\r\n }\r\n\r\n totalBytes += pulledBytes;\r\n }\r\n\r\n return PromiseHelper.fromResult>({\r\n buffer: transmitBuff.slice(0, totalBytes),\r\n isEnd: this.privIsClosed || totalBytes === 0,\r\n timeReceived: Date.now(),\r\n });\r\n },\r\n };\r\n });\r\n }\r\n\r\n public detach(audioNodeId: string): void {\r\n this.onEvent(new AudioStreamNodeDetachedEvent(this.privId, audioNodeId));\r\n }\r\n\r\n public turnOff(): Promise {\r\n return PromiseHelper.fromResult(false);\r\n }\r\n\r\n public get events(): EventSource {\r\n return this.privEvents;\r\n }\r\n\r\n public get deviceInfo(): Promise {\r\n return PromiseHelper.fromResult({\r\n bitspersample: this.privFormat.bitsPerSample,\r\n channelcount: this.privFormat.channels,\r\n connectivity: connectivity.Unknown,\r\n manufacturer: \"Speech SDK\",\r\n model: \"PullStream\",\r\n samplerate: this.privFormat.samplesPerSec,\r\n type: type.Stream,\r\n });\r\n }\r\n\r\n private onEvent = (event: AudioSourceEvent): void => {\r\n this.privEvents.onEvent(event);\r\n Events.instance.onEvent(event);\r\n }\r\n}\r\n","/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nvar base64 = require('base64-js')\nvar ieee754 = require('ieee754')\nvar isArray = require('isarray')\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return ''\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","'use strict'\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n","exports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * Represents audio stream format used for custom audio input configurations.\r\n * @class AudioStreamFormat\r\n */\r\nexport abstract class AudioStreamFormat {\r\n /**\r\n * Creates an audio stream format object representing the default audio stream\r\n * format (16KHz 16bit mono PCM).\r\n * @member AudioStreamFormat.getDefaultInputFormat\r\n * @function\r\n * @public\r\n * @returns {AudioStreamFormat} The audio stream format being created.\r\n */\r\n public static getDefaultInputFormat(): AudioStreamFormat {\r\n return AudioStreamFormatImpl.getDefaultInputFormat();\r\n }\r\n\r\n /**\r\n * Creates an audio stream format object with the specified pcm waveformat characteristics.\r\n * @member AudioStreamFormat.getWaveFormatPCM\r\n * @function\r\n * @public\r\n * @param {number} samplesPerSecond - Sample rate, in samples per second (Hertz).\r\n * @param {number} bitsPerSample - Bits per sample, typically 16.\r\n * @param {number} channels - Number of channels in the waveform-audio data. Monaural data\r\n * uses one channel and stereo data uses two channels.\r\n * @returns {AudioStreamFormat} The audio stream format being created.\r\n */\r\n public static getWaveFormatPCM(samplesPerSecond: number, bitsPerSample: number, channels: number): AudioStreamFormat {\r\n return new AudioStreamFormatImpl(samplesPerSecond, bitsPerSample, channels);\r\n }\r\n\r\n /**\r\n * Explicitly frees any external resource attached to the object\r\n * @member AudioStreamFormat.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public abstract close(): void;\r\n}\r\n\r\n/**\r\n * @private\r\n * @class AudioStreamFormatImpl\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class AudioStreamFormatImpl extends AudioStreamFormat {\r\n protected privHeader: ArrayBuffer;\r\n\r\n /**\r\n * Creates an instance with the given values.\r\n * @constructor\r\n * @param {number} samplesPerSec - Samples per second.\r\n * @param {number} bitsPerSample - Bits per sample.\r\n * @param {number} channels - Number of channels.\r\n */\r\n public constructor(samplesPerSec: number = 16000, bitsPerSample: number = 16, channels: number = 1) {\r\n super();\r\n this.formatTag = 1;\r\n this.bitsPerSample = bitsPerSample;\r\n this.samplesPerSec = samplesPerSec;\r\n this.channels = channels;\r\n this.avgBytesPerSec = this.samplesPerSec * this.channels * (this.bitsPerSample / 8);\r\n this.blockAlign = this.channels * Math.max(this.bitsPerSample, 8);\r\n\r\n this.privHeader = new ArrayBuffer(44);\r\n\r\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView\r\n const view = new DataView(this.privHeader);\r\n\r\n /* RIFF identifier */\r\n this.setString(view, 0, \"RIFF\");\r\n /* file length */\r\n view.setUint32(4, 0, true);\r\n /* RIFF type & Format */\r\n this.setString(view, 8, \"WAVEfmt \");\r\n /* format chunk length */\r\n view.setUint32(16, 16, true);\r\n /* sample format (raw) */\r\n view.setUint16(20, 1, true);\r\n /* channel count */\r\n view.setUint16(22, this.channels, true);\r\n /* sample rate */\r\n view.setUint32(24, this.samplesPerSec, true);\r\n /* byte rate (sample rate * block align) */\r\n view.setUint32(28, this.avgBytesPerSec, true);\r\n /* block align (channel count * bytes per sample) */\r\n view.setUint16(32, this.channels * (this.bitsPerSample / 8), true);\r\n /* bits per sample */\r\n view.setUint16(34, this.bitsPerSample, true);\r\n /* data chunk identifier */\r\n this.setString(view, 36, \"data\");\r\n /* data chunk length */\r\n view.setUint32(40, 0, true);\r\n }\r\n\r\n /**\r\n * Retrieves the default input format.\r\n * @member AudioStreamFormatImpl.getDefaultInputFormat\r\n * @function\r\n * @public\r\n * @returns {AudioStreamFormatImpl} The default input format.\r\n */\r\n public static getDefaultInputFormat(): AudioStreamFormatImpl {\r\n return new AudioStreamFormatImpl();\r\n }\r\n\r\n /**\r\n * Closes the configuration object.\r\n * @member AudioStreamFormatImpl.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(): void { return; }\r\n\r\n /**\r\n * The format of the audio, valid values: 1 (PCM)\r\n * @member AudioStreamFormatImpl.prototype.formatTag\r\n * @function\r\n * @public\r\n */\r\n public formatTag: number;\r\n\r\n /**\r\n * The number of channels, valid values: 1 (Mono).\r\n * @member AudioStreamFormatImpl.prototype.channels\r\n * @function\r\n * @public\r\n */\r\n public channels: number;\r\n\r\n /**\r\n * The sample rate, valid values: 16000.\r\n * @member AudioStreamFormatImpl.prototype.samplesPerSec\r\n * @function\r\n * @public\r\n */\r\n public samplesPerSec: number;\r\n\r\n /**\r\n * The bits per sample, valid values: 16\r\n * @member AudioStreamFormatImpl.prototype.b\r\n * @function\r\n * @public\r\n */\r\n public bitsPerSample: number;\r\n\r\n /**\r\n * Average bytes per second, usually calculated as nSamplesPerSec * nChannels * ceil(wBitsPerSample, 8).\r\n * @member AudioStreamFormatImpl.prototype.avgBytesPerSec\r\n * @function\r\n * @public\r\n */\r\n public avgBytesPerSec: number;\r\n\r\n /**\r\n * The size of a single frame, valid values: nChannels * ceil(wBitsPerSample, 8).\r\n * @member AudioStreamFormatImpl.prototype.blockAlign\r\n * @function\r\n * @public\r\n */\r\n public blockAlign: number;\r\n\r\n public get header(): ArrayBuffer {\r\n return this.privHeader;\r\n }\r\n\r\n protected setString = (view: DataView, offset: number, str: string): void => {\r\n for (let i = 0; i < str.length; i++) {\r\n view.setUint8(offset + i, str.charCodeAt(i));\r\n }\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n createNoDashGuid,\r\n Deferred,\r\n IAudioDestination,\r\n IStreamChunk,\r\n Promise,\r\n PromiseHelper,\r\n Stream,\r\n} from \"../../common/Exports\";\r\nimport {Contracts} from \"../Contracts\";\r\nimport {\r\n AudioStreamFormat,\r\n PushAudioOutputStreamCallback\r\n} from \"../Exports\";\r\nimport { AudioOutputFormatImpl } from \"./AudioOutputFormat\";\r\n\r\n/**\r\n * Represents audio output stream used for custom audio output configurations.\r\n * @class AudioOutputStream\r\n */\r\nexport abstract class AudioOutputStream {\r\n\r\n /**\r\n * Creates and initializes an instance.\r\n * @constructor\r\n */\r\n protected constructor() { }\r\n\r\n /**\r\n * Sets the format of the AudioOutputStream\r\n * Note: the format is set by the synthesizer before writing. Do not set it before passing it to AudioConfig\r\n * @member AudioOutputStream.prototype.format\r\n */\r\n public abstract set format(format: AudioStreamFormat);\r\n\r\n /**\r\n * Creates a memory backed PullAudioOutputStream with the specified audio format.\r\n * @member AudioOutputStream.createPullStream\r\n * @function\r\n * @public\r\n * @returns {PullAudioOutputStream} The audio output stream being created.\r\n */\r\n public static createPullStream(): PullAudioOutputStream {\r\n return PullAudioOutputStream.create();\r\n }\r\n\r\n /**\r\n * Explicitly frees any external resource attached to the object\r\n * @member AudioOutputStream.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public abstract close(): void;\r\n}\r\n\r\n/**\r\n * Represents memory backed push audio output stream used for custom audio output configurations.\r\n * @class PullAudioOutputStream\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport abstract class PullAudioOutputStream extends AudioOutputStream {\r\n\r\n /**\r\n * Creates a memory backed PullAudioOutputStream with the specified audio format.\r\n * @member PullAudioOutputStream.create\r\n * @function\r\n * @public\r\n * @returns {PullAudioOutputStream} The push audio output stream being created.\r\n */\r\n public static create(): PullAudioOutputStream {\r\n return new PullAudioOutputStreamImpl();\r\n }\r\n\r\n /**\r\n * Reads audio data from the internal buffer.\r\n * @member PullAudioOutputStream.prototype.read\r\n * @function\r\n * @public\r\n * @param {ArrayBuffer} dataBuffer - An ArrayBuffer to store the read data.\r\n * @returns {Promise} Audio buffer length has been read.\r\n */\r\n public abstract read(dataBuffer: ArrayBuffer): Promise;\r\n\r\n /**\r\n * Closes the stream.\r\n * @member PullAudioOutputStream.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public abstract close(): void;\r\n}\r\n\r\n/**\r\n * Represents memory backed push audio output stream used for custom audio output configurations.\r\n * @private\r\n * @class PullAudioOutputStreamImpl\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class PullAudioOutputStreamImpl extends PullAudioOutputStream implements IAudioDestination {\r\n private privFormat: AudioOutputFormatImpl;\r\n private privId: string;\r\n private privStream: Stream;\r\n private privLastChunkView: Int8Array;\r\n\r\n /**\r\n * Creates and initializes an instance with the given values.\r\n * @constructor\r\n */\r\n public constructor() {\r\n super();\r\n this.privId = createNoDashGuid();\r\n this.privStream = new Stream();\r\n }\r\n\r\n /**\r\n * Sets the format information to the stream. For internal use only.\r\n * @param {AudioStreamFormat} format - the format to be set.\r\n */\r\n public set format(format: AudioStreamFormat) {\r\n if (format === undefined || format === null) {\r\n this.privFormat = AudioOutputFormatImpl.getDefaultOutputFormat();\r\n }\r\n this.privFormat = format as AudioOutputFormatImpl;\r\n }\r\n\r\n /**\r\n * Format information for the audio\r\n */\r\n public get format(): AudioStreamFormat {\r\n return this.privFormat;\r\n }\r\n\r\n /**\r\n * Checks if the stream is closed\r\n * @member PullAudioOutputStreamImpl.prototype.isClosed\r\n * @property\r\n * @public\r\n */\r\n public get isClosed(): boolean {\r\n return this.privStream.isClosed;\r\n }\r\n\r\n /**\r\n * Gets the id of the stream\r\n * @member PullAudioOutputStreamImpl.prototype.id\r\n * @property\r\n * @public\r\n */\r\n public id(): string {\r\n return this.privId;\r\n }\r\n\r\n /**\r\n * Reads audio data from the internal buffer.\r\n * @member PullAudioOutputStreamImpl.prototype.read\r\n * @function\r\n * @public\r\n * @param {ArrayBuffer} dataBuffer - An ArrayBuffer to store the read data.\r\n * @returns {Promise} - Audio buffer length has been read.\r\n */\r\n public read(dataBuffer: ArrayBuffer): Promise {\r\n const intView: Int8Array = new Int8Array(dataBuffer);\r\n let totalBytes: number = 0;\r\n\r\n if (this.privLastChunkView !== undefined) {\r\n if (this.privLastChunkView.length > dataBuffer.byteLength) {\r\n intView.set(this.privLastChunkView.slice(0, dataBuffer.byteLength));\r\n this.privLastChunkView = this.privLastChunkView.slice(dataBuffer.byteLength);\r\n return PromiseHelper.fromResult(dataBuffer.byteLength);\r\n }\r\n intView.set(this.privLastChunkView);\r\n totalBytes = this.privLastChunkView.length;\r\n this.privLastChunkView = undefined;\r\n }\r\n\r\n const deffer: Deferred = new Deferred();\r\n // Until we have the minimum number of bytes to send in a transmission, keep asking for more.\r\n const readUntilFilled: () => void = (): void => {\r\n if (totalBytes < dataBuffer.byteLength && !this.privStream.isReadEnded) {\r\n this.privStream.read()\r\n .onSuccessContinueWith((chunk: IStreamChunk) => {\r\n if (chunk !== undefined && !chunk.isEnd) {\r\n let tmpBuffer: ArrayBuffer;\r\n if (chunk.buffer.byteLength > dataBuffer.byteLength - totalBytes) {\r\n tmpBuffer = chunk.buffer.slice(0, dataBuffer.byteLength - totalBytes);\r\n this.privLastChunkView = new Int8Array(chunk.buffer.slice(dataBuffer.byteLength - totalBytes));\r\n } else {\r\n tmpBuffer = chunk.buffer;\r\n }\r\n intView.set(new Int8Array(tmpBuffer), totalBytes);\r\n totalBytes += tmpBuffer.byteLength;\r\n readUntilFilled();\r\n } else {\r\n this.privStream.readEnded();\r\n deffer.resolve(totalBytes);\r\n }\r\n });\r\n } else {\r\n deffer.resolve(totalBytes);\r\n }\r\n };\r\n readUntilFilled();\r\n return deffer.promise();\r\n }\r\n\r\n /**\r\n * Writes the audio data specified by making an internal copy of the data.\r\n * @member PullAudioOutputStreamImpl.prototype.write\r\n * @function\r\n * @public\r\n * @param {ArrayBuffer} dataBuffer - The audio buffer of which this function will make a copy.\r\n */\r\n public write(dataBuffer: ArrayBuffer): void {\r\n Contracts.throwIfNullOrUndefined(this.privStream, \"must set format before writing\");\r\n this.privStream.writeStreamChunk({\r\n buffer: dataBuffer,\r\n isEnd: false,\r\n timeReceived: Date.now()\r\n });\r\n }\r\n\r\n /**\r\n * Closes the stream.\r\n * @member PullAudioOutputStreamImpl.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(): void {\r\n this.privStream.close();\r\n }\r\n}\r\n\r\n/*\r\n * Represents audio output stream used for custom audio output configurations.\r\n * @class PushAudioOutputStream\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport abstract class PushAudioOutputStream extends AudioOutputStream {\r\n /**\r\n * Creates and initializes and instance.\r\n * @constructor\r\n */\r\n protected constructor() { super(); }\r\n\r\n /**\r\n * Creates a PushAudioOutputStream that delegates to the specified callback interface for\r\n * write() and close() methods.\r\n * @member PushAudioOutputStream.create\r\n * @function\r\n * @public\r\n * @param {PushAudioOutputStreamCallback} callback - The custom audio output object,\r\n * derived from PushAudioOutputStreamCallback\r\n * @returns {PushAudioOutputStream} The push audio output stream being created.\r\n */\r\n public static create(callback: PushAudioOutputStreamCallback): PushAudioOutputStream {\r\n return new PushAudioOutputStreamImpl(callback);\r\n }\r\n\r\n /**\r\n * Explicitly frees any external resource attached to the object\r\n * @member PushAudioOutputStream.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public abstract close(): void;\r\n\r\n}\r\n\r\n/**\r\n * Represents audio output stream used for custom audio output configurations.\r\n * @private\r\n * @class PushAudioOutputStreamImpl\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class PushAudioOutputStreamImpl extends PushAudioOutputStream implements IAudioDestination {\r\n private readonly privId: string;\r\n private privCallback: PushAudioOutputStreamCallback;\r\n\r\n /**\r\n * Creates a PushAudioOutputStream that delegates to the specified callback interface for\r\n * read() and close() methods.\r\n * @constructor\r\n * @param {PushAudioOutputStreamCallback} callback - The custom audio output object,\r\n * derived from PushAudioOutputStreamCallback\r\n */\r\n public constructor(callback: PushAudioOutputStreamCallback) {\r\n super();\r\n this.privId = createNoDashGuid();\r\n this.privCallback = callback;\r\n }\r\n\r\n // tslint:disable-next-line:no-empty\r\n public set format(format: AudioStreamFormat) {}\r\n\r\n public write(buffer: ArrayBuffer): void {\r\n if (!!this.privCallback.write) {\r\n this.privCallback.write(buffer);\r\n }\r\n }\r\n\r\n public close(): void {\r\n if (!!this.privCallback.close) {\r\n this.privCallback.close();\r\n }\r\n }\r\n\r\n public id(): string {\r\n return this.privId;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { INumberDictionary } from \"../../common/Exports\";\r\nimport { SpeechSynthesisOutputFormat } from \"../SpeechSynthesisOutputFormat\";\r\nimport { AudioStreamFormatImpl } from \"./AudioStreamFormat\";\r\n\r\nexport enum AudioFormatTag {\r\n PCM = 1,\r\n MuLaw,\r\n Siren,\r\n MP3,\r\n SILKSkype,\r\n Opus,\r\n}\r\n\r\n/**\r\n * @private\r\n * @class AudioOutputFormatImpl\r\n * Added in version 1.11.0\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class AudioOutputFormatImpl extends AudioStreamFormatImpl {\r\n public static SpeechSynthesisOutputFormatToString: INumberDictionary = {\r\n [SpeechSynthesisOutputFormat.Raw8Khz8BitMonoMULaw]: \"raw-8khz-8bit-mono-mulaw\",\r\n [SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren]: \"riff-16khz-16kbps-mono-siren\",\r\n [SpeechSynthesisOutputFormat.Audio16Khz16KbpsMonoSiren]: \"audio-16khz-16kbps-mono-siren\",\r\n [SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3]: \"audio-16khz-32kbitrate-mono-mp3\",\r\n [SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3]: \"audio-16khz-128kbitrate-mono-mp3\",\r\n [SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3]: \"audio-16khz-64kbitrate-mono-mp3\",\r\n [SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3]: \"audio-24khz-48kbitrate-mono-mp3\",\r\n [SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3]: \"audio-24khz-96kbitrate-mono-mp3\",\r\n [SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3]: \"audio-24khz-160kbitrate-mono-mp3\",\r\n [SpeechSynthesisOutputFormat.Raw16Khz16BitMonoTrueSilk]: \"raw-16khz-16bit-mono-truesilk\",\r\n [SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm]: \"riff-16khz-16bit-mono-pcm\",\r\n [SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm]: \"riff-8khz-16bit-mono-pcm\",\r\n [SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm]: \"riff-24khz-16bit-mono-pcm\",\r\n [SpeechSynthesisOutputFormat.Riff8Khz8BitMonoMULaw]: \"riff-8khz-8bit-mono-mulaw\",\r\n [SpeechSynthesisOutputFormat.Raw16Khz16BitMonoPcm]: \"raw-16khz-16bit-mono-pcm\",\r\n [SpeechSynthesisOutputFormat.Raw24Khz16BitMonoPcm]: \"raw-24khz-16bit-mono-pcm\",\r\n [SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm]: \"raw-8khz-16bit-mono-pcm\",\r\n [SpeechSynthesisOutputFormat.Ogg16Khz16BitMonoOpus]: \"ogg-16khz-16bit-mono-opus\",\r\n [SpeechSynthesisOutputFormat.Ogg24Khz16BitMonoOpus]: \"ogg-24khz-16bit-mono-opus\",\r\n };\r\n private priAudioFormatString: string;\r\n /**\r\n * audio format string for synthesis request, which may differ from priAudioFormatString.\r\n * e.g. for riff format, we will request raw format and add a header in SDK side.\r\n */\r\n private readonly priRequestAudioFormatString: string;\r\n private readonly priHasHeader: boolean;\r\n\r\n /**\r\n * Creates an instance with the given values.\r\n * @constructor\r\n * @param formatTag\r\n * @param {number} samplesPerSec - Samples per second.\r\n * @param {number} bitsPerSample - Bits per sample.\r\n * @param {number} channels - Number of channels.\r\n * @param avgBytesPerSec\r\n * @param blockAlign\r\n * @param audioFormatString\r\n * @param requestAudioFormatString\r\n * @param hasHeader\r\n */\r\n public constructor(formatTag: AudioFormatTag,\r\n channels: number,\r\n samplesPerSec: number,\r\n avgBytesPerSec: number,\r\n blockAlign: number,\r\n bitsPerSample: number,\r\n audioFormatString: string,\r\n requestAudioFormatString: string,\r\n hasHeader: boolean) {\r\n super(samplesPerSec, bitsPerSample, channels);\r\n this.formatTag = formatTag;\r\n this.avgBytesPerSec = avgBytesPerSec;\r\n this.blockAlign = blockAlign;\r\n this.priAudioFormatString = audioFormatString;\r\n this.priRequestAudioFormatString = requestAudioFormatString;\r\n this.priHasHeader = hasHeader;\r\n }\r\n\r\n public static fromSpeechSynthesisOutputFormat(speechSynthesisOutputFormat?: SpeechSynthesisOutputFormat): AudioOutputFormatImpl {\r\n if (speechSynthesisOutputFormat === undefined) {\r\n return AudioOutputFormatImpl.getDefaultOutputFormat();\r\n }\r\n return AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString(\r\n AudioOutputFormatImpl.SpeechSynthesisOutputFormatToString[speechSynthesisOutputFormat]);\r\n }\r\n\r\n public static fromSpeechSynthesisOutputFormatString(speechSynthesisOutputFormatString: string): AudioOutputFormatImpl {\r\n switch (speechSynthesisOutputFormatString) {\r\n case \"raw-8khz-8bit-mono-mulaw\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.PCM,\r\n 1,\r\n 8000,\r\n 8000,\r\n 1,\r\n 8,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"riff-16khz-16kbps-mono-siren\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.Siren,\r\n 1,\r\n 16000,\r\n 2000,\r\n 40,\r\n 0,\r\n speechSynthesisOutputFormatString,\r\n \"audio-16khz-16kbps-mono-siren\",\r\n true);\r\n case \"audio-16khz-16kbps-mono-siren\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.Siren,\r\n 1,\r\n 16000,\r\n 2000,\r\n 40,\r\n 0,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"audio-16khz-32kbitrate-mono-mp3\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.MP3,\r\n 1,\r\n 16000,\r\n 32 << 7,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"audio-16khz-128kbitrate-mono-mp3\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.MP3,\r\n 1,\r\n 16000,\r\n 128 << 7,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"audio-16khz-64kbitrate-mono-mp3\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.MP3,\r\n 1,\r\n 16000,\r\n 64 << 7,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"audio-24khz-48kbitrate-mono-mp3\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.MP3,\r\n 1,\r\n 16000,\r\n 48 << 7,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"audio-24khz-96kbitrate-mono-mp3\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.MP3,\r\n 1,\r\n 16000,\r\n 96 << 7,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"audio-24khz-160kbitrate-mono-mp3\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.MP3,\r\n 1,\r\n 16000,\r\n 160 << 7,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"raw-16khz-16bit-mono-truesilk\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.SILKSkype,\r\n 1,\r\n 16000,\r\n 32000,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n\r\n case \"riff-8khz-16bit-mono-pcm\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.PCM,\r\n 1,\r\n 8000,\r\n 16000,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n \"raw-8khz-16bit-mono-pcm\",\r\n true);\r\n case \"riff-24khz-16bit-mono-pcm\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.PCM,\r\n 1,\r\n 24000,\r\n 48000,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n \"raw-24khz-16bit-mono-pcm\",\r\n true);\r\n case \"riff-8khz-8bit-mono-mulaw\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.MuLaw,\r\n 1,\r\n 8000,\r\n 8000,\r\n 1,\r\n 8,\r\n speechSynthesisOutputFormatString,\r\n \"raw-8khz-8bit-mono-mulaw\",\r\n true);\r\n case \"raw-16khz-16bit-mono-pcm\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.PCM,\r\n 1,\r\n 16000,\r\n 32000,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n \"raw-16khz-16bit-mono-pcm\",\r\n false);\r\n case \"raw-24khz-16bit-mono-pcm\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.PCM,\r\n 1,\r\n 24000,\r\n 48000,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n \"raw-24khz-16bit-mono-pcm\",\r\n false);\r\n case \"raw-8khz-16bit-mono-pcm\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.PCM,\r\n 1,\r\n 8000,\r\n 16000,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n \"raw-8khz-16bit-mono-pcm\",\r\n false);\r\n case \"ogg-16khz-16bit-mono-opus\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.Opus,\r\n 1,\r\n 16000,\r\n 8192,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n \"ogg-16khz-16bit-mono-opus\",\r\n false);\r\n case \"ogg-24khz-16bit-mono-opus\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.Opus,\r\n 1,\r\n 24000,\r\n 8192,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n \"ogg-24khz-16bit-mono-opus\",\r\n false);\r\n case \"riff-16khz-16bit-mono-pcm\":\r\n default:\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.PCM,\r\n 1,\r\n 16000,\r\n 32000,\r\n 2,\r\n 16,\r\n \"riff-16khz-16bit-mono-pcm\",\r\n \"raw-16khz-16bit-mono-pcm\",\r\n true);\r\n }\r\n }\r\n\r\n public static getDefaultOutputFormat(): AudioOutputFormatImpl {\r\n return AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString(\r\n (typeof window !== \"undefined\") ? \"audio-24khz-48kbitrate-mono-mp3\" : \"riff-16khz-16bit-mono-pcm\");\r\n }\r\n\r\n /**\r\n * The format tag of the audio\r\n * @AudioFormatTag AudioOutputFormatImpl.prototype.formatTag\r\n * @function\r\n * @public\r\n */\r\n public formatTag: AudioFormatTag;\r\n\r\n /**\r\n * Specifies if this audio output format has a header\r\n * @boolean AudioOutputFormatImpl.prototype.hasHeader\r\n * @function\r\n * @public\r\n */\r\n public get hasHeader(): boolean {\r\n return this.priHasHeader;\r\n }\r\n\r\n /**\r\n * Specifies the header of this format\r\n * @ArrayBuffer AudioOutputFormatImpl.prototype.header\r\n * @function\r\n * @public\r\n */\r\n public get header(): ArrayBuffer {\r\n if (this.hasHeader) {\r\n return this.privHeader;\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Updates the header based on the audio length\r\n * @member AudioOutputFormatImpl.updateHeader\r\n * @function\r\n * @public\r\n * @param {number} audioLength - the audio length\r\n */\r\n public updateHeader(audioLength: number): void {\r\n if (this.priHasHeader) {\r\n const view = new DataView(this.privHeader);\r\n view.setUint32(40, audioLength, true);\r\n }\r\n }\r\n\r\n /**\r\n * Specifies the audio format string to be sent to the service\r\n * @string AudioOutputFormatImpl.prototype.requestAudioFormatString\r\n * @function\r\n * @public\r\n */\r\n public get requestAudioFormatString(): string {\r\n return this.priRequestAudioFormatString;\r\n }\r\n\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * Define speech synthesis audio output formats.\r\n * @enum SpeechSynthesisOutputFormat\r\n * Added in version 1.11.0\r\n */\r\nexport enum SpeechSynthesisOutputFormat {\r\n /**\r\n * raw-8khz-8bit-mono-mulaw\r\n * @member SpeechSynthesisOutputFormat.Raw8Khz8BitMonoMULaw,\r\n */\r\n Raw8Khz8BitMonoMULaw,\r\n\r\n /**\r\n * riff-16khz-16kbps-mono-siren\r\n * @member SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren\r\n */\r\n Riff16Khz16KbpsMonoSiren ,\r\n\r\n /**\r\n * audio-16khz-16kbps-mono-siren\r\n * @member SpeechSynthesisOutputFormat.Audio16Khz16KbpsMonoSiren\r\n */\r\n Audio16Khz16KbpsMonoSiren,\r\n\r\n /**\r\n * audio-16khz-32kbitrate-mono-mp3\r\n * @member SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3\r\n */\r\n Audio16Khz32KBitRateMonoMp3,\r\n\r\n /**\r\n * audio-16khz-128kbitrate-mono-mp3\r\n * @member SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3\r\n */\r\n Audio16Khz128KBitRateMonoMp3,\r\n\r\n /**\r\n * audio-16khz-64kbitrate-mono-mp3\r\n * @member SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3\r\n */\r\n Audio16Khz64KBitRateMonoMp3,\r\n\r\n /**\r\n * audio-24khz-48kbitrate-mono-mp3\r\n * @member SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3\r\n */\r\n Audio24Khz48KBitRateMonoMp3,\r\n\r\n /**\r\n * audio-24khz-96kbitrate-mono-mp3\r\n * @member SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3\r\n */\r\n Audio24Khz96KBitRateMonoMp3,\r\n\r\n /**\r\n * audio-24khz-160kbitrate-mono-mp3\r\n * @member SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3\r\n */\r\n Audio24Khz160KBitRateMonoMp3,\r\n\r\n /**\r\n * raw-16khz-16bit-mono-truesilk\r\n * @member SpeechSynthesisOutputFormat.Raw16Khz16BitMonoTrueSilk\r\n */\r\n Raw16Khz16BitMonoTrueSilk,\r\n\r\n /**\r\n * riff-16khz-16bit-mono-pcm\r\n * @member SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm\r\n */\r\n Riff16Khz16BitMonoPcm,\r\n\r\n /**\r\n * riff-8khz-16bit-mono-pcm\r\n * @member SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm\r\n */\r\n Riff8Khz16BitMonoPcm,\r\n\r\n /**\r\n * riff-24khz-16bit-mono-pcm\r\n * @member SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm\r\n */\r\n Riff24Khz16BitMonoPcm,\r\n\r\n /**\r\n * riff-8khz-8bit-mono-mulaw\r\n * @member SpeechSynthesisOutputFormat.Riff8Khz8BitMonoMULaw\r\n */\r\n Riff8Khz8BitMonoMULaw,\r\n\r\n /**\r\n * raw-16khz-16bit-mono-pcm\r\n * @member SpeechSynthesisOutputFormat.Raw16Khz16BitMonoPcm\r\n */\r\n Raw16Khz16BitMonoPcm,\r\n\r\n /**\r\n * raw-24khz-16bit-mono-pcm\r\n * @member SpeechSynthesisOutputFormat.Raw24Khz16BitMonoPcm\r\n */\r\n Raw24Khz16BitMonoPcm,\r\n\r\n /**\r\n * raw-8khz-16bit-mono-pcm\r\n * @member SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm\r\n */\r\n Raw8Khz16BitMonoPcm,\r\n\r\n /**\r\n * ogg-16khz-16bit-mono-opus\r\n * @member SpeechSynthesisOutputFormat.Ogg16Khz16BitMonoOpus\r\n */\r\n Ogg16Khz16BitMonoOpus,\r\n\r\n /**\r\n * ogg-24khz-16bit-mono-opus\r\n * @member SpeechSynthesisOutputFormat.Ogg24Khz16BitMonoOpus\r\n */\r\n Ogg24Khz16BitMonoOpus,\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * Defines the possible reasons a recognition result might be canceled.\r\n * @class CancellationReason\r\n */\r\nexport enum CancellationReason {\r\n /**\r\n * Indicates that an error occurred during speech recognition.\r\n * @member CancellationReason.Error\r\n */\r\n Error,\r\n\r\n /**\r\n * Indicates that the end of the audio stream was reached.\r\n * @member CancellationReason.EndOfStream\r\n */\r\n EndOfStream,\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n /**\r\n * An abstract base class that defines callback methods (read() and close()) for\r\n * custom audio input streams).\r\n * @class PullAudioInputStreamCallback\r\n */\r\nexport abstract class PullAudioInputStreamCallback {\r\n\r\n /**\r\n * Reads data from audio input stream into the data buffer. The maximal number of bytes\r\n * to be read is determined by the size of dataBuffer.\r\n * @member PullAudioInputStreamCallback.prototype.read\r\n * @function\r\n * @public\r\n * @param {ArrayBuffer} dataBuffer - The byte array to store the read data.\r\n * @returns {number} the number of bytes have been read.\r\n */\r\n public abstract read(dataBuffer: ArrayBuffer): number;\r\n\r\n /**\r\n * Closes the audio input stream.\r\n * @member PullAudioInputStreamCallback.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public abstract close(): void;\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n/**\r\n * An abstract base class that defines callback methods (write() and close()) for\r\n * custom audio output streams).\r\n * @class PushAudioOutputStreamCallback\r\n */\r\nexport abstract class PushAudioOutputStreamCallback {\r\n\r\n /**\r\n * Writes audio data into the data buffer.\r\n * @member PushAudioOutputStreamCallback.prototype.write\r\n * @function\r\n * @public\r\n * @param {ArrayBuffer} dataBuffer - The byte array that stores the audio data to write.\r\n */\r\n public abstract write(dataBuffer: ArrayBuffer): void;\r\n\r\n /**\r\n * Closes the audio output stream.\r\n * @member PushAudioOutputStreamCallback.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public abstract close(): void;\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { Contracts } from \"./Contracts\";\r\n\r\n/**\r\n * Represents a keyword recognition model for recognizing when\r\n * the user says a keyword to initiate further speech recognition.\r\n * @class KeywordRecognitionModel\r\n */\r\nexport class KeywordRecognitionModel {\r\n private privDisposed: boolean = false;\r\n\r\n /**\r\n * Create and initializes a new instance.\r\n * @constructor\r\n */\r\n private constructor() {\r\n }\r\n\r\n /**\r\n * Creates a keyword recognition model using the specified filename.\r\n * @member KeywordRecognitionModel.fromFile\r\n * @function\r\n * @public\r\n * @param {string} fileName - A string that represents file name for the keyword recognition model.\r\n * Note, the file can point to a zip file in which case the model\r\n * will be extracted from the zip.\r\n * @returns {KeywordRecognitionModel} The keyword recognition model being created.\r\n */\r\n public static fromFile(fileName: string): KeywordRecognitionModel {\r\n Contracts.throwIfFileDoesNotExist(fileName, \"fileName\");\r\n\r\n throw new Error(\"Not yet implemented.\");\r\n }\r\n\r\n /**\r\n * Creates a keyword recognition model using the specified filename.\r\n * @member KeywordRecognitionModel.fromStream\r\n * @function\r\n * @public\r\n * @param {string} file - A File that represents file for the keyword recognition model.\r\n * Note, the file can point to a zip file in which case the model will be extracted from the zip.\r\n * @returns {KeywordRecognitionModel} The keyword recognition model being created.\r\n */\r\n public static fromStream(file: File): KeywordRecognitionModel {\r\n Contracts.throwIfNull(file, \"file\");\r\n\r\n throw new Error(\"Not yet implemented.\");\r\n }\r\n\r\n /**\r\n * Dispose of associated resources.\r\n * @member KeywordRecognitionModel.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(): void {\r\n if (this.privDisposed) {\r\n return;\r\n }\r\n\r\n this.privDisposed = true;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * Defines content for session events like SessionStarted/Stopped, SoundStarted/Stopped.\r\n * @class SessionEventArgs\r\n */\r\nexport class SessionEventArgs {\r\n private privSessionId: string;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {string} sessionId - The session id.\r\n */\r\n public constructor(sessionId: string) {\r\n this.privSessionId = sessionId;\r\n }\r\n\r\n /**\r\n * Represents the session identifier.\r\n * @member SessionEventArgs.prototype.sessionId\r\n * @function\r\n * @public\r\n * @returns {string} Represents the session identifier.\r\n */\r\n public get sessionId(): string {\r\n return this.privSessionId;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { SessionEventArgs } from \"./Exports\";\r\n\r\n/**\r\n * Defines payload for session events like Speech Start/End Detected\r\n * @class\r\n */\r\nexport class RecognitionEventArgs extends SessionEventArgs {\r\n private privOffset: number;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {number} offset - The offset.\r\n * @param {string} sessionId - The session id.\r\n */\r\n public constructor(offset: number, sessionId?: string) {\r\n super(sessionId);\r\n\r\n this.privOffset = offset;\r\n }\r\n\r\n /**\r\n * Represents the message offset\r\n * @member RecognitionEventArgs.prototype.offset\r\n * @function\r\n * @public\r\n */\r\n public get offset(): number {\r\n return this.privOffset;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * Define Speech Recognizer output formats.\r\n * @class OutputFormat\r\n */\r\nexport enum OutputFormat {\r\n /**\r\n * @member OutputFormat.Simple\r\n */\r\n Simple = 0,\r\n\r\n /**\r\n * @member OutputFormat.Detailed\r\n */\r\n Detailed,\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { IntentRecognitionResult, RecognitionEventArgs } from \"./Exports\";\r\n\r\n/**\r\n * Intent recognition result event arguments.\r\n * @class\r\n */\r\nexport class IntentRecognitionEventArgs extends RecognitionEventArgs {\r\n private privResult: IntentRecognitionResult;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param result - The result of the intent recognition.\r\n * @param offset - The offset.\r\n * @param sessionId - The session id.\r\n */\r\n public constructor(result: IntentRecognitionResult, offset?: number, sessionId?: string) {\r\n super(offset, sessionId);\r\n\r\n this.privResult = result;\r\n }\r\n\r\n /**\r\n * Represents the intent recognition result.\r\n * @member IntentRecognitionEventArgs.prototype.result\r\n * @function\r\n * @public\r\n * @returns {IntentRecognitionResult} Represents the intent recognition result.\r\n */\r\n public get result(): IntentRecognitionResult {\r\n return this.privResult;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { PropertyCollection, ResultReason } from \"./Exports\";\r\n\r\n/**\r\n * Defines result of speech recognition.\r\n * @class RecognitionResult\r\n */\r\nexport class RecognitionResult {\r\n private privResultId: string;\r\n private privReason: ResultReason;\r\n private privText: string;\r\n private privDuration: number;\r\n private privOffset: number;\r\n private privLanguage: string;\r\n private privLanguageDetectionConfidence: string;\r\n private privErrorDetails: string;\r\n private privJson: string;\r\n private privProperties: PropertyCollection;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {string} resultId - The result id.\r\n * @param {ResultReason} reason - The reason.\r\n * @param {string} text - The recognized text.\r\n * @param {number} duration - The duration.\r\n * @param {number} offset - The offset into the stream.\r\n * @param {string} language - Primary Language detected, if provided.\r\n * @param {string} languageDetectionConfidence - Primary Language confidence (\"Unknown,\" \"Low,\" \"Medium,\" \"High\"...), if provided.\r\n * @param {string} errorDetails - Error details, if provided.\r\n * @param {string} json - Additional Json, if provided.\r\n * @param {PropertyCollection} properties - Additional properties, if provided.\r\n */\r\n constructor(resultId?: string, reason?: ResultReason, text?: string, duration?: number,\r\n offset?: number, language?: string, languageDetectionConfidence?: string, errorDetails?: string, json?: string, properties?: PropertyCollection) {\r\n this.privResultId = resultId;\r\n this.privReason = reason;\r\n this.privText = text;\r\n this.privDuration = duration;\r\n this.privOffset = offset;\r\n this.privLanguage = language;\r\n this.privLanguageDetectionConfidence = languageDetectionConfidence;\r\n this.privErrorDetails = errorDetails;\r\n this.privJson = json;\r\n this.privProperties = properties;\r\n }\r\n\r\n /**\r\n * Specifies the result identifier.\r\n * @member RecognitionResult.prototype.resultId\r\n * @function\r\n * @public\r\n * @returns {string} Specifies the result identifier.\r\n */\r\n public get resultId(): string {\r\n return this.privResultId;\r\n }\r\n\r\n /**\r\n * Specifies status of the result.\r\n * @member RecognitionResult.prototype.reason\r\n * @function\r\n * @public\r\n * @returns {ResultReason} Specifies status of the result.\r\n */\r\n public get reason(): ResultReason {\r\n return this.privReason;\r\n }\r\n\r\n /**\r\n * Presents the recognized text in the result.\r\n * @member RecognitionResult.prototype.text\r\n * @function\r\n * @public\r\n * @returns {string} Presents the recognized text in the result.\r\n */\r\n public get text(): string {\r\n return this.privText;\r\n }\r\n\r\n /**\r\n * Duration of recognized speech in 100 nano second incements.\r\n * @member RecognitionResult.prototype.duration\r\n * @function\r\n * @public\r\n * @returns {number} Duration of recognized speech in 100 nano second incements.\r\n */\r\n public get duration(): number {\r\n return this.privDuration;\r\n }\r\n\r\n /**\r\n * Offset of recognized speech in 100 nano second incements.\r\n * @member RecognitionResult.prototype.offset\r\n * @function\r\n * @public\r\n * @returns {number} Offset of recognized speech in 100 nano second incements.\r\n */\r\n public get offset(): number {\r\n return this.privOffset;\r\n }\r\n\r\n /**\r\n * Primary Language detected.\r\n * @member RecognitionResult.prototype.language\r\n * @function\r\n * @public\r\n * @returns {string} language detected.\r\n */\r\n public get language(): string {\r\n return this.privLanguage;\r\n }\r\n\r\n /**\r\n * Primary Language detection confidence (Unknown, Low, Medium, High).\r\n * @member RecognitionResult.prototype.languageDetectionConfidence\r\n * @function\r\n * @public\r\n * @returns {string} detection confidence strength.\r\n */\r\n public get languageDetectionConfidence(): string {\r\n return this.privLanguageDetectionConfidence;\r\n }\r\n\r\n /**\r\n * In case of an unsuccessful recognition, provides details of the occurred error.\r\n * @member RecognitionResult.prototype.errorDetails\r\n * @function\r\n * @public\r\n * @returns {string} a brief description of an error.\r\n */\r\n public get errorDetails(): string {\r\n return this.privErrorDetails;\r\n }\r\n\r\n /**\r\n * A string containing Json serialized recognition result as it was received from the service.\r\n * @member RecognitionResult.prototype.json\r\n * @function\r\n * @private\r\n * @returns {string} Json serialized representation of the result.\r\n */\r\n public get json(): string {\r\n return this.privJson;\r\n }\r\n\r\n /**\r\n * The set of properties exposed in the result.\r\n * @member RecognitionResult.prototype.properties\r\n * @function\r\n * @public\r\n * @returns {PropertyCollection} The set of properties exposed in the result.\r\n */\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { PropertyCollection, RecognitionResult, ResultReason } from \"./Exports\";\r\n\r\n/**\r\n * Defines result of speech recognition.\r\n * @class SpeechRecognitionResult\r\n */\r\nexport class SpeechRecognitionResult extends RecognitionResult {\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @public\r\n * @param {string} resultId - The result id.\r\n * @param {ResultReason} reason - The reason.\r\n * @param {string} text - The recognized text.\r\n * @param {number} duration - The duration.\r\n * @param {number} offset - The offset into the stream.\r\n * @param {string} language - Primary Language detected, if provided.\r\n * @param {string} languageDetectionConfidence - Primary Language confidence (\"Unknown,\" \"Low,\" \"Medium,\" \"High\"...), if provided.\r\n * @param {string} errorDetails - Error details, if provided.\r\n * @param {string} json - Additional Json, if provided.\r\n * @param {PropertyCollection} properties - Additional properties, if provided.\r\n */\r\n public constructor(resultId?: string, reason?: ResultReason, text?: string,\r\n duration?: number, offset?: number, language?: string,\r\n languageDetectionConfidence?: string, errorDetails?: string,\r\n json?: string, properties?: PropertyCollection) {\r\n super(resultId, reason, text, duration, offset, language, languageDetectionConfidence, errorDetails, json, properties);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { PropertyCollection, ResultReason, SpeechRecognitionResult } from \"./Exports\";\r\n\r\n/**\r\n * Intent recognition result.\r\n * @class\r\n */\r\nexport class IntentRecognitionResult extends SpeechRecognitionResult {\r\n private privIntentId: string;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param intentId - The intent id.\r\n * @param resultId - The result id.\r\n * @param reason - The reason.\r\n * @param text - The recognized text.\r\n * @param duration - The duration.\r\n * @param offset - The offset into the stream.\r\n * @param language - Primary Language detected, if provided.\r\n * @param languageDetectionConfidence - Primary Language confidence (\"Unknown,\" \"Low,\" \"Medium,\" \"High\"...), if provided.\r\n * @param errorDetails - Error details, if provided.\r\n * @param json - Additional Json, if provided.\r\n * @param properties - Additional properties, if provided.\r\n */\r\n constructor(intentId?: string, resultId?: string, reason?: ResultReason, text?: string,\r\n duration?: number, offset?: number, language?: string, languageDetectionConfidence?: string,\r\n errorDetails?: string, json?: string, properties?: PropertyCollection) {\r\n super(resultId, reason, text, duration, offset, language, languageDetectionConfidence, errorDetails, json, properties);\r\n\r\n this.privIntentId = intentId;\r\n }\r\n\r\n /**\r\n * A String that represents the intent identifier being recognized.\r\n * @member IntentRecognitionResult.prototype.intentId\r\n * @function\r\n * @public\r\n * @returns {string} A String that represents the intent identifier being recognized.\r\n */\r\n public get intentId(): string {\r\n return this.privIntentId;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { Contracts } from \"./Contracts\";\r\n\r\n/**\r\n * Language understanding model\r\n * @class LanguageUnderstandingModel\r\n */\r\nexport class LanguageUnderstandingModel {\r\n /**\r\n * Creates and initializes a new instance\r\n * @constructor\r\n */\r\n protected constructor() {\r\n }\r\n\r\n /**\r\n * Creates an language understanding model using the specified endpoint.\r\n * @member LanguageUnderstandingModel.fromEndpoint\r\n * @function\r\n * @public\r\n * @param {URL} uri - A String that represents the endpoint of the language understanding model.\r\n * @returns {LanguageUnderstandingModel} The language understanding model being created.\r\n */\r\n public static fromEndpoint(uri: URL): LanguageUnderstandingModel {\r\n Contracts.throwIfNull(uri, \"uri\");\r\n Contracts.throwIfNullOrWhitespace(uri.hostname, \"uri\");\r\n\r\n const langModelImp: LanguageUnderstandingModelImpl = new LanguageUnderstandingModelImpl();\r\n // Need to extract the app ID from the URL.\r\n // URL is in the format: https://.api.cognitive.microsoft.com/luis/v2.0/apps/?subscription-key=&timezoneOffset=-360\r\n\r\n // Start tearing the string apart.\r\n\r\n // region can be extracted from the host name.\r\n const firstDot: number = uri.host.indexOf(\".\");\r\n if (-1 === firstDot) {\r\n throw new Error(\"Could not determine region from endpoint\");\r\n }\r\n langModelImp.region = uri.host.substr(0, firstDot);\r\n\r\n // Now the app ID.\r\n\r\n const lastSegment: number = uri.pathname.lastIndexOf(\"/\") + 1;\r\n if (-1 === lastSegment) {\r\n throw new Error(\"Could not determine appId from endpoint\");\r\n }\r\n\r\n langModelImp.appId = uri.pathname.substr(lastSegment);\r\n\r\n // And finally the key.\r\n langModelImp.subscriptionKey = uri.searchParams.get(\"subscription-key\");\r\n if (undefined === langModelImp.subscriptionKey) {\r\n throw new Error(\"Could not determine subscription key from endpoint\");\r\n }\r\n\r\n return langModelImp;\r\n }\r\n\r\n /**\r\n * Creates an language understanding model using the application id of Language Understanding service.\r\n * @member LanguageUnderstandingModel.fromAppId\r\n * @function\r\n * @public\r\n * @param {string} appId - A String that represents the application id of Language Understanding service.\r\n * @returns {LanguageUnderstandingModel} The language understanding model being created.\r\n */\r\n public static fromAppId(appId: string): LanguageUnderstandingModel {\r\n Contracts.throwIfNullOrWhitespace(appId, \"appId\");\r\n\r\n const langModelImp: LanguageUnderstandingModelImpl = new LanguageUnderstandingModelImpl();\r\n langModelImp.appId = appId;\r\n return langModelImp;\r\n }\r\n\r\n /**\r\n * Creates a language understanding model using hostname, subscription key and application\r\n * id of Language Understanding service.\r\n * @member LanguageUnderstandingModel.fromSubscription\r\n * @function\r\n * @public\r\n * @param {string} subscriptionKey - A String that represents the subscription key of\r\n * Language Understanding service.\r\n * @param {string} appId - A String that represents the application id of Language\r\n * Understanding service.\r\n * @param {LanguageUnderstandingModel} region - A String that represents the region\r\n * of the Language Understanding service (see the region page).\r\n * @returns {LanguageUnderstandingModel} The language understanding model being created.\r\n */\r\n public static fromSubscription(subscriptionKey: string, appId: string, region: string): LanguageUnderstandingModel {\r\n Contracts.throwIfNullOrWhitespace(subscriptionKey, \"subscriptionKey\");\r\n Contracts.throwIfNullOrWhitespace(appId, \"appId\");\r\n Contracts.throwIfNullOrWhitespace(region, \"region\");\r\n\r\n const langModelImp: LanguageUnderstandingModelImpl = new LanguageUnderstandingModelImpl();\r\n langModelImp.appId = appId;\r\n langModelImp.region = region;\r\n langModelImp.subscriptionKey = subscriptionKey;\r\n return langModelImp;\r\n }\r\n}\r\n\r\n/**\r\n * @private\r\n * @class LanguageUnderstandingModelImpl\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class LanguageUnderstandingModelImpl extends LanguageUnderstandingModel {\r\n public appId: string;\r\n public region: string;\r\n public subscriptionKey: string;\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { RecognitionEventArgs, SpeechRecognitionResult } from \"./Exports\";\r\n\r\n/**\r\n * Defines contents of speech recognizing/recognized event.\r\n * @class SpeechRecognitionEventArgs\r\n */\r\nexport class SpeechRecognitionEventArgs extends RecognitionEventArgs {\r\n private privResult: SpeechRecognitionResult;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {SpeechRecognitionResult} result - The speech recognition result.\r\n * @param {number} offset - The offset.\r\n * @param {string} sessionId - The session id.\r\n */\r\n public constructor(result: SpeechRecognitionResult, offset?: number, sessionId?: string) {\r\n super(offset, sessionId);\r\n\r\n this.privResult = result;\r\n }\r\n\r\n /**\r\n * Specifies the recognition result.\r\n * @member SpeechRecognitionEventArgs.prototype.result\r\n * @function\r\n * @public\r\n * @returns {SpeechRecognitionResult} the recognition result.\r\n */\r\n public get result(): SpeechRecognitionResult {\r\n return this.privResult;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { CancellationErrorCode, CancellationReason, RecognitionEventArgs } from \"./Exports\";\r\n\r\n/**\r\n * Defines content of a RecognitionErrorEvent.\r\n * @class SpeechRecognitionCanceledEventArgs\r\n */\r\nexport class SpeechRecognitionCanceledEventArgs extends RecognitionEventArgs {\r\n private privReason: CancellationReason;\r\n private privErrorDetails: string;\r\n private privErrorCode: CancellationErrorCode;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {CancellationReason} reason - The cancellation reason.\r\n * @param {string} errorDetails - Error details, if provided.\r\n * @param {number} offset - The offset.\r\n * @param {string} sessionId - The session id.\r\n */\r\n public constructor(reason: CancellationReason, errorDetails: string,\r\n errorCode: CancellationErrorCode, offset?: number, sessionId?: string) {\r\n super(offset, sessionId);\r\n\r\n this.privReason = reason;\r\n this.privErrorDetails = errorDetails;\r\n this.privErrorCode = errorCode;\r\n }\r\n\r\n /**\r\n * The reason the recognition was canceled.\r\n * @member SpeechRecognitionCanceledEventArgs.prototype.reason\r\n * @function\r\n * @public\r\n * @returns {CancellationReason} Specifies the reason canceled.\r\n */\r\n public get reason(): CancellationReason {\r\n return this.privReason;\r\n }\r\n\r\n /**\r\n * The error code in case of an unsuccessful recognition.\r\n * Added in version 1.1.0.\r\n * @return An error code that represents the error reason.\r\n */\r\n public get errorCode(): CancellationErrorCode {\r\n return this.privErrorCode;\r\n }\r\n\r\n /**\r\n * In case of an unsuccessful recognition, provides details of the occurred error.\r\n * @member SpeechRecognitionCanceledEventArgs.prototype.errorDetails\r\n * @function\r\n * @public\r\n * @returns {string} A String that represents the error details.\r\n */\r\n public get errorDetails(): string {\r\n return this.privErrorDetails;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { RecognitionEventArgs, TranslationRecognitionResult } from \"./Exports\";\r\n\r\n/**\r\n * Translation text result event arguments.\r\n * @class TranslationRecognitionEventArgs\r\n */\r\nexport class TranslationRecognitionEventArgs extends RecognitionEventArgs {\r\n private privResult: TranslationRecognitionResult;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {TranslationRecognitionResult} result - The translation recognition result.\r\n * @param {number} offset - The offset.\r\n * @param {string} sessionId - The session id.\r\n */\r\n public constructor(result: TranslationRecognitionResult, offset?: number, sessionId?: string) {\r\n super(offset, sessionId);\r\n\r\n this.privResult = result;\r\n }\r\n\r\n /**\r\n * Specifies the recognition result.\r\n * @member TranslationRecognitionEventArgs.prototype.result\r\n * @function\r\n * @public\r\n * @returns {TranslationRecognitionResult} the recognition result.\r\n */\r\n public get result(): TranslationRecognitionResult {\r\n return this.privResult;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { SessionEventArgs, TranslationSynthesisResult } from \"./Exports\";\r\n\r\n/**\r\n * Translation Synthesis event arguments\r\n * @class TranslationSynthesisEventArgs\r\n */\r\nexport class TranslationSynthesisEventArgs extends SessionEventArgs {\r\n private privResult: TranslationSynthesisResult;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {TranslationSynthesisResult} result - The translation synthesis result.\r\n * @param {string} sessionId - The session id.\r\n */\r\n public constructor(result: TranslationSynthesisResult, sessionId?: string) {\r\n super(sessionId);\r\n\r\n this.privResult = result;\r\n }\r\n\r\n /**\r\n * Specifies the translation synthesis result.\r\n * @member TranslationSynthesisEventArgs.prototype.result\r\n * @function\r\n * @public\r\n * @returns {TranslationSynthesisResult} Specifies the translation synthesis result.\r\n */\r\n public get result(): TranslationSynthesisResult {\r\n return this.privResult;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { PropertyCollection, ResultReason, SpeechRecognitionResult, Translations } from \"./Exports\";\r\n\r\n/**\r\n * Translation text result.\r\n * @class TranslationRecognitionResult\r\n */\r\nexport class TranslationRecognitionResult extends SpeechRecognitionResult {\r\n private privTranslations: Translations;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {Translations} translations - The translations.\r\n * @param {string} resultId - The result id.\r\n * @param {ResultReason} reason - The reason.\r\n * @param {string} text - The recognized text.\r\n * @param {number} duration - The duration.\r\n * @param {number} offset - The offset into the stream.\r\n * @param {string} errorDetails - Error details, if provided.\r\n * @param {string} json - Additional Json, if provided.\r\n * @param {PropertyCollection} properties - Additional properties, if provided.\r\n */\r\n public constructor(translations: Translations, resultId?: string, reason?: ResultReason,\r\n text?: string, duration?: number, offset?: number, errorDetails?: string,\r\n json?: string, properties?: PropertyCollection) {\r\n super(resultId, reason, text, duration, offset, undefined, undefined, errorDetails, json, properties);\r\n\r\n this.privTranslations = translations;\r\n }\r\n\r\n /**\r\n * Presents the translation results. Each item in the dictionary represents\r\n * a translation result in one of target languages, where the key is the name\r\n * of the target language, in BCP-47 format, and the value is the translation\r\n * text in the specified language.\r\n * @member TranslationRecognitionResult.prototype.translations\r\n * @function\r\n * @public\r\n * @returns {Translations} the current translation map that holds all translations requested.\r\n */\r\n public get translations(): Translations {\r\n return this.privTranslations;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ResultReason } from \"./ResultReason\";\r\n\r\n/**\r\n * Defines translation synthesis result, i.e. the voice output of the translated\r\n * text in the target language.\r\n * @class TranslationSynthesisResult\r\n */\r\nexport class TranslationSynthesisResult {\r\n private privReason: ResultReason;\r\n private privAudio: ArrayBuffer;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {ResultReason} reason - The synthesis reason.\r\n * @param {ArrayBuffer} audio - The audio data.\r\n */\r\n constructor(reason: ResultReason, audio: ArrayBuffer) {\r\n this.privReason = reason;\r\n this.privAudio = audio;\r\n }\r\n\r\n /**\r\n * Translated text in the target language.\r\n * @member TranslationSynthesisResult.prototype.audio\r\n * @function\r\n * @public\r\n * @returns {ArrayBuffer} Translated audio in the target language.\r\n */\r\n public get audio(): ArrayBuffer {\r\n return this.privAudio;\r\n }\r\n\r\n /**\r\n * The synthesis status.\r\n * @member TranslationSynthesisResult.prototype.reason\r\n * @function\r\n * @public\r\n * @returns {ResultReason} The synthesis status.\r\n */\r\n public get reason(): ResultReason {\r\n return this.privReason;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * Defines the possible reasons a recognition result might be generated.\r\n * @class ResultReason\r\n */\r\nexport enum ResultReason {\r\n /**\r\n * Indicates speech could not be recognized. More details\r\n * can be found in the NoMatchDetails object.\r\n * @member ResultReason.NoMatch\r\n */\r\n NoMatch,\r\n\r\n /**\r\n * Indicates that the recognition was canceled. More details\r\n * can be found using the CancellationDetails object.\r\n * @member ResultReason.Canceled\r\n */\r\n Canceled,\r\n\r\n /**\r\n * Indicates the speech result contains hypothesis text.\r\n * @member ResultReason.RecognizedSpeech\r\n */\r\n RecognizingSpeech,\r\n\r\n /**\r\n * Indicates the speech result contains final text that has been recognized.\r\n * Speech Recognition is now complete for this phrase.\r\n * @member ResultReason.RecognizedSpeech\r\n */\r\n RecognizedSpeech,\r\n\r\n /**\r\n * Indicates the intent result contains hypothesis text and intent.\r\n * @member ResultReason.RecognizingIntent\r\n */\r\n RecognizingIntent,\r\n\r\n /**\r\n * Indicates the intent result contains final text and intent.\r\n * Speech Recognition and Intent determination are now complete for this phrase.\r\n * @member ResultReason.RecognizedIntent\r\n */\r\n RecognizedIntent,\r\n\r\n /**\r\n * Indicates the translation result contains hypothesis text and its translation(s).\r\n * @member ResultReason.TranslatingSpeech\r\n */\r\n TranslatingSpeech,\r\n\r\n /**\r\n * Indicates the translation result contains final text and corresponding translation(s).\r\n * Speech Recognition and Translation are now complete for this phrase.\r\n * @member ResultReason.TranslatedSpeech\r\n */\r\n TranslatedSpeech,\r\n\r\n /**\r\n * Indicates the synthesized audio result contains a non-zero amount of audio data\r\n * @member ResultReason.SynthesizingAudio\r\n */\r\n SynthesizingAudio,\r\n\r\n /**\r\n * Indicates the synthesized audio is now complete for this phrase.\r\n * @member ResultReason.SynthesizingAudioCompleted\r\n */\r\n SynthesizingAudioCompleted,\r\n\r\n /**\r\n * Indicates the speech synthesis is now started\r\n * @member ResultReason.SynthesizingAudioStarted\r\n */\r\n SynthesizingAudioStarted,\r\n\r\n /**\r\n * Indicates the voice profile is being enrolled and customers need to send more audio to create a voice profile.\r\n * @member ResultReason.EnrollingVoiceProfile\r\n */\r\n EnrollingVoiceProfile,\r\n\r\n /**\r\n * Indicates the voice profile has been enrolled.\r\n * @member ResultReason.EnrolledVoiceProfile\r\n */\r\n EnrolledVoiceProfile,\r\n\r\n /**\r\n * Indicates successful identification of some speakers.\r\n * @member ResultReason.RecognizedSpeakers\r\n */\r\n RecognizedSpeakers,\r\n\r\n /**\r\n * Indicates successfully verified one speaker.\r\n * @member ResultReason.RecognizedSpeaker\r\n */\r\n RecognizedSpeaker,\r\n\r\n /**\r\n * Indicates a voice profile has been reset successfully.\r\n * @member ResultReason.ResetVoiceProfile\r\n */\r\n ResetVoiceProfile,\r\n\r\n /**\r\n * Indicates a voice profile has been deleted successfully.\r\n * @member ResultReason.DeletedVoiceProfile\r\n */\r\n DeletedVoiceProfile,\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n ForceDictationPropertyName,\r\n OutputFormatPropertyName,\r\n ServicePropertiesPropertyName\r\n} from \"../common.speech/Exports\";\r\nimport {IStringDictionary} from \"../common/Exports\";\r\nimport {Contracts} from \"./Contracts\";\r\nimport {\r\n OutputFormat,\r\n ProfanityOption,\r\n PropertyCollection,\r\n PropertyId,\r\n ServicePropertyChannel,\r\n SpeechSynthesisOutputFormat,\r\n} from \"./Exports\";\r\n\r\n/**\r\n * Speech configuration.\r\n * @class SpeechConfig\r\n */\r\nexport abstract class SpeechConfig {\r\n /**\r\n * Creates and initializes an instance.\r\n * @constructor\r\n */\r\n protected constructor() { }\r\n\r\n /**\r\n * Static instance of SpeechConfig returned by passing subscriptionKey and service region.\r\n * Note: Please use your LanguageUnderstanding subscription key in case you want to use the Intent recognizer.\r\n * @member SpeechConfig.fromSubscription\r\n * @function\r\n * @public\r\n * @param {string} subscriptionKey - The subscription key.\r\n * @param {string} region - The region name (see the region page).\r\n * @returns {SpeechConfig} The speech factory\r\n */\r\n public static fromSubscription(subscriptionKey: string, region: string): SpeechConfig {\r\n Contracts.throwIfNullOrWhitespace(subscriptionKey, \"subscriptionKey\");\r\n Contracts.throwIfNullOrWhitespace(region, \"region\");\r\n\r\n const speechImpl: SpeechConfigImpl = new SpeechConfigImpl();\r\n speechImpl.setProperty(PropertyId.SpeechServiceConnection_Region, region);\r\n speechImpl.setProperty(PropertyId.SpeechServiceConnection_IntentRegion, region);\r\n speechImpl.setProperty(PropertyId.SpeechServiceConnection_Key, subscriptionKey);\r\n\r\n return speechImpl;\r\n }\r\n\r\n /**\r\n * Creates an instance of the speech config with specified endpoint and subscription key.\r\n * This method is intended only for users who use a non-standard service endpoint or parameters.\r\n * Note: Please use your LanguageUnderstanding subscription key in case you want to use the Intent recognizer.\r\n * Note: The query parameters specified in the endpoint URL are not changed, even if they are set by any other APIs.\r\n * For example, if language is defined in the uri as query parameter \"language=de-DE\", and also set by\r\n * SpeechConfig.speechRecognitionLanguage = \"en-US\", the language setting in uri takes precedence,\r\n * and the effective language is \"de-DE\". Only the parameters that are not specified in the\r\n * endpoint URL can be set by other APIs.\r\n * Note: To use authorization token with fromEndpoint, pass an empty string to the subscriptionKey in the\r\n * fromEndpoint method, and then set authorizationToken=\"token\" on the created SpeechConfig instance to\r\n * use the authorization token.\r\n * @member SpeechConfig.fromEndpoint\r\n * @function\r\n * @public\r\n * @param {URL} endpoint - The service endpoint to connect to.\r\n * @param {string} subscriptionKey - The subscription key. If a subscription key is not specified, an authorization token must be set.\r\n * @returns {SpeechConfig} A speech factory instance.\r\n */\r\n public static fromEndpoint(endpoint: URL, subscriptionKey?: string): SpeechConfig {\r\n Contracts.throwIfNull(endpoint, \"endpoint\");\r\n\r\n const speechImpl: SpeechConfigImpl = new SpeechConfigImpl();\r\n speechImpl.setProperty(PropertyId.SpeechServiceConnection_Endpoint, endpoint.href);\r\n\r\n if (undefined !== subscriptionKey) {\r\n speechImpl.setProperty(PropertyId.SpeechServiceConnection_Key, subscriptionKey);\r\n }\r\n return speechImpl;\r\n }\r\n\r\n /**\r\n * Creates an instance of the speech config with specified host and subscription key.\r\n * This method is intended only for users who use a non-default service host. Standard resource path will be assumed.\r\n * For services with a non-standard resource path or no path at all, use fromEndpoint instead.\r\n * Note: Query parameters are not allowed in the host URI and must be set by other APIs.\r\n * Note: To use an authorization token with fromHost, use fromHost(URL),\r\n * and then set the AuthorizationToken property on the created SpeechConfig instance.\r\n * Note: Added in version 1.9.0.\r\n * @member SpeechConfig.fromHost\r\n * @function\r\n * @public\r\n * @param {URL} host - The service endpoint to connect to. Format is \"protocol://host:port\" where \":port\" is optional.\r\n * @param {string} subscriptionKey - The subscription key. If a subscription key is not specified, an authorization token must be set.\r\n * @returns {SpeechConfig} A speech factory instance.\r\n */\r\n public static fromHost(hostName: URL, subscriptionKey?: string): SpeechConfig {\r\n Contracts.throwIfNull(hostName, \"hostName\");\r\n\r\n const speechImpl: SpeechConfigImpl = new SpeechConfigImpl();\r\n speechImpl.setProperty(PropertyId.SpeechServiceConnection_Host, hostName.protocol + \"//\" + hostName.hostname + (hostName.port === \"\" ? \"\" : \":\" + hostName.port));\r\n\r\n if (undefined !== subscriptionKey) {\r\n speechImpl.setProperty(PropertyId.SpeechServiceConnection_Key, subscriptionKey);\r\n }\r\n return speechImpl;\r\n }\r\n\r\n /**\r\n * Creates an instance of the speech factory with specified initial authorization token and region.\r\n * Note: The caller needs to ensure that the authorization token is valid. Before the authorization token\r\n * expires, the caller needs to refresh it by calling this setter with a new valid token.\r\n * Note: Please use a token derived from your LanguageUnderstanding subscription key in case you want\r\n * to use the Intent recognizer. As configuration values are copied when creating a new recognizer,\r\n * the new token value will not apply to recognizers that have already been created. For recognizers\r\n * that have been created before, you need to set authorization token of the corresponding recognizer\r\n * to refresh the token. Otherwise, the recognizers will encounter errors during recognition.\r\n * @member SpeechConfig.fromAuthorizationToken\r\n * @function\r\n * @public\r\n * @param {string} authorizationToken - The initial authorization token.\r\n * @param {string} region - The region name (see the region page).\r\n * @returns {SpeechConfig} A speech factory instance.\r\n */\r\n public static fromAuthorizationToken(authorizationToken: string, region: string): SpeechConfig {\r\n Contracts.throwIfNull(authorizationToken, \"authorizationToken\");\r\n Contracts.throwIfNullOrWhitespace(region, \"region\");\r\n\r\n const speechImpl: SpeechConfigImpl = new SpeechConfigImpl();\r\n speechImpl.setProperty(PropertyId.SpeechServiceConnection_Region, region);\r\n speechImpl.setProperty(PropertyId.SpeechServiceConnection_IntentRegion, region);\r\n speechImpl.authorizationToken = authorizationToken;\r\n return speechImpl;\r\n }\r\n\r\n /**\r\n * Sets the proxy configuration.\r\n * Only relevant in Node.js environments.\r\n * Added in version 1.4.0.\r\n * @param proxyHostName The host name of the proxy server.\r\n * @param proxyPort The port number of the proxy server.\r\n */\r\n public abstract setProxy(proxyHostName: string, proxyPort: number): void;\r\n\r\n /**\r\n * Sets the proxy configuration.\r\n * Only relevant in Node.js environments.\r\n * Added in version 1.4.0.\r\n * @param proxyHostName The host name of the proxy server, without the protocol scheme (http://)\r\n * @param proxyPort The port number of the proxy server.\r\n * @param proxyUserName The user name of the proxy server.\r\n * @param proxyPassword The password of the proxy server.\r\n */\r\n public abstract setProxy(proxyHostName: string, proxyPort: number, proxyUserName: string, proxyPassword: string): void;\r\n\r\n /**\r\n * Gets the authorization token.\r\n * @member SpeechConfig.prototype.authorizationToken\r\n * @function\r\n * @public\r\n */\r\n public abstract get authorizationToken(): string;\r\n\r\n /**\r\n * Gets/Sets the authorization token.\r\n * Note: The caller needs to ensure that the authorization token is valid. Before the authorization token\r\n * expires, the caller needs to refresh it by calling this setter with a new valid token.\r\n * @member SpeechConfig.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @param {string} value - The authorization token.\r\n */\r\n public abstract set authorizationToken(value: string);\r\n\r\n /**\r\n * Returns the configured language.\r\n * @member SpeechConfig.prototype.speechRecognitionLanguage\r\n * @function\r\n * @public\r\n */\r\n public abstract get speechRecognitionLanguage(): string;\r\n\r\n /**\r\n * Gets/Sets the input language.\r\n * @member SpeechConfig.prototype.speechRecognitionLanguage\r\n * @function\r\n * @public\r\n * @param {string} value - The authorization token.\r\n */\r\n public abstract set speechRecognitionLanguage(value: string);\r\n\r\n /**\r\n * Sets an arbitrary property.\r\n * @member SpeechConfig.prototype.setProperty\r\n * @function\r\n * @public\r\n * @param {string} name - The name of the property to set.\r\n * @param {string} value - The new value of the property.\r\n */\r\n public abstract setProperty(name: string, value: string): void;\r\n\r\n /**\r\n * Returns the current value of an arbitrary property.\r\n * @member SpeechConfig.prototype.getProperty\r\n * @function\r\n * @public\r\n * @param {string} name - The name of the property to query.\r\n * @param {string} def - The value to return in case the property is not known.\r\n * @returns {string} The current value, or provided default, of the given property.\r\n */\r\n public abstract getProperty(name: string, def?: string): string;\r\n\r\n /**\r\n * Gets speech recognition output format (simple or detailed).\r\n * Note: This output format is for speech recognition result, use [SpeechConfig.speechSynthesisOutputFormat] to\r\n * get synthesized audio output format.\r\n * @member SpeechConfig.prototype.outputFormat\r\n * @function\r\n * @public\r\n * @returns {OutputFormat} Returns the output format.\r\n */\r\n public abstract get outputFormat(): OutputFormat;\r\n\r\n /**\r\n * Gets/Sets speech recognition output format (simple or detailed).\r\n * Note: This output format is for speech recognition result, use [SpeechConfig.speechSynthesisOutputFormat] to\r\n * set synthesized audio output format.\r\n * @member SpeechConfig.prototype.outputFormat\r\n * @function\r\n * @public\r\n */\r\n public abstract set outputFormat(format: OutputFormat);\r\n\r\n /**\r\n * Gets the endpoint ID of a customized speech model that is used for speech recognition.\r\n * @member SpeechConfig.prototype.endpointId\r\n * @function\r\n * @public\r\n * @return {string} The endpoint ID\r\n */\r\n public abstract get endpointId(): string;\r\n\r\n /**\r\n * Gets/Sets the endpoint ID of a customized speech model that is used for speech recognition.\r\n * @member SpeechConfig.prototype.endpointId\r\n * @function\r\n * @public\r\n * @param {string} value - The endpoint ID\r\n */\r\n public abstract set endpointId(value: string);\r\n\r\n /**\r\n * Closes the configuration.\r\n * @member SpeechConfig.prototype.close\r\n * @function\r\n * @public\r\n */\r\n /* tslint:disable:no-empty */\r\n public close(): void { }\r\n\r\n /**\r\n * @member SpeechConfig.prototype.subscriptionKey\r\n * @function\r\n * @public\r\n * @return {string} The subscription key set on the config.\r\n */\r\n public abstract get subscriptionKey(): string;\r\n\r\n /**\r\n * @member SpeechConfig.prototype.region\r\n * @function\r\n * @public\r\n * @return {region} The region set on the config.\r\n */\r\n public abstract get region(): string;\r\n\r\n /**\r\n * @member SpeechConfig.prototype.setServiceProperty\r\n * @function\r\n * @public\r\n * @param {name} The name of the property.\r\n * @param {value} Value to set.\r\n * @param {channel} The channel used to pass the specified property to service.\r\n * @summary Sets a property value that will be passed to service using the specified channel.\r\n * Added in version 1.7.0.\r\n */\r\n public abstract setServiceProperty(name: string, value: string, channel: ServicePropertyChannel): void;\r\n\r\n /**\r\n * @member SpeechConfig.prototype.setProfanity\r\n * @function\r\n * @public\r\n * @param {profanity} Profanity option to set.\r\n * @summary Sets profanity option.\r\n * Added in version 1.7.0.\r\n */\r\n public abstract setProfanity(profanity: ProfanityOption): void;\r\n\r\n /**\r\n * @member SpeechConfig.prototype.enableAudioLogging\r\n * @function\r\n * @public\r\n * @summary Enable audio logging in service.\r\n * Added in version 1.7.0.\r\n */\r\n public abstract enableAudioLogging(): void;\r\n\r\n /**\r\n * @member SpeechConfig.prototype.requestWordLevelTimestamps\r\n * @function\r\n * @public\r\n * @summary Includes word-level timestamps.\r\n * Added in version 1.7.0.\r\n */\r\n public abstract requestWordLevelTimestamps(): void;\r\n\r\n /**\r\n * @member SpeechConfig.prototype.enableDictation\r\n * @function\r\n * @public\r\n * @summary Enable dictation. Only supported in speech continuous recognition.\r\n * Added in version 1.7.0.\r\n */\r\n public abstract enableDictation(): void;\r\n\r\n /**\r\n * Gets the language of the speech synthesizer.\r\n * @member SpeechConfig.prototype.speechSynthesisLanguage\r\n * @function\r\n * @public\r\n * @returns {string} Returns the speech synthesis language.\r\n * Added in version 1.11.0.\r\n */\r\n public abstract get speechSynthesisLanguage(): string;\r\n\r\n /**\r\n * Sets the language of the speech synthesizer.\r\n * @member SpeechConfig.prototype.speechSynthesisLanguage\r\n * @function\r\n * @public\r\n * Added in version 1.11.0.\r\n */\r\n public abstract set speechSynthesisLanguage(language: string);\r\n\r\n /**\r\n * Gets the voice of the speech synthesizer.\r\n * @member SpeechConfig.prototype.speechSynthesisVoiceName\r\n * @function\r\n * @public\r\n * @returns {string} Returns the speech synthesis voice.\r\n * Added in version 1.11.0.\r\n */\r\n public abstract get speechSynthesisVoiceName(): string;\r\n\r\n /**\r\n * Sets the voice of the speech synthesizer. (see available voices).\r\n * @member SpeechConfig.prototype.speechSynthesisVoiceName\r\n * @function\r\n * @public\r\n * Added in version 1.11.0.\r\n */\r\n public abstract set speechSynthesisVoiceName(voice: string);\r\n\r\n /**\r\n * Gets the speech synthesis output format.\r\n * @member SpeechConfig.prototype.speechSynthesisOutputFormat\r\n * @function\r\n * @public\r\n * @returns {SpeechSynthesisOutputFormat} Returns the speech synthesis output format\r\n * Added in version 1.11.0.\r\n */\r\n public abstract get speechSynthesisOutputFormat(): SpeechSynthesisOutputFormat;\r\n\r\n /**\r\n * Sets the speech synthesis output format (e.g. Riff16Khz16BitMonoPcm).\r\n * @member SpeechConfig.prototype.speechSynthesisOutputFormat\r\n * @function\r\n * @public\r\n * The default format is Audio16Khz64KBitRateMonoMp3 for browser and Riff16Khz16BitMonoPcm for Node.JS\r\n * Added in version 1.11.0.\r\n */\r\n public abstract set speechSynthesisOutputFormat(format: SpeechSynthesisOutputFormat);\r\n}\r\n\r\n/**\r\n * @public\r\n * @class SpeechConfigImpl\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class SpeechConfigImpl extends SpeechConfig {\r\n\r\n private privProperties: PropertyCollection;\r\n\r\n public constructor() {\r\n super();\r\n this.privProperties = new PropertyCollection();\r\n this.speechRecognitionLanguage = \"en-US\"; // Should we have a default?\r\n this.outputFormat = OutputFormat.Simple;\r\n }\r\n\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n public get endPoint(): URL {\r\n return new URL(this.privProperties.getProperty(PropertyId.SpeechServiceConnection_Endpoint));\r\n }\r\n\r\n public get subscriptionKey(): string {\r\n return this.privProperties.getProperty(PropertyId.SpeechServiceConnection_Key);\r\n }\r\n\r\n public get region(): string {\r\n return this.privProperties.getProperty(PropertyId.SpeechServiceConnection_Region);\r\n }\r\n\r\n public get authorizationToken(): string {\r\n return this.privProperties.getProperty(PropertyId.SpeechServiceAuthorization_Token);\r\n }\r\n\r\n public set authorizationToken(value: string) {\r\n this.privProperties.setProperty(PropertyId.SpeechServiceAuthorization_Token, value);\r\n }\r\n\r\n public get speechRecognitionLanguage(): string {\r\n return this.privProperties.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage);\r\n }\r\n\r\n public set speechRecognitionLanguage(value: string) {\r\n this.privProperties.setProperty(PropertyId.SpeechServiceConnection_RecoLanguage, value);\r\n }\r\n\r\n public get autoDetectSourceLanguages(): string {\r\n return this.privProperties.getProperty(PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages);\r\n }\r\n\r\n public set autoDetectSourceLanguages(value: string) {\r\n this.privProperties.setProperty(PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, value);\r\n }\r\n\r\n public get outputFormat(): OutputFormat {\r\n return (OutputFormat as any)[this.privProperties.getProperty(OutputFormatPropertyName, undefined)];\r\n }\r\n\r\n public set outputFormat(value: OutputFormat) {\r\n this.privProperties.setProperty(OutputFormatPropertyName, OutputFormat[value]);\r\n }\r\n\r\n public get endpointId(): string {\r\n return this.privProperties.getProperty(PropertyId.SpeechServiceConnection_EndpointId);\r\n }\r\n\r\n public set endpointId(value: string) {\r\n this.privProperties.setProperty(PropertyId.SpeechServiceConnection_EndpointId, value);\r\n }\r\n\r\n public setProperty(name: string | PropertyId, value: string): void {\r\n Contracts.throwIfNull(value, \"value\");\r\n\r\n this.privProperties.setProperty(name, value);\r\n }\r\n\r\n public getProperty(name: string | PropertyId, def?: string): string {\r\n\r\n return this.privProperties.getProperty(name, def);\r\n }\r\n\r\n public setProxy(proxyHostName: string, proxyPort: number): void;\r\n public setProxy(proxyHostName: string, proxyPort: number, proxyUserName: string, proxyPassword: string): void;\r\n public setProxy(proxyHostName: any, proxyPort: any, proxyUserName?: any, proxyPassword?: any): void {\r\n this.setProperty(PropertyId[PropertyId.SpeechServiceConnection_ProxyHostName], proxyHostName);\r\n this.setProperty(PropertyId[PropertyId.SpeechServiceConnection_ProxyPort], proxyPort);\r\n this.setProperty(PropertyId[PropertyId.SpeechServiceConnection_ProxyUserName], proxyUserName);\r\n this.setProperty(PropertyId[PropertyId.SpeechServiceConnection_ProxyPassword], proxyPassword);\r\n }\r\n\r\n public setServiceProperty(name: string, value: string, channel: ServicePropertyChannel): void {\r\n const currentProperties: IStringDictionary = JSON.parse(this.privProperties.getProperty(ServicePropertiesPropertyName, \"{}\"));\r\n\r\n currentProperties[name] = value;\r\n\r\n this.privProperties.setProperty(ServicePropertiesPropertyName, JSON.stringify(currentProperties));\r\n }\r\n\r\n public setProfanity(profanity: ProfanityOption): void {\r\n this.privProperties.setProperty(PropertyId.SpeechServiceResponse_ProfanityOption, ProfanityOption[profanity]);\r\n }\r\n\r\n public enableAudioLogging(): void {\r\n this.privProperties.setProperty(PropertyId.SpeechServiceConnection_EnableAudioLogging, \"true\");\r\n }\r\n public requestWordLevelTimestamps(): void {\r\n this.privProperties.setProperty(PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps, \"true\");\r\n }\r\n public enableDictation(): void {\r\n this.privProperties.setProperty(ForceDictationPropertyName, \"true\");\r\n }\r\n\r\n public clone(): SpeechConfigImpl {\r\n const ret: SpeechConfigImpl = new SpeechConfigImpl();\r\n ret.privProperties = this.privProperties.clone();\r\n return ret;\r\n }\r\n\r\n public get speechSynthesisLanguage(): string {\r\n return this.privProperties.getProperty(PropertyId.SpeechServiceConnection_SynthLanguage);\r\n }\r\n\r\n public set speechSynthesisLanguage(language: string) {\r\n this.privProperties.setProperty(PropertyId.SpeechServiceConnection_SynthLanguage, language);\r\n }\r\n\r\n public get speechSynthesisVoiceName(): string {\r\n return this.privProperties.getProperty(PropertyId.SpeechServiceConnection_SynthVoice);\r\n }\r\n\r\n public set speechSynthesisVoiceName(voice: string) {\r\n this.privProperties.setProperty(PropertyId.SpeechServiceConnection_SynthVoice, voice);\r\n }\r\n\r\n public get speechSynthesisOutputFormat(): SpeechSynthesisOutputFormat {\r\n return (SpeechSynthesisOutputFormat as any)[this.privProperties.getProperty(PropertyId.SpeechServiceConnection_SynthOutputFormat, undefined)];\r\n }\r\n\r\n public set speechSynthesisOutputFormat(format: SpeechSynthesisOutputFormat) {\r\n this.privProperties.setProperty(PropertyId.SpeechServiceConnection_SynthOutputFormat, SpeechSynthesisOutputFormat[format]);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n ForceDictationPropertyName,\r\n OutputFormatPropertyName,\r\n ServicePropertiesPropertyName\r\n} from \"../common.speech/Exports\";\r\nimport { IStringDictionary } from \"../common/Exports\";\r\nimport { Contracts } from \"./Contracts\";\r\nimport {\r\n OutputFormat,\r\n ProfanityOption,\r\n PropertyCollection,\r\n PropertyId,\r\n ServicePropertyChannel,\r\n SpeechConfig, SpeechSynthesisOutputFormat,\r\n} from \"./Exports\";\r\n\r\n/**\r\n * Speech translation configuration.\r\n * @class SpeechTranslationConfig\r\n */\r\nexport abstract class SpeechTranslationConfig extends SpeechConfig {\r\n\r\n /**\r\n * Creates an instance of recognizer config.\r\n */\r\n protected constructor() {\r\n super();\r\n }\r\n\r\n /**\r\n * Static instance of SpeechTranslationConfig returned by passing a subscription key and service region.\r\n * @member SpeechTranslationConfig.fromSubscription\r\n * @function\r\n * @public\r\n * @param {string} subscriptionKey - The subscription key.\r\n * @param {string} region - The region name (see the region page).\r\n * @returns {SpeechTranslationConfig} The speech translation config.\r\n */\r\n public static fromSubscription(subscriptionKey: string, region: string): SpeechTranslationConfig {\r\n Contracts.throwIfNullOrWhitespace(subscriptionKey, \"subscriptionKey\");\r\n Contracts.throwIfNullOrWhitespace(region, \"region\");\r\n\r\n const ret: SpeechTranslationConfigImpl = new SpeechTranslationConfigImpl();\r\n ret.properties.setProperty(PropertyId.SpeechServiceConnection_Key, subscriptionKey);\r\n ret.properties.setProperty(PropertyId.SpeechServiceConnection_Region, region);\r\n return ret;\r\n }\r\n\r\n /**\r\n * Static instance of SpeechTranslationConfig returned by passing authorization token and service region.\r\n * Note: The caller needs to ensure that the authorization token is valid. Before the authorization token\r\n * expires, the caller needs to refresh it by setting the property authorizationToken with a new\r\n * valid token. Otherwise, all the recognizers created by this SpeechTranslationConfig instance\r\n * will encounter errors during recognition.\r\n * As configuration values are copied when creating a new recognizer, the new token value will not apply\r\n * to recognizers that have already been created.\r\n * For recognizers that have been created before, you need to set authorization token of the corresponding recognizer\r\n * to refresh the token. Otherwise, the recognizers will encounter errors during recognition.\r\n * @member SpeechTranslationConfig.fromAuthorizationToken\r\n * @function\r\n * @public\r\n * @param {string} authorizationToken - The authorization token.\r\n * @param {string} region - The region name (see the region page).\r\n * @returns {SpeechTranslationConfig} The speech translation config.\r\n */\r\n public static fromAuthorizationToken(authorizationToken: string, region: string): SpeechTranslationConfig {\r\n Contracts.throwIfNullOrWhitespace(authorizationToken, \"authorizationToken\");\r\n Contracts.throwIfNullOrWhitespace(region, \"region\");\r\n\r\n const ret: SpeechTranslationConfigImpl = new SpeechTranslationConfigImpl();\r\n ret.properties.setProperty(PropertyId.SpeechServiceAuthorization_Token, authorizationToken);\r\n ret.properties.setProperty(PropertyId.SpeechServiceConnection_Region, region);\r\n return ret;\r\n }\r\n\r\n /**\r\n * Creates an instance of the speech config with specified host and subscription key.\r\n * This method is intended only for users who use a non-default service host. Standard resource path will be assumed.\r\n * For services with a non-standard resource path or no path at all, use fromEndpoint instead.\r\n * Note: Query parameters are not allowed in the host URI and must be set by other APIs.\r\n * Note: To use an authorization token with fromHost, use fromHost(URL),\r\n * and then set the AuthorizationToken property on the created SpeechConfig instance.\r\n * Note: Added in version 1.9.0.\r\n * @member SpeechConfig.fromHost\r\n * @function\r\n * @public\r\n * @param {URL} host - The service endpoint to connect to. Format is \"protocol://host:port\" where \":port\" is optional.\r\n * @param {string} subscriptionKey - The subscription key. If a subscription key is not specified, an authorization token must be set.\r\n * @returns {SpeechConfig} A speech factory instance.\r\n */\r\n public static fromHost(hostName: URL, subscriptionKey?: string): SpeechConfig {\r\n Contracts.throwIfNull(hostName, \"hostName\");\r\n\r\n const speechImpl: SpeechTranslationConfigImpl = new SpeechTranslationConfigImpl();\r\n speechImpl.setProperty(PropertyId.SpeechServiceConnection_Host, hostName.protocol + \"//\" + hostName.hostname + (hostName.port === \"\" ? \"\" : \":\" + hostName.port));\r\n\r\n if (undefined !== subscriptionKey) {\r\n speechImpl.setProperty(PropertyId.SpeechServiceConnection_Key, subscriptionKey);\r\n }\r\n return speechImpl;\r\n }\r\n\r\n /**\r\n * Creates an instance of the speech translation config with specified endpoint and subscription key.\r\n * This method is intended only for users who use a non-standard service endpoint or paramters.\r\n * Note: The query properties specified in the endpoint URL are not changed, even if they are\r\n * set by any other APIs. For example, if language is defined in the uri as query parameter\r\n * \"language=de-DE\", and also set by the speechRecognitionLanguage property, the language\r\n * setting in uri takes precedence, and the effective language is \"de-DE\".\r\n * Only the properties that are not specified in the endpoint URL can be set by other APIs.\r\n * Note: To use authorization token with fromEndpoint, pass an empty string to the subscriptionKey in the\r\n * fromEndpoint method, and then set authorizationToken=\"token\" on the created SpeechConfig instance to\r\n * use the authorization token.\r\n * @member SpeechTranslationConfig.fromEndpoint\r\n * @function\r\n * @public\r\n * @param {URL} endpoint - The service endpoint to connect to.\r\n * @param {string} subscriptionKey - The subscription key.\r\n * @returns {SpeechTranslationConfig} A speech config instance.\r\n */\r\n public static fromEndpoint(endpoint: URL, subscriptionKey: string): SpeechTranslationConfig {\r\n Contracts.throwIfNull(endpoint, \"endpoint\");\r\n Contracts.throwIfNull(subscriptionKey, \"subscriptionKey\");\r\n\r\n const ret: SpeechTranslationConfigImpl = new SpeechTranslationConfigImpl();\r\n ret.properties.setProperty(PropertyId.SpeechServiceConnection_Endpoint, endpoint.href);\r\n ret.properties.setProperty(PropertyId.SpeechServiceConnection_Key, subscriptionKey);\r\n return ret;\r\n }\r\n\r\n /**\r\n * Gets/Sets the authorization token.\r\n * Note: The caller needs to ensure that the authorization token is valid. Before the authorization token\r\n * expires, the caller needs to refresh it by calling this setter with a new valid token.\r\n * @member SpeechTranslationConfig.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @param {string} value - The authorization token.\r\n */\r\n public abstract set authorizationToken(value: string);\r\n\r\n /**\r\n * Gets/Sets the speech recognition language.\r\n * @member SpeechTranslationConfig.prototype.speechRecognitionLanguage\r\n * @function\r\n * @public\r\n * @param {string} value - The authorization token.\r\n */\r\n public abstract set speechRecognitionLanguage(value: string);\r\n\r\n /**\r\n * Add a (text) target language to translate into.\r\n * @member SpeechTranslationConfig.prototype.addTargetLanguage\r\n * @function\r\n * @public\r\n * @param {string} value - The language such as de-DE\r\n */\r\n public abstract addTargetLanguage(value: string): void;\r\n\r\n /**\r\n * Gets the (text) target language to translate into.\r\n * @member SpeechTranslationConfig.prototype.targetLanguages\r\n * @function\r\n * @public\r\n * @param {string} value - The language such as de-DE\r\n */\r\n public abstract get targetLanguages(): string[];\r\n\r\n /**\r\n * Gets the selected voice name.\r\n * @member SpeechTranslationConfig.prototype.voiceName\r\n * @function\r\n * @public\r\n * @returns {string} The voice name.\r\n */\r\n public abstract get voiceName(): string;\r\n\r\n /**\r\n * Gets/Sets voice of the translated language, enable voice synthesis output.\r\n * @member SpeechTranslationConfig.prototype.voiceName\r\n * @function\r\n * @public\r\n * @param {string} value - The name of the voice.\r\n */\r\n public abstract set voiceName(value: string);\r\n\r\n /**\r\n * Sets a named property as value\r\n * @member SpeechTranslationConfig.prototype.setProperty\r\n * @function\r\n * @public\r\n * @param {string} name - The name of the property.\r\n * @param {string} value - The value.\r\n */\r\n public abstract setProperty(name: string, value: string): void;\r\n\r\n /**\r\n * Dispose of associated resources.\r\n * @member SpeechTranslationConfig.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public abstract close(): void;\r\n}\r\n\r\n/**\r\n * @private\r\n * @class SpeechTranslationConfigImpl\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class SpeechTranslationConfigImpl extends SpeechTranslationConfig {\r\n\r\n private privSpeechProperties: PropertyCollection;\r\n\r\n public constructor() {\r\n super();\r\n this.privSpeechProperties = new PropertyCollection();\r\n this.outputFormat = OutputFormat.Simple;\r\n }\r\n /**\r\n * Gets/Sets the authorization token.\r\n * If this is set, subscription key is ignored.\r\n * User needs to make sure the provided authorization token is valid and not expired.\r\n * @member SpeechTranslationConfigImpl.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @param {string} value - The authorization token.\r\n */\r\n public set authorizationToken(value: string) {\r\n Contracts.throwIfNullOrWhitespace(value, \"value\");\r\n\r\n this.privSpeechProperties.setProperty(PropertyId.SpeechServiceAuthorization_Token, value);\r\n }\r\n\r\n /**\r\n * Gets/Sets the speech recognition language.\r\n * @member SpeechTranslationConfigImpl.prototype.speechRecognitionLanguage\r\n * @function\r\n * @public\r\n * @param {string} value - The authorization token.\r\n */\r\n public set speechRecognitionLanguage(value: string) {\r\n Contracts.throwIfNullOrWhitespace(value, \"value\");\r\n this.privSpeechProperties.setProperty(PropertyId.SpeechServiceConnection_RecoLanguage, value);\r\n }\r\n\r\n /**\r\n * @member SpeechTranslationConfigImpl.prototype.subscriptionKey\r\n * @function\r\n * @public\r\n */\r\n public get subscriptionKey(): string {\r\n return this.privSpeechProperties.getProperty(PropertyId[PropertyId.SpeechServiceConnection_Key]);\r\n }\r\n\r\n /**\r\n * Gets the output format\r\n * @member SpeechTranslationConfigImpl.prototype.outputFormat\r\n * @function\r\n * @public\r\n */\r\n public get outputFormat(): OutputFormat {\r\n return (OutputFormat as any)[this.privSpeechProperties.getProperty(OutputFormatPropertyName, undefined)];\r\n }\r\n\r\n /**\r\n * Gets/Sets the output format\r\n * @member SpeechTranslationConfigImpl.prototype.outputFormat\r\n * @function\r\n * @public\r\n */\r\n public set outputFormat(value: OutputFormat) {\r\n this.privSpeechProperties.setProperty(OutputFormatPropertyName, OutputFormat[value]);\r\n }\r\n\r\n /**\r\n * Gets the endpoint id.\r\n * @member SpeechTranslationConfigImpl.prototype.endpointId\r\n * @function\r\n * @public\r\n */\r\n public get endpointId(): string {\r\n return this.privSpeechProperties.getProperty(PropertyId.SpeechServiceConnection_EndpointId);\r\n }\r\n\r\n /**\r\n * Gets/Sets the endpoint id.\r\n * @member SpeechTranslationConfigImpl.prototype.endpointId\r\n * @function\r\n * @public\r\n */\r\n public set endpointId(value: string) {\r\n this.privSpeechProperties.setProperty(PropertyId.SpeechServiceConnection_EndpointId, value);\r\n }\r\n\r\n /**\r\n * Add a (text) target language to translate into.\r\n * @member SpeechTranslationConfigImpl.prototype.addTargetLanguage\r\n * @function\r\n * @public\r\n * @param {string} value - The language such as de-DE\r\n */\r\n public addTargetLanguage(value: string): void {\r\n Contracts.throwIfNullOrWhitespace(value, \"value\");\r\n\r\n const languages: string[] = this.targetLanguages;\r\n languages.push(value);\r\n this.privSpeechProperties.setProperty(PropertyId.SpeechServiceConnection_TranslationToLanguages, languages.join(\",\"));\r\n }\r\n\r\n /**\r\n * Gets the (text) target language to translate into.\r\n * @member SpeechTranslationConfigImpl.prototype.targetLanguages\r\n * @function\r\n * @public\r\n * @param {string} value - The language such as de-DE\r\n */\r\n public get targetLanguages(): string[] {\r\n\r\n if (this.privSpeechProperties.getProperty(PropertyId.SpeechServiceConnection_TranslationToLanguages, undefined) !== undefined) {\r\n return this.privSpeechProperties.getProperty(PropertyId.SpeechServiceConnection_TranslationToLanguages).split(\",\");\r\n } else {\r\n return [];\r\n }\r\n\r\n }\r\n\r\n /**\r\n * Gets the voice name.\r\n * @member SpeechTranslationConfigImpl.prototype.voiceName\r\n * @function\r\n * @public\r\n */\r\n public get voiceName(): string {\r\n return this.getProperty(PropertyId[PropertyId.SpeechServiceConnection_TranslationVoice]);\r\n }\r\n\r\n /**\r\n * Gets/Sets the voice of the translated language, enable voice synthesis output.\r\n * @member SpeechTranslationConfigImpl.prototype.voiceName\r\n * @function\r\n * @public\r\n * @param {string} value - The name of the voice.\r\n */\r\n public set voiceName(value: string) {\r\n Contracts.throwIfNullOrWhitespace(value, \"value\");\r\n\r\n this.privSpeechProperties.setProperty(PropertyId.SpeechServiceConnection_TranslationVoice, value);\r\n }\r\n\r\n /**\r\n * Provides the region.\r\n * @member SpeechTranslationConfigImpl.prototype.region\r\n * @function\r\n * @public\r\n * @returns {string} The region.\r\n */\r\n public get region(): string {\r\n return this.privSpeechProperties.getProperty(PropertyId.SpeechServiceConnection_Region);\r\n }\r\n\r\n public setProxy(proxyHostName: string, proxyPort: number): void;\r\n public setProxy(proxyHostName: string, proxyPort: number, proxyUserName: string, proxyPassword: string): void;\r\n public setProxy(proxyHostName: any, proxyPort: any, proxyUserName?: any, proxyPassword?: any): void {\r\n this.setProperty(PropertyId[PropertyId.SpeechServiceConnection_ProxyHostName], proxyHostName);\r\n this.setProperty(PropertyId[PropertyId.SpeechServiceConnection_ProxyPort], proxyPort);\r\n this.setProperty(PropertyId[PropertyId.SpeechServiceConnection_ProxyUserName], proxyUserName);\r\n this.setProperty(PropertyId[PropertyId.SpeechServiceConnection_ProxyPassword], proxyPassword);\r\n }\r\n\r\n /**\r\n * Gets an arbitrary property value.\r\n * @member SpeechTranslationConfigImpl.prototype.getProperty\r\n * @function\r\n * @public\r\n * @param {string} name - The name of the property.\r\n * @param {string} def - The default value of the property in case it is not set.\r\n * @returns {string} The value of the property.\r\n */\r\n public getProperty(name: string, def?: string): string {\r\n return this.privSpeechProperties.getProperty(name, def);\r\n }\r\n\r\n /**\r\n * Gets/Sets an arbitrary property value.\r\n * @member SpeechTranslationConfigImpl.prototype.setProperty\r\n * @function\r\n * @public\r\n * @param {string} name - The name of the property.\r\n * @param {string} value - The value of the property.\r\n */\r\n public setProperty(name: string | PropertyId, value: string): void {\r\n this.privSpeechProperties.setProperty(name, value);\r\n }\r\n\r\n /**\r\n * Provides access to custom properties.\r\n * @member SpeechTranslationConfigImpl.prototype.properties\r\n * @function\r\n * @public\r\n * @returns {PropertyCollection} The properties.\r\n */\r\n public get properties(): PropertyCollection {\r\n return this.privSpeechProperties;\r\n }\r\n\r\n /**\r\n * Dispose of associated resources.\r\n * @member SpeechTranslationConfigImpl.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(): void {\r\n return;\r\n }\r\n\r\n public setServiceProperty(name: string, value: string, channel: ServicePropertyChannel): void {\r\n const currentProperties: IStringDictionary = JSON.parse(this.privSpeechProperties.getProperty(ServicePropertiesPropertyName, \"{}\"));\r\n\r\n currentProperties[name] = value;\r\n\r\n this.privSpeechProperties.setProperty(ServicePropertiesPropertyName, JSON.stringify(currentProperties));\r\n }\r\n\r\n public setProfanity(profanity: ProfanityOption): void {\r\n this.privSpeechProperties.setProperty(PropertyId.SpeechServiceResponse_ProfanityOption, ProfanityOption[profanity]);\r\n }\r\n\r\n public enableAudioLogging(): void {\r\n this.privSpeechProperties.setProperty(PropertyId.SpeechServiceConnection_EnableAudioLogging, \"true\");\r\n }\r\n public requestWordLevelTimestamps(): void {\r\n this.privSpeechProperties.setProperty(PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps, \"true\");\r\n }\r\n public enableDictation(): void {\r\n this.privSpeechProperties.setProperty(ForceDictationPropertyName, \"true\");\r\n }\r\n\r\n public get speechSynthesisLanguage(): string {\r\n return this.privSpeechProperties.getProperty(PropertyId.SpeechServiceConnection_SynthLanguage);\r\n }\r\n\r\n public set speechSynthesisLanguage(language: string) {\r\n this.privSpeechProperties.setProperty(PropertyId.SpeechServiceConnection_SynthLanguage, language);\r\n }\r\n\r\n public get speechSynthesisVoiceName(): string {\r\n return this.privSpeechProperties.getProperty(PropertyId.SpeechServiceConnection_SynthVoice);\r\n }\r\n\r\n public set speechSynthesisVoiceName(voice: string) {\r\n this.privSpeechProperties.setProperty(PropertyId.SpeechServiceConnection_SynthVoice, voice);\r\n }\r\n\r\n public get speechSynthesisOutputFormat(): SpeechSynthesisOutputFormat {\r\n return (SpeechSynthesisOutputFormat as any)[this.privSpeechProperties.getProperty(PropertyId.SpeechServiceConnection_SynthOutputFormat, undefined)];\r\n }\r\n\r\n public set speechSynthesisOutputFormat(format: SpeechSynthesisOutputFormat) {\r\n this.privSpeechProperties.setProperty(PropertyId.SpeechServiceConnection_SynthOutputFormat, SpeechSynthesisOutputFormat[format]);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { PropertyId } from \"./Exports\";\r\n\r\n/**\r\n * Represents collection of properties and their values.\r\n * @class PropertyCollection\r\n */\r\nexport class PropertyCollection {\r\n private privKeys: string[] = [] as string[];\r\n private privValues: string[] = [] as string[];\r\n\r\n /**\r\n * Returns the property value in type String. The parameter must have the same type as String.\r\n * Currently only String, int and bool are allowed.\r\n * If the name is not available, the specified defaultValue is returned.\r\n * @member PropertyCollection.prototype.getProperty\r\n * @function\r\n * @public\r\n * @param {string} key - The parameter name.\r\n * @param {string} def - The default value which is returned if the parameter\r\n * is not available in the collection.\r\n * @returns {string} value of the parameter.\r\n */\r\n public getProperty(key: PropertyId | string, def?: string): string {\r\n let keyToUse: string;\r\n\r\n if (typeof key === \"string\") {\r\n keyToUse = key;\r\n } else {\r\n keyToUse = PropertyId[key];\r\n }\r\n\r\n for (let n = 0; n < this.privKeys.length; n++) {\r\n if (this.privKeys[n] === keyToUse) {\r\n return this.privValues[n];\r\n }\r\n }\r\n\r\n return def;\r\n }\r\n\r\n /**\r\n * Sets the String value of the parameter specified by name.\r\n * @member PropertyCollection.prototype.setProperty\r\n * @function\r\n * @public\r\n * @param {string} key - The parameter name.\r\n * @param {string} value - The value of the parameter.\r\n */\r\n public setProperty(key: string | PropertyId, value: string): void {\r\n let keyToUse: string;\r\n\r\n if (typeof key === \"string\") {\r\n keyToUse = key;\r\n } else {\r\n keyToUse = PropertyId[key];\r\n }\r\n\r\n for (let n = 0; n < this.privKeys.length; n++) {\r\n if (this.privKeys[n] === keyToUse) {\r\n this.privValues[n] = value;\r\n return;\r\n }\r\n }\r\n\r\n this.privKeys.push(keyToUse);\r\n this.privValues.push(value);\r\n }\r\n\r\n /**\r\n * Clones the collection.\r\n * @member PropertyCollection.prototype.clone\r\n * @function\r\n * @public\r\n * @returns {PropertyCollection} A copy of the collection.\r\n */\r\n public clone(): PropertyCollection {\r\n const clonedMap = new PropertyCollection();\r\n\r\n for (let n = 0; n < this.privKeys.length; n++) {\r\n clonedMap.privKeys.push(this.privKeys[n]);\r\n clonedMap.privValues.push(this.privValues[n]);\r\n }\r\n\r\n return clonedMap;\r\n }\r\n\r\n /**\r\n * Merges this set of properties into another, no overwrites.\r\n * @member PropertyCollection.prototype.mergeTo\r\n * @function\r\n * @public\r\n * @param {PropertyCollection} The collection to merge into.\r\n */\r\n public mergeTo(destinationCollection: PropertyCollection): void {\r\n this.privKeys.forEach((key: string | PropertyId) => {\r\n if (destinationCollection.getProperty(key, undefined) === undefined) {\r\n const value = this.getProperty(key);\r\n destinationCollection.setProperty(key, value);\r\n }\r\n });\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * Defines speech property ids.\r\n * @class PropertyId\r\n */\r\nexport enum PropertyId {\r\n\r\n /**\r\n * The Cognitive Services Speech Service subscription Key. If you are using an intent recognizer, you need to specify\r\n * to specify the LUIS endpoint key for your particular LUIS app. Under normal circumstances, you shouldn't\r\n * have to use this property directly.\r\n * Instead, use [[SpeechConfig.fromSubscription]].\r\n * @member PropertyId.SpeechServiceConnection_Key\r\n */\r\n SpeechServiceConnection_Key = 0,\r\n\r\n /**\r\n * The Cognitive Services Speech Service endpoint (url). Under normal circumstances, you shouldn't\r\n * have to use this property directly.\r\n * Instead, use [[SpeechConfig.fromEndpoint]].\r\n * NOTE: This endpoint is not the same as the endpoint used to obtain an access token.\r\n * @member PropertyId.SpeechServiceConnection_Endpoint\r\n */\r\n SpeechServiceConnection_Endpoint,\r\n\r\n /**\r\n * The Cognitive Services Speech Service region. Under normal circumstances, you shouldn't have to\r\n * use this property directly.\r\n * Instead, use [[SpeechConfig.fromSubscription]], [[SpeechConfig.fromEndpoint]], [[SpeechConfig.fromAuthorizationToken]].\r\n * @member PropertyId.SpeechServiceConnection_Region\r\n */\r\n SpeechServiceConnection_Region,\r\n\r\n /**\r\n * The Cognitive Services Speech Service authorization token (aka access token). Under normal circumstances,\r\n * you shouldn't have to use this property directly.\r\n * Instead, use [[SpeechConfig.fromAuthorizationToken]], [[SpeechRecognizer.authorizationToken]],\r\n * [[IntentRecognizer.authorizationToken]], [[TranslationRecognizer.authorizationToken]], [[SpeakerRecognizer.authorizationToken]].\r\n * @member PropertyId.SpeechServiceAuthorization_Token\r\n */\r\n SpeechServiceAuthorization_Token,\r\n\r\n /**\r\n * The Cognitive Services Speech Service authorization type. Currently unused.\r\n * @member PropertyId.SpeechServiceAuthorization_Type\r\n */\r\n SpeechServiceAuthorization_Type,\r\n\r\n /**\r\n * The Cognitive Services Speech Service endpoint id. Under normal circumstances, you shouldn't\r\n * have to use this property directly.\r\n * Instead, use [[SpeechConfig.endpointId]].\r\n * NOTE: The endpoint id is available in the Speech Portal, listed under Endpoint Details.\r\n * @member PropertyId.SpeechServiceConnection_EndpointId\r\n */\r\n SpeechServiceConnection_EndpointId,\r\n\r\n /**\r\n * The list of comma separated languages (BCP-47 format) used as target translation languages. Under normal circumstances,\r\n * you shouldn't have to use this property directly.\r\n * Instead use [[SpeechTranslationConfig.addTargetLanguage]],\r\n * [[SpeechTranslationConfig.targetLanguages]], [[TranslationRecognizer.targetLanguages]].\r\n * @member PropertyId.SpeechServiceConnection_TranslationToLanguages\r\n */\r\n SpeechServiceConnection_TranslationToLanguages,\r\n\r\n /**\r\n * The name of the Cognitive Service Text to Speech Service Voice. Under normal circumstances, you shouldn't have to use this\r\n * property directly.\r\n * Instead, use [[SpeechTranslationConfig.voiceName]].\r\n * NOTE: Valid voice names can be found here.\r\n * @member PropertyId.SpeechServiceConnection_TranslationVoice\r\n */\r\n SpeechServiceConnection_TranslationVoice,\r\n\r\n /**\r\n * Translation features.\r\n * @member PropertyId.SpeechServiceConnection_TranslationFeatures\r\n */\r\n SpeechServiceConnection_TranslationFeatures,\r\n\r\n /**\r\n * The Language Understanding Service Region. Under normal circumstances, you shouldn't have to use this property directly.\r\n * Instead, use [[LanguageUnderstandingModel]].\r\n * @member PropertyId.SpeechServiceConnection_IntentRegion\r\n */\r\n SpeechServiceConnection_IntentRegion,\r\n\r\n /**\r\n * The host name of the proxy server used to connect to the Cognitive Services Speech Service. Only relevant in Node.js environments.\r\n * You shouldn't have to use this property directly.\r\n * Instead use .\r\n * Added in version 1.4.0.\r\n */\r\n SpeechServiceConnection_ProxyHostName,\r\n\r\n /**\r\n * The port of the proxy server used to connect to the Cognitive Services Speech Service. Only relevant in Node.js environments.\r\n * You shouldn't have to use this property directly.\r\n * Instead use .\r\n * Added in version 1.4.0.\r\n */\r\n SpeechServiceConnection_ProxyPort,\r\n\r\n /**\r\n * The user name of the proxy server used to connect to the Cognitive Services Speech Service. Only relevant in Node.js environments.\r\n * You shouldn't have to use this property directly.\r\n * Instead use .\r\n * Added in version 1.4.0.\r\n */\r\n SpeechServiceConnection_ProxyUserName,\r\n\r\n /**\r\n * The password of the proxy server used to connect to the Cognitive Services Speech Service. Only relevant in Node.js environments.\r\n * You shouldn't have to use this property directly.\r\n * Instead use .\r\n * Added in version 1.4.0.\r\n */\r\n SpeechServiceConnection_ProxyPassword,\r\n\r\n /**\r\n * The Cognitive Services Speech Service recognition Mode. Can be \"INTERACTIVE\", \"CONVERSATION\", \"DICTATION\".\r\n * This property is intended to be read-only. The SDK is using it internally.\r\n * @member PropertyId.SpeechServiceConnection_RecoMode\r\n */\r\n SpeechServiceConnection_RecoMode,\r\n\r\n /**\r\n * The spoken language to be recognized (in BCP-47 format). Under normal circumstances, you shouldn't have to use this property\r\n * directly.\r\n * Instead, use [[SpeechConfig.speechRecognitionLanguage]].\r\n * @member PropertyId.SpeechServiceConnection_RecoLanguage\r\n */\r\n SpeechServiceConnection_RecoLanguage,\r\n\r\n /**\r\n * The session id. This id is a universally unique identifier (aka UUID) representing a specific binding of an audio input stream\r\n * and the underlying speech recognition instance to which it is bound. Under normal circumstances, you shouldn't have to use this\r\n * property directly.\r\n * Instead use [[SessionEventArgs.sessionId]].\r\n * @member PropertyId.Speech_SessionId\r\n */\r\n Speech_SessionId,\r\n\r\n /**\r\n * The spoken language to be synthesized (e.g. en-US)\r\n * @member PropertyId.SpeechServiceConnection_SynthLanguage\r\n */\r\n SpeechServiceConnection_SynthLanguage,\r\n\r\n /**\r\n * The name of the TTS voice to be used for speech synthesis\r\n * @member PropertyId.SpeechServiceConnection_SynthVoice\r\n */\r\n SpeechServiceConnection_SynthVoice,\r\n\r\n /**\r\n * The string to specify TTS output audio format\r\n * @member PropertyId.SpeechServiceConnection_SynthOutputFormat\r\n */\r\n SpeechServiceConnection_SynthOutputFormat,\r\n\r\n /**\r\n * The list of comma separated languages used as possible source languages\r\n * Added in version 1.13.0\r\n * @member PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages\r\n */\r\n SpeechServiceConnection_AutoDetectSourceLanguages,\r\n\r\n /**\r\n * The requested Cognitive Services Speech Service response output format (simple or detailed). Under normal circumstances, you shouldn't have\r\n * to use this property directly.\r\n * Instead use [[SpeechConfig.outputFormat]].\r\n * @member PropertyId.SpeechServiceResponse_RequestDetailedResultTrueFalse\r\n */\r\n SpeechServiceResponse_RequestDetailedResultTrueFalse,\r\n\r\n /**\r\n * The requested Cognitive Services Speech Service response output profanity level. Currently unused.\r\n * @member PropertyId.SpeechServiceResponse_RequestProfanityFilterTrueFalse\r\n */\r\n SpeechServiceResponse_RequestProfanityFilterTrueFalse,\r\n\r\n /**\r\n * The Cognitive Services Speech Service response output (in JSON format). This property is available on recognition result objects only.\r\n * @member PropertyId.SpeechServiceResponse_JsonResult\r\n */\r\n SpeechServiceResponse_JsonResult,\r\n\r\n /**\r\n * The Cognitive Services Speech Service error details (in JSON format). Under normal circumstances, you shouldn't have to\r\n * use this property directly. Instead use [[CancellationDetails.errorDetails]].\r\n * @member PropertyId.SpeechServiceResponse_JsonErrorDetails\r\n */\r\n SpeechServiceResponse_JsonErrorDetails,\r\n\r\n /**\r\n * The cancellation reason. Currently unused.\r\n * @member PropertyId.CancellationDetails_Reason\r\n */\r\n CancellationDetails_Reason,\r\n\r\n /**\r\n * The cancellation text. Currently unused.\r\n * @member PropertyId.CancellationDetails_ReasonText\r\n */\r\n CancellationDetails_ReasonText,\r\n\r\n /**\r\n * The Cancellation detailed text. Currently unused.\r\n * @member PropertyId.CancellationDetails_ReasonDetailedText\r\n */\r\n CancellationDetails_ReasonDetailedText,\r\n\r\n /**\r\n * The Language Understanding Service response output (in JSON format). Available via [[IntentRecognitionResult]]\r\n * @member PropertyId.LanguageUnderstandingServiceResponse_JsonResult\r\n */\r\n LanguageUnderstandingServiceResponse_JsonResult,\r\n\r\n /**\r\n * The URL string built from speech configuration.\r\n * This property is intended to be read-only. The SDK is using it internally.\r\n * NOTE: Added in version 1.7.0.\r\n */\r\n SpeechServiceConnection_Url,\r\n\r\n /**\r\n * The initial silence timeout value (in milliseconds) used by the service.\r\n * Added in version 1.7.0\r\n */\r\n SpeechServiceConnection_InitialSilenceTimeoutMs,\r\n\r\n /**\r\n * The end silence timeout value (in milliseconds) used by the service.\r\n * Added in version 1.7.0\r\n */\r\n SpeechServiceConnection_EndSilenceTimeoutMs,\r\n\r\n /**\r\n * A boolean value specifying whether audio logging is enabled in the service or not.\r\n * Added in version 1.7.0\r\n */\r\n SpeechServiceConnection_EnableAudioLogging,\r\n\r\n /**\r\n * The requested Cognitive Services Speech Service response output profanity setting.\r\n * Allowed values are \"masked\", \"removed\", and \"raw\".\r\n * Added in version 1.7.0.\r\n */\r\n SpeechServiceResponse_ProfanityOption,\r\n\r\n /**\r\n * A string value specifying which post processing option should be used by service.\r\n * Allowed values are \"TrueText\".\r\n * Added in version 1.7.0\r\n */\r\n SpeechServiceResponse_PostProcessingOption,\r\n\r\n /**\r\n * A boolean value specifying whether to include word-level timestamps in the response result.\r\n * Added in version 1.7.0\r\n */\r\n SpeechServiceResponse_RequestWordLevelTimestamps,\r\n\r\n /**\r\n * The number of times a word has to be in partial results to be returned.\r\n * Added in version 1.7.0\r\n */\r\n SpeechServiceResponse_StablePartialResultThreshold,\r\n\r\n /**\r\n * A string value specifying the output format option in the response result. Internal use only.\r\n * Added in version 1.7.0.\r\n */\r\n SpeechServiceResponse_OutputFormatOption,\r\n\r\n /**\r\n * A boolean value to request for stabilizing translation partial results by omitting words in the end.\r\n * Added in version 1.7.0.\r\n */\r\n SpeechServiceResponse_TranslationRequestStablePartialResult,\r\n\r\n /**\r\n * Identifier used to connect to the backend service.\r\n * @member PropertyId.Conversation_ApplicationId\r\n */\r\n Conversation_ApplicationId,\r\n\r\n /**\r\n * Type of dialog backend to connect to.\r\n * @member PropertyId.Conversation_DialogType\r\n */\r\n Conversation_DialogType,\r\n\r\n /**\r\n * Silence timeout for listening\r\n * @member PropertyId.Conversation_Initial_Silence_Timeout\r\n */\r\n Conversation_Initial_Silence_Timeout,\r\n\r\n /**\r\n * From Id to add to speech recognition activities.\r\n * @member PropertyId.Conversation_From_Id\r\n */\r\n Conversation_From_Id,\r\n\r\n /**\r\n * ConversationId for the session.\r\n * @member PropertyId.Conversation_Conversation_Id\r\n */\r\n Conversation_Conversation_Id,\r\n\r\n /**\r\n * Comma separated list of custom voice deployment ids.\r\n * @member PropertyId.Conversation_Custom_Voice_Deployment_Ids\r\n */\r\n Conversation_Custom_Voice_Deployment_Ids,\r\n\r\n /**\r\n * Speech activity template, stamp properties from the template on the activity generated by the service for speech.\r\n * @member PropertyId.Conversation_Speech_Activity_Template\r\n * Added in version 1.10.0.\r\n */\r\n Conversation_Speech_Activity_Template,\r\n\r\n /**\r\n * The Cognitive Services Speech Service host (url). Under normal circumstances, you shouldn't have to use this property directly.\r\n * Instead, use [[SpeechConfig.fromHost]].\r\n */\r\n SpeechServiceConnection_Host,\r\n\r\n /**\r\n * Set the host for service calls to the Conversation Translator REST management and websocket calls.\r\n */\r\n ConversationTranslator_Host,\r\n\r\n /**\r\n * Optionally set the the host's display name.\r\n * Used when joining a conversation.\r\n */\r\n ConversationTranslator_Name,\r\n\r\n /**\r\n * Optionally set a value for the X-CorrelationId request header.\r\n * Used for troubleshooting errors in the server logs. It should be a valid guid.\r\n */\r\n ConversationTranslator_CorrelationId,\r\n\r\n /**\r\n * Set the conversation token to be sent to the speech service. This enables the\r\n * service to service call from the speech service to the Conversation Translator service for relaying\r\n * recognitions. For internal use.\r\n */\r\n ConversationTranslator_Token\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n CognitiveSubscriptionKeyAuthentication,\r\n CognitiveTokenAuthentication,\r\n Context,\r\n IAuthentication,\r\n IConnectionFactory,\r\n OS,\r\n RecognitionMode,\r\n RecognizerConfig,\r\n ServiceRecognizerBase,\r\n SpeechServiceConfig,\r\n} from \"../common.speech/Exports\";\r\nimport { Promise, PromiseHelper } from \"../common/Exports\";\r\nimport { Contracts } from \"./Contracts\";\r\nimport {\r\n AudioConfig,\r\n Connection,\r\n PropertyCollection,\r\n PropertyId,\r\n RecognitionEventArgs,\r\n SessionEventArgs,\r\n SpeechRecognitionResult,\r\n} from \"./Exports\";\r\n\r\n/**\r\n * Defines the base class Recognizer which mainly contains common event handlers.\r\n * @class Recognizer\r\n */\r\nexport abstract class Recognizer {\r\n private privDisposed: boolean;\r\n protected audioConfig: AudioConfig;\r\n protected privReco: ServiceRecognizerBase;\r\n protected privProperties: PropertyCollection;\r\n private privConnectionFactory: IConnectionFactory;\r\n\r\n /**\r\n * Creates and initializes an instance of a Recognizer\r\n * @constructor\r\n * @param {AudioConfig} audioInput - An optional audio input stream associated with the recognizer\r\n */\r\n protected constructor(audioConfig: AudioConfig, properties: PropertyCollection, connectionFactory: IConnectionFactory) {\r\n this.audioConfig = (audioConfig !== undefined) ? audioConfig : AudioConfig.fromDefaultMicrophoneInput();\r\n this.privDisposed = false;\r\n this.privProperties = properties.clone();\r\n this.privConnectionFactory = connectionFactory;\r\n this.implCommonRecognizerSetup();\r\n }\r\n\r\n /**\r\n * Defines event handler for session started events.\r\n * @member Recognizer.prototype.sessionStarted\r\n * @function\r\n * @public\r\n */\r\n public sessionStarted: (sender: Recognizer, event: SessionEventArgs) => void;\r\n\r\n /**\r\n * Defines event handler for session stopped events.\r\n * @member Recognizer.prototype.sessionStopped\r\n * @function\r\n * @public\r\n */\r\n public sessionStopped: (sender: Recognizer, event: SessionEventArgs) => void;\r\n\r\n /**\r\n * Defines event handler for speech started events.\r\n * @member Recognizer.prototype.speechStartDetected\r\n * @function\r\n * @public\r\n */\r\n public speechStartDetected: (sender: Recognizer, event: RecognitionEventArgs) => void;\r\n\r\n /**\r\n * Defines event handler for speech stopped events.\r\n * @member Recognizer.prototype.speechEndDetected\r\n * @function\r\n * @public\r\n */\r\n public speechEndDetected: (sender: Recognizer, event: RecognitionEventArgs) => void;\r\n\r\n /**\r\n * Dispose of associated resources.\r\n * @member Recognizer.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(): void {\r\n Contracts.throwIfDisposed(this.privDisposed);\r\n\r\n this.dispose(true);\r\n }\r\n\r\n /**\r\n * @Internal\r\n * Internal data member to support fromRecognizer* pattern methods on other classes.\r\n * Do not use externally, object returned will change without warning or notice.\r\n */\r\n public get internalData(): object {\r\n return this.privReco;\r\n }\r\n\r\n /**\r\n * This method performs cleanup of resources.\r\n * The Boolean parameter disposing indicates whether the method is called\r\n * from Dispose (if disposing is true) or from the finalizer (if disposing is false).\r\n * Derived classes should override this method to dispose resource if needed.\r\n * @member Recognizer.prototype.dispose\r\n * @function\r\n * @public\r\n * @param {boolean} disposing - Flag to request disposal.\r\n */\r\n protected dispose(disposing: boolean): void {\r\n if (this.privDisposed) {\r\n return;\r\n }\r\n\r\n if (disposing) {\r\n if (this.privReco) {\r\n this.privReco.audioSource.turnOff();\r\n this.privReco.dispose();\r\n }\r\n }\r\n\r\n this.privDisposed = true;\r\n }\r\n\r\n /**\r\n * This method returns the current state of the telemetry setting.\r\n * @member Recognizer.prototype.telemetryEnabled\r\n * @function\r\n * @public\r\n * @returns true if the telemetry is enabled, false otherwise.\r\n */\r\n public static get telemetryEnabled(): boolean {\r\n return ServiceRecognizerBase.telemetryDataEnabled;\r\n }\r\n\r\n /**\r\n * This method globally enables or disables telemetry.\r\n * @member Recognizer.prototype.enableTelemetry\r\n * @function\r\n * @public\r\n * @param enabled - Global setting for telemetry collection.\r\n * If set to true, telemetry information like microphone errors,\r\n * recognition errors are collected and sent to Microsoft.\r\n * If set to false, no telemetry is sent to Microsoft.\r\n */\r\n /* tslint:disable:member-ordering */\r\n public static enableTelemetry(enabled: boolean): void {\r\n ServiceRecognizerBase.telemetryDataEnabled = enabled;\r\n }\r\n\r\n //\r\n // ################################################################################################################\r\n // IMPLEMENTATION.\r\n // Move to independent class\r\n // ################################################################################################################\r\n //\r\n protected abstract createRecognizerConfig(speechConfig: SpeechServiceConfig): RecognizerConfig;\r\n\r\n // Creates the correct service recognizer for the type\r\n protected abstract createServiceRecognizer(\r\n authentication: IAuthentication,\r\n connectionFactory: IConnectionFactory,\r\n audioConfig: AudioConfig,\r\n recognizerConfig: RecognizerConfig): ServiceRecognizerBase;\r\n\r\n // Does the generic recognizer setup that is common across all recognizer types.\r\n protected implCommonRecognizerSetup(): void {\r\n\r\n let osPlatform = (typeof window !== \"undefined\") ? \"Browser\" : \"Node\";\r\n let osName = \"unknown\";\r\n let osVersion = \"unknown\";\r\n\r\n if (typeof navigator !== \"undefined\") {\r\n osPlatform = osPlatform + \"/\" + navigator.platform;\r\n osName = navigator.userAgent;\r\n osVersion = navigator.appVersion;\r\n }\r\n\r\n const recognizerConfig = this.createRecognizerConfig(\r\n new SpeechServiceConfig(\r\n new Context(new OS(osPlatform, osName, osVersion))));\r\n\r\n const subscriptionKey = this.privProperties.getProperty(PropertyId.SpeechServiceConnection_Key, undefined);\r\n const authentication = (subscriptionKey && subscriptionKey !== \"\") ?\r\n new CognitiveSubscriptionKeyAuthentication(subscriptionKey) :\r\n new CognitiveTokenAuthentication(\r\n (authFetchEventId: string): Promise => {\r\n const authorizationToken = this.privProperties.getProperty(PropertyId.SpeechServiceAuthorization_Token, undefined);\r\n return PromiseHelper.fromResult(authorizationToken);\r\n },\r\n (authFetchEventId: string): Promise => {\r\n const authorizationToken = this.privProperties.getProperty(PropertyId.SpeechServiceAuthorization_Token, undefined);\r\n return PromiseHelper.fromResult(authorizationToken);\r\n });\r\n\r\n this.privReco = this.createServiceRecognizer(\r\n authentication,\r\n this.privConnectionFactory,\r\n this.audioConfig,\r\n recognizerConfig);\r\n }\r\n\r\n protected recognizeOnceAsyncImpl(recognitionMode: RecognitionMode, cb?: (e: SpeechRecognitionResult) => void, err?: (e: string) => void): void {\r\n try {\r\n Contracts.throwIfDisposed(this.privDisposed);\r\n\r\n this.implRecognizerStop().on((_: boolean): void => {\r\n try {\r\n this.privReco.recognize(recognitionMode, (e: SpeechRecognitionResult) => {\r\n this.implRecognizerStop().on((_: boolean): void => {\r\n if (!!cb) {\r\n cb(e);\r\n }\r\n }, (error: string): void => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n\r\n }, (e: string) => {\r\n this.implRecognizerStop(); // We're already in an error path so best effort here.\r\n if (!!err) {\r\n err(e);\r\n }\r\n /* tslint:disable:no-empty */\r\n }).on((_: boolean): void => { },\r\n (error: string) => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error);\r\n }\r\n }\r\n\r\n // Destroy the recognizer.\r\n this.dispose(true);\r\n }\r\n }, (error: string): void => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error);\r\n }\r\n }\r\n\r\n // Destroy the recognizer.\r\n this.dispose(true);\r\n }\r\n }\r\n\r\n public startContinuousRecognitionAsyncImpl(recognitionMode: RecognitionMode, cb?: () => void, err?: (e: string) => void): void {\r\n try {\r\n Contracts.throwIfDisposed(this.privDisposed);\r\n\r\n this.implRecognizerStop().on((_: boolean): void => {\r\n this.privReco.recognize(recognitionMode, undefined, undefined).on((_: boolean): void => {\r\n // report result to promise.\r\n if (!!cb) {\r\n try {\r\n cb();\r\n } catch (e) {\r\n if (!!err) {\r\n err(e);\r\n }\r\n }\r\n cb = undefined;\r\n }\r\n }, (error: string): void => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n // Destroy the recognizer.\r\n this.dispose(true);\r\n });\r\n }, (error: string): void => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n // Destroy the recognizer.\r\n this.dispose(true);\r\n });\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error);\r\n }\r\n }\r\n\r\n // Destroy the recognizer.\r\n this.dispose(true);\r\n }\r\n }\r\n\r\n protected stopContinuousRecognitionAsyncImpl(cb?: () => void, err?: (e: string) => void): void {\r\n try {\r\n Contracts.throwIfDisposed(this.privDisposed);\r\n\r\n this.implRecognizerStop().on((_: boolean) => {\r\n if (!!cb) {\r\n try {\r\n cb();\r\n } catch (e) {\r\n if (!!err) {\r\n err(e);\r\n }\r\n }\r\n }\r\n }, (error: string) => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error);\r\n }\r\n }\r\n\r\n // Destroy the recognizer.\r\n this.dispose(true);\r\n }\r\n }\r\n\r\n protected implRecognizerStop(): Promise {\r\n if (this.privReco) {\r\n return this.privReco.stopRecognizing();\r\n }\r\n return PromiseHelper.fromResult(true);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n IAuthentication,\r\n IConnectionFactory,\r\n OutputFormatPropertyName,\r\n RecognitionMode,\r\n RecognizerConfig,\r\n ServiceRecognizerBase,\r\n SpeechServiceConfig,\r\n SpeechServiceRecognizer,\r\n} from \"../common.speech/Exports\";\r\nimport { SpeechConnectionFactory } from \"../common.speech/SpeechConnectionFactory\";\r\nimport { AudioConfigImpl } from \"./Audio/AudioConfig\";\r\nimport { Contracts } from \"./Contracts\";\r\nimport {\r\n AudioConfig,\r\n AutoDetectSourceLanguageConfig,\r\n KeywordRecognitionModel,\r\n OutputFormat,\r\n PropertyCollection,\r\n PropertyId,\r\n Recognizer,\r\n SpeechRecognitionCanceledEventArgs,\r\n SpeechRecognitionEventArgs,\r\n SpeechRecognitionResult,\r\n} from \"./Exports\";\r\nimport { SpeechConfig, SpeechConfigImpl } from \"./SpeechConfig\";\r\n\r\n/**\r\n * Performs speech recognition from microphone, file, or other audio input streams, and gets transcribed text as result.\r\n * @class SpeechRecognizer\r\n */\r\nexport class SpeechRecognizer extends Recognizer {\r\n private privDisposedSpeechRecognizer: boolean;\r\n\r\n /**\r\n * SpeechRecognizer constructor.\r\n * @constructor\r\n * @param {SpeechConfig} speechConfig - an set of initial properties for this recognizer\r\n * @param {AudioConfig} audioConfig - An optional audio configuration associated with the recognizer\r\n */\r\n public constructor(speechConfig: SpeechConfig, audioConfig?: AudioConfig) {\r\n const speechConfigImpl: SpeechConfigImpl = speechConfig as SpeechConfigImpl;\r\n Contracts.throwIfNull(speechConfigImpl, \"speechConfig\");\r\n\r\n Contracts.throwIfNullOrWhitespace(\r\n speechConfigImpl.properties.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage),\r\n PropertyId[PropertyId.SpeechServiceConnection_RecoLanguage]);\r\n\r\n super(audioConfig, speechConfigImpl.properties, new SpeechConnectionFactory());\r\n this.privDisposedSpeechRecognizer = false;\r\n }\r\n\r\n /**\r\n * SpeechRecognizer constructor.\r\n * @constructor\r\n * @param {SpeechConfig} speechConfig - an set of initial properties for this recognizer\r\n * @param {AutoDetectSourceLanguageConfig} autoDetectSourceLanguageConfig - An source language detection configuration associated with the recognizer\r\n * @param {AudioConfig} audioConfig - An optional audio configuration associated with the recognizer\r\n */\r\n public static FromConfig(speechConfig: SpeechConfig, autoDetectSourceLanguageConfig: AutoDetectSourceLanguageConfig, audioConfig?: AudioConfig): SpeechRecognizer {\r\n const speechConfigImpl: SpeechConfigImpl = speechConfig as SpeechConfigImpl;\r\n autoDetectSourceLanguageConfig.properties.mergeTo(speechConfigImpl.properties);\r\n const recognizer = new SpeechRecognizer(speechConfig, audioConfig);\r\n return recognizer;\r\n }\r\n\r\n /**\r\n * The event recognizing signals that an intermediate recognition result is received.\r\n * @member SpeechRecognizer.prototype.recognizing\r\n * @function\r\n * @public\r\n */\r\n public recognizing: (sender: Recognizer, event: SpeechRecognitionEventArgs) => void;\r\n\r\n /**\r\n * The event recognized signals that a final recognition result is received.\r\n * @member SpeechRecognizer.prototype.recognized\r\n * @function\r\n * @public\r\n */\r\n public recognized: (sender: Recognizer, event: SpeechRecognitionEventArgs) => void;\r\n\r\n /**\r\n * The event canceled signals that an error occurred during recognition.\r\n * @member SpeechRecognizer.prototype.canceled\r\n * @function\r\n * @public\r\n */\r\n public canceled: (sender: Recognizer, event: SpeechRecognitionCanceledEventArgs) => void;\r\n\r\n /**\r\n * Gets the endpoint id of a customized speech model that is used for speech recognition.\r\n * @member SpeechRecognizer.prototype.endpointId\r\n * @function\r\n * @public\r\n * @returns {string} the endpoint id of a customized speech model that is used for speech recognition.\r\n */\r\n public get endpointId(): string {\r\n Contracts.throwIfDisposed(this.privDisposedSpeechRecognizer);\r\n\r\n return this.properties.getProperty(PropertyId.SpeechServiceConnection_EndpointId, \"00000000-0000-0000-0000-000000000000\");\r\n }\r\n\r\n /**\r\n * Gets the authorization token used to communicate with the service.\r\n * @member SpeechRecognizer.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @returns {string} Authorization token.\r\n */\r\n public get authorizationToken(): string {\r\n return this.properties.getProperty(PropertyId.SpeechServiceAuthorization_Token);\r\n }\r\n\r\n /**\r\n * Gets/Sets the authorization token used to communicate with the service.\r\n * @member SpeechRecognizer.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @param {string} token - Authorization token.\r\n */\r\n public set authorizationToken(token: string) {\r\n Contracts.throwIfNullOrWhitespace(token, \"token\");\r\n this.properties.setProperty(PropertyId.SpeechServiceAuthorization_Token, token);\r\n }\r\n\r\n /**\r\n * Gets the spoken language of recognition.\r\n * @member SpeechRecognizer.prototype.speechRecognitionLanguage\r\n * @function\r\n * @public\r\n * @returns {string} The spoken language of recognition.\r\n */\r\n public get speechRecognitionLanguage(): string {\r\n Contracts.throwIfDisposed(this.privDisposedSpeechRecognizer);\r\n\r\n return this.properties.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage);\r\n }\r\n\r\n /**\r\n * Gets the output format of recognition.\r\n * @member SpeechRecognizer.prototype.outputFormat\r\n * @function\r\n * @public\r\n * @returns {OutputFormat} The output format of recognition.\r\n */\r\n public get outputFormat(): OutputFormat {\r\n Contracts.throwIfDisposed(this.privDisposedSpeechRecognizer);\r\n\r\n if (this.properties.getProperty(OutputFormatPropertyName, OutputFormat[OutputFormat.Simple]) === OutputFormat[OutputFormat.Simple]) {\r\n return OutputFormat.Simple;\r\n } else {\r\n return OutputFormat.Detailed;\r\n }\r\n }\r\n\r\n /**\r\n * The collection of properties and their values defined for this SpeechRecognizer.\r\n * @member SpeechRecognizer.prototype.properties\r\n * @function\r\n * @public\r\n * @returns {PropertyCollection} The collection of properties and their values defined for this SpeechRecognizer.\r\n */\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n /**\r\n * Starts speech recognition, and stops after the first utterance is recognized.\r\n * The task returns the recognition text as result.\r\n * Note: RecognizeOnceAsync() returns when the first utterance has been recognized,\r\n * so it is suitable only for single shot recognition\r\n * like command or query. For long-running recognition, use StartContinuousRecognitionAsync() instead.\r\n * @member SpeechRecognizer.prototype.recognizeOnceAsync\r\n * @function\r\n * @public\r\n * @param cb - Callback that received the SpeechRecognitionResult.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public recognizeOnceAsync(cb?: (e: SpeechRecognitionResult) => void, err?: (e: string) => void): void {\r\n this.recognizeOnceAsyncImpl(RecognitionMode.Interactive, cb, err);\r\n }\r\n\r\n /**\r\n * Starts speech recognition, until stopContinuousRecognitionAsync() is called.\r\n * User must subscribe to events to receive recognition results.\r\n * @member SpeechRecognizer.prototype.startContinuousRecognitionAsync\r\n * @function\r\n * @public\r\n * @param cb - Callback invoked once the recognition has started.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public startContinuousRecognitionAsync(cb?: () => void, err?: (e: string) => void): void {\r\n this.startContinuousRecognitionAsyncImpl(RecognitionMode.Conversation, cb, err);\r\n }\r\n\r\n /**\r\n * Stops continuous speech recognition.\r\n * @member SpeechRecognizer.prototype.stopContinuousRecognitionAsync\r\n * @function\r\n * @public\r\n * @param cb - Callback invoked once the recognition has stopped.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public stopContinuousRecognitionAsync(cb?: () => void, err?: (e: string) => void): void {\r\n this.stopContinuousRecognitionAsyncImpl(cb, err);\r\n }\r\n\r\n /**\r\n * Starts speech recognition with keyword spotting, until\r\n * stopKeywordRecognitionAsync() is called.\r\n * User must subscribe to events to receive recognition results.\r\n * Note: Key word spotting functionality is only available on the\r\n * Speech Devices SDK. This functionality is currently not included in the SDK itself.\r\n * @member SpeechRecognizer.prototype.startKeywordRecognitionAsync\r\n * @function\r\n * @public\r\n * @param {KeywordRecognitionModel} model The keyword recognition model that\r\n * specifies the keyword to be recognized.\r\n * @param cb - Callback invoked once the recognition has started.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public startKeywordRecognitionAsync(model: KeywordRecognitionModel, cb?: () => void, err?: (e: string) => void): void {\r\n Contracts.throwIfNull(model, \"model\");\r\n\r\n if (!!err) {\r\n err(\"Not yet implemented.\");\r\n }\r\n }\r\n\r\n /**\r\n * Stops continuous speech recognition.\r\n * Note: Key word spotting functionality is only available on the\r\n * Speech Devices SDK. This functionality is currently not included in the SDK itself.\r\n * @member SpeechRecognizer.prototype.stopKeywordRecognitionAsync\r\n * @function\r\n * @public\r\n * @param cb - Callback invoked once the recognition has stopped.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public stopKeywordRecognitionAsync(cb?: () => void, err?: (e: string) => void): void {\r\n if (!!cb) {\r\n cb();\r\n }\r\n }\r\n\r\n /**\r\n * closes all external resources held by an instance of this class.\r\n * @member SpeechRecognizer.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(): void {\r\n Contracts.throwIfDisposed(this.privDisposedSpeechRecognizer);\r\n\r\n this.dispose(true);\r\n }\r\n\r\n /**\r\n * Disposes any resources held by the object.\r\n * @member SpeechRecognizer.prototype.dispose\r\n * @function\r\n * @public\r\n * @param {boolean} disposing - true if disposing the object.\r\n */\r\n protected dispose(disposing: boolean): void {\r\n if (this.privDisposedSpeechRecognizer) {\r\n return;\r\n }\r\n\r\n if (disposing) {\r\n this.implRecognizerStop(); // Dispose is synchronous, so just start it....\r\n this.privDisposedSpeechRecognizer = true;\r\n }\r\n\r\n super.dispose(disposing);\r\n }\r\n\r\n protected createRecognizerConfig(speechConfig: SpeechServiceConfig): RecognizerConfig {\r\n return new RecognizerConfig(\r\n speechConfig,\r\n this.properties);\r\n }\r\n\r\n protected createServiceRecognizer(\r\n authentication: IAuthentication,\r\n connectionFactory: IConnectionFactory,\r\n audioConfig: AudioConfig,\r\n recognizerConfig: RecognizerConfig): ServiceRecognizerBase {\r\n const configImpl: AudioConfigImpl = audioConfig as AudioConfigImpl;\r\n return new SpeechServiceRecognizer(authentication, connectionFactory, configImpl, recognizerConfig, this);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n ProxyInfo,\r\n WebsocketConnection,\r\n} from \"../common.browser/Exports\";\r\nimport {\r\n ForceDictationPropertyName,\r\n OutputFormatPropertyName,\r\n} from \"../common.speech/Exports\";\r\nimport {\r\n IConnection,\r\n IStringDictionary\r\n} from \"../common/Exports\";\r\nimport {\r\n OutputFormat,\r\n PropertyId\r\n} from \"../sdk/Exports\";\r\nimport {\r\n ConnectionFactoryBase\r\n} from \"./ConnectionFactoryBase\";\r\nimport {\r\n AuthInfo,\r\n RecognitionMode,\r\n RecognizerConfig,\r\n WebsocketMessageFormatter\r\n} from \"./Exports\";\r\nimport {\r\n QueryParameterNames\r\n} from \"./QueryParameterNames\";\r\n\r\nexport class SpeechConnectionFactory extends ConnectionFactoryBase {\r\n\r\n private readonly interactiveRelativeUri: string = \"/speech/recognition/interactive/cognitiveservices/v1\";\r\n private readonly conversationRelativeUri: string = \"/speech/recognition/conversation/cognitiveservices/v1\";\r\n private readonly dictationRelativeUri: string = \"/speech/recognition/dictation/cognitiveservices/v1\";\r\n\r\n public create = (\r\n config: RecognizerConfig,\r\n authInfo: AuthInfo,\r\n connectionId?: string): IConnection => {\r\n\r\n let endpoint: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint, undefined);\r\n const region: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Region, undefined);\r\n const hostSuffix: string = (region && region.toLowerCase().startsWith(\"china\")) ? \".azure.cn\" : \".microsoft.com\";\r\n const host: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, \"wss://\" + region + \".stt.speech\" + hostSuffix);\r\n\r\n const queryParams: IStringDictionary = {};\r\n\r\n const endpointId: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_EndpointId, undefined);\r\n const language: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage, undefined);\r\n\r\n if (endpointId) {\r\n if (!endpoint || endpoint.search(QueryParameterNames.DeploymentIdParamName) === -1) {\r\n queryParams[QueryParameterNames.DeploymentIdParamName] = endpointId;\r\n }\r\n } else if (language) {\r\n if (!endpoint || endpoint.search(QueryParameterNames.LanguageParamName) === -1) {\r\n queryParams[QueryParameterNames.LanguageParamName] = language;\r\n }\r\n }\r\n\r\n if (!endpoint || endpoint.search(QueryParameterNames.FormatParamName) === -1) {\r\n queryParams[QueryParameterNames.FormatParamName] = config.parameters.getProperty(OutputFormatPropertyName, OutputFormat[OutputFormat.Simple]).toLowerCase();\r\n }\r\n\r\n if (config.autoDetectSourceLanguages !== undefined) {\r\n queryParams[QueryParameterNames.EnableLanguageID] = \"true\";\r\n }\r\n\r\n this.setCommonUrlParams(config, queryParams, endpoint);\r\n\r\n if (!endpoint) {\r\n switch (config.recognitionMode) {\r\n case RecognitionMode.Conversation:\r\n if (config.parameters.getProperty(ForceDictationPropertyName, \"false\") === \"true\") {\r\n endpoint = host + this.dictationRelativeUri;\r\n } else {\r\n endpoint = host + this.conversationRelativeUri;\r\n }\r\n break;\r\n case RecognitionMode.Dictation:\r\n endpoint = host + this.dictationRelativeUri;\r\n break;\r\n default:\r\n endpoint = host + this.interactiveRelativeUri; // default is interactive\r\n break;\r\n }\r\n }\r\n\r\n const headers: IStringDictionary = {};\r\n if (authInfo.token !== undefined && authInfo.token !== \"\") {\r\n headers[authInfo.headerName] = authInfo.token;\r\n }\r\n headers[QueryParameterNames.ConnectionIdHeader] = connectionId;\r\n\r\n config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, endpoint);\r\n\r\n return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), connectionId);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n ServicePropertiesPropertyName,\r\n} from \"../common.speech/Exports\";\r\nimport { IConnection, IStringDictionary } from \"../common/Exports\";\r\nimport { OutputFormat, PropertyId } from \"../sdk/Exports\";\r\nimport { AuthInfo, IConnectionFactory, RecognitionMode, RecognizerConfig, WebsocketMessageFormatter } from \"./Exports\";\r\nimport { QueryParameterNames } from \"./QueryParameterNames\";\r\n\r\nexport abstract class ConnectionFactoryBase implements IConnectionFactory {\r\n public abstract create(\r\n config: RecognizerConfig,\r\n authInfo: AuthInfo,\r\n connectionId?: string): IConnection;\r\n\r\n protected setCommonUrlParams(\r\n config: RecognizerConfig,\r\n queryParams: IStringDictionary,\r\n endpoint: string): void {\r\n\r\n this.setUrlParameter(PropertyId.SpeechServiceConnection_EnableAudioLogging,\r\n QueryParameterNames.EnableAudioLogging,\r\n config,\r\n queryParams,\r\n endpoint);\r\n\r\n this.setUrlParameter(PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps,\r\n QueryParameterNames.EnableWordLevelTimestamps,\r\n config,\r\n queryParams,\r\n endpoint);\r\n\r\n this.setUrlParameter(PropertyId.SpeechServiceResponse_ProfanityOption,\r\n QueryParameterNames.Profanify,\r\n config,\r\n queryParams,\r\n endpoint);\r\n\r\n this.setUrlParameter(PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs,\r\n QueryParameterNames.InitialSilenceTimeoutMs,\r\n config,\r\n queryParams,\r\n endpoint);\r\n\r\n this.setUrlParameter(PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs,\r\n QueryParameterNames.EndSilenceTimeoutMs,\r\n config,\r\n queryParams,\r\n endpoint);\r\n\r\n this.setUrlParameter(PropertyId.SpeechServiceResponse_StablePartialResultThreshold,\r\n QueryParameterNames.StableIntermediateThreshold,\r\n config,\r\n queryParams,\r\n endpoint);\r\n\r\n const serviceProperties: IStringDictionary = JSON.parse(config.parameters.getProperty(ServicePropertiesPropertyName, \"{}\"));\r\n\r\n Object.keys(serviceProperties).forEach((value: string, num: number, array: string[]) => {\r\n queryParams[value] = serviceProperties[value];\r\n });\r\n }\r\n\r\n protected setUrlParameter(\r\n propId: PropertyId,\r\n parameterName: string,\r\n config: RecognizerConfig,\r\n queryParams: IStringDictionary,\r\n endpoint: string): void {\r\n\r\n const value: string = config.parameters.getProperty(propId, undefined);\r\n\r\n if (value && (!endpoint || endpoint.search(parameterName) === -1)) {\r\n queryParams[parameterName] = value.toLocaleLowerCase();\r\n }\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nexport class QueryParameterNames {\r\n public static get TestHooksParamName(): string {\r\n return \"testhooks\";\r\n }\r\n public static get ConnectionIdHeader(): string {\r\n return \"X-ConnectionId\";\r\n }\r\n public static get DeploymentIdParamName(): string {\r\n return \"cid\";\r\n }\r\n public static get FormatParamName(): string {\r\n return \"format\";\r\n }\r\n public static get LanguageParamName(): string {\r\n return \"language\";\r\n }\r\n public static get TranslationFromParamName(): string {\r\n return \"from\";\r\n }\r\n public static get TranslationToParamName(): string {\r\n return \"to\";\r\n }\r\n public static get Profanify(): string {\r\n return \"profanity\";\r\n }\r\n public static get EnableAudioLogging(): string {\r\n return \"storeAudio\";\r\n }\r\n public static get EnableWordLevelTimestamps(): string {\r\n return \"wordLevelTimestamps\";\r\n }\r\n public static get InitialSilenceTimeoutMs(): string {\r\n return \"initialSilenceTimeoutMs\";\r\n }\r\n public static get EndSilenceTimeoutMs(): string {\r\n return \"endSilenceTimeoutMs\";\r\n }\r\n public static get StableIntermediateThreshold(): string {\r\n return \"stableIntermediateThreshold\";\r\n }\r\n public static get StableTranslation(): string {\r\n return \"stableTranslation\";\r\n }\r\n public static get EnableLanguageID(): string {\r\n return \"lidEnabled\";\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n AddedLmIntent,\r\n IAuthentication,\r\n IConnectionFactory,\r\n IntentConnectionFactory,\r\n IntentServiceRecognizer,\r\n RecognitionMode,\r\n RecognizerConfig,\r\n ServiceRecognizerBase,\r\n SpeechServiceConfig,\r\n} from \"../common.speech/Exports\";\r\nimport { AudioConfigImpl } from \"./Audio/AudioConfig\";\r\nimport { Contracts } from \"./Contracts\";\r\nimport {\r\n AudioConfig,\r\n IntentRecognitionCanceledEventArgs,\r\n IntentRecognitionEventArgs,\r\n IntentRecognitionResult,\r\n KeywordRecognitionModel,\r\n LanguageUnderstandingModel,\r\n PropertyCollection,\r\n PropertyId,\r\n Recognizer,\r\n SpeechConfig,\r\n} from \"./Exports\";\r\nimport { LanguageUnderstandingModelImpl } from \"./LanguageUnderstandingModel\";\r\nimport { SpeechConfigImpl } from \"./SpeechConfig\";\r\n\r\n/**\r\n * Intent recognizer.\r\n * @class\r\n */\r\nexport class IntentRecognizer extends Recognizer {\r\n private privDisposedIntentRecognizer: boolean;\r\n private privAddedIntents: string[][];\r\n private privAddedLmIntents: { [id: string]: AddedLmIntent; };\r\n private privUmbrellaIntent: AddedLmIntent;\r\n\r\n /**\r\n * Initializes an instance of the IntentRecognizer.\r\n * @constructor\r\n * @param {SpeechConfig} speechConfig - The set of configuration properties.\r\n * @param {AudioConfig} audioConfig - An optional audio input config associated with the recognizer\r\n */\r\n public constructor(speechConfig: SpeechConfig, audioConfig?: AudioConfig) {\r\n Contracts.throwIfNullOrUndefined(speechConfig, \"speechConfig\");\r\n const configImpl: SpeechConfigImpl = speechConfig as SpeechConfigImpl;\r\n Contracts.throwIfNullOrUndefined(configImpl, \"speechConfig\");\r\n\r\n super(audioConfig, configImpl.properties, new IntentConnectionFactory());\r\n this.privAddedIntents = [];\r\n this.privAddedLmIntents = {};\r\n\r\n this.privDisposedIntentRecognizer = false;\r\n this.privProperties = configImpl.properties;\r\n\r\n Contracts.throwIfNullOrWhitespace(this.properties.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage), PropertyId[PropertyId.SpeechServiceConnection_RecoLanguage]);\r\n }\r\n\r\n /**\r\n * The event recognizing signals that an intermediate recognition result is received.\r\n * @member IntentRecognizer.prototype.recognizing\r\n * @function\r\n * @public\r\n */\r\n public recognizing: (sender: IntentRecognizer, event: IntentRecognitionEventArgs) => void;\r\n\r\n /**\r\n * The event recognized signals that a final recognition result is received.\r\n * @member IntentRecognizer.prototype.recognized\r\n * @function\r\n * @public\r\n */\r\n public recognized: (sender: IntentRecognizer, event: IntentRecognitionEventArgs) => void;\r\n\r\n /**\r\n * The event canceled signals that an error occurred during recognition.\r\n * @member IntentRecognizer.prototype.canceled\r\n * @function\r\n * @public\r\n */\r\n public canceled: (sender: IntentRecognizer, event: IntentRecognitionCanceledEventArgs) => void;\r\n\r\n /**\r\n * Gets the spoken language of recognition.\r\n * @member IntentRecognizer.prototype.speechRecognitionLanguage\r\n * @function\r\n * @public\r\n * @returns {string} the spoken language of recognition.\r\n */\r\n public get speechRecognitionLanguage(): string {\r\n Contracts.throwIfDisposed(this.privDisposedIntentRecognizer);\r\n\r\n return this.properties.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage);\r\n }\r\n\r\n /**\r\n * Gets the authorization token used to communicate with the service.\r\n * @member IntentRecognizer.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @returns {string} Authorization token.\r\n */\r\n public get authorizationToken(): string {\r\n return this.properties.getProperty(PropertyId.SpeechServiceAuthorization_Token);\r\n }\r\n\r\n /**\r\n * Gets/Sets the authorization token used to communicate with the service.\r\n * Note: Please use a token derived from your LanguageUnderstanding subscription key for the Intent recognizer.\r\n * @member IntentRecognizer.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @param {string} value - Authorization token.\r\n */\r\n public set authorizationToken(value: string) {\r\n this.properties.setProperty(PropertyId.SpeechServiceAuthorization_Token, value);\r\n }\r\n\r\n /**\r\n * The collection of properties and their values defined for this IntentRecognizer.\r\n * @member IntentRecognizer.prototype.properties\r\n * @function\r\n * @public\r\n * @returns {PropertyCollection} The collection of properties and their\r\n * values defined for this IntentRecognizer.\r\n */\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n /**\r\n * Starts intent recognition, and stops after the first utterance is recognized.\r\n * The task returns the recognition text and intent as result.\r\n * Note: RecognizeOnceAsync() returns when the first utterance has been recognized,\r\n * so it is suitable only for single shot recognition like command or query.\r\n * For long-running recognition, use StartContinuousRecognitionAsync() instead.\r\n * @member IntentRecognizer.prototype.recognizeOnceAsync\r\n * @function\r\n * @public\r\n * @param cb - Callback that received the recognition has finished with an IntentRecognitionResult.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public recognizeOnceAsync(cb?: (e: IntentRecognitionResult) => void, err?: (e: string) => void): void {\r\n Contracts.throwIfDisposed(this.privDisposedIntentRecognizer);\r\n\r\n if (Object.keys(this.privAddedLmIntents).length !== 0 || undefined !== this.privUmbrellaIntent) {\r\n const context: IIntentContext = this.buildSpeechContext();\r\n\r\n this.privReco.speechContext.setSection(\"intent\", context.Intent);\r\n this.privReco.dynamicGrammar.addReferenceGrammar(context.ReferenceGrammars);\r\n\r\n const intentReco: IntentServiceRecognizer = this.privReco as IntentServiceRecognizer;\r\n intentReco.setIntents(this.privAddedLmIntents, this.privUmbrellaIntent);\r\n }\r\n\r\n this.recognizeOnceAsyncImpl(RecognitionMode.Interactive, cb, err);\r\n }\r\n\r\n /**\r\n * Starts speech recognition, until stopContinuousRecognitionAsync() is called.\r\n * User must subscribe to events to receive recognition results.\r\n * @member IntentRecognizer.prototype.startContinuousRecognitionAsync\r\n * @function\r\n * @public\r\n * @param cb - Callback invoked once the recognition has started.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public startContinuousRecognitionAsync(cb?: () => void, err?: (e: string) => void): void {\r\n if (Object.keys(this.privAddedLmIntents).length !== 0) {\r\n const context: IIntentContext = this.buildSpeechContext();\r\n\r\n this.privReco.speechContext.setSection(\"intent\", context.Intent);\r\n this.privReco.dynamicGrammar.addReferenceGrammar(context.ReferenceGrammars);\r\n\r\n const intentReco: IntentServiceRecognizer = this.privReco as IntentServiceRecognizer;\r\n intentReco.setIntents(this.privAddedLmIntents, this.privUmbrellaIntent);\r\n }\r\n\r\n this.startContinuousRecognitionAsyncImpl(RecognitionMode.Conversation, cb, err);\r\n }\r\n\r\n /**\r\n * Stops continuous intent recognition.\r\n * @member IntentRecognizer.prototype.stopContinuousRecognitionAsync\r\n * @function\r\n * @public\r\n * @param cb - Callback invoked once the recognition has stopped.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public stopContinuousRecognitionAsync(cb?: () => void, err?: (e: string) => void): void {\r\n this.stopContinuousRecognitionAsyncImpl(cb, err);\r\n }\r\n\r\n /**\r\n * Starts speech recognition with keyword spotting, until stopKeywordRecognitionAsync() is called.\r\n * User must subscribe to events to receive recognition results.\r\n * Note: Key word spotting functionality is only available on the Speech Devices SDK.\r\n * This functionality is currently not included in the SDK itself.\r\n * @member IntentRecognizer.prototype.startKeywordRecognitionAsync\r\n * @function\r\n * @public\r\n * @param {KeywordRecognitionModel} model - The keyword recognition model that specifies the keyword to be recognized.\r\n * @param cb - Callback invoked once the recognition has started.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public startKeywordRecognitionAsync(model: KeywordRecognitionModel, cb?: () => void, err?: (e: string) => void): void {\r\n Contracts.throwIfNull(model, \"model\");\r\n\r\n if (!!err) {\r\n err(\"Not yet implemented.\");\r\n }\r\n }\r\n\r\n /**\r\n * Stops continuous speech recognition.\r\n * Note: Key word spotting functionality is only available on the Speech Devices SDK.\r\n * This functionality is currently not included in the SDK itself.\r\n * @member IntentRecognizer.prototype.stopKeywordRecognitionAsync\r\n * @function\r\n * @public\r\n * @param cb - Callback invoked once the recognition has stopped.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public stopKeywordRecognitionAsync(cb?: () => void, err?: (e: string) => void): void {\r\n if (!!cb) {\r\n cb();\r\n }\r\n }\r\n\r\n /**\r\n * Adds a phrase that should be recognized as intent.\r\n * @member IntentRecognizer.prototype.addIntent\r\n * @function\r\n * @public\r\n * @param {string} intentId - A String that represents the identifier of the intent to be recognized.\r\n * @param {string} phrase - A String that specifies the phrase representing the intent.\r\n */\r\n public addIntent(simplePhrase: string, intentId?: string): void {\r\n Contracts.throwIfDisposed(this.privDisposedIntentRecognizer);\r\n Contracts.throwIfNullOrWhitespace(intentId, \"intentId\");\r\n Contracts.throwIfNullOrWhitespace(simplePhrase, \"simplePhrase\");\r\n\r\n this.privAddedIntents.push([intentId, simplePhrase]);\r\n }\r\n\r\n /**\r\n * Adds an intent from Language Understanding service for recognition.\r\n * @member IntentRecognizer.prototype.addIntentWithLanguageModel\r\n * @function\r\n * @public\r\n * @param {string} intentId - A String that represents the identifier of the intent\r\n * to be recognized. Ignored if intentName is empty.\r\n * @param {string} model - The intent model from Language Understanding service.\r\n * @param {string} intentName - The intent name defined in the intent model. If it\r\n * is empty, all intent names defined in the model will be added.\r\n */\r\n public addIntentWithLanguageModel(intentId: string, model: LanguageUnderstandingModel, intentName?: string): void {\r\n Contracts.throwIfDisposed(this.privDisposedIntentRecognizer);\r\n Contracts.throwIfNullOrWhitespace(intentId, \"intentId\");\r\n Contracts.throwIfNull(model, \"model\");\r\n\r\n const modelImpl: LanguageUnderstandingModelImpl = model as LanguageUnderstandingModelImpl;\r\n Contracts.throwIfNullOrWhitespace(modelImpl.appId, \"model.appId\");\r\n\r\n this.privAddedLmIntents[intentId] = new AddedLmIntent(modelImpl, intentName);\r\n }\r\n\r\n /**\r\n * @summary Adds all intents from the specified Language Understanding Model.\r\n * @member IntentRecognizer.prototype.addAllIntents\r\n * @function\r\n * @public\r\n * @function\r\n * @public\r\n * @param {LanguageUnderstandingModel} model - The language understanding model containing the intents.\r\n * @param {string} intentId - A custom id String to be returned in the IntentRecognitionResult's getIntentId() method.\r\n */\r\n public addAllIntents(model: LanguageUnderstandingModel, intentId?: string): void {\r\n Contracts.throwIfNull(model, \"model\");\r\n\r\n const modelImpl: LanguageUnderstandingModelImpl = model as LanguageUnderstandingModelImpl;\r\n Contracts.throwIfNullOrWhitespace(modelImpl.appId, \"model.appId\");\r\n\r\n this.privUmbrellaIntent = new AddedLmIntent(modelImpl, intentId);\r\n }\r\n\r\n /**\r\n * closes all external resources held by an instance of this class.\r\n * @member IntentRecognizer.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(): void {\r\n Contracts.throwIfDisposed(this.privDisposedIntentRecognizer);\r\n\r\n this.dispose(true);\r\n }\r\n\r\n protected createRecognizerConfig(speechConfig: SpeechServiceConfig): RecognizerConfig {\r\n return new RecognizerConfig(speechConfig, this.properties);\r\n }\r\n\r\n protected createServiceRecognizer(authentication: IAuthentication, connectionFactory: IConnectionFactory, audioConfig: AudioConfig, recognizerConfig: RecognizerConfig): ServiceRecognizerBase {\r\n const audioImpl: AudioConfigImpl = audioConfig as AudioConfigImpl;\r\n return new IntentServiceRecognizer(authentication, connectionFactory, audioImpl, recognizerConfig, this);\r\n }\r\n\r\n protected dispose(disposing: boolean): void {\r\n if (this.privDisposedIntentRecognizer) {\r\n return;\r\n }\r\n\r\n if (disposing) {\r\n this.privDisposedIntentRecognizer = true;\r\n super.dispose(disposing);\r\n }\r\n }\r\n\r\n private buildSpeechContext(): IIntentContext {\r\n let appId: string;\r\n let region: string;\r\n let subscriptionKey: string;\r\n const refGrammers: string[] = [];\r\n\r\n if (undefined !== this.privUmbrellaIntent) {\r\n appId = this.privUmbrellaIntent.modelImpl.appId;\r\n region = this.privUmbrellaIntent.modelImpl.region;\r\n subscriptionKey = this.privUmbrellaIntent.modelImpl.subscriptionKey;\r\n }\r\n\r\n // Build the reference grammer array.\r\n for (const intentId of Object.keys(this.privAddedLmIntents)) {\r\n const addedLmIntent: AddedLmIntent = this.privAddedLmIntents[intentId];\r\n\r\n // validate all the same model, region, and key...\r\n if (appId === undefined) {\r\n appId = addedLmIntent.modelImpl.appId;\r\n } else {\r\n if (appId !== addedLmIntent.modelImpl.appId) {\r\n throw new Error(\"Intents must all be from the same LUIS model\");\r\n }\r\n }\r\n\r\n if (region === undefined) {\r\n region = addedLmIntent.modelImpl.region;\r\n } else {\r\n if (region !== addedLmIntent.modelImpl.region) {\r\n throw new Error(\"Intents must all be from the same LUIS model in a single region\");\r\n }\r\n }\r\n\r\n if (subscriptionKey === undefined) {\r\n subscriptionKey = addedLmIntent.modelImpl.subscriptionKey;\r\n } else {\r\n if (subscriptionKey !== addedLmIntent.modelImpl.subscriptionKey) {\r\n throw new Error(\"Intents must all use the same subscription key\");\r\n }\r\n }\r\n\r\n const grammer: string = \"luis/\" + appId + \"-PRODUCTION#\" + intentId;\r\n refGrammers.push(grammer);\r\n }\r\n\r\n return {\r\n Intent: {\r\n id: appId,\r\n key: (subscriptionKey === undefined) ? this.privProperties.getProperty(PropertyId[PropertyId.SpeechServiceConnection_Key]) : subscriptionKey,\r\n provider: \"LUIS\",\r\n },\r\n ReferenceGrammars: (undefined === this.privUmbrellaIntent) ? refGrammers : [\"luis/\" + appId + \"-PRODUCTION\"],\r\n };\r\n }\r\n}\r\n\r\ninterface IIntentContext {\r\n Intent: {\r\n id: string,\r\n key: string,\r\n provider: string,\r\n };\r\n ReferenceGrammars: string[];\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * Output format\r\n * @class VoiceProfileType\r\n */\r\nexport enum VoiceProfileType {\r\n\r\n /**\r\n * Text independent speaker identification\r\n * @member VoiceProfileType.TextIndependentIdentification\r\n */\r\n TextIndependentIdentification,\r\n\r\n /**\r\n * Text dependent speaker verification\r\n * @member VoiceProfileType.TextDependentVerification\r\n */\r\n TextDependentVerification,\r\n\r\n /**\r\n * Text independent speaker verification\r\n * @member VoiceProfileType.TextIndependentVerification\r\n */\r\n TextIndependentVerification,\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n IAuthentication,\r\n IConnectionFactory,\r\n RecognitionMode,\r\n RecognizerConfig,\r\n ServiceRecognizerBase,\r\n SpeechServiceConfig,\r\n TranslationConnectionFactory,\r\n TranslationServiceRecognizer,\r\n} from \"../common.speech/Exports\";\r\nimport { AudioConfigImpl } from \"./Audio/AudioConfig\";\r\nimport { Contracts } from \"./Contracts\";\r\nimport {\r\n AudioConfig,\r\n PropertyCollection,\r\n PropertyId,\r\n Recognizer,\r\n TranslationRecognitionCanceledEventArgs,\r\n TranslationRecognitionEventArgs,\r\n TranslationRecognitionResult,\r\n TranslationSynthesisEventArgs,\r\n} from \"./Exports\";\r\nimport { SpeechTranslationConfig, SpeechTranslationConfigImpl } from \"./SpeechTranslationConfig\";\r\n\r\n/**\r\n * Translation recognizer\r\n * @class TranslationRecognizer\r\n */\r\nexport class TranslationRecognizer extends Recognizer {\r\n private privDisposedTranslationRecognizer: boolean;\r\n\r\n /**\r\n * Initializes an instance of the TranslationRecognizer.\r\n * @constructor\r\n * @param {SpeechTranslationConfig} speechConfig - Set of properties to configure this recognizer.\r\n * @param {AudioConfig} audioConfig - An optional audio config associated with the recognizer\r\n */\r\n public constructor(speechConfig: SpeechTranslationConfig, audioConfig?: AudioConfig) {\r\n const configImpl = speechConfig as SpeechTranslationConfigImpl;\r\n Contracts.throwIfNull(configImpl, \"speechConfig\");\r\n\r\n super(audioConfig, configImpl.properties, new TranslationConnectionFactory());\r\n\r\n this.privDisposedTranslationRecognizer = false;\r\n this.privProperties = configImpl.properties.clone();\r\n\r\n if (this.properties.getProperty(PropertyId.SpeechServiceConnection_TranslationVoice, undefined) !== undefined) {\r\n Contracts.throwIfNullOrWhitespace(\r\n this.properties.getProperty(PropertyId.SpeechServiceConnection_TranslationVoice),\r\n PropertyId[PropertyId.SpeechServiceConnection_TranslationVoice]);\r\n }\r\n\r\n Contracts.throwIfNullOrWhitespace(\r\n this.properties.getProperty(PropertyId.SpeechServiceConnection_TranslationToLanguages),\r\n PropertyId[PropertyId.SpeechServiceConnection_TranslationToLanguages]);\r\n\r\n Contracts.throwIfNullOrWhitespace(this.properties.getProperty(\r\n PropertyId.SpeechServiceConnection_RecoLanguage),\r\n PropertyId[PropertyId.SpeechServiceConnection_RecoLanguage]);\r\n }\r\n\r\n /**\r\n * The event recognizing signals that an intermediate recognition result is received.\r\n * @member TranslationRecognizer.prototype.recognizing\r\n * @function\r\n * @public\r\n */\r\n public recognizing: (sender: TranslationRecognizer, event: TranslationRecognitionEventArgs) => void;\r\n\r\n /**\r\n * The event recognized signals that a final recognition result is received.\r\n * @member TranslationRecognizer.prototype.recognized\r\n * @function\r\n * @public\r\n */\r\n public recognized: (sender: TranslationRecognizer, event: TranslationRecognitionEventArgs) => void;\r\n\r\n /**\r\n * The event canceled signals that an error occurred during recognition.\r\n * @member TranslationRecognizer.prototype.canceled\r\n * @function\r\n * @public\r\n */\r\n public canceled: (sender: TranslationRecognizer, event: TranslationRecognitionCanceledEventArgs) => void;\r\n\r\n /**\r\n * The event synthesizing signals that a translation synthesis result is received.\r\n * @member TranslationRecognizer.prototype.synthesizing\r\n * @function\r\n * @public\r\n */\r\n public synthesizing: (sender: TranslationRecognizer, event: TranslationSynthesisEventArgs) => void;\r\n\r\n /**\r\n * Gets the language name that was set when the recognizer was created.\r\n * @member TranslationRecognizer.prototype.speechRecognitionLanguage\r\n * @function\r\n * @public\r\n * @returns {string} Gets the language name that was set when the recognizer was created.\r\n */\r\n public get speechRecognitionLanguage(): string {\r\n Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer);\r\n\r\n return this.properties.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage);\r\n }\r\n\r\n /**\r\n * Gets target languages for translation that were set when the recognizer was created.\r\n * The language is specified in BCP-47 format. The translation will provide translated text for each of language.\r\n * @member TranslationRecognizer.prototype.targetLanguages\r\n * @function\r\n * @public\r\n * @returns {string[]} Gets target languages for translation that were set when the recognizer was created.\r\n */\r\n public get targetLanguages(): string[] {\r\n Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer);\r\n\r\n return this.properties.getProperty(PropertyId.SpeechServiceConnection_TranslationToLanguages).split(\",\");\r\n }\r\n\r\n /**\r\n * Gets the name of output voice.\r\n * @member TranslationRecognizer.prototype.voiceName\r\n * @function\r\n * @public\r\n * @returns {string} the name of output voice.\r\n */\r\n public get voiceName(): string {\r\n Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer);\r\n\r\n return this.properties.getProperty(PropertyId.SpeechServiceConnection_TranslationVoice, undefined);\r\n }\r\n\r\n /**\r\n * Gets the authorization token used to communicate with the service.\r\n * @member TranslationRecognizer.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @returns {string} Authorization token.\r\n */\r\n public get authorizationToken(): string {\r\n return this.properties.getProperty(PropertyId.SpeechServiceAuthorization_Token);\r\n }\r\n\r\n /**\r\n * Gets/Sets the authorization token used to communicate with the service.\r\n * @member TranslationRecognizer.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @param {string} value - Authorization token.\r\n */\r\n public set authorizationToken(value: string) {\r\n this.properties.setProperty(PropertyId.SpeechServiceAuthorization_Token, value);\r\n }\r\n\r\n /**\r\n * The collection of properties and their values defined for this TranslationRecognizer.\r\n * @member TranslationRecognizer.prototype.properties\r\n * @function\r\n * @public\r\n * @returns {PropertyCollection} The collection of properties and their values defined for this TranslationRecognizer.\r\n */\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n /**\r\n * Starts recognition and translation, and stops after the first utterance is recognized.\r\n * The task returns the translation text as result.\r\n * Note: recognizeOnceAsync returns when the first utterance has been recognized, so it is suitableonly\r\n * for single shot recognition like command or query. For long-running recognition,\r\n * use startContinuousRecognitionAsync() instead.\r\n * @member TranslationRecognizer.prototype.recognizeOnceAsync\r\n * @function\r\n * @public\r\n * @param cb - Callback that received the result when the translation has completed.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public recognizeOnceAsync(cb?: (e: TranslationRecognitionResult) => void, err?: (e: string) => void): void {\r\n Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer);\r\n this.recognizeOnceAsyncImpl(RecognitionMode.Conversation, cb, err);\r\n }\r\n\r\n /**\r\n * Starts recognition and translation, until stopContinuousRecognitionAsync() is called.\r\n * User must subscribe to events to receive translation results.\r\n * @member TranslationRecognizer.prototype.startContinuousRecognitionAsync\r\n * @function\r\n * @public\r\n * @param cb - Callback that received the translation has started.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public startContinuousRecognitionAsync(cb?: () => void, err?: (e: string) => void): void {\r\n this.startContinuousRecognitionAsyncImpl(RecognitionMode.Conversation, cb, err);\r\n }\r\n\r\n /**\r\n * Stops continuous recognition and translation.\r\n * @member TranslationRecognizer.prototype.stopContinuousRecognitionAsync\r\n * @function\r\n * @public\r\n * @param cb - Callback that received the translation has stopped.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public stopContinuousRecognitionAsync(cb?: () => void, err?: (e: string) => void): void {\r\n this.stopContinuousRecognitionAsyncImpl(cb, err);\r\n }\r\n\r\n /**\r\n * closes all external resources held by an instance of this class.\r\n * @member TranslationRecognizer.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(): void {\r\n Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer);\r\n\r\n this.dispose(true);\r\n }\r\n\r\n protected dispose(disposing: boolean): boolean {\r\n if (this.privDisposedTranslationRecognizer) {\r\n return;\r\n }\r\n\r\n if (disposing) {\r\n this.implRecognizerStop();\r\n this.privDisposedTranslationRecognizer = true;\r\n super.dispose(disposing);\r\n }\r\n }\r\n\r\n protected createRecognizerConfig(speechConfig: SpeechServiceConfig): RecognizerConfig {\r\n return new RecognizerConfig(speechConfig, this.properties);\r\n }\r\n\r\n protected createServiceRecognizer(\r\n authentication: IAuthentication,\r\n connectionFactory: IConnectionFactory,\r\n audioConfig: AudioConfig,\r\n recognizerConfig: RecognizerConfig): ServiceRecognizerBase {\r\n\r\n const configImpl: AudioConfigImpl = audioConfig as AudioConfigImpl;\r\n\r\n return new TranslationServiceRecognizer(authentication, connectionFactory, configImpl, recognizerConfig, this);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { PropertyCollection } from \"./Exports\";\r\n\r\n/**\r\n * Represents collection of parameters and their values.\r\n * @class Translation\r\n */\r\nexport class Translations {\r\n // Use an PropertyCollection internally, just wrapping it to hide the | enum syntax it has.\r\n private privMap: PropertyCollection = new PropertyCollection();\r\n\r\n /**\r\n * Returns the parameter value in type String. The parameter must have the same type as String.\r\n * Currently only String, int and bool are allowed.\r\n * If the name is not available, the specified defaultValue is returned.\r\n * @member Translation.prototype.get\r\n * @function\r\n * @public\r\n * @param {string} key - The parameter name.\r\n * @param {string} def - The default value which is returned if the parameter is not available in the collection.\r\n * @returns {string} value of the parameter.\r\n */\r\n public get(key: string, def?: string): string {\r\n return this.privMap.getProperty(key, def);\r\n }\r\n\r\n /**\r\n * Sets the String value of the parameter specified by name.\r\n * @member Translation.prototype.set\r\n * @function\r\n * @public\r\n * @param {string} key - The parameter name.\r\n * @param {string} value - The value of the parameter.\r\n */\r\n public set(key: string, value: string): void {\r\n this.privMap.setProperty(key, value);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * Defines the possible reasons a recognition result might not be recognized.\r\n * @class NoMatchReason\r\n */\r\nexport enum NoMatchReason {\r\n\r\n /**\r\n * Indicates that speech was detected, but not recognized.\r\n * @member NoMatchReason.NotRecognized\r\n */\r\n NotRecognized,\r\n\r\n /**\r\n * Indicates that the start of the audio stream contained only silence,\r\n * and the service timed out waiting for speech.\r\n * @member NoMatchReason.InitialSilenceTimeout\r\n */\r\n InitialSilenceTimeout,\r\n\r\n /**\r\n * Indicates that the start of the audio stream contained only noise,\r\n * and the service timed out waiting for speech.\r\n * @member NoMatchReason.InitialBabbleTimeout\r\n */\r\n InitialBabbleTimeout,\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { RecognitionStatus, SimpleSpeechPhrase } from \"../../src/common.speech/Exports\";\r\nimport { IntentRecognitionResult, NoMatchReason, SpeechRecognitionResult, TranslationRecognitionResult } from \"./Exports\";\r\n\r\n/**\r\n * Contains detailed information for NoMatch recognition results.\r\n * @class NoMatchDetails\r\n */\r\nexport class NoMatchDetails {\r\n private privReason: NoMatchReason;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {NoMatchReason} reason - The no-match reason.\r\n */\r\n private constructor(reason: NoMatchReason) {\r\n this.privReason = reason;\r\n }\r\n\r\n /**\r\n * Creates an instance of NoMatchDetails object for the NoMatch SpeechRecognitionResults.\r\n * @member NoMatchDetails.fromResult\r\n * @function\r\n * @public\r\n * @param {SpeechRecognitionResult | IntentRecognitionResult | TranslationRecognitionResult}\r\n * result - The recognition result that was not recognized.\r\n * @returns {NoMatchDetails} The no match details object being created.\r\n */\r\n public static fromResult(result: SpeechRecognitionResult | IntentRecognitionResult | TranslationRecognitionResult): NoMatchDetails {\r\n const simpleSpeech: SimpleSpeechPhrase = SimpleSpeechPhrase.fromJSON(result.json);\r\n\r\n let reason: NoMatchReason = NoMatchReason.NotRecognized;\r\n\r\n switch (simpleSpeech.RecognitionStatus) {\r\n case RecognitionStatus.BabbleTimeout:\r\n reason = NoMatchReason.InitialBabbleTimeout;\r\n break;\r\n case RecognitionStatus.InitialSilenceTimeout:\r\n reason = NoMatchReason.InitialSilenceTimeout;\r\n break;\r\n default:\r\n reason = NoMatchReason.NotRecognized;\r\n break;\r\n }\r\n\r\n return new NoMatchDetails(reason);\r\n }\r\n\r\n /**\r\n * The reason the recognition was canceled.\r\n * @member NoMatchDetails.prototype.reason\r\n * @function\r\n * @public\r\n * @returns {NoMatchReason} Specifies the reason canceled.\r\n */\r\n public get reason(): NoMatchReason {\r\n return this.privReason;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { CancellationErrorCode, CancellationReason, TranslationRecognitionResult } from \"./Exports\";\r\n\r\n/**\r\n * Define payload of speech recognition canceled result events.\r\n * @class TranslationRecognitionCanceledEventArgs\r\n */\r\nexport class TranslationRecognitionCanceledEventArgs {\r\n private privResult: TranslationRecognitionResult;\r\n private privSessionId: string;\r\n private privCancelReason: CancellationReason;\r\n private privErrorDetails: string;\r\n private privErrorCode: CancellationErrorCode;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {string} sessionid - The session id.\r\n * @param {CancellationReason} cancellationReason - The cancellation reason.\r\n * @param {string} errorDetails - Error details, if provided.\r\n * @param {TranslationRecognitionResult} result - The result.\r\n */\r\n public constructor(\r\n sessionid: string,\r\n cancellationReason: CancellationReason,\r\n errorDetails: string,\r\n errorCode: CancellationErrorCode,\r\n result: TranslationRecognitionResult) {\r\n this.privCancelReason = cancellationReason;\r\n this.privErrorDetails = errorDetails;\r\n this.privResult = result;\r\n this.privSessionId = sessionid;\r\n this.privErrorCode = errorCode;\r\n }\r\n\r\n /**\r\n * Specifies the recognition result.\r\n * @member TranslationRecognitionCanceledEventArgs.prototype.result\r\n * @function\r\n * @public\r\n * @returns {TranslationRecognitionResult} the recognition result.\r\n */\r\n public get result(): TranslationRecognitionResult {\r\n return this.privResult;\r\n }\r\n\r\n /**\r\n * Specifies the session identifier.\r\n * @member TranslationRecognitionCanceledEventArgs.prototype.sessionId\r\n * @function\r\n * @public\r\n * @returns {string} the session identifier.\r\n */\r\n public get sessionId(): string {\r\n return this.privSessionId;\r\n }\r\n\r\n /**\r\n * The reason the recognition was canceled.\r\n * @member TranslationRecognitionCanceledEventArgs.prototype.reason\r\n * @function\r\n * @public\r\n * @returns {CancellationReason} Specifies the reason canceled.\r\n */\r\n public get reason(): CancellationReason {\r\n return this.privCancelReason;\r\n }\r\n\r\n /**\r\n * The error code in case of an unsuccessful recognition.\r\n * Added in version 1.1.0.\r\n * @return An error code that represents the error reason.\r\n */\r\n public get errorCode(): CancellationErrorCode {\r\n return this.privErrorCode;\r\n }\r\n\r\n /**\r\n * In case of an unsuccessful recognition, provides details of the occurred error.\r\n * @member TranslationRecognitionCanceledEventArgs.prototype.errorDetails\r\n * @function\r\n * @public\r\n * @returns {string} A String that represents the error details.\r\n */\r\n public get errorDetails(): string {\r\n return this.privErrorDetails;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { CancellationErrorCode, CancellationReason, IntentRecognitionEventArgs, IntentRecognitionResult } from \"./Exports\";\r\n\r\n/**\r\n * Define payload of intent recognition canceled result events.\r\n * @class IntentRecognitionCanceledEventArgs\r\n */\r\nexport class IntentRecognitionCanceledEventArgs extends IntentRecognitionEventArgs {\r\n private privReason: CancellationReason;\r\n private privErrorDetails: string;\r\n private privErrorCode: CancellationErrorCode;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {CancellationReason} result - The result of the intent recognition.\r\n * @param {string} offset - The offset.\r\n * @param {IntentRecognitionResult} sessionId - The session id.\r\n */\r\n public constructor(\r\n reason: CancellationReason,\r\n errorDetails: string,\r\n errorCode: CancellationErrorCode,\r\n result?: IntentRecognitionResult,\r\n offset?: number,\r\n sessionId?: string) {\r\n super(result, offset, sessionId);\r\n\r\n this.privReason = reason;\r\n this.privErrorDetails = errorDetails;\r\n this.privErrorCode = errorCode;\r\n }\r\n\r\n /**\r\n * The reason the recognition was canceled.\r\n * @member IntentRecognitionCanceledEventArgs.prototype.reason\r\n * @function\r\n * @public\r\n * @returns {CancellationReason} Specifies the reason canceled.\r\n */\r\n public get reason(): CancellationReason {\r\n return this.privReason;\r\n }\r\n\r\n /**\r\n * The error code in case of an unsuccessful recognition.\r\n * Added in version 1.1.0.\r\n * @return An error code that represents the error reason.\r\n */\r\n public get errorCode(): CancellationErrorCode {\r\n return this.privErrorCode;\r\n }\r\n\r\n /**\r\n * In case of an unsuccessful recognition, provides details of the occurred error.\r\n * @member IntentRecognitionCanceledEventArgs.prototype.errorDetails\r\n * @function\r\n * @public\r\n * @returns {string} A String that represents the error details.\r\n */\r\n public get errorDetails(): string {\r\n return this.privErrorDetails;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n CancellationErrorCode,\r\n CancellationReason,\r\n} from \"./Exports\";\r\n\r\n/**\r\n * Contains detailed information about why a result was canceled.\r\n * @class CancellationDetailsBase\r\n */\r\nexport class CancellationDetailsBase {\r\n private privReason: CancellationReason;\r\n private privErrorDetails: string;\r\n private privErrorCode: CancellationErrorCode;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {CancellationReason} reason - The cancellation reason.\r\n * @param {string} errorDetails - The error details, if provided.\r\n */\r\n protected constructor(reason: CancellationReason, errorDetails: string, errorCode: CancellationErrorCode) {\r\n this.privReason = reason;\r\n this.privErrorDetails = errorDetails;\r\n this.privErrorCode = errorCode;\r\n }\r\n\r\n /**\r\n * The reason the recognition was canceled.\r\n * @member CancellationDetailsBase.prototype.reason\r\n * @function\r\n * @public\r\n * @returns {CancellationReason} Specifies the reason canceled.\r\n */\r\n public get reason(): CancellationReason {\r\n return this.privReason;\r\n }\r\n\r\n /**\r\n * In case of an unsuccessful recognition, provides details of the occurred error.\r\n * @member CancellationDetailsBase.prototype.errorDetails\r\n * @function\r\n * @public\r\n * @returns {string} A String that represents the error details.\r\n */\r\n public get errorDetails(): string {\r\n return this.privErrorDetails;\r\n }\r\n\r\n /**\r\n * The error code in case of an unsuccessful recognition.\r\n * Added in version 1.1.0.\r\n * @return An error code that represents the error reason.\r\n */\r\n public get ErrorCode(): CancellationErrorCode {\r\n return this.privErrorCode;\r\n }\r\n\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { CancellationErrorCodePropertyName, EnumTranslation, SimpleSpeechPhrase } from \"../common.speech/Exports\";\r\nimport { CancellationDetailsBase } from \"./CancellationDetailsBase\";\r\nimport {\r\n CancellationErrorCode,\r\n CancellationReason,\r\n RecognitionResult,\r\n SpeechSynthesisResult\r\n} from \"./Exports\";\r\n\r\n/**\r\n * Contains detailed information about why a result was canceled.\r\n * @class CancellationDetails\r\n */\r\nexport class CancellationDetails extends CancellationDetailsBase {\r\n\r\n private constructor(reason: CancellationReason, errorDetails: string, errorCode: CancellationErrorCode) {\r\n super(reason, errorDetails, errorCode);\r\n }\r\n\r\n /**\r\n * Creates an instance of CancellationDetails object for the canceled RecognitionResult.\r\n * @member CancellationDetails.fromResult\r\n * @function\r\n * @public\r\n * @param {RecognitionResult | SpeechSynthesisResult} result - The result that was canceled.\r\n * @returns {CancellationDetails} The cancellation details object being created.\r\n */\r\n public static fromResult(result: RecognitionResult | SpeechSynthesisResult): CancellationDetails {\r\n let reason = CancellationReason.Error;\r\n let errorCode: CancellationErrorCode = CancellationErrorCode.NoError;\r\n\r\n if (result instanceof RecognitionResult && !!result.json) {\r\n const simpleSpeech: SimpleSpeechPhrase = SimpleSpeechPhrase.fromJSON(result.json);\r\n reason = EnumTranslation.implTranslateCancelResult(simpleSpeech.RecognitionStatus);\r\n }\r\n\r\n if (!!result.properties) {\r\n errorCode = (CancellationErrorCode as any)[result.properties.getProperty(CancellationErrorCodePropertyName, CancellationErrorCode[CancellationErrorCode.NoError])];\r\n }\r\n\r\n return new CancellationDetails(reason, result.errorDetails, errorCode);\r\n }\r\n\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * Defines error code in case that CancellationReason is Error.\r\n * Added in version 1.1.0.\r\n */\r\nexport enum CancellationErrorCode {\r\n /**\r\n * Indicates that no error occurred during speech recognition.\r\n */\r\n NoError,\r\n\r\n /**\r\n * Indicates an authentication error.\r\n */\r\n AuthenticationFailure,\r\n\r\n /**\r\n * Indicates that one or more recognition parameters are invalid.\r\n */\r\n BadRequestParameters,\r\n\r\n /**\r\n * Indicates that the number of parallel requests exceeded the number of allowed\r\n * concurrent transcriptions for the subscription.\r\n */\r\n TooManyRequests,\r\n\r\n /**\r\n * Indicates a connection error.\r\n */\r\n ConnectionFailure,\r\n\r\n /**\r\n * Indicates a time-out error when waiting for response from service.\r\n */\r\n ServiceTimeout,\r\n\r\n /**\r\n * Indicates that an error is returned by the service.\r\n */\r\n ServiceError,\r\n\r\n /**\r\n * Indicates an unexpected runtime error.\r\n */\r\n RuntimeError,\r\n}\r\n","//\r\n// Copyright (c) Microsoft. All rights reserved.\r\n// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.\r\n//\r\n\r\nimport { SessionEventArgs } from \"./Exports\";\r\n\r\n/**\r\n * Defines payload for connection events like Connected/Disconnected.\r\n * Added in version 1.2.0\r\n */\r\nexport class ConnectionEventArgs extends SessionEventArgs {\r\n}\r\n","//\r\n// Copyright (c) Microsoft. All rights reserved.\r\n// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.\r\n//\r\n\r\nimport { SessionEventArgs } from \"./Exports\";\r\n\r\n/**\r\n * Defines payload for any Service message event\r\n * Added in version 1.9.0\r\n */\r\n\r\nexport class ServiceEventArgs extends SessionEventArgs {\r\n private privJsonResult: string;\r\n private privEventName: string;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {string} json - json payload of the USP message.\r\n */\r\n public constructor(json: string, name: string, sessionId?: string) {\r\n super(sessionId);\r\n this.privJsonResult = json;\r\n this.privEventName = name;\r\n }\r\n\r\n public get jsonString(): string {\r\n return this.privJsonResult;\r\n }\r\n\r\n public get eventName(): string {\r\n return this.privEventName;\r\n }\r\n}\r\n","//\r\n// Copyright (c) Microsoft. All rights reserved.\r\n// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.\r\n//\r\n\r\nimport {\r\n ServiceRecognizerBase,\r\n SynthesisAdapterBase,\r\n} from \"../common.speech/Exports\";\r\nimport {\r\n ConnectionEvent,\r\n ConnectionMessageReceivedEvent,\r\n ConnectionMessageSentEvent,\r\n IDetachable,\r\n ServiceEvent,\r\n} from \"../common/Exports\";\r\nimport {\r\n ConnectionMessageImpl\r\n} from \"./ConnectionMessage\";\r\nimport { Contracts } from \"./Contracts\";\r\nimport {\r\n ConnectionEventArgs,\r\n ConnectionMessageEventArgs,\r\n Recognizer,\r\n ServiceEventArgs,\r\n SpeechSynthesizer,\r\n} from \"./Exports\";\r\n\r\n/**\r\n * Connection is a proxy class for managing connection to the speech service of the specified Recognizer.\r\n * By default, a Recognizer autonomously manages connection to service when needed.\r\n * The Connection class provides additional methods for users to explicitly open or close a connection and\r\n * to subscribe to connection status changes.\r\n * The use of Connection is optional, and mainly for scenarios where fine tuning of application\r\n * behavior based on connection status is needed. Users can optionally call Open() to manually set up a connection\r\n * in advance before starting recognition on the Recognizer associated with this Connection.\r\n * If the Recognizer needs to connect or disconnect to service, it will\r\n * setup or shutdown the connection independently. In this case the Connection will be notified by change of connection\r\n * status via Connected/Disconnected events.\r\n * Added in version 1.2.1.\r\n */\r\nexport class Connection {\r\n private privInternalData: ServiceRecognizerBase | SynthesisAdapterBase;\r\n private privEventListener: IDetachable;\r\n private privServiceEventListener: IDetachable;\r\n\r\n /**\r\n * Gets the Connection instance from the specified recognizer.\r\n * @param recognizer The recognizer associated with the connection.\r\n * @return The Connection instance of the recognizer.\r\n */\r\n public static fromRecognizer(recognizer: Recognizer): Connection {\r\n const recoBase: ServiceRecognizerBase = recognizer.internalData as ServiceRecognizerBase;\r\n\r\n const ret: Connection = new Connection();\r\n\r\n ret.privInternalData = recoBase;\r\n ret.setupEvents();\r\n return ret;\r\n }\r\n\r\n /**\r\n * Gets the Connection instance from the specified synthesizer.\r\n * @param synthesizer The synthesizer associated with the connection.\r\n * @return The Connection instance of the synthesizer.\r\n */\r\n public static fromSynthesizer(synthesizer: SpeechSynthesizer): Connection {\r\n const synthBase: SynthesisAdapterBase = synthesizer.internalData as SynthesisAdapterBase;\r\n\r\n const ret: Connection = new Connection();\r\n\r\n ret.privInternalData = synthBase;\r\n ret.setupEvents();\r\n return ret;\r\n }\r\n\r\n /**\r\n * Starts to set up connection to the service.\r\n * Users can optionally call openConnection() to manually set up a connection in advance before starting recognition on the\r\n * Recognizer associated with this Connection. After starting recognition, calling Open() will have no effect\r\n *\r\n * Note: On return, the connection might not be ready yet. Please subscribe to the Connected event to\r\n * be notified when the connection is established.\r\n */\r\n public openConnection(): void {\r\n this.privInternalData.connect();\r\n }\r\n\r\n /**\r\n * Closes the connection the service.\r\n * Users can optionally call closeConnection() to manually shutdown the connection of the associated Recognizer.\r\n *\r\n * If closeConnection() is called during recognition, recognition will fail and cancel with an error.\r\n */\r\n public closeConnection(): void {\r\n if (this.privInternalData instanceof SynthesisAdapterBase) {\r\n throw new Error(\"Disconnecting a synthesizer's connection is currently not supported\");\r\n } else {\r\n (this.privInternalData as ServiceRecognizerBase).disconnect();\r\n }\r\n }\r\n\r\n /**\r\n * Appends a parameter in a message to service.\r\n * Added in version 1.12.1.\r\n * @param path The path of the network message.\r\n * @param propertyName Name of the property\r\n * @param propertyValue Value of the property. This is a json string.\r\n */\r\n public setMessageProperty(path: string, propertyName: string, propertyValue: string): void {\r\n Contracts.throwIfNullOrWhitespace(propertyName, \"propertyName\");\r\n\r\n if (this.privInternalData instanceof ServiceRecognizerBase) {\r\n if (path.toLowerCase() !== \"speech.context\") {\r\n throw new Error(\"Only speech.context message property sets are currently supported for recognizer\");\r\n } else {\r\n (this.privInternalData as ServiceRecognizerBase).speechContext.setSection(propertyName, propertyValue);\r\n }\r\n } else if (this.privInternalData instanceof SynthesisAdapterBase) {\r\n if (path.toLowerCase() !== \"synthesis.context\") {\r\n throw new Error(\"Only synthesis.context message property sets are currently supported for synthesizer\");\r\n } else {\r\n (this.privInternalData as SynthesisAdapterBase).synthesisContext.setSection(propertyName, propertyValue);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sends a message to the speech service.\r\n * Added in version 1.13.0.\r\n * @param path The WebSocket path of the message\r\n * @param payload The payload of the message. This is a json string or a ArrayBuffer.\r\n * @param success A callback to indicate success.\r\n * @param error A callback to indicate an error.\r\n */\r\n public sendMessageAsync(path: string, payload: string | ArrayBuffer, success?: () => void, error?: (error: string) => void): void {\r\n this.privInternalData.sendNetworkMessage(path, payload, success, error);\r\n }\r\n\r\n /**\r\n * Any message from service that is not being processed by any other top level recognizers.\r\n *\r\n * Will be removed in 2.0.\r\n */\r\n public receivedServiceMessage: (args: ServiceEventArgs) => void;\r\n\r\n /**\r\n * Any message received from the Speech Service.\r\n */\r\n public messageReceived: (args: ConnectionMessageEventArgs) => void;\r\n\r\n /**\r\n * Any message sent to the Speech Service.\r\n */\r\n public messageSent: (args: ConnectionMessageEventArgs) => void;\r\n\r\n /**\r\n * The Connected event to indicate that the recognizer is connected to service.\r\n */\r\n public connected: (args: ConnectionEventArgs) => void;\r\n\r\n /**\r\n * The Disconnected event to indicate that the recognizer is disconnected from service.\r\n */\r\n public disconnected: (args: ConnectionEventArgs) => void;\r\n\r\n /**\r\n * Dispose of associated resources.\r\n */\r\n public close(): void {\r\n /* tslint:disable:no-empty */\r\n }\r\n\r\n private setupEvents(): void {\r\n this.privEventListener = this.privInternalData.connectionEvents.attach((connectionEvent: ConnectionEvent): void => {\r\n if (connectionEvent.name === \"ConnectionEstablishedEvent\") {\r\n if (!!this.connected) {\r\n this.connected(new ConnectionEventArgs(connectionEvent.connectionId));\r\n }\r\n } else if (connectionEvent.name === \"ConnectionClosedEvent\") {\r\n if (!!this.disconnected) {\r\n this.disconnected(new ConnectionEventArgs(connectionEvent.connectionId));\r\n }\r\n } else if (connectionEvent.name === \"ConnectionMessageSentEvent\") {\r\n if (!!this.messageSent) {\r\n this.messageSent(new ConnectionMessageEventArgs(new ConnectionMessageImpl((connectionEvent as ConnectionMessageSentEvent).message)));\r\n }\r\n } else if (connectionEvent.name === \"ConnectionMessageReceivedEvent\") {\r\n if (!!this.messageReceived) {\r\n this.messageReceived(new ConnectionMessageEventArgs(new ConnectionMessageImpl((connectionEvent as ConnectionMessageReceivedEvent).message)));\r\n }\r\n }\r\n });\r\n\r\n this.privServiceEventListener = this.privInternalData.serviceEvents.attach((e: ServiceEvent): void => {\r\n if (!!this.receivedServiceMessage) {\r\n this.receivedServiceMessage(new ServiceEventArgs(e.jsonString, e.name));\r\n }\r\n });\r\n }\r\n}\r\n","//\r\n// Copyright (c) Microsoft. All rights reserved.\r\n// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.\r\n//\r\n\r\nimport {\r\n ConnectionMessage as IntConnectionMessage,\r\n MessageType\r\n} from \"../common/Exports\";\r\nimport {\r\n PropertyCollection\r\n} from \"./PropertyCollection\";\r\nimport { PropertyId } from \"./PropertyId\";\r\n\r\n/**\r\n * ConnectionMessage represents implementation specific messages sent to and received from\r\n * the speech service. These messages are provided for debugging purposes and should not\r\n * be used for production use cases with the Azure Cognitive Services Speech Service.\r\n * Messages sent to and received from the Speech Service are subject to change without\r\n * notice. This includes message contents, headers, payloads, ordering, etc.\r\n * Added in version 1.11.0.\r\n */\r\nexport abstract class ConnectionMessage {\r\n /**\r\n * The message path.\r\n */\r\n public abstract get path(): string;\r\n\r\n /**\r\n * Checks to see if the ConnectionMessage is a text message.\r\n * See also IsBinaryMessage().\r\n */\r\n public abstract get isTextMessage(): boolean;\r\n\r\n /**\r\n * Checks to see if the ConnectionMessage is a binary message.\r\n * See also GetBinaryMessage().\r\n */\r\n public abstract get isBinaryMessage(): boolean;\r\n\r\n /**\r\n * Gets the text message payload. Typically the text message content-type is\r\n * application/json. To determine other content-types use\r\n * Properties.GetProperty(\"Content-Type\").\r\n */\r\n public abstract get TextMessage(): string;\r\n\r\n /**\r\n * Gets the binary message payload.\r\n */\r\n public abstract get binaryMessage(): ArrayBuffer;\r\n\r\n /**\r\n * A collection of properties and their values defined for this .\r\n * Message headers can be accessed via this collection (e.g. \"Content-Type\").\r\n */\r\n public abstract get properties(): PropertyCollection;\r\n\r\n /**\r\n * Returns a string that represents the connection message.\r\n */\r\n public abstract toString(): string;\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class ConnectionMessageImpl {\r\n\r\n private privConnectionMessage: IntConnectionMessage;\r\n private privProperties: PropertyCollection;\r\n\r\n constructor(message: IntConnectionMessage) {\r\n this.privConnectionMessage = message;\r\n this.privProperties = new PropertyCollection();\r\n if (!!this.privConnectionMessage.headers[\"X-ConnectionId\"]) {\r\n this.privProperties.setProperty(PropertyId.Speech_SessionId, this.privConnectionMessage.headers[\"X-ConnectionId\"]);\r\n }\r\n\r\n Object.keys(this.privConnectionMessage.headers).forEach((header: string, index: number, array: string[]): void => {\r\n this.privProperties.setProperty(header, this.privConnectionMessage.headers[header]);\r\n });\r\n }\r\n\r\n /**\r\n * The message path.\r\n */\r\n public get path(): string {\r\n return this.privConnectionMessage.headers[Object.keys(this.privConnectionMessage.headers).find((key: string) => key.toLowerCase() === \"path\".toLowerCase())];\r\n }\r\n\r\n /**\r\n * Checks to see if the ConnectionMessage is a text message.\r\n * See also IsBinaryMessage().\r\n */\r\n public get isTextMessage(): boolean {\r\n return this.privConnectionMessage.messageType === MessageType.Text;\r\n }\r\n\r\n /**\r\n * Checks to see if the ConnectionMessage is a binary message.\r\n * See also GetBinaryMessage().\r\n */\r\n public get isBinaryMessage(): boolean {\r\n return this.privConnectionMessage.messageType === MessageType.Binary;\r\n }\r\n\r\n /**\r\n * Gets the text message payload. Typically the text message content-type is\r\n * application/json. To determine other content-types use\r\n * Properties.GetProperty(\"Content-Type\").\r\n */\r\n public get TextMessage(): string {\r\n return this.privConnectionMessage.textBody;\r\n }\r\n\r\n /**\r\n * Gets the binary message payload.\r\n */\r\n public get binaryMessage(): ArrayBuffer {\r\n return this.privConnectionMessage.binaryBody;\r\n }\r\n\r\n /**\r\n * A collection of properties and their values defined for this .\r\n * Message headers can be accessed via this collection (e.g. \"Content-Type\").\r\n */\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n /**\r\n * Returns a string that represents the connection message.\r\n */\r\n public toString(): string {\r\n return \"\";\r\n }\r\n}\r\n","// 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\";\r\nimport { Recognizer } from \"./Exports\";\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): PhraseListGrammar {\r\n const recoBase: ServiceRecognizerBase = recognizer.internalData as ServiceRecognizerBase;\r\n\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","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { Contracts } from \"./Contracts\";\r\nimport { PropertyCollection, PropertyId, ServicePropertyChannel, SpeechConfigImpl } from \"./Exports\";\r\n\r\n/**\r\n * Class that defines base configurations for dialog service connector\r\n * @class DialogServiceConfig\r\n */\r\nexport abstract class DialogServiceConfig {\r\n\r\n /**\r\n * Creates an instance of DialogService config.\r\n * @constructor\r\n */\r\n protected constructor() { }\r\n\r\n /**\r\n * Sets an arbitrary property.\r\n * @member DialogServiceConfig.prototype.setProperty\r\n * @function\r\n * @public\r\n * @param {string} name - The name of the property to set.\r\n * @param {string} value - The new value of the property.\r\n */\r\n public abstract setProperty(name: string, value: string): void;\r\n\r\n /**\r\n * Returns the current value of an arbitrary property.\r\n * @member DialogServiceConfig.prototype.getProperty\r\n * @function\r\n * @public\r\n * @param {string} name - The name of the property to query.\r\n * @param {string} def - The value to return in case the property is not known.\r\n * @returns {string} The current value, or provided default, of the given property.\r\n */\r\n public abstract getProperty(name: string, def?: string): string;\r\n\r\n /**\r\n * @member DialogServiceConfig.prototype.setServiceProperty\r\n * @function\r\n * @public\r\n * @param {name} The name of the property.\r\n * @param {value} Value to set.\r\n * @param {channel} The channel used to pass the specified property to service.\r\n * @summary Sets a property value that will be passed to service using the specified channel.\r\n */\r\n public abstract setServiceProperty(name: string, value: string, channel: ServicePropertyChannel): void;\r\n\r\n /**\r\n * Sets the proxy configuration.\r\n * Only relevant in Node.js environments.\r\n * Added in version 1.4.0.\r\n * @param proxyHostName The host name of the proxy server.\r\n * @param proxyPort The port number of the proxy server.\r\n */\r\n public abstract setProxy(proxyHostName: string, proxyPort: number): void;\r\n\r\n /**\r\n * Sets the proxy configuration.\r\n * Only relevant in Node.js environments.\r\n * Added in version 1.4.0.\r\n * @param proxyHostName The host name of the proxy server, without the protocol scheme (http://)\r\n * @param porxyPort The port number of the proxy server.\r\n * @param proxyUserName The user name of the proxy server.\r\n * @param proxyPassword The password of the proxy server.\r\n */\r\n public abstract setProxy(proxyHostName: string, proxyPort: number, proxyUserName: string, proxyPassword: string): void;\r\n\r\n /**\r\n * Returns the configured language.\r\n * @member DialogServiceConfig.prototype.speechRecognitionLanguage\r\n * @function\r\n * @public\r\n */\r\n public abstract get speechRecognitionLanguage(): string;\r\n\r\n /**\r\n * Gets/Sets the input language.\r\n * @member DialogServiceConfig.prototype.speechRecognitionLanguage\r\n * @function\r\n * @public\r\n * @param {string} value - The language to use for recognition.\r\n */\r\n public abstract set speechRecognitionLanguage(value: string);\r\n\r\n /**\r\n * Not used in DialogServiceConfig\r\n * @member DialogServiceConfig.applicationId\r\n */\r\n public applicationId: string;\r\n}\r\n\r\n/**\r\n * Dialog Service configuration.\r\n * @class DialogServiceConfigImpl\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class DialogServiceConfigImpl extends DialogServiceConfig {\r\n\r\n private privSpeechConfig: SpeechConfigImpl;\r\n\r\n /**\r\n * Creates an instance of dialogService config.\r\n */\r\n public constructor() {\r\n super();\r\n this.privSpeechConfig = new SpeechConfigImpl();\r\n }\r\n\r\n /**\r\n * Provides access to custom properties.\r\n * @member DialogServiceConfigImpl.prototype.properties\r\n * @function\r\n * @public\r\n * @returns {PropertyCollection} The properties.\r\n */\r\n public get properties(): PropertyCollection {\r\n return this.privSpeechConfig.properties;\r\n }\r\n\r\n /**\r\n * Gets the speech recognition language.\r\n * @member DialogServiceConfigImpl.prototype.speechRecognitionLanguage\r\n * @function\r\n * @public\r\n */\r\n public get speechRecognitionLanguage(): string {\r\n return this.privSpeechConfig.speechRecognitionLanguage;\r\n }\r\n\r\n /**\r\n * Sets the speech recognition language.\r\n * @member DialogServiceConfigImpl.prototype.speechRecognitionLanguage\r\n * @function\r\n * @public\r\n * @param {string} value - The language to set.\r\n */\r\n public set speechRecognitionLanguage(value: string) {\r\n Contracts.throwIfNullOrWhitespace(value, \"value\");\r\n this.privSpeechConfig.speechRecognitionLanguage = value;\r\n }\r\n\r\n /**\r\n * Sets a named property as value\r\n * @member DialogServiceConfigImpl.prototype.setProperty\r\n * @function\r\n * @public\r\n * @param {PropertyId | string} name - The property to set.\r\n * @param {string} value - The value.\r\n */\r\n public setProperty(name: string | PropertyId, value: string): void {\r\n this.privSpeechConfig.setProperty(name, value);\r\n }\r\n\r\n /**\r\n * Sets a named property as value\r\n * @member DialogServiceConfigImpl.prototype.getProperty\r\n * @function\r\n * @public\r\n * @param {PropertyId | string} name - The property to get.\r\n * @param {string} def - The default value to return in case the property is not known.\r\n * @returns {string} The current value, or provided default, of the given property.\r\n */\r\n public getProperty(name: string | PropertyId, def?: string): string {\r\n return this.privSpeechConfig.getProperty(name);\r\n }\r\n\r\n /**\r\n * Sets the proxy configuration.\r\n * Only relevant in Node.js environments.\r\n * Added in version 1.4.0.\r\n * @param proxyHostName The host name of the proxy server, without the protocol scheme (http://)\r\n * @param proxyPort The port number of the proxy server.\r\n * @param proxyUserName The user name of the proxy server.\r\n * @param proxyPassword The password of the proxy server.\r\n */\r\n public setProxy(proxyHostName: string, proxyPort: number, proxyUserName?: string, proxyPassword?: string): void {\r\n this.setProperty(PropertyId.SpeechServiceConnection_ProxyHostName, proxyHostName);\r\n this.setProperty(PropertyId.SpeechServiceConnection_ProxyPort, `${proxyPort}`);\r\n if (proxyUserName) {\r\n this.setProperty(PropertyId.SpeechServiceConnection_ProxyUserName, proxyUserName);\r\n }\r\n if (proxyPassword) {\r\n this.setProperty(PropertyId.SpeechServiceConnection_ProxyPassword, proxyPassword);\r\n }\r\n }\r\n\r\n public setServiceProperty(name: string, value: string, channel: ServicePropertyChannel): void {\r\n this.privSpeechConfig.setServiceProperty(name, value, channel);\r\n }\r\n\r\n /**\r\n * Dispose of associated resources.\r\n * @member DialogServiceConfigImpl.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(): void {\r\n return;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { Contracts } from \"./Contracts\";\r\nimport { DialogServiceConfigImpl } from \"./DialogServiceConfig\";\r\nimport { PropertyId } from \"./Exports\";\r\n\r\n/**\r\n * Class that defines configurations for the dialog service connector object for using a Bot Framework backend.\r\n * @class BotFrameworkConfig\r\n */\r\nexport class BotFrameworkConfig extends DialogServiceConfigImpl {\r\n\r\n /**\r\n * Creates an instance of BotFrameworkConfig.\r\n */\r\n public constructor() {\r\n super();\r\n }\r\n\r\n /**\r\n * Creates an instance of the bot framework config with the specified subscription and region.\r\n * @member BotFrameworkConfig.fromSubscription\r\n * @function\r\n * @public\r\n * @param subscription Subscription key associated with the bot\r\n * @param region The region name (see the region page).\r\n * @param botId Optional, ID for using a specific bot.\r\n * @returns {BotFrameworkConfig} A new bot framework config.\r\n */\r\n public static fromSubscription(subscription: string, region: string, botId?: string): BotFrameworkConfig {\r\n Contracts.throwIfNullOrWhitespace(subscription, \"subscription\");\r\n Contracts.throwIfNullOrWhitespace(region, \"region\");\r\n\r\n const botFrameworkConfig: BotFrameworkConfig = new DialogServiceConfigImpl();\r\n botFrameworkConfig.setProperty(PropertyId.Conversation_DialogType, \"bot_framework\");\r\n botFrameworkConfig.setProperty(PropertyId.SpeechServiceConnection_Key, subscription);\r\n botFrameworkConfig.setProperty(PropertyId.SpeechServiceConnection_Region, region);\r\n\r\n if (botId) {\r\n botFrameworkConfig.setProperty(PropertyId.Conversation_ApplicationId, botId);\r\n }\r\n\r\n return botFrameworkConfig;\r\n }\r\n\r\n /**\r\n * Creates an instance of the bot framework config with the specified authorization token and region.\r\n * Note: The caller needs to ensure that the authorization token is valid. Before the authorization token\r\n * expires, the caller needs to refresh it by calling this setter with a new valid token.\r\n * As configuration values are copied when creating a new recognizer, the new token value will not apply to recognizers that have already been created.\r\n * For recognizers that have been created before, you need to set authorization token of the corresponding recognizer\r\n * to refresh the token. Otherwise, the recognizers will encounter errors during recognition.\r\n * @member BotFrameworkConfig.fromAuthorizationToken\r\n * @function\r\n * @public\r\n * @param authorizationToken The authorization token associated with the bot\r\n * @param region The region name (see the region page).\r\n * @returns {BotFrameworkConfig} A new bot framework config.\r\n */\r\n public static fromAuthorizationToken(authorizationToken: string, region: string): BotFrameworkConfig {\r\n Contracts.throwIfNullOrWhitespace(authorizationToken, \"authorizationToken\");\r\n Contracts.throwIfNullOrWhitespace(region, \"region\");\r\n\r\n const botFrameworkConfig: BotFrameworkConfig = new DialogServiceConfigImpl();\r\n botFrameworkConfig.setProperty(PropertyId.Conversation_DialogType, \"bot_framework\");\r\n botFrameworkConfig.setProperty(PropertyId.SpeechServiceAuthorization_Token, authorizationToken);\r\n botFrameworkConfig.setProperty(PropertyId.SpeechServiceConnection_Region, region);\r\n return botFrameworkConfig;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { Contracts } from \"./Contracts\";\r\nimport { DialogServiceConfigImpl } from \"./DialogServiceConfig\";\r\nimport { PropertyId } from \"./Exports\";\r\n\r\n/**\r\n * Class that defines configurations for the dialog service connector object for using a CustomCommands backend.\r\n * @class CustomCommandsConfig\r\n */\r\nexport class CustomCommandsConfig extends DialogServiceConfigImpl {\r\n\r\n /**\r\n * Creates an instance of CustomCommandsConfig.\r\n */\r\n public constructor() {\r\n super();\r\n }\r\n\r\n /**\r\n * Creates an instance of the bot framework config with the specified subscription and region.\r\n * @member CustomCommandsConfig.fromSubscription\r\n * @function\r\n * @public\r\n * @param applicationId Speech Commands application id.\r\n * @param subscription Subscription key associated with the bot\r\n * @param region The region name (see the region page).\r\n * @returns {CustomCommandsConfig} A new bot framework config.\r\n */\r\n public static fromSubscription(applicationId: string, subscription: string, region: string): CustomCommandsConfig {\r\n Contracts.throwIfNullOrWhitespace(applicationId, \"applicationId\");\r\n Contracts.throwIfNullOrWhitespace(subscription, \"subscription\");\r\n Contracts.throwIfNullOrWhitespace(region, \"region\");\r\n\r\n const customCommandsConfig: CustomCommandsConfig = new DialogServiceConfigImpl();\r\n customCommandsConfig.setProperty(PropertyId.Conversation_DialogType, \"custom_commands\");\r\n customCommandsConfig.setProperty(PropertyId.Conversation_ApplicationId, applicationId);\r\n customCommandsConfig.setProperty(PropertyId.SpeechServiceConnection_Key, subscription);\r\n customCommandsConfig.setProperty(PropertyId.SpeechServiceConnection_Region, region);\r\n return customCommandsConfig;\r\n }\r\n\r\n /**\r\n * Creates an instance of the bot framework config with the specified Speech Commands application id, authorization token and region.\r\n * Note: The caller needs to ensure that the authorization token is valid. Before the authorization token\r\n * expires, the caller needs to refresh it by calling this setter with a new valid token.\r\n * As configuration values are copied when creating a new recognizer, the new token value will not apply to recognizers that have already been created.\r\n * For recognizers that have been created before, you need to set authorization token of the corresponding recognizer\r\n * to refresh the token. Otherwise, the recognizers will encounter errors during recognition.\r\n * @member CustomCommandsConfig.fromAuthorizationToken\r\n * @function\r\n * @public\r\n * @param applicationId Speech Commands application id.\r\n * @param authorizationToken The authorization token associated with the application.\r\n * @param region The region name (see the region page).\r\n * @returns {CustomCommandsConfig} A new speech commands config.\r\n */\r\n public static fromAuthorizationToken(applicationId: string, authorizationToken: string, region: string): CustomCommandsConfig {\r\n Contracts.throwIfNullOrWhitespace(applicationId, \"applicationId\");\r\n Contracts.throwIfNullOrWhitespace(authorizationToken, \"authorizationToken\");\r\n Contracts.throwIfNullOrWhitespace(region, \"region\");\r\n\r\n const customCommandsConfig: CustomCommandsConfig = new DialogServiceConfigImpl();\r\n customCommandsConfig.setProperty(PropertyId.Conversation_DialogType, \"custom_commands\");\r\n customCommandsConfig.setProperty(PropertyId.Conversation_ApplicationId, applicationId);\r\n customCommandsConfig.setProperty(PropertyId.SpeechServiceAuthorization_Token, authorizationToken);\r\n customCommandsConfig.setProperty(PropertyId.SpeechServiceConnection_Region, region);\r\n return customCommandsConfig;\r\n }\r\n\r\n /**\r\n * Sets the corresponding backend application identifier.\r\n * @member CustomCommandsConfig.prototype.Conversation_ApplicationId\r\n * @function\r\n * @public\r\n * @param {string} value - The application identifier to set.\r\n */\r\n public set applicationId(value: string) {\r\n Contracts.throwIfNullOrWhitespace(value, \"value\");\r\n this.setProperty(PropertyId.Conversation_ApplicationId, value);\r\n }\r\n\r\n /**\r\n * Gets the corresponding backend application identifier.\r\n * @member CustomCommandsConfig.prototype.Conversation_ApplicationId\r\n * @function\r\n * @public\r\n * @param {string} value - The application identifier to get.\r\n */\r\n public get applicationId(): string {\r\n return this.getProperty(PropertyId.Conversation_ApplicationId);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { DialogConnectionFactory } from \"../common.speech/DialogConnectorFactory\";\r\nimport {\r\n DialogServiceAdapter,\r\n IAgentConfig,\r\n IAuthentication,\r\n IConnectionFactory,\r\n RecognitionMode,\r\n RecognizerConfig,\r\n ServiceRecognizerBase,\r\n SpeechServiceConfig,\r\n} from \"../common.speech/Exports\";\r\nimport { ActivityReceivedEventArgs } from \"./ActivityReceivedEventArgs\";\r\nimport { AudioConfigImpl } from \"./Audio/AudioConfig\";\r\nimport { Contracts } from \"./Contracts\";\r\nimport { DialogServiceConfig, DialogServiceConfigImpl } from \"./DialogServiceConfig\";\r\nimport {\r\n AudioConfig,\r\n PropertyCollection,\r\n Recognizer,\r\n SpeechRecognitionCanceledEventArgs,\r\n SpeechRecognitionEventArgs,\r\n SpeechRecognitionResult\r\n} from \"./Exports\";\r\nimport { PropertyId } from \"./PropertyId\";\r\nimport { SpeechSynthesisOutputFormat } from \"./SpeechSynthesisOutputFormat\";\r\n\r\n/**\r\n * Dialog Service Connector\r\n * @class DialogServiceConnector\r\n */\r\nexport class DialogServiceConnector extends Recognizer {\r\n private privIsDisposed: boolean;\r\n private isTurnComplete: boolean;\r\n\r\n /**\r\n * Initializes an instance of the DialogServiceConnector.\r\n * @constructor\r\n * @param {DialogServiceConfig} dialogConfig - Set of properties to configure this recognizer.\r\n * @param {AudioConfig} audioConfig - An optional audio config associated with the recognizer\r\n */\r\n public constructor(dialogConfig: DialogServiceConfig, audioConfig?: AudioConfig) {\r\n const dialogServiceConfigImpl = dialogConfig as DialogServiceConfigImpl;\r\n Contracts.throwIfNull(dialogConfig, \"dialogConfig\");\r\n\r\n super(audioConfig, dialogServiceConfigImpl.properties, new DialogConnectionFactory());\r\n\r\n this.isTurnComplete = true;\r\n this.privIsDisposed = false;\r\n this.privProperties = dialogServiceConfigImpl.properties.clone();\r\n\r\n const agentConfig = this.buildAgentConfig();\r\n this.privReco.agentConfig.set(agentConfig);\r\n }\r\n\r\n /**\r\n * The event recognizing signals that an intermediate recognition result is received.\r\n * @member DialogServiceConnector.prototype.recognizing\r\n * @function\r\n * @public\r\n */\r\n public recognizing: (sender: DialogServiceConnector, event: SpeechRecognitionEventArgs) => void;\r\n\r\n /**\r\n * The event recognized signals that a final recognition result is received.\r\n * @member DialogServiceConfig.prototype.recognized\r\n * @function\r\n * @public\r\n */\r\n public recognized: (sender: DialogServiceConnector, event: SpeechRecognitionEventArgs) => void;\r\n\r\n /**\r\n * The event canceled signals that an error occurred during recognition.\r\n * @member DialogServiceConnector.prototype.canceled\r\n * @function\r\n * @public\r\n */\r\n public canceled: (sender: DialogServiceConnector, event: SpeechRecognitionCanceledEventArgs) => void;\r\n\r\n /**\r\n * The event activityReceived signals that an activity has been received.\r\n * @member DialogServiceConnector.prototype.activityReceived\r\n * @function\r\n * @public\r\n */\r\n public activityReceived: (sender: DialogServiceConnector, event: ActivityReceivedEventArgs) => void;\r\n\r\n /**\r\n * Starts a connection to the service.\r\n * Users can optionally call connect() to manually set up a connection in advance, before starting interactions.\r\n *\r\n * Note: On return, the connection might not be ready yet. Please subscribe to the Connected event to\r\n * be notified when the connection is established.\r\n * @member DialogServiceConnector.prototype.connect\r\n * @function\r\n * @public\r\n */\r\n public connect(): void {\r\n this.privReco.connect();\r\n }\r\n\r\n /**\r\n * Closes the connection the service.\r\n * Users can optionally call disconnect() to manually shutdown the connection of the associated DialogServiceConnector.\r\n *\r\n * If disconnect() is called during a recognition, recognition will fail and cancel with an error.\r\n */\r\n public disconnect(): void {\r\n this.privReco.disconnect();\r\n }\r\n\r\n /**\r\n * Gets the authorization token used to communicate with the service.\r\n * @member DialogServiceConnector.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @returns {string} Authorization token.\r\n */\r\n public get authorizationToken(): string {\r\n return this.properties.getProperty(PropertyId.SpeechServiceAuthorization_Token);\r\n }\r\n\r\n /**\r\n * Sets the authorization token used to communicate with the service.\r\n * @member DialogServiceConnector.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @param {string} token - Authorization token.\r\n */\r\n public set authorizationToken(token: string) {\r\n Contracts.throwIfNullOrWhitespace(token, \"token\");\r\n this.properties.setProperty(PropertyId.SpeechServiceAuthorization_Token, token);\r\n }\r\n\r\n /**\r\n * The collection of properties and their values defined for this DialogServiceConnector.\r\n * @member DialogServiceConnector.prototype.properties\r\n * @function\r\n * @public\r\n * @returns {PropertyCollection} The collection of properties and their values defined for this DialogServiceConnector.\r\n */\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n /** Gets the template for the activity generated by service from speech.\r\n * Properties from the template will be stamped on the generated activity.\r\n * It can be empty\r\n */\r\n public get speechActivityTemplate(): string {\r\n return this.properties.getProperty(PropertyId.Conversation_Speech_Activity_Template);\r\n }\r\n\r\n /** Sets the template for the activity generated by service from speech.\r\n * Properties from the template will be stamped on the generated activity.\r\n * It can be null or empty.\r\n * Note: it has to be a valid Json object.\r\n */\r\n public set speechActivityTemplate(speechActivityTemplate: string) {\r\n this.properties.setProperty(PropertyId.Conversation_Speech_Activity_Template, speechActivityTemplate);\r\n }\r\n\r\n /**\r\n * Starts recognition and stops after the first utterance is recognized.\r\n * @member DialogServiceConnector.prototype.listenOnceAsync\r\n * @function\r\n * @public\r\n * @param cb - Callback that received the result when the reco has completed.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public listenOnceAsync(cb?: (e: SpeechRecognitionResult) => void, err?: (e: string) => void): void {\r\n if (this.isTurnComplete) {\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n\r\n this.connect();\r\n\r\n this.implRecognizerStop();\r\n this.isTurnComplete = false;\r\n\r\n this.privReco.recognize(\r\n RecognitionMode.Conversation,\r\n (e: SpeechRecognitionResult) => {\r\n this.implRecognizerStop();\r\n\r\n this.isTurnComplete = true;\r\n\r\n if (!!cb) {\r\n cb(e);\r\n }\r\n },\r\n (e: string) => {\r\n this.implRecognizerStop();\r\n this.isTurnComplete = true;\r\n if (!!err) {\r\n err(e);\r\n }\r\n /* tslint:disable:no-empty */\r\n }).on((_: boolean): void => { },\r\n (error: string): void => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error);\r\n }\r\n }\r\n\r\n // Destroy the recognizer.\r\n this.dispose(true);\r\n }\r\n }\r\n }\r\n\r\n public sendActivityAsync(activity: string): void {\r\n this.privReco.sendMessage(activity);\r\n }\r\n\r\n /**\r\n * closes all external resources held by an instance of this class.\r\n * @member DialogServiceConnector.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(): void {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n\r\n this.dispose(true);\r\n }\r\n\r\n protected dispose(disposing: boolean): boolean {\r\n if (this.privIsDisposed) {\r\n return;\r\n }\r\n\r\n if (disposing) {\r\n this.implRecognizerStop();\r\n this.privIsDisposed = true;\r\n super.dispose(disposing);\r\n }\r\n }\r\n\r\n protected createRecognizerConfig(speechConfig: SpeechServiceConfig): RecognizerConfig {\r\n return new RecognizerConfig(speechConfig, this.privProperties);\r\n }\r\n\r\n protected createServiceRecognizer(\r\n authentication: IAuthentication,\r\n connectionFactory: IConnectionFactory,\r\n audioConfig: AudioConfig,\r\n recognizerConfig: RecognizerConfig): ServiceRecognizerBase {\r\n\r\n const audioSource: AudioConfigImpl = audioConfig as AudioConfigImpl;\r\n\r\n return new DialogServiceAdapter(authentication, connectionFactory, audioSource, recognizerConfig, this);\r\n }\r\n\r\n private buildAgentConfig(): IAgentConfig {\r\n const communicationType = this.properties.getProperty(\"Conversation_Communication_Type\", \"Default\");\r\n\r\n return {\r\n botInfo: {\r\n commType: communicationType,\r\n commandsCulture: undefined,\r\n connectionId: this.properties.getProperty(PropertyId.Conversation_ApplicationId),\r\n conversationId: this.properties.getProperty(PropertyId.Conversation_Conversation_Id, undefined),\r\n fromId: this.properties.getProperty(PropertyId.Conversation_From_Id, undefined),\r\n ttsAudioFormat: (SpeechSynthesisOutputFormat as any)[this.properties.getProperty(PropertyId.SpeechServiceConnection_SynthOutputFormat, undefined)]\r\n },\r\n version: 0.2\r\n };\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n ProxyInfo,\r\n WebsocketConnection,\r\n} from \"../common.browser/Exports\";\r\nimport { OutputFormatPropertyName } from \"../common.speech/Exports\";\r\nimport { IConnection, IStringDictionary } from \"../common/Exports\";\r\nimport { OutputFormat, PropertyId } from \"../sdk/Exports\";\r\nimport { ConnectionFactoryBase } from \"./ConnectionFactoryBase\";\r\nimport { AuthInfo, RecognizerConfig, WebsocketMessageFormatter } from \"./Exports\";\r\nimport { QueryParameterNames } from \"./QueryParameterNames\";\r\n\r\nconst baseUrl: string = \"convai.speech\";\r\n\r\ninterface IBackendValues {\r\n authHeader: string;\r\n resourcePath: string;\r\n version: string;\r\n}\r\n\r\nconst botFramework: IBackendValues = {\r\n authHeader: \"X-DLS-Secret\",\r\n resourcePath: \"\",\r\n version: \"v3\"\r\n};\r\n\r\nconst customCommands: IBackendValues = {\r\n authHeader: \"X-CommandsAppId\",\r\n resourcePath: \"commands\",\r\n version: \"v1\"\r\n};\r\n\r\nconst pathSuffix: string = \"api\";\r\n\r\nfunction getDialogSpecificValues(dialogType: string): IBackendValues {\r\n switch (dialogType) {\r\n case \"custom_commands\": {\r\n return customCommands;\r\n }\r\n case \"bot_framework\": {\r\n return botFramework;\r\n }\r\n }\r\n throw new Error(`Invalid dialog type '${dialogType}'`);\r\n}\r\n\r\nexport class DialogConnectionFactory extends ConnectionFactoryBase {\r\n\r\n public create = (\r\n config: RecognizerConfig,\r\n authInfo: AuthInfo,\r\n connectionId?: string): IConnection => {\r\n\r\n const applicationId: string = config.parameters.getProperty(PropertyId.Conversation_ApplicationId, \"\");\r\n const dialogType: string = config.parameters.getProperty(PropertyId.Conversation_DialogType);\r\n const region: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Region);\r\n\r\n const language: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage, \"en-US\");\r\n\r\n const queryParams: IStringDictionary = {};\r\n queryParams[QueryParameterNames.LanguageParamName] = language;\r\n queryParams[QueryParameterNames.FormatParamName] = config.parameters.getProperty(PropertyId.SpeechServiceResponse_OutputFormatOption, OutputFormat[OutputFormat.Simple]).toLowerCase();\r\n\r\n const {resourcePath, version, authHeader} = getDialogSpecificValues(dialogType);\r\n\r\n const headers: IStringDictionary = {};\r\n\r\n if (authInfo.token != null && authInfo.token !== \"\") {\r\n headers[authInfo.headerName] = authInfo.token;\r\n }\r\n headers[QueryParameterNames.ConnectionIdHeader] = connectionId;\r\n\r\n if (applicationId !== \"\") {\r\n headers[authHeader] = applicationId;\r\n }\r\n\r\n let endpoint: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint, \"\");\r\n if (endpoint === \"\") {\r\n const hostSuffix = (region && region.toLowerCase().startsWith(\"china\")) ? \".azure.cn\" : \".microsoft.com\";\r\n // ApplicationId is only required for CustomCommands, so we're using that to determine default endpoint\r\n if (applicationId === \"\") {\r\n endpoint = `wss://${region}.${baseUrl}${hostSuffix}/${pathSuffix}/${version}`;\r\n } else {\r\n endpoint = `wss://${region}.${baseUrl}${hostSuffix}/${resourcePath}/${pathSuffix}/${version}`;\r\n }\r\n }\r\n\r\n this.setCommonUrlParams(config, queryParams, endpoint);\r\n\r\n return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), connectionId);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { PullAudioOutputStream } from \"./Audio/AudioOutputStream\";\r\n\r\n/**\r\n * Defines contents of received message/events.\r\n * @class ActivityReceivedEventArgs\r\n */\r\nexport class ActivityReceivedEventArgs {\r\n private privActivity: any;\r\n private privAudioStream: PullAudioOutputStream;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {any} activity - The activity..\r\n */\r\n public constructor(activity: any, audioStream?: PullAudioOutputStream) {\r\n this.privActivity = activity;\r\n this.privAudioStream = audioStream;\r\n }\r\n\r\n /**\r\n * Gets the received activity\r\n * @member ActivityReceivedEventArgs.prototype.activity\r\n * @function\r\n * @public\r\n * @returns {any} the received activity.\r\n */\r\n public get activity(): any {\r\n return this.privActivity;\r\n }\r\n\r\n public get audioStream(): PullAudioOutputStream {\r\n return this.privAudioStream;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * Defines channels used to pass property settings to service.\r\n * Added in version 1.7.0.\r\n */\r\nexport enum ServicePropertyChannel {\r\n /**\r\n * Uses URI query parameter to pass property settings to service.\r\n */\r\n UriQueryParameter = 0.\r\n}\r\n","// Copyright (c) Microsoft Corporation.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * Profanity option.\r\n * Added in version 1.7.0.\r\n */\r\nexport enum ProfanityOption {\r\n Masked = 0,\r\n Removed = 1,\r\n Raw = 2\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { InvalidOperationError } from \"../../common/Error\";\r\nimport { AudioStreamFormat, PullAudioInputStreamCallback } from \"../Exports\";\r\nimport { AudioStreamFormatImpl } from \"./AudioStreamFormat\";\r\n\r\ntype AudioDataTypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array;\r\n/**\r\n * Base audio player class\r\n * TODO: Plays only PCM for now.\r\n * @class\r\n */\r\nexport class BaseAudioPlayer {\r\n\r\n private audioContext: AudioContext = null;\r\n private gainNode: GainNode = null;\r\n private audioFormat: AudioStreamFormatImpl;\r\n private autoUpdateBufferTimer: any = 0;\r\n private samples: Float32Array;\r\n private startTime: number;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n */\r\n public constructor(audioFormat: AudioStreamFormat) {\r\n this.init(audioFormat);\r\n }\r\n\r\n /**\r\n * play Audio sample\r\n * @param newAudioData audio data to be played.\r\n */\r\n public playAudioSample(newAudioData: ArrayBuffer): void {\r\n this.ensureInitializedContext();\r\n const audioData = this.formatAudioData(newAudioData);\r\n const newSamplesData = new Float32Array(this.samples.length + audioData.length);\r\n newSamplesData.set(this.samples, 0);\r\n newSamplesData.set(audioData, this.samples.length);\r\n this.samples = newSamplesData;\r\n }\r\n /**\r\n * stops audio and clears the buffers\r\n */\r\n public stopAudio(): void {\r\n if (this.audioContext !== null) {\r\n this.samples = new Float32Array();\r\n clearInterval(this.autoUpdateBufferTimer);\r\n this.audioContext.close();\r\n this.audioContext = null;\r\n }\r\n }\r\n\r\n private init(audioFormat: AudioStreamFormat): void {\r\n this.audioFormat = audioFormat as AudioStreamFormatImpl;\r\n this.samples = new Float32Array();\r\n }\r\n\r\n private ensureInitializedContext(): void {\r\n if (this.audioContext === null) {\r\n this.createAudioContext();\r\n const timerPeriod = 200;\r\n this.autoUpdateBufferTimer = setInterval(() => {\r\n this.updateAudioBuffer();\r\n }, timerPeriod);\r\n }\r\n }\r\n\r\n private createAudioContext(): void {\r\n // new ((window as any).AudioContext || (window as any).webkitAudioContext)();\r\n this.audioContext = new AudioContext();\r\n\r\n // TODO: Various examples shows this gain node, it does not seem to be needed unless we plan\r\n // to control the volume, not likely\r\n this.gainNode = this.audioContext.createGain();\r\n this.gainNode.gain.value = 1;\r\n this.gainNode.connect(this.audioContext.destination);\r\n this.startTime = this.audioContext.currentTime;\r\n }\r\n\r\n private formatAudioData(audioData: ArrayBuffer): Float32Array {\r\n switch (this.audioFormat.bitsPerSample) {\r\n case 8:\r\n return this.formatArrayBuffer(new Int8Array(audioData), 128);\r\n case 16:\r\n return this.formatArrayBuffer(new Int16Array(audioData), 32768);\r\n case 32:\r\n return this.formatArrayBuffer(new Int32Array(audioData), 2147483648);\r\n default:\r\n throw new InvalidOperationError(\"Only WAVE_FORMAT_PCM (8/16/32 bps) format supported at this time\");\r\n }\r\n }\r\n\r\n private formatArrayBuffer(audioData: AudioDataTypedArray, maxValue: number): Float32Array {\r\n const float32Data = new Float32Array(audioData.length);\r\n for (let i = 0; i < audioData.length; i++) {\r\n float32Data[i] = audioData[i] / maxValue;\r\n }\r\n return float32Data;\r\n }\r\n\r\n private updateAudioBuffer(): void {\r\n if (this.samples.length === 0) {\r\n return;\r\n }\r\n\r\n const channelCount = this.audioFormat.channels;\r\n const bufferSource = this.audioContext.createBufferSource();\r\n const frameCount = this.samples.length / channelCount;\r\n const audioBuffer = this.audioContext.createBuffer(channelCount, frameCount, this.audioFormat.samplesPerSec);\r\n\r\n // TODO: Should we do the conversion in the pushAudioSample instead?\r\n for (let channel = 0; channel < channelCount; channel++) {\r\n // Fill in individual channel data\r\n let channelOffset = channel;\r\n const audioData = audioBuffer.getChannelData(channel);\r\n for (let i = 0; i < this.samples.length; i++, channelOffset += channelCount) {\r\n audioData[i] = this.samples[channelOffset];\r\n }\r\n }\r\n\r\n if (this.startTime < this.audioContext.currentTime) {\r\n this.startTime = this.audioContext.currentTime;\r\n }\r\n\r\n bufferSource.buffer = audioBuffer;\r\n bufferSource.connect(this.gainNode);\r\n bufferSource.start(this.startTime);\r\n\r\n // Make sure we play the next sample after the current one.\r\n this.startTime += audioBuffer.duration;\r\n\r\n // Clear the samples for the next pushed data.\r\n this.samples = new Float32Array();\r\n }\r\n}\r\n","//\r\n// Copyright (c) Microsoft. All rights reserved.\r\n// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.\r\n//\r\n\r\nimport {\r\n ConnectionMessage,\r\n SessionEventArgs\r\n} from \"./Exports\";\r\n\r\nexport class ConnectionMessageEventArgs {\r\n\r\n private privConnectionMessage: ConnectionMessage;\r\n\r\n constructor(message: ConnectionMessage) {\r\n this.privConnectionMessage = message;\r\n }\r\n\r\n /**\r\n * Gets the associated with this .\r\n */\r\n public get message(): ConnectionMessage {\r\n return this.privConnectionMessage;\r\n }\r\n\r\n /**\r\n * Returns a string that represents the connection message event.\r\n */\r\n public toString(): string {\r\n return \"Message: \" + this.privConnectionMessage.toString();\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { VoiceProfileType } from \"./Exports\";\r\n\r\n/**\r\n * Defines Voice Profile class for Speaker Recognition\r\n * @class VoiceProfile\r\n */\r\nexport class VoiceProfile {\r\n private privId: string;\r\n private privProfileType: VoiceProfileType;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {string} profileId - profileId of this Voice Profile.\r\n * @param {VoiceProfileType} profileType - profileType of this Voice Profile.\r\n */\r\n constructor(profileId: string, profileType: VoiceProfileType) {\r\n this.privId = profileId;\r\n this.privProfileType = profileType;\r\n }\r\n\r\n /**\r\n * profileId of this Voice Profile instance\r\n * @member VoiceProfile.prototype.profileId\r\n * @function\r\n * @public\r\n * @returns {string} profileId of this Voice Profile instance.\r\n */\r\n public get profileId(): string {\r\n return this.privId;\r\n }\r\n\r\n /**\r\n * profileType of this Voice Profile instance\r\n * @member VoiceProfile.prototype.profileType\r\n * @function\r\n * @public\r\n * @returns {VoiceProfileType} profile type of this Voice Profile instance.\r\n */\r\n public get profileType(): VoiceProfileType {\r\n return this.privProfileType;\r\n }\r\n\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { CancellationErrorCodePropertyName } from \"../common.speech/Exports\";\r\nimport { Contracts } from \"./Contracts\";\r\nimport {\r\n CancellationDetailsBase,\r\n CancellationErrorCode,\r\n CancellationReason,\r\n PropertyCollection,\r\n PropertyId,\r\n ResultReason,\r\n} from \"./Exports\";\r\n\r\nexport interface IEnrollmentResultDetails {\r\n enrollmentsCount: number;\r\n enrollmentsLength: number;\r\n enrollmentsSpeechLength: number;\r\n remainingEnrollmentsCount: number;\r\n remainingEnrollmentsSpeechLength: number;\r\n audioLength: number;\r\n audioSpeechLength: number;\r\n enrollmentStatus: string;\r\n}\r\n\r\n/**\r\n * Output format\r\n * @class VoiceProfileEnrollmentResult\r\n */\r\nexport class VoiceProfileEnrollmentResult {\r\n private privReason: ResultReason;\r\n private privDetails: IEnrollmentResultDetails;\r\n private privProperties: PropertyCollection;\r\n private privErrorDetails: string;\r\n\r\n public constructor(reason: ResultReason, json: string, statusText: string) {\r\n this.privReason = reason;\r\n this.privProperties = new PropertyCollection();\r\n if (this.privReason !== ResultReason.Canceled) {\r\n this.privDetails = JSON.parse(json);\r\n Contracts.throwIfNullOrUndefined(json, \"JSON\");\r\n if (this.privDetails.enrollmentStatus.toLowerCase() === \"enrolling\") {\r\n this.privReason = ResultReason.EnrollingVoiceProfile;\r\n }\r\n } else {\r\n this.privErrorDetails = statusText;\r\n this.privProperties.setProperty(CancellationErrorCodePropertyName, CancellationErrorCode[CancellationErrorCode.ServiceError]);\r\n }\r\n }\r\n\r\n public get reason(): ResultReason {\r\n return this.privReason;\r\n }\r\n\r\n public get enrollmentsCount(): number {\r\n return this.privDetails.enrollmentsCount;\r\n }\r\n\r\n public get enrollmentsLength(): number {\r\n return this.privDetails.enrollmentsLength;\r\n }\r\n\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n public get errorDetails(): string {\r\n return this.privErrorDetails;\r\n }\r\n}\r\n\r\n/**\r\n * @class VoiceProfileEnrollmentCancellationDetails\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class VoiceProfileEnrollmentCancellationDetails extends CancellationDetailsBase {\r\n\r\n private constructor(reason: CancellationReason, errorDetails: string, errorCode: CancellationErrorCode) {\r\n super(reason, errorDetails, errorCode);\r\n }\r\n\r\n /**\r\n * Creates an instance of VoiceProfileEnrollmentCancellationDetails object for the canceled VoiceProfileEnrollmentResult.\r\n * @member VoiceProfileEnrollmentCancellationDetails.fromResult\r\n * @function\r\n * @public\r\n * @param {VoiceProfileEnrollmentResult} result - The result that was canceled.\r\n * @returns {VoiceProfileEnrollmentCancellationDetails} The cancellation details object being created.\r\n */\r\n public static fromResult(result: VoiceProfileEnrollmentResult): VoiceProfileEnrollmentCancellationDetails {\r\n const reason = CancellationReason.Error;\r\n let errorCode: CancellationErrorCode = CancellationErrorCode.NoError;\r\n\r\n if (!!result.properties) {\r\n errorCode = (CancellationErrorCode as any)[result.properties.getProperty(CancellationErrorCodePropertyName, CancellationErrorCode[CancellationErrorCode.NoError])];\r\n }\r\n\r\n return new VoiceProfileEnrollmentCancellationDetails(reason, result.errorDetails, errorCode);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { CancellationErrorCodePropertyName } from \"../common.speech/Exports\";\r\nimport { Contracts } from \"./Contracts\";\r\nimport {\r\n CancellationDetailsBase,\r\n CancellationErrorCode,\r\n CancellationReason,\r\n PropertyCollection,\r\n ResultReason,\r\n} from \"./Exports\";\r\n\r\n/**\r\n * Output format\r\n * @class VoiceProfileResult\r\n */\r\nexport class VoiceProfileResult {\r\n private privReason: ResultReason;\r\n private privProperties: PropertyCollection;\r\n private privErrorDetails: string;\r\n\r\n public constructor(reason: ResultReason, statusText: string) {\r\n this.privReason = reason;\r\n this.privProperties = new PropertyCollection();\r\n if (reason === ResultReason.Canceled) {\r\n Contracts.throwIfNullOrUndefined(statusText, \"statusText\");\r\n this.privErrorDetails = statusText;\r\n this.privProperties.setProperty(CancellationErrorCodePropertyName, CancellationErrorCode[CancellationErrorCode.ServiceError]);\r\n }\r\n }\r\n\r\n public get reason(): ResultReason {\r\n return this.privReason;\r\n }\r\n\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n public get errorDetails(): string {\r\n return this.privErrorDetails;\r\n }\r\n}\r\n\r\n/**\r\n * @class VoiceProfileCancellationDetails\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class VoiceProfileCancellationDetails extends CancellationDetailsBase {\r\n\r\n private constructor(reason: CancellationReason, errorDetails: string, errorCode: CancellationErrorCode) {\r\n super(reason, errorDetails, errorCode);\r\n }\r\n\r\n /**\r\n * Creates an instance of VoiceProfileCancellationDetails object for the canceled VoiceProfileResult.\r\n * @member VoiceProfileCancellationDetails.fromResult\r\n * @function\r\n * @public\r\n * @param {VoiceProfileResult} result - The result that was canceled.\r\n * @returns {VoiceProfileCancellationDetails} The cancellation details object being created.\r\n */\r\n public static fromResult(result: VoiceProfileResult): VoiceProfileCancellationDetails {\r\n const reason = CancellationReason.Error;\r\n let errorCode: CancellationErrorCode = CancellationErrorCode.NoError;\r\n\r\n if (!!result.properties) {\r\n errorCode = (CancellationErrorCode as any)[result.properties.getProperty(CancellationErrorCodePropertyName, CancellationErrorCode[CancellationErrorCode.NoError])];\r\n }\r\n\r\n return new VoiceProfileCancellationDetails(reason, result.errorDetails, errorCode);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n FileAudioSource,\r\n IRestResponse,\r\n} from \"../common.browser/Exports\";\r\nimport {\r\n Context,\r\n OS,\r\n SpeakerIdMessageAdapter,\r\n SpeakerRecognitionConfig,\r\n} from \"../common.speech/Exports\";\r\nimport { IAudioSource, PromiseResult } from \"../common/Exports\";\r\nimport { AudioConfig, AudioConfigImpl } from \"./audio/AudioConfig\";\r\nimport { Contracts } from \"./Contracts\";\r\nimport {\r\n PropertyCollection,\r\n PropertyId,\r\n ResultReason,\r\n VoiceProfile,\r\n VoiceProfileEnrollmentResult,\r\n VoiceProfileResult,\r\n VoiceProfileType,\r\n} from \"./Exports\";\r\nimport { SpeechConfig, SpeechConfigImpl } from \"./SpeechConfig\";\r\n\r\n/**\r\n * Defines VoiceProfileClient class for Speaker Recognition\r\n * Handles operations from user for Voice Profile operations (e.g. createProfile, deleteProfile)\r\n * @class VoiceProfileClient\r\n */\r\nexport class VoiceProfileClient {\r\n protected privProperties: PropertyCollection;\r\n private privAdapter: SpeakerIdMessageAdapter;\r\n\r\n /**\r\n * Gets the authorization token used to communicate with the service.\r\n * @member VoiceProfileClient.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @returns {string} Authorization token.\r\n */\r\n public get authorizationToken(): string {\r\n return this.properties.getProperty(PropertyId.SpeechServiceAuthorization_Token);\r\n }\r\n\r\n /**\r\n * Gets/Sets the authorization token used to communicate with the service.\r\n * @member VoiceProfileClient.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @param {string} token - Authorization token.\r\n */\r\n public set authorizationToken(token: string) {\r\n Contracts.throwIfNullOrWhitespace(token, \"token\");\r\n this.properties.setProperty(PropertyId.SpeechServiceAuthorization_Token, token);\r\n }\r\n\r\n /**\r\n * The collection of properties and their values defined for this VoiceProfileClient.\r\n * @member VoiceProfileClient.prototype.properties\r\n * @function\r\n * @public\r\n * @returns {PropertyCollection} The collection of properties and their values defined for this VoiceProfileClient.\r\n */\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n /**\r\n * VoiceProfileClient constructor.\r\n * @constructor\r\n * @param {SpeechConfig} speechConfig - An set of initial properties for this synthesizer (authentication key, region, &c)\r\n */\r\n public constructor(speechConfig: SpeechConfig) {\r\n const speechConfigImpl: SpeechConfigImpl = speechConfig as SpeechConfigImpl;\r\n Contracts.throwIfNull(speechConfigImpl, \"speechConfig\");\r\n\r\n this.privProperties = speechConfigImpl.properties.clone();\r\n this.implClientSetup();\r\n }\r\n\r\n /**\r\n * Create a speaker recognition voice profile\r\n * @member VoiceProfileClient.prototype.createProfileAsync\r\n * @function\r\n * @public\r\n * @param {VoiceProfileType} profileType Type of Voice Profile to be created\r\n * specifies the keyword to be recognized.\r\n * @param {string} lang Language string (locale) for Voice Profile\r\n * @param cb - Callback invoked once Voice Profile has been created.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public createProfileAsync(profileType: VoiceProfileType, lang: string, cb?: (e: VoiceProfile) => void, err?: (e: string) => void): void {\r\n this.privAdapter.createProfile(profileType, lang).on((result: IRestResponse) => {\r\n if (!!cb) {\r\n const response: { profileId: string } = result.json();\r\n const profile = new VoiceProfile(response.profileId, profileType);\r\n cb(profile);\r\n }\r\n },\r\n (error: string) => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Create a speaker recognition voice profile\r\n * @member VoiceProfileClient.prototype.enrollProfileAsync\r\n * @function\r\n * @public\r\n * @param {VoiceProfile} profile Voice Profile to create enrollment for\r\n * @param {AudioConfig} audioConfig source info from which to create enrollment\r\n * @param cb - Callback invoked once Enrollment request has been submitted.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public enrollProfileAsync(profile: VoiceProfile, audioConfig: AudioConfig, cb?: (e: VoiceProfileEnrollmentResult) => void, err?: (e: string) => void): void {\r\n const configImpl: AudioConfigImpl = audioConfig as AudioConfigImpl;\r\n Contracts.throwIfNullOrUndefined(configImpl, \"audioConfig\");\r\n this.privAdapter.createEnrollment(profile, configImpl).on((result: IRestResponse) => {\r\n if (!!cb) {\r\n cb(\r\n new VoiceProfileEnrollmentResult(\r\n result.ok ? ResultReason.EnrolledVoiceProfile : ResultReason.Canceled,\r\n result.data,\r\n result.statusText,\r\n )\r\n );\r\n }\r\n },\r\n (error: string) => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Delete a speaker recognition voice profile\r\n * @member VoiceProfileClient.prototype.deleteProfileAsync\r\n * @function\r\n * @public\r\n * @param {VoiceProfile} profile Voice Profile to be deleted\r\n * @param cb - Callback invoked once Voice Profile has been deleted.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public deleteProfileAsync(profile: VoiceProfile, cb?: (response: VoiceProfileResult) => void, err?: (e: string) => void): void {\r\n this.privAdapter.deleteProfile(profile).on((result: IRestResponse) => {\r\n this.handleResultCallbacks(result, ResultReason.DeletedVoiceProfile, cb);\r\n },\r\n (error: string) => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Remove all enrollments for a speaker recognition voice profile\r\n * @member VoiceProfileClient.prototype.resetProfileAsync\r\n * @function\r\n * @public\r\n * @param {VoiceProfile} profile Voice Profile to be reset\r\n * @param cb - Callback invoked once Voice Profile has been reset.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public resetProfileAsync(profile: VoiceProfile, cb?: (response: VoiceProfileResult) => void, err?: (e: string) => void): void {\r\n this.privAdapter.resetProfile(profile).on((result: IRestResponse) => {\r\n this.handleResultCallbacks(result, ResultReason.ResetVoiceProfile, cb);\r\n },\r\n (error: string) => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Included for compatibility\r\n * @member VoiceProfileClient.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(): void {\r\n return;\r\n }\r\n\r\n // Does class setup, swiped from Recognizer.\r\n protected implClientSetup(): void {\r\n\r\n let osPlatform = (typeof window !== \"undefined\") ? \"Browser\" : \"Node\";\r\n let osName = \"unknown\";\r\n let osVersion = \"unknown\";\r\n\r\n if (typeof navigator !== \"undefined\") {\r\n osPlatform = osPlatform + \"/\" + navigator.platform;\r\n osName = navigator.userAgent;\r\n osVersion = navigator.appVersion;\r\n }\r\n\r\n const recognizerConfig =\r\n new SpeakerRecognitionConfig(\r\n new Context(new OS(osPlatform, osName, osVersion)),\r\n this.privProperties);\r\n\r\n this.privAdapter = new SpeakerIdMessageAdapter(recognizerConfig);\r\n }\r\n\r\n private handleResultCallbacks(result: IRestResponse, successReason: ResultReason, cb?: (response: VoiceProfileResult) => void): void {\r\n if (!!cb) {\r\n const response: VoiceProfileResult =\r\n new VoiceProfileResult(\r\n result.ok ? successReason : ResultReason.Canceled,\r\n result.statusText\r\n );\r\n cb(response);\r\n }\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n IRestResponse,\r\n} from \"../common.browser/Exports\";\r\nimport {\r\n Context,\r\n OS,\r\n SpeakerIdMessageAdapter,\r\n SpeakerRecognitionConfig,\r\n} from \"../common.speech/Exports\";\r\nimport { IAudioSource, PromiseResult } from \"../common/Exports\";\r\nimport { AudioConfig, AudioConfigImpl } from \"./audio/AudioConfig\";\r\nimport { Contracts } from \"./Contracts\";\r\nimport {\r\n PropertyCollection,\r\n PropertyId,\r\n ResultReason,\r\n SpeakerIdentificationModel,\r\n SpeakerRecognitionResult,\r\n SpeakerRecognitionResultType,\r\n SpeakerVerificationModel,\r\n VoiceProfile,\r\n} from \"./Exports\";\r\nimport { SpeechConfig, SpeechConfigImpl } from \"./SpeechConfig\";\r\n\r\n/**\r\n * Defines SpeakerRecognizer class for Speaker Recognition\r\n * Handles operations from user for Voice Profile operations (e.g. createProfile, deleteProfile)\r\n * @class SpeakerRecognizer\r\n */\r\nexport class SpeakerRecognizer {\r\n protected privProperties: PropertyCollection;\r\n private privAdapter: SpeakerIdMessageAdapter;\r\n private privAudioConfigImpl: AudioConfigImpl;\r\n\r\n /**\r\n * Gets the authorization token used to communicate with the service.\r\n * @member SpeakerRecognizer.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @returns {string} Authorization token.\r\n */\r\n public get authorizationToken(): string {\r\n return this.properties.getProperty(PropertyId.SpeechServiceAuthorization_Token);\r\n }\r\n\r\n /**\r\n * Gets/Sets the authorization token used to communicate with the service.\r\n * @member SpeakerRecognizer.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @param {string} token - Authorization token.\r\n */\r\n public set authorizationToken(token: string) {\r\n Contracts.throwIfNullOrWhitespace(token, \"token\");\r\n this.properties.setProperty(PropertyId.SpeechServiceAuthorization_Token, token);\r\n }\r\n\r\n /**\r\n * The collection of properties and their values defined for this SpeakerRecognizer.\r\n * @member SpeakerRecognizer.prototype.properties\r\n * @function\r\n * @public\r\n * @returns {PropertyCollection} The collection of properties and their values defined for this SpeakerRecognizer.\r\n */\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n /**\r\n * SpeakerRecognizer constructor.\r\n * @constructor\r\n * @param {SpeechConfig} speechConfig - An set of initial properties for this recognizer (authentication key, region, &c)\r\n */\r\n public constructor(speechConfig: SpeechConfig, audioConfig: AudioConfig) {\r\n const speechConfigImpl: SpeechConfigImpl = speechConfig as SpeechConfigImpl;\r\n Contracts.throwIfNull(speechConfigImpl, \"speechConfig\");\r\n\r\n this.privAudioConfigImpl = audioConfig as AudioConfigImpl;\r\n Contracts.throwIfNull(this.privAudioConfigImpl, \"audioConfig\");\r\n\r\n this.privProperties = speechConfigImpl.properties.clone();\r\n this.implSRSetup();\r\n }\r\n\r\n /**\r\n * Get recognition result for model using given audio\r\n * @member SpeakerRecognizer.prototype.recognizeOnceAsync\r\n * @function\r\n * @public\r\n * @param {SpeakerIdentificationModel} model Model containing Voice Profiles to be identified\r\n * @param cb - Callback invoked once result is returned.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public recognizeOnceAsync(model: SpeakerIdentificationModel | SpeakerVerificationModel, cb?: (e: SpeakerRecognitionResult) => void, err?: (e: string) => void): void {\r\n if (model instanceof SpeakerIdentificationModel) {\r\n this.privAdapter.identifySpeaker(model, this.privAudioConfigImpl).continueWith((promiseResult: PromiseResult) => {\r\n this.handleResultCallbacks(promiseResult, SpeakerRecognitionResultType.Identify, undefined, cb, err);\r\n });\r\n } else if (model instanceof SpeakerVerificationModel) {\r\n this.privAdapter.verifySpeaker(model, this.privAudioConfigImpl).continueWith((promiseResult: PromiseResult) => {\r\n this.handleResultCallbacks(promiseResult, SpeakerRecognitionResultType.Verify, model.voiceProfile.profileId, cb, err);\r\n });\r\n } else {\r\n throw new Error(\"SpeakerRecognizer.recognizeOnce: Unexpected model type\");\r\n }\r\n }\r\n\r\n /**\r\n * Included for compatibility\r\n * @member SpeakerRecognizer.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(): void {\r\n return;\r\n }\r\n\r\n // Does class setup, swiped from Recognizer.\r\n private implSRSetup(): void {\r\n\r\n let osPlatform = (typeof window !== \"undefined\") ? \"Browser\" : \"Node\";\r\n let osName = \"unknown\";\r\n let osVersion = \"unknown\";\r\n\r\n if (typeof navigator !== \"undefined\") {\r\n osPlatform = osPlatform + \"/\" + navigator.platform;\r\n osName = navigator.userAgent;\r\n osVersion = navigator.appVersion;\r\n }\r\n\r\n const recognizerConfig =\r\n new SpeakerRecognitionConfig(\r\n new Context(new OS(osPlatform, osName, osVersion)),\r\n this.privProperties);\r\n\r\n this.privAdapter = new SpeakerIdMessageAdapter(recognizerConfig);\r\n }\r\n\r\n private handleResultCallbacks(promiseResult: PromiseResult, resultType: SpeakerRecognitionResultType, profileId?: string, cb?: (response: SpeakerRecognitionResult) => void, err?: (e: string) => void): void {\r\n try {\r\n if (promiseResult.isError) {\r\n if (!!err) {\r\n err(promiseResult.error);\r\n }\r\n } else if (promiseResult.isCompleted && !!cb) {\r\n cb(\r\n new SpeakerRecognitionResult(\r\n resultType,\r\n promiseResult.result.data,\r\n profileId,\r\n promiseResult.result.ok ? ResultReason.RecognizedSpeaker : ResultReason.Canceled,\r\n )\r\n );\r\n }\r\n } catch (e) {\r\n if (!!err) {\r\n err(e);\r\n }\r\n }\r\n }\r\n\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { Contracts } from \"./Contracts\";\r\nimport {\r\n VoiceProfile,\r\n VoiceProfileType,\r\n} from \"./Exports\";\r\n\r\n/**\r\n * Defines SpeakerIdentificationModel class for Speaker Recognition\r\n * Model contains a set of profiles against which to identify speaker(s)\r\n * @class SpeakerIdentificationModel\r\n */\r\nexport class SpeakerIdentificationModel {\r\n private privVoiceProfiles: VoiceProfile[] = [];\r\n\r\n private constructor(profiles: VoiceProfile[]) {\r\n Contracts.throwIfNullOrUndefined(profiles, \"VoiceProfiles\");\r\n if (profiles.length === 0) {\r\n throw new Error(\"Empty Voice Profiles array\");\r\n }\r\n profiles.forEach((profile: VoiceProfile) => {\r\n if (profile.profileType !== VoiceProfileType.TextIndependentIdentification) {\r\n throw new Error(\"Identification model can only be created from Identification profile: \" + profile.profileId);\r\n }\r\n this.privVoiceProfiles.push(profile);\r\n });\r\n }\r\n public static fromProfiles(profiles: VoiceProfile[]): SpeakerIdentificationModel {\r\n return new SpeakerIdentificationModel(profiles);\r\n }\r\n\r\n public get voiceProfileIds(): string {\r\n return this.privVoiceProfiles.map((profile: VoiceProfile) => profile.profileId).join(\",\");\r\n }\r\n\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { Contracts } from \"./Contracts\";\r\nimport {\r\n VoiceProfile,\r\n VoiceProfileType,\r\n} from \"./Exports\";\r\n\r\n/**\r\n * Defines SpeakerVerificationModel class for Speaker Recognition\r\n * Model contains a profile against which to verify a speaker\r\n * @class SpeakerVerificationModel\r\n */\r\nexport class SpeakerVerificationModel {\r\n private privVoiceProfile: VoiceProfile;\r\n\r\n private constructor(profile: VoiceProfile) {\r\n Contracts.throwIfNullOrUndefined(profile, \"VoiceProfile\");\r\n if (profile.profileType === VoiceProfileType.TextIndependentIdentification) {\r\n throw new Error(\"Verification model cannot be created from Identification profile\");\r\n }\r\n this.privVoiceProfile = profile;\r\n }\r\n\r\n public static fromProfile(profile: VoiceProfile): SpeakerVerificationModel {\r\n return new SpeakerVerificationModel(profile);\r\n }\r\n\r\n public get voiceProfile(): VoiceProfile {\r\n return this.privVoiceProfile;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { AutoDetectSourceLanguagesOpenRangeOptionName } from \"../common.speech/Exports\";\r\nimport {Contracts} from \"./Contracts\";\r\nimport {\r\n PropertyCollection,\r\n PropertyId,\r\n SourceLanguageConfig,\r\n} from \"./Exports\";\r\n\r\n/**\r\n * Language auto detect configuration.\r\n * @class AutoDetectSourceLanguageConfig\r\n * Added in version 1.13.0.\r\n */\r\nexport class AutoDetectSourceLanguageConfig {\r\n private privProperties: PropertyCollection;\r\n\r\n private constructor() {\r\n this.privProperties = new PropertyCollection();\r\n }\r\n\r\n /**\r\n * @member AutoDetectSourceLanguageConfig.fromOpenRange\r\n * @function\r\n * @public\r\n * Only [[SpeechSynthesizer]] supports source language auto detection from open range,\r\n * for [[Recognizer]], please use AutoDetectSourceLanguageConfig with specific source languages.\r\n * @return {AutoDetectSourceLanguageConfig} Instance of AutoDetectSourceLanguageConfig\r\n * @summary Creates an instance of the AutoDetectSourceLanguageConfig with open range.\r\n */\r\n public static fromOpenRange(): AutoDetectSourceLanguageConfig {\r\n const config = new AutoDetectSourceLanguageConfig();\r\n config.properties.setProperty(PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, AutoDetectSourceLanguagesOpenRangeOptionName);\r\n return config;\r\n }\r\n\r\n /**\r\n * @member AutoDetectSourceLanguageConfig.fromLanguages\r\n * @function\r\n * @public\r\n * @param {string[]} languages Comma-separated string of languages (eg. \"en-US,fr-FR\") to populate properties of config.\r\n * @return {AutoDetectSourceLanguageConfig} Instance of AutoDetectSourceLanguageConfig\r\n * @summary Creates an instance of the AutoDetectSourceLanguageConfig with given languages.\r\n */\r\n public static fromLanguages(languages: string[]): AutoDetectSourceLanguageConfig {\r\n Contracts.throwIfArrayEmptyOrWhitespace(languages, \"languages\");\r\n const config = new AutoDetectSourceLanguageConfig();\r\n config.properties.setProperty(PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, languages.join());\r\n return config;\r\n }\r\n\r\n /**\r\n * @member AutoDetectSourceLanguageConfig.fromSourceLanguageConfigs\r\n * @function\r\n * @public\r\n * @param {SourceLanguageConfig[]} configs SourceLanguageConfigs to populate properties of config.\r\n * @return {AutoDetectSourceLanguageConfig} Instance of AutoDetectSourceLanguageConfig\r\n * @summary Creates an instance of the AutoDetectSourceLanguageConfig with given SourceLanguageConfigs.\r\n */\r\n public static fromSourceLanguageConfigs(configs: SourceLanguageConfig[]): AutoDetectSourceLanguageConfig {\r\n if (configs.length < 1) {\r\n throw new Error(\"Expected non-empty SourceLanguageConfig array.\");\r\n }\r\n const autoConfig = new AutoDetectSourceLanguageConfig();\r\n const langs: string[] = [];\r\n configs.forEach((config: SourceLanguageConfig) => {\r\n langs.push(config.language);\r\n if (config.endpointId !== undefined && config.endpointId !== \"\") {\r\n const customProperty = config.language + PropertyId.SpeechServiceConnection_EndpointId.toString();\r\n autoConfig.properties.setProperty(customProperty, config.endpointId);\r\n }\r\n });\r\n autoConfig.properties.setProperty(PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, langs.join());\r\n\r\n return autoConfig;\r\n }\r\n\r\n /**\r\n * @member AutoDetectSourceLanguageConfig.prototype.properties\r\n * @function\r\n * @public\r\n * @return {PropertyCollection} Properties of the config.\r\n * @summary Gets a auto detected language config properties\r\n */\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { Contracts } from \"./Contracts\";\r\nimport {\r\n SpeechRecognitionResult,\r\n} from \"./Exports\";\r\n\r\n/**\r\n * Output format\r\n * @class AutoDetectSourceLanguageResult\r\n */\r\nexport class AutoDetectSourceLanguageResult {\r\n\r\n private privLanguage: string;\r\n private privLanguageDetectionConfidence: string;\r\n\r\n private constructor(language: string, languageDetectionConfidence: string) {\r\n Contracts.throwIfNullOrUndefined(language, \"language\");\r\n Contracts.throwIfNullOrUndefined(languageDetectionConfidence, \"languageDetectionConfidence\");\r\n this.privLanguage = language;\r\n this.privLanguageDetectionConfidence = languageDetectionConfidence;\r\n }\r\n\r\n /**\r\n * Creates an instance of AutoDetectSourceLanguageResult object from a SpeechRecognitionResult instance.\r\n * @member AutoDetectSourceLanguageResult.fromResult\r\n * @function\r\n * @public\r\n * @param {SpeechRecognitionResult} result - The recognition result.\r\n * @returns {AutoDetectSourceLanguageResult} AutoDetectSourceLanguageResult object being created.\r\n */\r\n public static fromResult(result: SpeechRecognitionResult): AutoDetectSourceLanguageResult {\r\n return new AutoDetectSourceLanguageResult(result.language, result.languageDetectionConfidence);\r\n }\r\n\r\n public get language(): string {\r\n return this.privLanguage;\r\n }\r\n\r\n public get languageDetectionConfidence(): string {\r\n return this.privLanguageDetectionConfidence;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { Contracts } from \"./Contracts\";\r\n\r\n/**\r\n * Source Language configuration.\r\n * @class SourceLanguageConfig\r\n */\r\nexport class SourceLanguageConfig {\r\n private privLanguage: string;\r\n private privEndpointId: string;\r\n\r\n private constructor(language: string, endpointId?: string) {\r\n Contracts.throwIfNullOrUndefined(language, \"language\");\r\n this.privLanguage = language;\r\n this.privEndpointId = endpointId;\r\n }\r\n\r\n /**\r\n * @member SourceLanguageConfig.fromLanguage\r\n * @function\r\n * @public\r\n * @param {string} language language (eg. \"en-US\") value of config.\r\n * @param {string?} endpointId endpointId of model bound to given language of config.\r\n * @return {SourceLanguageConfig} Instance of SourceLanguageConfig\r\n * @summary Creates an instance of the SourceLanguageConfig with the given language and optional endpointId.\r\n * Added in version 1.13.0.\r\n */\r\n public static fromLanguage(language: string, endpointId?: string): SourceLanguageConfig {\r\n return new SourceLanguageConfig(language, endpointId);\r\n }\r\n\r\n public get language(): string {\r\n return this.privLanguage;\r\n }\r\n\r\n public get endpointId(): string {\r\n return this.privEndpointId;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { CancellationErrorCodePropertyName } from \"../common.speech/Exports\";\r\nimport { Contracts } from \"./Contracts\";\r\nimport {\r\n CancellationDetailsBase,\r\n CancellationErrorCode,\r\n CancellationReason,\r\n PropertyCollection,\r\n PropertyId,\r\n ResultReason,\r\n} from \"./Exports\";\r\n\r\nexport enum SpeakerRecognitionResultType {\r\n Verify,\r\n Identify\r\n}\r\n/**\r\n * Output format\r\n * @class SpeakerRecognitionResult\r\n */\r\nexport class SpeakerRecognitionResult {\r\n private privReason: ResultReason;\r\n private privProperties: PropertyCollection;\r\n private privProfileId: string;\r\n private privScore: number;\r\n private privErrorDetails: string;\r\n\r\n public constructor(resultType: SpeakerRecognitionResultType, data: string, profileId: string, resultReason: ResultReason = ResultReason.RecognizedSpeaker) {\r\n this.privProperties = new PropertyCollection();\r\n this.privReason = resultReason;\r\n if (this.privReason !== ResultReason.Canceled) {\r\n if (resultType === SpeakerRecognitionResultType.Identify) {\r\n const json: { identifiedProfile: { profileId: string, score: number } } = JSON.parse(data);\r\n Contracts.throwIfNullOrUndefined(json, \"JSON\");\r\n this.privProfileId = json.identifiedProfile.profileId;\r\n this.privScore = json.identifiedProfile.score;\r\n } else {\r\n const json: { recognitionResult: string, score: number } = JSON.parse(data);\r\n Contracts.throwIfNullOrUndefined(json, \"JSON\");\r\n this.privScore = json.score;\r\n if (json.recognitionResult.toLowerCase() !== \"accept\") {\r\n this.privReason = ResultReason.NoMatch;\r\n }\r\n if (profileId !== undefined && profileId !== \"\") {\r\n this.privProfileId = profileId;\r\n }\r\n }\r\n } else {\r\n const json: { statusText: string } = JSON.parse(data);\r\n Contracts.throwIfNullOrUndefined(json, \"JSON\");\r\n this.privErrorDetails = json.statusText;\r\n this.privProperties.setProperty(CancellationErrorCodePropertyName, CancellationErrorCode[CancellationErrorCode.ServiceError]);\r\n }\r\n this.privProperties.setProperty(PropertyId.SpeechServiceResponse_JsonResult, data);\r\n }\r\n\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n public get reason(): ResultReason {\r\n return this.privReason;\r\n }\r\n\r\n public get profileId(): string {\r\n return this.privProfileId;\r\n }\r\n\r\n public get errorDetails(): string {\r\n return this.privErrorDetails;\r\n }\r\n\r\n public get score(): number {\r\n return this.privScore;\r\n }\r\n}\r\n\r\n/**\r\n * @class SpeakerRecognitionCancellationDetails\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class SpeakerRecognitionCancellationDetails extends CancellationDetailsBase {\r\n\r\n private constructor(reason: CancellationReason, errorDetails: string, errorCode: CancellationErrorCode) {\r\n super(reason, errorDetails, errorCode);\r\n }\r\n\r\n /**\r\n * Creates an instance of SpeakerRecognitionCancellationDetails object for the canceled SpeakerRecognitionResult\r\n * @member SpeakerRecognitionCancellationDetails.fromResult\r\n * @function\r\n * @public\r\n * @param {SpeakerRecognitionResult} result - The result that was canceled.\r\n * @returns {SpeakerRecognitionCancellationDetails} The cancellation details object being created.\r\n */\r\n public static fromResult(result: SpeakerRecognitionResult): SpeakerRecognitionCancellationDetails {\r\n const reason = CancellationReason.Error;\r\n let errorCode: CancellationErrorCode = CancellationErrorCode.NoError;\r\n\r\n if (!!result.properties) {\r\n errorCode = (CancellationErrorCode as any)[result.properties.getProperty(CancellationErrorCodePropertyName, CancellationErrorCode[CancellationErrorCode.NoError])];\r\n }\r\n\r\n return new SpeakerRecognitionCancellationDetails(reason, result.errorDetails, errorCode);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n// Multi-device Conversation is a Preview feature.\r\n\r\nexport { Conversation } from \"./Conversation\";\r\nexport { ConversationExpirationEventArgs } from \"./ConversationExpirationEventArgs\";\r\nexport { ConversationParticipantsChangedEventArgs } from \"./ConversationParticipantsChangedEventArgs\";\r\nexport { ConversationTranslationCanceledEventArgs } from \"./ConversationTranslationCanceledEventArgs\";\r\nexport { ConversationTranslationEventArgs } from \"./ConversationTranslationEventArgs\";\r\nexport { ConversationTranslationResult } from \"./ConversationTranslationResult\";\r\nexport { ConversationTranslator } from \"./ConversationTranslator\";\r\nexport { Participant, User } from \"./IParticipant\";\r\nexport { ParticipantChangedReason } from \"./ParticipantChangedReason\";\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n// Multi-device Conversation is a Preview feature.\r\n\r\nimport {\r\n ConversationConnectionConfig,\r\n ConversationManager,\r\n ConversationReceivedTranslationEventArgs,\r\n ConversationTranslatorCommandTypes,\r\n ConversationTranslatorMessageTypes,\r\n ConversationTranslatorRecognizer,\r\n IInternalConversation,\r\n IInternalParticipant,\r\n InternalParticipants,\r\n LockRoomEventArgs,\r\n MuteAllEventArgs,\r\n ParticipantAttributeEventArgs,\r\n ParticipantEventArgs,\r\n ParticipantsListEventArgs\r\n} from \"../../common.speech/Exports\";\r\nimport { IDisposable, IErrorMessages } from \"../../common/Exports\";\r\nimport { Contracts } from \"../Contracts\";\r\nimport {\r\n Connection,\r\n ConnectionEventArgs,\r\n ConversationExpirationEventArgs,\r\n ConversationParticipantsChangedEventArgs,\r\n ConversationTranslationCanceledEventArgs,\r\n ConversationTranslationEventArgs,\r\n ConversationTranslator,\r\n Participant,\r\n ParticipantChangedReason,\r\n ProfanityOption,\r\n PropertyCollection,\r\n PropertyId,\r\n SpeechTranslationConfig\r\n} from \"../Exports\";\r\nimport { SpeechTranslationConfigImpl } from \"../SpeechTranslationConfig\";\r\nimport { Callback, IConversation } from \"./IConversation\";\r\nimport { IParticipant, IUser } from \"./IParticipant\";\r\n\r\nexport abstract class Conversation implements IConversation {\r\n\r\n public abstract get authorizationToken(): string;\r\n public abstract set authorizationToken(value: string);\r\n\r\n public abstract get config(): SpeechTranslationConfig;\r\n\r\n public abstract get conversationId(): string;\r\n public abstract get properties(): PropertyCollection;\r\n public abstract get speechRecognitionLanguage(): string;\r\n\r\n protected constructor() { }\r\n\r\n /**\r\n * Create a conversation\r\n * @param speechConfig\r\n * @param cb\r\n * @param err\r\n */\r\n public static createConversationAsync(speechConfig: SpeechTranslationConfig, cb?: Callback, err?: Callback): Conversation {\r\n Contracts.throwIfNullOrUndefined(speechConfig, ConversationConnectionConfig.restErrors.invalidArgs.replace(\"{arg}\", \"config\"));\r\n Contracts.throwIfNullOrUndefined(speechConfig.region, ConversationConnectionConfig.restErrors.invalidArgs.replace(\"{arg}\", \"SpeechServiceConnection_Region\"));\r\n if (!speechConfig.subscriptionKey && !speechConfig.getProperty(PropertyId[PropertyId.SpeechServiceAuthorization_Token])) {\r\n Contracts.throwIfNullOrUndefined(speechConfig.subscriptionKey, ConversationConnectionConfig.restErrors.invalidArgs.replace(\"{arg}\", \"SpeechServiceConnection_Key\"));\r\n }\r\n const conversationImpl: ConversationImpl = new ConversationImpl(speechConfig);\r\n\r\n conversationImpl.createConversationAsync(\r\n (() => {\r\n if (!!cb) {\r\n cb();\r\n }\r\n }),\r\n (error: any) => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n\r\n return conversationImpl;\r\n }\r\n\r\n /** Start a conversation. */\r\n public abstract startConversationAsync(cb?: Callback, err?: Callback): void;\r\n\r\n /** Delete a conversation. After this no one will be able to join the conversation. */\r\n public abstract deleteConversationAsync(cb?: Callback, err?: Callback): void;\r\n\r\n /** End a conversation. */\r\n public abstract endConversationAsync(cb?: Callback, err?: Callback): void;\r\n\r\n /** Lock a conversation. This will prevent new participants from joining. */\r\n public abstract lockConversationAsync(cb?: Callback, err?: Callback): void;\r\n\r\n /**\r\n * Mute all other participants in the conversation. After this no other participants will\r\n * have their speech recognitions broadcast, nor be able to send text messages.\r\n */\r\n public abstract muteAllParticipantsAsync(cb?: Callback, err?: Callback): void;\r\n\r\n /**\r\n * Mute a participant.\r\n * @param userId A user identifier\r\n */\r\n public abstract muteParticipantAsync(userId: string, cb?: Callback, err?: Callback): void;\r\n\r\n /**\r\n * Remove a participant from a conversation using the user id, Participant or User object\r\n * @param userId A user identifier\r\n */\r\n public abstract removeParticipantAsync(userId: string | IParticipant | IUser, cb?: Callback, err?: Callback): void;\r\n\r\n /** Unlocks a conversation. */\r\n public abstract unlockConversationAsync(cb?: Callback, err?: Callback): void;\r\n\r\n /** Unmute all other participants in the conversation. */\r\n public abstract unmuteAllParticipantsAsync(cb?: Callback, err?: Callback): void;\r\n\r\n /**\r\n * Unmute a participant.\r\n * @param userId A user identifier\r\n */\r\n public abstract unmuteParticipantAsync(userId: string, cb?: Callback, err?: Callback): void;\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class ConversationImpl extends Conversation implements IDisposable {\r\n\r\n private privConfig: SpeechTranslationConfig;\r\n private privProperties: PropertyCollection;\r\n private privLanguage: string;\r\n private privToken: string;\r\n private privIsDisposed: boolean = false;\r\n private privRoom: IInternalConversation;\r\n private privManager: ConversationManager;\r\n private privConversationRecognizer: ConversationTranslatorRecognizer;\r\n private privConversationRecognizerConnection: Connection;\r\n private privIsConnected: boolean = false;\r\n private privParticipants: InternalParticipants;\r\n private privIsReady: boolean;\r\n private privConversationTranslator: ConversationTranslator;\r\n private privErrors: IErrorMessages = ConversationConnectionConfig.restErrors;\r\n private readonly privTextMessageMaxLength: number;\r\n\r\n public set conversationTranslator(value: ConversationTranslator) {\r\n this.privConversationTranslator = value;\r\n }\r\n\r\n // get the internal data about a conversation\r\n public get room(): IInternalConversation {\r\n return this.privRoom;\r\n }\r\n\r\n // get the wrapper for connecting to the websockets\r\n public get connection(): ConversationTranslatorRecognizer {\r\n return this.privConversationRecognizer; // this.privConnection;\r\n }\r\n\r\n // get / set the speech auth token\r\n public get authorizationToken(): string {\r\n return this.privToken;\r\n }\r\n public set authorizationToken(value: string) {\r\n Contracts.throwIfNullOrWhitespace(value, \"authorizationToken\");\r\n this.privToken = value;\r\n }\r\n\r\n // get the config\r\n public get config(): SpeechTranslationConfig {\r\n return this.privConfig;\r\n }\r\n // get the conversation Id\r\n public get conversationId(): string {\r\n return this.privRoom ? this.privRoom.roomId : \"\";\r\n }\r\n\r\n // get the properties\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n // get the speech language\r\n public get speechRecognitionLanguage(): string {\r\n return this.privLanguage;\r\n }\r\n\r\n public get isMutedByHost(): boolean {\r\n return this.privParticipants.me?.isHost ? false : this.privParticipants.me?.isMuted;\r\n }\r\n\r\n public get isConnected(): boolean {\r\n return this.privIsConnected && this.privIsReady;\r\n }\r\n\r\n public get participants(): Participant[] {\r\n return this.toParticipants(true);\r\n }\r\n\r\n public get me(): Participant {\r\n return this.toParticipant(this.privParticipants.me);\r\n }\r\n\r\n public get host(): Participant {\r\n return this.toParticipant(this.privParticipants.host);\r\n }\r\n\r\n /**\r\n * Create a conversation impl\r\n * @param speechConfig\r\n */\r\n public constructor(speechConfig: SpeechTranslationConfig) {\r\n super();\r\n this.privProperties = new PropertyCollection();\r\n this.privManager = new ConversationManager();\r\n\r\n // check the speech language\r\n const language: string = speechConfig.getProperty(PropertyId[PropertyId.SpeechServiceConnection_RecoLanguage]);\r\n if (!language) {\r\n speechConfig.setProperty(PropertyId[PropertyId.SpeechServiceConnection_RecoLanguage], ConversationConnectionConfig.defaultLanguageCode);\r\n }\r\n this.privLanguage = speechConfig.getProperty(PropertyId[PropertyId.SpeechServiceConnection_RecoLanguage]);\r\n\r\n // check the target language(s)\r\n if (speechConfig.targetLanguages.length === 0) {\r\n speechConfig.addTargetLanguage(this.privLanguage);\r\n }\r\n\r\n // check the profanity setting: speech and conversationTranslator should be in sync\r\n const profanity: string = speechConfig.getProperty(PropertyId[PropertyId.SpeechServiceResponse_ProfanityOption]);\r\n if (!profanity) {\r\n speechConfig.setProfanity(ProfanityOption.Masked);\r\n }\r\n\r\n // check the nickname: it should pass this regex: ^\\w+([\\s-][\\w\\(\\)]+)*$\"\r\n // TODO: specify the regex required. Nicknames must be unique or get the duplicate nickname error\r\n // TODO: check what the max length is and if a truncation is required or if the service handles it without an error\r\n let hostNickname: string = speechConfig.getProperty(PropertyId[PropertyId.ConversationTranslator_Name]);\r\n if (hostNickname === undefined || hostNickname === null || hostNickname.length <= 1 || hostNickname.length > 50) {\r\n hostNickname = \"Host\";\r\n }\r\n speechConfig.setProperty(PropertyId[PropertyId.ConversationTranslator_Name], hostNickname);\r\n\r\n // save the speech config for future usage\r\n this.privConfig = speechConfig;\r\n\r\n // save the config properties\r\n const configImpl = speechConfig as SpeechTranslationConfigImpl;\r\n Contracts.throwIfNull(configImpl, \"speechConfig\");\r\n this.privProperties = configImpl.properties.clone();\r\n this.privIsConnected = false;\r\n this.privParticipants = new InternalParticipants();\r\n this.privIsReady = false;\r\n this.privTextMessageMaxLength = 1000;\r\n }\r\n\r\n /**\r\n * Create a new conversation as Host\r\n * @param cb\r\n * @param err\r\n */\r\n public createConversationAsync(cb?: Callback, err?: Callback): void {\r\n try {\r\n if (!!this.privConversationRecognizer) {\r\n this.handleError(new Error(this.privErrors.permissionDeniedStart), err);\r\n }\r\n this.privManager.createOrJoin(this.privProperties, undefined,\r\n ((room: IInternalConversation) => {\r\n if (!room) {\r\n this.handleError(new Error(this.privErrors.permissionDeniedConnect), err);\r\n }\r\n this.privRoom = room;\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any) => {\r\n this.handleError(error, err);\r\n }));\r\n } catch (error) {\r\n this.handleError(error, err);\r\n }\r\n }\r\n\r\n /**\r\n * Starts a new conversation as host.\r\n * @param cb\r\n * @param err\r\n */\r\n public startConversationAsync(cb?: Callback, err?: Callback): void {\r\n try {\r\n // check if there is already a recognizer\r\n if (!!this.privConversationRecognizer) {\r\n this.handleError(new Error(this.privErrors.permissionDeniedStart), err);\r\n }\r\n // check if there is conversation data available\r\n Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedConnect);\r\n // connect to the conversation websocket\r\n this.privParticipants.meId = this.privRoom.participantId;\r\n this.privConversationRecognizer = new ConversationTranslatorRecognizer(this.privConfig);\r\n this.privConversationRecognizer.conversation = this.privRoom;\r\n this.privConversationRecognizerConnection = Connection.fromRecognizer(this.privConversationRecognizer);\r\n this.privConversationRecognizerConnection.connected = this.onConnected;\r\n this.privConversationRecognizerConnection.disconnected = this.onDisconnected;\r\n this.privConversationRecognizer.canceled = this.onCanceled;\r\n this.privConversationRecognizer.participantUpdateCommandReceived = this.onParticipantUpdateCommandReceived;\r\n this.privConversationRecognizer.lockRoomCommandReceived = this.onLockRoomCommandReceived;\r\n this.privConversationRecognizer.muteAllCommandReceived = this.onMuteAllCommandReceived;\r\n this.privConversationRecognizer.participantJoinCommandReceived = this.onParticipantJoinCommandReceived;\r\n this.privConversationRecognizer.participantLeaveCommandReceived = this.onParticipantLeaveCommandReceived;\r\n this.privConversationRecognizer.translationReceived = this.onTranslationReceived;\r\n this.privConversationRecognizer.participantsListReceived = this.onParticipantsListReceived;\r\n this.privConversationRecognizer.conversationExpiration = this.onConversationExpiration;\r\n this.privConversationRecognizer.connect(this.privRoom.token,\r\n (() => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any) => {\r\n this.handleError(error, err);\r\n }));\r\n } catch (error) {\r\n this.handleError(error, err);\r\n }\r\n }\r\n\r\n /**\r\n * Join a conversation as a participant.\r\n * @param conversation\r\n * @param nickname\r\n * @param lang\r\n * @param cb\r\n * @param err\r\n */\r\n public joinConversationAsync(conversationId: string, nickname: string, lang: string, cb?: Callback, err?: Callback): void {\r\n try {\r\n // TODO\r\n // if (!!this.privConversationRecognizer) {\r\n // throw new Error(this.privErrors.permissionDeniedStart);\r\n // }\r\n Contracts.throwIfNullOrWhitespace(conversationId, this.privErrors.invalidArgs.replace(\"{arg}\", \"conversationId\"));\r\n Contracts.throwIfNullOrWhitespace(nickname, this.privErrors.invalidArgs.replace(\"{arg}\", \"nickname\"));\r\n Contracts.throwIfNullOrWhitespace(lang, this.privErrors.invalidArgs.replace(\"{arg}\", \"language\"));\r\n // join the conversation\r\n this.privManager.createOrJoin(this.privProperties, conversationId,\r\n ((room: IInternalConversation) => {\r\n Contracts.throwIfNullOrUndefined(room, this.privErrors.permissionDeniedConnect);\r\n this.privRoom = room;\r\n this.privConfig.authorizationToken = room.cognitiveSpeechAuthToken;\r\n // join callback\r\n if (!!cb) {\r\n cb(room.cognitiveSpeechAuthToken);\r\n }\r\n }),\r\n ((error: any) => {\r\n this.handleError(error, err);\r\n }));\r\n } catch (error) {\r\n this.handleError(error, err);\r\n }\r\n }\r\n\r\n /**\r\n * Deletes a conversation\r\n * @param cb\r\n * @param err\r\n */\r\n public deleteConversationAsync(cb?: Callback, err?: Callback): void {\r\n try {\r\n Contracts.throwIfNullOrUndefined(this.privProperties, this.privErrors.permissionDeniedConnect);\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.token, this.privErrors.permissionDeniedConnect);\r\n this.privManager.leave(this.privProperties, this.privRoom.token,\r\n (() => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any) => {\r\n this.handleError(error, err);\r\n }));\r\n this.dispose();\r\n } catch (error) {\r\n this.handleError(error, err);\r\n }\r\n }\r\n\r\n /**\r\n * Issues a request to close the client websockets\r\n * @param cb\r\n * @param err\r\n */\r\n public endConversationAsync(cb?: Callback, err?: Callback): void {\r\n try {\r\n this.close(true);\r\n this.handleCallback(cb, err);\r\n } catch (error) {\r\n this.handleError(error, err);\r\n }\r\n }\r\n\r\n /**\r\n * Issues a request to lock the conversation\r\n * @param cb\r\n * @param err\r\n */\r\n public lockConversationAsync(cb?: Callback, err?: Callback): void {\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed());\r\n Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend);\r\n if (!this.canSendAsHost) {\r\n this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace(\"{command}\", \"lock\")), err);\r\n }\r\n this.privConversationRecognizer?.sendLockRequest(true,\r\n (() => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any) => {\r\n this.handleError(error, err);\r\n }));\r\n } catch (error) {\r\n this.handleError(error, err);\r\n }\r\n }\r\n\r\n /**\r\n * Issues a request to mute the conversation\r\n * @param cb\r\n * @param err\r\n */\r\n public muteAllParticipantsAsync(cb?: Callback, err?: Callback): void {\r\n\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed());\r\n Contracts.throwIfNullOrUndefined(this.privConversationRecognizer, this.privErrors.permissionDeniedSend);\r\n Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend);\r\n // check the user's permissions\r\n if (!this.canSendAsHost) {\r\n this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace(\"{command}\", \"mute\")), err);\r\n }\r\n this.privConversationRecognizer?.sendMuteAllRequest(true,\r\n (() => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any) => {\r\n this.handleError(error, err);\r\n }));\r\n } catch (error) {\r\n this.handleError(error, err);\r\n }\r\n }\r\n\r\n /**\r\n * Issues a request to mute a participant in the conversation\r\n * @param userId\r\n * @param cb\r\n * @param err\r\n */\r\n public muteParticipantAsync(userId: string, cb?: Callback, err?: Callback): void {\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed());\r\n Contracts.throwIfNullOrWhitespace(userId, this.privErrors.invalidArgs.replace(\"{arg}\", \"userId\"));\r\n Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend);\r\n // check the connection is open (host + participant can perform the mute command)\r\n if (!this.canSend) {\r\n this.handleError(new Error(this.privErrors.permissionDeniedSend), err);\r\n }\r\n // if not host, check the participant is not muting another participant\r\n if (!this.me.isHost && this.me.id !== userId) {\r\n this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace(\"{command}\", \"mute\")), err);\r\n }\r\n // check the user exists\r\n const exists: number = this.privParticipants.getParticipantIndex(userId);\r\n if (exists === -1) {\r\n this.handleError(new Error(this.privErrors.invalidParticipantRequest), err);\r\n }\r\n this.privConversationRecognizer?.sendMuteRequest(userId, true, (() => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any) => {\r\n this.handleError(error, err);\r\n }));\r\n } catch (error) {\r\n this.handleError(error, err);\r\n }\r\n }\r\n\r\n /**\r\n * Issues a request to remove a participant from the conversation\r\n * @param userId\r\n * @param cb\r\n * @param err\r\n */\r\n public removeParticipantAsync(userId: string | IParticipant | IUser, cb?: Callback, err?: Callback): void {\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed());\r\n Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend);\r\n if (!this.canSendAsHost) {\r\n this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace(\"{command}\", \"remove\")), err);\r\n }\r\n let participantId: string = \"\";\r\n if (typeof userId === \"string\") {\r\n participantId = userId as string;\r\n } else if (userId.hasOwnProperty(\"id\")) {\r\n const participant: IParticipant = userId as IParticipant;\r\n participantId = participant.id;\r\n } else if (userId.hasOwnProperty(\"userId\")) {\r\n const user: IUser = userId as IUser;\r\n participantId = user.userId;\r\n }\r\n Contracts.throwIfNullOrWhitespace(participantId, this.privErrors.invalidArgs.replace(\"{arg}\", \"userId\"));\r\n // check the participant exists\r\n const index: number = this.participants.findIndex((p: Participant) => p.id === participantId);\r\n if (index === -1) {\r\n this.handleError(new Error(this.privErrors.invalidParticipantRequest), err);\r\n }\r\n this.privConversationRecognizer?.sendEjectRequest(participantId, (() => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any) => {\r\n this.handleError(error, err);\r\n }));\r\n } catch (error) {\r\n this.handleError(error, err);\r\n }\r\n }\r\n\r\n /**\r\n * Issues a request to unlock the conversation\r\n * @param cb\r\n * @param err\r\n */\r\n public unlockConversationAsync(cb?: Callback, err?: Callback): void {\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed());\r\n Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend);\r\n if (!this.canSendAsHost) {\r\n this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace(\"{command}\", \"unlock\")), err);\r\n }\r\n this.privConversationRecognizer?.sendLockRequest(false, (() => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any) => {\r\n this.handleError(error, err);\r\n }));\r\n } catch (error) {\r\n this.handleError(error, err);\r\n }\r\n }\r\n\r\n /**\r\n * Issues a request to unmute all participants in the conversation\r\n * @param cb\r\n * @param err\r\n */\r\n public unmuteAllParticipantsAsync(cb?: Callback, err?: Callback): void {\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed());\r\n Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend);\r\n if (!this.canSendAsHost) {\r\n this.handleError(new Error(this.privErrors.permissionDeniedConversation.replace(\"{command}\", \"unmute all\")), err);\r\n }\r\n this.privConversationRecognizer?.sendMuteAllRequest(false, (() => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any) => {\r\n this.handleError(error, err);\r\n }));\r\n } catch (error) {\r\n this.handleError(error, err);\r\n }\r\n }\r\n\r\n /**\r\n * Issues a request to unmute a participant in the conversation\r\n * @param userId\r\n * @param cb\r\n * @param err\r\n */\r\n public unmuteParticipantAsync(userId: string, cb?: Callback, err?: Callback): void {\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed());\r\n Contracts.throwIfNullOrWhitespace(userId, this.privErrors.invalidArgs.replace(\"{arg}\", \"userId\"));\r\n Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend);\r\n // check the connection is open (host + participant can perform the mute command)\r\n if (!this.canSend) {\r\n this.handleError(new Error(this.privErrors.permissionDeniedSend), err);\r\n }\r\n // if not host, check the participant is not muting another participant\r\n if (!this.me.isHost && this.me.id !== userId) {\r\n this.handleError(new Error(this.privErrors.permissionDeniedParticipant.replace(\"{command}\", \"mute\")), err);\r\n }\r\n // check the user exists\r\n const exists: number = this.privParticipants.getParticipantIndex(userId);\r\n if (exists === -1) {\r\n this.handleError(new Error(this.privErrors.invalidParticipantRequest), err);\r\n }\r\n this.privConversationRecognizer?.sendMuteRequest(userId, false, (() => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any) => {\r\n this.handleError(error, err);\r\n }));\r\n } catch (error) {\r\n this.handleError(error, err);\r\n }\r\n }\r\n\r\n /**\r\n * Send a text message\r\n * @param message\r\n * @param cb\r\n * @param err\r\n */\r\n public sendTextMessageAsync(message: string, cb?: Callback, err?: Callback): void {\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed());\r\n Contracts.throwIfNullOrWhitespace(message, this.privErrors.invalidArgs.replace(\"{arg}\", \"message\"));\r\n Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend);\r\n if (!this.canSend) {\r\n this.handleError(new Error(this.privErrors.permissionDeniedSend), err);\r\n }\r\n // TODO: is a max length check required?\r\n if (message.length > this.privTextMessageMaxLength) {\r\n this.handleError(new Error(this.privErrors.invalidArgs.replace(\"{arg}\", \"message length\")), err);\r\n }\r\n this.privConversationRecognizer?.sendMessageRequest(message, (() => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any) => {\r\n this.handleError(error, err);\r\n }));\r\n } catch (error) {\r\n this.handleError(error, err);\r\n }\r\n }\r\n\r\n /**\r\n * Change nickname\r\n * @param message\r\n * @param cb\r\n * @param err\r\n */\r\n public changeNicknameAsync(nickname: string, cb?: Callback, err?: Callback): void {\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n Contracts.throwIfDisposed(this.privConversationRecognizer.isDisposed());\r\n Contracts.throwIfNullOrWhitespace(nickname, this.privErrors.invalidArgs.replace(\"{arg}\", \"nickname\"));\r\n Contracts.throwIfNullOrUndefined(this.privRoom, this.privErrors.permissionDeniedSend);\r\n if (!this.canSend) {\r\n this.handleError(new Error(this.privErrors.permissionDeniedSend), err);\r\n }\r\n this.privConversationRecognizer?.sendChangeNicknameRequest(nickname, (() => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any) => {\r\n this.handleError(error, err);\r\n }));\r\n } catch (error) {\r\n this.handleError(error, err);\r\n }\r\n }\r\n\r\n public isDisposed(): boolean {\r\n return this.privIsDisposed;\r\n }\r\n\r\n public dispose(reason?: string): void {\r\n if (this.isDisposed) {\r\n return;\r\n }\r\n this.privIsDisposed = true;\r\n this.config?.close();\r\n if (this.privConversationRecognizerConnection) {\r\n this.privConversationRecognizerConnection.closeConnection();\r\n this.privConversationRecognizerConnection.close();\r\n this.privConversationRecognizerConnection = undefined;\r\n }\r\n this.privConfig = undefined;\r\n this.privLanguage = undefined;\r\n this.privProperties = undefined;\r\n this.privRoom = undefined;\r\n this.privToken = undefined;\r\n this.privManager = undefined;\r\n this.privConversationRecognizer = undefined;\r\n this.privIsConnected = false;\r\n this.privIsReady = false;\r\n this.privParticipants = undefined;\r\n this.privRoom = undefined;\r\n }\r\n\r\n /** websocket callbacks */\r\n private onConnected = (e: ConnectionEventArgs): void => {\r\n this.privIsConnected = true;\r\n try {\r\n if (!!this.privConversationTranslator.sessionStarted) {\r\n this.privConversationTranslator.sessionStarted(this.privConversationTranslator, e);\r\n }\r\n } catch (e) {\r\n //\r\n }\r\n }\r\n\r\n private onDisconnected = (e: ConnectionEventArgs): void => {\r\n this.close(false);\r\n try {\r\n if (!!this.privConversationTranslator.sessionStopped) {\r\n this.privConversationTranslator.sessionStopped(this.privConversationTranslator, e);\r\n }\r\n } catch (e) {\r\n //\r\n }\r\n }\r\n\r\n private onCanceled = (r: ConversationTranslatorRecognizer, e: ConversationTranslationCanceledEventArgs): void => {\r\n this.close(false); // ?\r\n try {\r\n if (!!this.privConversationTranslator.canceled) {\r\n this.privConversationTranslator.canceled(this.privConversationTranslator, e);\r\n }\r\n } catch (e) {\r\n //\r\n }\r\n }\r\n\r\n private onParticipantUpdateCommandReceived = (r: ConversationTranslatorRecognizer, e: ParticipantAttributeEventArgs): void => {\r\n try {\r\n const updatedParticipant: any = this.privParticipants.getParticipant(e.id);\r\n if (updatedParticipant !== undefined) {\r\n\r\n switch (e.key) {\r\n case ConversationTranslatorCommandTypes.changeNickname:\r\n updatedParticipant.displayName = e.value;\r\n break;\r\n case ConversationTranslatorCommandTypes.setUseTTS:\r\n updatedParticipant.useTts = e.value;\r\n break;\r\n case ConversationTranslatorCommandTypes.setProfanityFiltering:\r\n updatedParticipant.profanity = e.value;\r\n break;\r\n case ConversationTranslatorCommandTypes.setMute:\r\n updatedParticipant.isMuted = e.value;\r\n break;\r\n case ConversationTranslatorCommandTypes.setTranslateToLanguages:\r\n updatedParticipant.translateToLanguages = e.value;\r\n break;\r\n }\r\n this.privParticipants.addOrUpdateParticipant(updatedParticipant);\r\n\r\n if (!!this.privConversationTranslator?.participantsChanged) {\r\n this.privConversationTranslator?.participantsChanged(\r\n this.privConversationTranslator,\r\n new ConversationParticipantsChangedEventArgs(ParticipantChangedReason.Updated,\r\n [this.toParticipant(updatedParticipant)], e.sessionId));\r\n }\r\n }\r\n } catch (e) {\r\n //\r\n }\r\n }\r\n\r\n private onLockRoomCommandReceived = (r: ConversationTranslatorRecognizer, e: LockRoomEventArgs): void => {\r\n // TODO\r\n }\r\n\r\n private onMuteAllCommandReceived = (r: ConversationTranslatorRecognizer, e: MuteAllEventArgs): void => {\r\n try {\r\n this.privParticipants.participants.forEach((p: IInternalParticipant) => p.isMuted = (p.isHost ? false : e.isMuted));\r\n if (!!this.privConversationTranslator?.participantsChanged) {\r\n this.privConversationTranslator?.participantsChanged(\r\n this.privConversationTranslator,\r\n new ConversationParticipantsChangedEventArgs(ParticipantChangedReason.Updated,\r\n this.toParticipants(false), e.sessionId));\r\n }\r\n } catch (e) {\r\n //\r\n }\r\n }\r\n\r\n private onParticipantJoinCommandReceived = (r: ConversationTranslatorRecognizer, e: ParticipantEventArgs): void => {\r\n try {\r\n const newParticipant: IInternalParticipant = this.privParticipants.addOrUpdateParticipant(e.participant);\r\n if (newParticipant !== undefined) {\r\n if (!!this.privConversationTranslator?.participantsChanged) {\r\n this.privConversationTranslator?.participantsChanged(\r\n this.privConversationTranslator,\r\n new ConversationParticipantsChangedEventArgs(ParticipantChangedReason.JoinedConversation,\r\n [this.toParticipant(newParticipant)], e.sessionId));\r\n }\r\n }\r\n } catch (e) {\r\n //\r\n }\r\n }\r\n\r\n private onParticipantLeaveCommandReceived = (r: ConversationTranslatorRecognizer, e: ParticipantEventArgs): void => {\r\n try {\r\n const ejectedParticipant: IInternalParticipant = this.privParticipants.getParticipant(e.participant.id);\r\n if (ejectedParticipant !== undefined) {\r\n // remove the participant from the internal participants list\r\n this.privParticipants.deleteParticipant(e.participant.id);\r\n if (!!this.privConversationTranslator?.participantsChanged) {\r\n // notify subscribers that the participant has left the conversation\r\n this.privConversationTranslator?.participantsChanged(\r\n this.privConversationTranslator,\r\n new ConversationParticipantsChangedEventArgs(ParticipantChangedReason.LeftConversation,\r\n [this.toParticipant(ejectedParticipant)], e.sessionId));\r\n }\r\n }\r\n } catch (e) {\r\n //\r\n }\r\n }\r\n\r\n private onTranslationReceived = (r: ConversationTranslatorRecognizer, e: ConversationReceivedTranslationEventArgs): void => {\r\n try {\r\n switch (e.command) {\r\n case ConversationTranslatorMessageTypes.final:\r\n if (!!this.privConversationTranslator?.transcribed) {\r\n this.privConversationTranslator?.transcribed(\r\n this.privConversationTranslator,\r\n new ConversationTranslationEventArgs(e.payload, undefined, e.sessionId));\r\n }\r\n break;\r\n case ConversationTranslatorMessageTypes.partial:\r\n if (!!this.privConversationTranslator?.transcribing) {\r\n this.privConversationTranslator?.transcribing(\r\n this.privConversationTranslator,\r\n new ConversationTranslationEventArgs(e.payload, undefined, e.sessionId));\r\n }\r\n break;\r\n case ConversationTranslatorMessageTypes.instantMessage:\r\n if (!!this.privConversationTranslator?.textMessageReceived) {\r\n this.privConversationTranslator?.textMessageReceived(\r\n this.privConversationTranslator,\r\n new ConversationTranslationEventArgs(e.payload, undefined, e.sessionId));\r\n }\r\n break;\r\n }\r\n } catch (e) {\r\n //\r\n }\r\n }\r\n\r\n private onParticipantsListReceived = (r: ConversationTranslatorRecognizer, e: ParticipantsListEventArgs): void => {\r\n try {\r\n // check if the session token needs to be updated\r\n if (e.sessionToken !== undefined && e.sessionToken !== null) {\r\n this.privRoom.token = e.sessionToken;\r\n }\r\n // save the participants\r\n this.privParticipants.participants = [...e.participants];\r\n // enable the conversation\r\n if (this.privParticipants.me !== undefined) {\r\n this.privIsReady = true;\r\n }\r\n if (!!this.privConversationTranslator?.participantsChanged) {\r\n this.privConversationTranslator?.participantsChanged(\r\n this.privConversationTranslator,\r\n new ConversationParticipantsChangedEventArgs(ParticipantChangedReason.JoinedConversation, this.toParticipants(true), e.sessionId));\r\n }\r\n // if this is the host, update the nickname if needed\r\n if (this.me.isHost) {\r\n const nickname: string = this.privConversationTranslator.properties.getProperty(PropertyId.ConversationTranslator_Name);\r\n if (nickname !== undefined && nickname.length > 0 && nickname !== this.me.displayName) {\r\n // issue a change nickname request\r\n this.changeNicknameAsync(nickname);\r\n }\r\n }\r\n } catch (e) {\r\n //\r\n }\r\n }\r\n\r\n private onConversationExpiration = (r: ConversationTranslatorRecognizer, e: ConversationExpirationEventArgs): void => {\r\n try {\r\n if (!!this.privConversationTranslator?.conversationExpiration) {\r\n this.privConversationTranslator?.conversationExpiration(\r\n this.privConversationTranslator,\r\n e);\r\n }\r\n } catch (e) {\r\n //\r\n }\r\n }\r\n\r\n private close(dispose: boolean): void {\r\n try {\r\n this.privIsConnected = false;\r\n this.privConversationRecognizerConnection?.closeConnection();\r\n this.privConversationRecognizerConnection?.close();\r\n this.privConversationRecognizer.close();\r\n this.privConversationRecognizerConnection = undefined;\r\n this.privConversationRecognizer = undefined;\r\n this.privConversationTranslator?.dispose();\r\n } catch (e) {\r\n // ignore error\r\n }\r\n if (dispose) {\r\n this.dispose();\r\n }\r\n }\r\n\r\n /** Helpers */\r\n private get canSend(): boolean {\r\n return this.privIsConnected && !this.privParticipants.me?.isMuted;\r\n }\r\n\r\n private get canSendAsHost(): boolean {\r\n return this.privIsConnected && this.privParticipants.me?.isHost;\r\n }\r\n\r\n private handleCallback(cb: any, err: any): void {\r\n if (!!cb) {\r\n try {\r\n cb();\r\n } catch (e) {\r\n if (!!err) {\r\n err(e);\r\n }\r\n }\r\n cb = undefined;\r\n }\r\n }\r\n\r\n private handleError(error: any, err: any): void {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n err(typedError.name + \": \" + typedError.message);\r\n\r\n } else {\r\n err(error);\r\n }\r\n }\r\n }\r\n\r\n /** Participant Helpers */\r\n private toParticipants(includeHost: boolean): Participant[] {\r\n\r\n const participants: Participant[] = this.privParticipants.participants.map((p: IInternalParticipant) => {\r\n return this.toParticipant(p);\r\n });\r\n if (!includeHost) {\r\n return participants.filter((p: Participant) => p.isHost === false);\r\n } else {\r\n return participants;\r\n }\r\n }\r\n\r\n private toParticipant(p: IInternalParticipant): Participant {\r\n return new Participant(p.id, p.avatar, p.displayName, p.isHost, p.isMuted, p.isUsingTts, p.preferredLanguage);\r\n }\r\n\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n// Multi-device Conversation is a Preview feature.\r\n\r\nimport { SessionEventArgs } from \"../Exports\";\r\n\r\nexport class ConversationExpirationEventArgs extends SessionEventArgs {\r\n private privExpirationTime: number;\r\n\r\n constructor(expirationTime: number, sessionId?: string) {\r\n super(sessionId);\r\n this.privExpirationTime = expirationTime;\r\n }\r\n\r\n /** How much longer until the conversation expires (in minutes). */\r\n get expirationTime(): number {\r\n return this.privExpirationTime;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n// Multi-device Conversation is a Preview feature.\r\n\r\nimport { SessionEventArgs } from \"../Exports\";\r\nimport { ParticipantChangedReason } from \"./Exports\";\r\nimport { IParticipant } from \"./IParticipant\";\r\n\r\nexport class ConversationParticipantsChangedEventArgs extends SessionEventArgs {\r\n private privReason: ParticipantChangedReason;\r\n private privParticipant: IParticipant[];\r\n\r\n public constructor(reason: ParticipantChangedReason, participants: IParticipant[], sessionId?: string) {\r\n super(sessionId);\r\n this.privReason = reason;\r\n this.privParticipant = participants;\r\n }\r\n\r\n public get reason(): ParticipantChangedReason {\r\n return this.privReason;\r\n }\r\n\r\n public get participants(): IParticipant[] {\r\n return this.privParticipant;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n// Multi-device Conversation is a Preview feature.\r\n\r\nimport { CancellationErrorCode, CancellationReason, RecognitionEventArgs } from \"../Exports\";\r\n\r\nexport class ConversationTranslationCanceledEventArgs extends RecognitionEventArgs {\r\n private privReason: CancellationReason;\r\n private privErrorDetails: string;\r\n private privErrorCode: CancellationErrorCode;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {CancellationReason} reason - The cancellation reason.\r\n * @param {string} errorDetails - Error details, if provided.\r\n * @param {number} offset - The offset.\r\n * @param {string} sessionId - The session id.\r\n */\r\n public constructor(reason: CancellationReason,\r\n errorDetails: string,\r\n errorCode: CancellationErrorCode,\r\n offset?: number,\r\n sessionId?: string) {\r\n super(offset, sessionId);\r\n\r\n this.privReason = reason;\r\n this.privErrorDetails = errorDetails;\r\n this.privErrorCode = errorCode;\r\n }\r\n\r\n /**\r\n * The reason the recognition was canceled.\r\n * @member SpeechRecognitionCanceledEventArgs.prototype.reason\r\n * @function\r\n * @public\r\n * @returns {CancellationReason} Specifies the reason canceled.\r\n */\r\n public get reason(): CancellationReason {\r\n return this.privReason;\r\n }\r\n\r\n /**\r\n * The error code in case of an unsuccessful recognition.\r\n * Added in version 1.1.0.\r\n * @return An error code that represents the error reason.\r\n */\r\n public get errorCode(): CancellationErrorCode {\r\n return this.privErrorCode;\r\n }\r\n\r\n /**\r\n * In case of an unsuccessful recognition, provides details of the occurred error.\r\n * @member SpeechRecognitionCanceledEventArgs.prototype.errorDetails\r\n * @function\r\n * @public\r\n * @returns {string} A String that represents the error details.\r\n */\r\n public get errorDetails(): string {\r\n return this.privErrorDetails;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n// Multi-device Conversation is a Preview feature.\r\n\r\nimport { RecognitionEventArgs } from \"../Exports\";\r\nimport { ConversationTranslationResult } from \"./Exports\";\r\n\r\nexport class ConversationTranslationEventArgs extends RecognitionEventArgs {\r\n private privResult: ConversationTranslationResult;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {ConversationTranslationResult} result - The translation recognition result.\r\n * @param {number} offset - The offset.\r\n * @param {string} sessionId - The session id.\r\n */\r\n public constructor(result: ConversationTranslationResult, offset?: number, sessionId?: string) {\r\n super(offset, sessionId);\r\n this.privResult = result;\r\n }\r\n\r\n /**\r\n * Specifies the recognition result.\r\n * @returns {ConversationTranslationResult} the recognition result.\r\n */\r\n public get result(): ConversationTranslationResult {\r\n return this.privResult;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n// Multi-device Conversation is a Preview feature.\r\n\r\nimport { PropertyCollection } from \"../PropertyCollection\";\r\nimport { ResultReason } from \"../ResultReason\";\r\nimport { TranslationRecognitionResult } from \"../TranslationRecognitionResult\";\r\nimport { Translations } from \"../Translations\";\r\n\r\nexport class ConversationTranslationResult extends TranslationRecognitionResult {\r\n private privId: string;\r\n private privOrigLang: string;\r\n\r\n public constructor(participantId: string,\r\n translations: Translations,\r\n originalLanguage?: string,\r\n resultId?: string,\r\n reason?: ResultReason,\r\n text?: string,\r\n duration?: number,\r\n offset?: number,\r\n errorDetails?: string,\r\n json?: string,\r\n properties?: PropertyCollection) {\r\n super(translations, resultId, reason, text, duration, offset, errorDetails, json, properties);\r\n this.privId = participantId;\r\n this.privOrigLang = originalLanguage;\r\n }\r\n\r\n /**\r\n * The unique identifier for the participant this result is for.\r\n */\r\n public get participantId(): string {\r\n return this.privId;\r\n }\r\n\r\n /**\r\n * The original language this result was in.\r\n */\r\n public get originalLang(): string {\r\n return this.privOrigLang;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n// Multi-device Conversation is a Preview feature.\r\n\r\nimport { ConversationConnectionConfig } from \"../../common.speech/Exports\";\r\nimport { IDisposable, IErrorMessages } from \"../../common/Exports\";\r\nimport { Contracts } from \"../Contracts\";\r\nimport {\r\n AudioConfig,\r\n CancellationErrorCode,\r\n CancellationReason,\r\n Connection,\r\n ConnectionEventArgs,\r\n ProfanityOption,\r\n PropertyCollection,\r\n PropertyId,\r\n Recognizer,\r\n SessionEventArgs,\r\n SpeechTranslationConfig,\r\n TranslationRecognitionCanceledEventArgs,\r\n TranslationRecognitionEventArgs,\r\n TranslationRecognizer\r\n} from \"../Exports\";\r\nimport { ConversationImpl } from \"./Conversation\";\r\nimport {\r\n ConversationExpirationEventArgs,\r\n ConversationParticipantsChangedEventArgs,\r\n ConversationTranslationCanceledEventArgs,\r\n ConversationTranslationEventArgs,\r\n Participant,\r\n} from \"./Exports\";\r\nimport { Callback, IConversation } from \"./IConversation\";\r\nimport { IConversationTranslator } from \"./IConversationTranslator\";\r\n\r\nexport enum SpeechState {\r\n Inactive, Connecting, Connected\r\n}\r\n\r\n/***\r\n * Join, leave or connect to a conversation.\r\n */\r\nexport class ConversationTranslator implements IConversationTranslator, IDisposable {\r\n\r\n private privSpeechRecognitionLanguage: string;\r\n private privProperties: PropertyCollection;\r\n private privAudioConfig: AudioConfig;\r\n private privSpeechTranslationConfig: SpeechTranslationConfig;\r\n private privTranslationRecognizerConnection: Connection;\r\n private privIsDisposed: boolean = false;\r\n private privTranslationRecognizer: TranslationRecognizer;\r\n private privIsSpeaking: boolean = false;\r\n private privConversation: ConversationImpl;\r\n private privSpeechState: SpeechState = SpeechState.Inactive;\r\n private privErrors: IErrorMessages = ConversationConnectionConfig.restErrors;\r\n private privPlaceholderKey: string = \"abcdefghijklmnopqrstuvwxyz012345\";\r\n private privPlaceholderRegion: string = \"westus\";\r\n\r\n public constructor(audioConfig?: AudioConfig) {\r\n this.privProperties = new PropertyCollection();\r\n this.privAudioConfig = audioConfig;\r\n }\r\n\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n public get speechRecognitionLanguage(): string {\r\n return this.privSpeechRecognitionLanguage;\r\n }\r\n\r\n public get participants(): Participant[] {\r\n return this.privConversation?.participants;\r\n }\r\n\r\n public canceled: (sender: IConversationTranslator, event: ConversationTranslationCanceledEventArgs) => void;\r\n public conversationExpiration: (sender: IConversationTranslator, event: ConversationExpirationEventArgs) => void;\r\n public participantsChanged: (sender: IConversationTranslator, event: ConversationParticipantsChangedEventArgs) => void;\r\n public sessionStarted: (sender: IConversationTranslator, event: SessionEventArgs) => void;\r\n public sessionStopped: (sender: IConversationTranslator, event: SessionEventArgs) => void;\r\n public textMessageReceived: (sender: IConversationTranslator, event: ConversationTranslationEventArgs) => void;\r\n public transcribed: (sender: IConversationTranslator, event: ConversationTranslationEventArgs) => void;\r\n public transcribing: (sender: IConversationTranslator, event: ConversationTranslationEventArgs) => void;\r\n\r\n /**\r\n * Join a conversation. If this is the host, pass in the previously created Conversation object.\r\n * @param conversation\r\n * @param nickname\r\n * @param lang\r\n * @param cb\r\n * @param err\r\n */\r\n public joinConversationAsync(conversation: IConversation, nickname: string, cb?: Callback, err?: Callback): void;\r\n public joinConversationAsync(conversationId: string, nickname: string, lang: string, cb?: Callback, err?: Callback): void;\r\n public joinConversationAsync(conversation: any, nickname: string, param1?: string | Callback, param2?: Callback, param3?: Callback): void {\r\n\r\n try {\r\n\r\n if (typeof conversation === \"string\") {\r\n\r\n Contracts.throwIfNullOrUndefined(conversation, this.privErrors.invalidArgs.replace(\"{arg}\", \"conversation id\"));\r\n Contracts.throwIfNullOrWhitespace(nickname, this.privErrors.invalidArgs.replace(\"{arg}\", \"nickname\"));\r\n\r\n if (!!this.privConversation) {\r\n this.handleError(new Error(this.privErrors.permissionDeniedStart), param3);\r\n }\r\n\r\n let lang: string = param1 as string;\r\n if (lang === undefined || lang === null || lang === \"\") { lang = ConversationConnectionConfig.defaultLanguageCode; }\r\n\r\n // create a placecholder config\r\n this.privSpeechTranslationConfig = SpeechTranslationConfig.fromSubscription(\r\n this.privPlaceholderKey,\r\n this.privPlaceholderRegion);\r\n this.privSpeechTranslationConfig.setProfanity(ProfanityOption.Masked);\r\n this.privSpeechTranslationConfig.addTargetLanguage(lang);\r\n this.privSpeechTranslationConfig.setProperty(PropertyId[PropertyId.SpeechServiceConnection_RecoLanguage], lang);\r\n this.privSpeechTranslationConfig.setProperty(PropertyId[PropertyId.ConversationTranslator_Name], nickname);\r\n\r\n const endpoint: string = this.privProperties.getProperty(PropertyId.ConversationTranslator_Host);\r\n if (endpoint) {\r\n this.privSpeechTranslationConfig.setProperty(PropertyId[PropertyId.ConversationTranslator_Host], endpoint);\r\n }\r\n const speechEndpointHost: string = this.privProperties.getProperty(PropertyId.SpeechServiceConnection_Host);\r\n if (speechEndpointHost) {\r\n this.privSpeechTranslationConfig.setProperty(PropertyId[PropertyId.SpeechServiceConnection_Host], speechEndpointHost);\r\n }\r\n\r\n // join the conversation\r\n this.privConversation = new ConversationImpl(this.privSpeechTranslationConfig);\r\n this.privConversation.conversationTranslator = this;\r\n\r\n this.privConversation.joinConversationAsync(\r\n conversation,\r\n nickname,\r\n lang,\r\n ((result: string) => {\r\n\r\n if (!result) {\r\n this.handleError(new Error(this.privErrors.permissionDeniedConnect), param3);\r\n }\r\n\r\n this.privSpeechTranslationConfig.authorizationToken = result;\r\n\r\n // connect to the ws\r\n this.privConversation.startConversationAsync(\r\n (() => {\r\n this.handleCallback(param2, param3);\r\n }),\r\n ((error: any) => {\r\n this.handleError(error, param3);\r\n }));\r\n\r\n }),\r\n ((error: any) => {\r\n this.handleError(error, param3);\r\n }));\r\n\r\n } else if (typeof conversation === \"object\") {\r\n\r\n Contracts.throwIfNullOrUndefined(conversation, this.privErrors.invalidArgs.replace(\"{arg}\", \"conversation id\"));\r\n Contracts.throwIfNullOrWhitespace(nickname, this.privErrors.invalidArgs.replace(\"{arg}\", \"nickname\"));\r\n\r\n // save the nickname\r\n this.privProperties.setProperty(PropertyId.ConversationTranslator_Name, nickname);\r\n // ref the conversation object\r\n this.privConversation = conversation as ConversationImpl;\r\n // ref the conversation translator object\r\n this.privConversation.conversationTranslator = this;\r\n\r\n Contracts.throwIfNullOrUndefined(this.privConversation, this.privErrors.permissionDeniedConnect);\r\n Contracts.throwIfNullOrUndefined(this.privConversation.room.token, this.privErrors.permissionDeniedConnect);\r\n\r\n this.privSpeechTranslationConfig = conversation.config;\r\n\r\n this.handleCallback(param1 as Callback, param2);\r\n } else {\r\n this.handleError(\r\n new Error(this.privErrors.invalidArgs.replace(\"{arg}\", \"invalid conversation type\")),\r\n param2);\r\n }\r\n\r\n } catch (error) {\r\n this.handleError(error, typeof param1 === \"string\" ? param3 : param2);\r\n }\r\n }\r\n\r\n /**\r\n * Leave the conversation\r\n * @param cb\r\n * @param err\r\n */\r\n public leaveConversationAsync(cb?: Callback, err?: Callback): void {\r\n\r\n try {\r\n\r\n // stop the speech websocket\r\n this.cancelSpeech();\r\n\r\n // stop the websocket\r\n this.privConversation.endConversationAsync(\r\n (() => {\r\n // https delete request\r\n this.privConversation.deleteConversationAsync(\r\n (() => {\r\n this.handleCallback(cb, err);\r\n this.dispose();\r\n }),\r\n ((error: any) => {\r\n this.handleError(error, err);\r\n }));\r\n }),\r\n ((error: any) => {\r\n this.handleError(error, err);\r\n }));\r\n\r\n } catch (error) {\r\n this.handleError(error, err);\r\n }\r\n }\r\n\r\n /**\r\n * Send a text message\r\n * @param message\r\n * @param cb\r\n * @param err\r\n */\r\n public sendTextMessageAsync(message: string, cb?: Callback, err?: Callback): void {\r\n\r\n try {\r\n Contracts.throwIfNullOrUndefined(this.privConversation, this.privErrors.permissionDeniedSend);\r\n Contracts.throwIfNullOrWhitespace(message, this.privErrors.invalidArgs.replace(\"{arg}\", message));\r\n\r\n this.privConversation?.sendTextMessageAsync(message, cb, err);\r\n } catch (error) {\r\n\r\n this.handleError(error, err);\r\n }\r\n }\r\n\r\n /**\r\n * Start speaking\r\n * @param cb\r\n * @param err\r\n */\r\n public startTranscribingAsync(cb?: Callback, err?: Callback): void {\r\n\r\n try {\r\n Contracts.throwIfNullOrUndefined(this.privConversation, this.privErrors.permissionDeniedSend);\r\n Contracts.throwIfNullOrUndefined(this.privConversation.room.token, this.privErrors.permissionDeniedConnect);\r\n\r\n if (!this.canSpeak) {\r\n this.handleError(new Error(this.privErrors.permissionDeniedSend), err);\r\n }\r\n\r\n if (this.privTranslationRecognizer === undefined) {\r\n this.connectTranslatorRecognizer(\r\n (() => {\r\n this.startContinuousRecognition(\r\n (() => {\r\n this.privIsSpeaking = true;\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any) => {\r\n\r\n this.privIsSpeaking = false;\r\n // this.fireCancelEvent(error);\r\n this.cancelSpeech();\r\n this.handleError(error, err);\r\n }));\r\n }),\r\n ((error: any) => {\r\n this.handleError(error, err);\r\n }));\r\n } else {\r\n this.startContinuousRecognition(\r\n (() => {\r\n this.privIsSpeaking = true;\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any) => {\r\n this.privIsSpeaking = false;\r\n // this.fireCancelEvent(error);\r\n this.cancelSpeech();\r\n\r\n this.handleError(error, err);\r\n }));\r\n }\r\n\r\n } catch (error) {\r\n\r\n this.handleError(error, err);\r\n\r\n this.cancelSpeech();\r\n\r\n }\r\n }\r\n\r\n /**\r\n * Stop speaking\r\n * @param cb\r\n * @param err\r\n */\r\n public stopTranscribingAsync(cb?: Callback, err?: Callback): void {\r\n\r\n try {\r\n if (!this.privIsSpeaking) {\r\n // stop speech\r\n this.cancelSpeech();\r\n this.handleCallback(cb, err);\r\n return;\r\n }\r\n\r\n // stop the recognition but leave the websocket open\r\n this.privIsSpeaking = false;\r\n this.privTranslationRecognizer?.stopContinuousRecognitionAsync(() => {\r\n this.handleCallback(cb, err);\r\n }, (error: any) => {\r\n this.handleError(error, err);\r\n this.cancelSpeech();\r\n });\r\n\r\n } catch (error) {\r\n this.handleError(error, err);\r\n this.cancelSpeech();\r\n }\r\n }\r\n\r\n public isDisposed(): boolean {\r\n return this.privIsDisposed;\r\n }\r\n\r\n public dispose(reason?: string): void {\r\n if (this.isDisposed && !this.privIsSpeaking) {\r\n return;\r\n }\r\n this.cancelSpeech();\r\n this.privIsDisposed = true;\r\n this.privSpeechTranslationConfig?.close();\r\n this.privSpeechRecognitionLanguage = undefined;\r\n this.privProperties = undefined;\r\n this.privAudioConfig = undefined;\r\n this.privSpeechTranslationConfig = undefined;\r\n this.privConversation?.dispose();\r\n this.privConversation = undefined;\r\n }\r\n\r\n /**\r\n * Connect to the speech translation recognizer.\r\n * Currently there is no language validation performed before sending the SpeechLanguage code to the service.\r\n * If it's an invalid language the raw error will be: 'Error during WebSocket handshake: Unexpected response code: 400'\r\n * e.g. pass in 'fr' instead of 'fr-FR', or a text-only language 'cy'\r\n * @param cb\r\n * @param err\r\n */\r\n private connectTranslatorRecognizer(cb?: Callback, err?: Callback): void {\r\n\r\n try {\r\n\r\n if (this.privAudioConfig === undefined) {\r\n this.privAudioConfig = AudioConfig.fromDefaultMicrophoneInput();\r\n }\r\n\r\n // clear the temp subscription key if it's a participant joining\r\n if (this.privSpeechTranslationConfig.getProperty(PropertyId[PropertyId.SpeechServiceConnection_Key])\r\n === this.privPlaceholderKey) {\r\n this.privSpeechTranslationConfig.setProperty(PropertyId[PropertyId.SpeechServiceConnection_Key], \"\");\r\n }\r\n\r\n // TODO\r\n const token: string = encodeURIComponent(this.privConversation.room.token);\r\n\r\n let endpointHost: string = this.privSpeechTranslationConfig.getProperty(\r\n PropertyId[PropertyId.SpeechServiceConnection_Host], ConversationConnectionConfig.speechHost);\r\n endpointHost = endpointHost.replace(\"{region}\", this.privConversation.room.cognitiveSpeechRegion);\r\n\r\n const url: string = `wss://${endpointHost}${ConversationConnectionConfig.speechPath}?${ConversationConnectionConfig.configParams.token}=${token}`;\r\n\r\n this.privSpeechTranslationConfig.setProperty(PropertyId[PropertyId.SpeechServiceConnection_Endpoint], url);\r\n\r\n this.privTranslationRecognizer = new TranslationRecognizer(this.privSpeechTranslationConfig, this.privAudioConfig);\r\n this.privTranslationRecognizerConnection = Connection.fromRecognizer(this.privTranslationRecognizer);\r\n this.privTranslationRecognizerConnection.connected = this.onSpeechConnected;\r\n this.privTranslationRecognizerConnection.disconnected = this.onSpeechDisconnected;\r\n this.privTranslationRecognizer.recognized = this.onSpeechRecognized;\r\n this.privTranslationRecognizer.recognizing = this.onSpeechRecognizing;\r\n this.privTranslationRecognizer.canceled = this.onSpeechCanceled;\r\n this.privTranslationRecognizer.sessionStarted = this.onSpeechSessionStarted;\r\n this.privTranslationRecognizer.sessionStopped = this.onSpeechSessionStopped;\r\n\r\n this.handleCallback(cb, err);\r\n\r\n } catch (error) {\r\n\r\n this.handleError(error, err);\r\n\r\n this.cancelSpeech();\r\n // this.fireCancelEvent(error); ?\r\n\r\n }\r\n }\r\n\r\n /**\r\n * Handle the start speaking request\r\n * @param cb\r\n * @param err\r\n */\r\n private startContinuousRecognition(cb?: Callback, err?: Callback): void {\r\n this.privTranslationRecognizer.startContinuousRecognitionAsync(cb, err);\r\n }\r\n\r\n /** Recognizer callbacks */\r\n private onSpeechConnected = (e: ConnectionEventArgs) => {\r\n this.privSpeechState = SpeechState.Connected;\r\n }\r\n\r\n private onSpeechDisconnected = (e: ConnectionEventArgs) => {\r\n this.privSpeechState = SpeechState.Inactive;\r\n this.cancelSpeech();\r\n }\r\n\r\n private onSpeechRecognized = (r: TranslationRecognizer, e: TranslationRecognitionEventArgs) => {\r\n // TODO: add support for getting recognitions from here if own speech\r\n\r\n // if there is an error connecting to the conversation service from the speech service the error will be returned in the ErrorDetails field.\r\n if (e.result?.errorDetails) {\r\n this.cancelSpeech();\r\n // TODO: format the error message contained in 'errorDetails'\r\n this.fireCancelEvent(e.result.errorDetails);\r\n }\r\n }\r\n\r\n private onSpeechRecognizing = (r: TranslationRecognizer, e: TranslationRecognitionEventArgs) => {\r\n // TODO: add support for getting recognitions from here if own speech\r\n }\r\n\r\n private onSpeechCanceled = (r: TranslationRecognizer, e: TranslationRecognitionCanceledEventArgs) => {\r\n if (this.privSpeechState !== SpeechState.Inactive) {\r\n try {\r\n this.cancelSpeech();\r\n } catch (error) {\r\n this.privSpeechState = SpeechState.Inactive;\r\n }\r\n }\r\n }\r\n\r\n private onSpeechSessionStarted = (r: Recognizer, e: SessionEventArgs) => {\r\n this.privSpeechState = SpeechState.Connected;\r\n\r\n }\r\n\r\n private onSpeechSessionStopped = (r: Recognizer, e: SessionEventArgs) => {\r\n this.privSpeechState = SpeechState.Inactive;\r\n }\r\n\r\n /**\r\n * Fire a cancel event\r\n * @param error\r\n */\r\n private fireCancelEvent(error: any): void {\r\n try {\r\n if (!!this.canceled) {\r\n const cancelEvent: ConversationTranslationCanceledEventArgs = new ConversationTranslationCanceledEventArgs(\r\n error?.reason ?? CancellationReason.Error,\r\n error?.errorDetails ?? error,\r\n error?.errorCode ?? CancellationErrorCode.RuntimeError,\r\n undefined,\r\n error?.sessionId);\r\n\r\n this.canceled(this, cancelEvent);\r\n }\r\n } catch (e) {\r\n //\r\n }\r\n }\r\n\r\n /**\r\n * Cancel the speech websocket\r\n */\r\n private cancelSpeech(): void {\r\n try {\r\n this.privIsSpeaking = false;\r\n this.privTranslationRecognizer?.stopContinuousRecognitionAsync();\r\n this.privTranslationRecognizerConnection?.closeConnection();\r\n this.privTranslationRecognizerConnection = undefined;\r\n this.privTranslationRecognizer = undefined;\r\n this.privSpeechState = SpeechState.Inactive;\r\n } catch (e) {\r\n // ignore the error\r\n }\r\n }\r\n\r\n private get canSpeak(): boolean {\r\n\r\n // is there a Conversation websocket available\r\n if (!this.privConversation.isConnected) {\r\n return false;\r\n }\r\n\r\n // is the user already speaking\r\n if (this.privIsSpeaking || this.privSpeechState === SpeechState.Connected || this.privSpeechState === SpeechState.Connecting) {\r\n return false;\r\n }\r\n\r\n // is the user muted\r\n if (this.privConversation.isMutedByHost) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n private handleCallback(cb: Callback, err: Callback): void {\r\n if (!!cb) {\r\n try {\r\n cb();\r\n } catch (e) {\r\n if (!!err) {\r\n err(e);\r\n }\r\n }\r\n cb = undefined;\r\n }\r\n }\r\n\r\n private handleError(error: any, err: Callback): void {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n err(typedError.name + \": \" + typedError.message);\r\n\r\n } else {\r\n err(error);\r\n }\r\n }\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n// Multi-device Conversation is a Preview feature.\r\n\r\nimport { PropertyCollection } from \"../Exports\";\r\n\r\n/**\r\n * Represents a user in a conversation.\r\n * Added in version 1.4.0\r\n */\r\nexport interface IUser {\r\n /** Gets the user's ID */\r\n readonly userId: string;\r\n}\r\n\r\nexport class User implements IUser {\r\n private privUserId: string;\r\n\r\n constructor(userId: string) {\r\n this.privUserId = userId;\r\n }\r\n\r\n public get userId(): string {\r\n return this.privUserId;\r\n }\r\n}\r\n\r\n/**\r\n * Represents a participant in a conversation.\r\n * Added in version 1.4.0\r\n */\r\nexport interface IParticipant {\r\n /** Gets the colour of the user's avatar as an HTML hex string (e.g. FF0000 for red). */\r\n readonly avatar: string;\r\n /**\r\n * The participant's display name. Please note that there may be more than one participant\r\n * with the same name. You can use property to tell them apart.\r\n */\r\n readonly displayName: string;\r\n /** The unique identifier for the participant. */\r\n readonly id: string;\r\n /** Gets whether or not this participant is the host. */\r\n readonly isHost: boolean;\r\n /** Gets whether or not this participant is muted. */\r\n readonly isMuted: boolean;\r\n /** Gets whether or not the participant is using Text To Speech (TTS). */\r\n readonly isUsingTts: boolean;\r\n /** The participant's preferred spoken language. */\r\n readonly preferredLanguage: string;\r\n /** Contains properties of the participant. */\r\n readonly properties: PropertyCollection;\r\n}\r\n\r\n// tslint:disable-next-line: max-classes-per-file\r\nexport class Participant implements IParticipant {\r\n private privAvatar: string;\r\n private privDisplayName: string;\r\n private privId: string;\r\n private privIsHost: boolean;\r\n private privIsMuted: boolean;\r\n private privIsUsingTts: boolean;\r\n private privPreferredLanguage: string;\r\n private privPoperties: PropertyCollection;\r\n\r\n constructor(id: string, avatar: string, displayName: string, isHost: boolean, isMuted: boolean, isUsingTts: boolean, preferredLanguage: string) {\r\n this.privId = id;\r\n this.privAvatar = avatar;\r\n this.privDisplayName = displayName;\r\n this.privIsHost = isHost;\r\n this.privIsMuted = isMuted;\r\n this.privIsUsingTts = isUsingTts;\r\n this.privPreferredLanguage = preferredLanguage;\r\n this.privPoperties = new PropertyCollection();\r\n }\r\n public get avatar(): string {\r\n return this.privAvatar;\r\n }\r\n\r\n public get displayName(): string {\r\n return this.privDisplayName;\r\n }\r\n\r\n public get id(): string {\r\n return this.privId;\r\n }\r\n\r\n public get preferredLanguage(): string {\r\n return this.privPreferredLanguage;\r\n }\r\n\r\n public get isHost(): boolean {\r\n return this.privIsHost;\r\n }\r\n\r\n public get isMuted(): boolean {\r\n return this.privIsMuted;\r\n }\r\n\r\n public get isUsingTts(): boolean {\r\n return this.privIsUsingTts;\r\n }\r\n\r\n public get properties(): PropertyCollection {\r\n return this.privPoperties;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n// Multi-device Conversation is a Preview feature.\r\n\r\nexport enum ParticipantChangedReason {\r\n /** Participant has joined the conversation. */\r\n JoinedConversation,\r\n\r\n /** Participant has left the conversation. This could be voluntary, or involuntary\r\n * (e.g. they are experiencing networking issues).\r\n */\r\n LeftConversation,\r\n\r\n /** The participants' state has changed (e.g. they became muted, changed their nickname). */\r\n Updated\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {PathLike} from \"fs\";\r\nimport {\r\n AutoDetectSourceLanguagesOpenRangeOptionName,\r\n CognitiveSubscriptionKeyAuthentication,\r\n CognitiveTokenAuthentication,\r\n Context,\r\n IAuthentication,\r\n ISynthesisConnectionFactory,\r\n OS,\r\n SpeechServiceConfig,\r\n SpeechSynthesisConnectionFactory,\r\n SynthesisAdapterBase,\r\n SynthesizerConfig,\r\n} from \"../common.speech/Exports\";\r\nimport {\r\n createNoDashGuid,\r\n IAudioDestination,\r\n IStringDictionary,\r\n Promise,\r\n PromiseHelper,\r\n Queue\r\n} from \"../common/Exports\";\r\nimport { AudioOutputConfigImpl } from \"./Audio/AudioConfig\";\r\nimport { AudioFileWriter } from \"./Audio/AudioFileWriter\";\r\nimport { AudioOutputFormatImpl } from \"./Audio/AudioOutputFormat\";\r\nimport {\r\n PullAudioOutputStreamImpl,\r\n PushAudioOutputStreamImpl\r\n} from \"./Audio/AudioOutputStream\";\r\nimport { Contracts } from \"./Contracts\";\r\nimport {\r\n AudioConfig,\r\n AudioOutputStream,\r\n AutoDetectSourceLanguageConfig,\r\n PropertyCollection,\r\n PropertyId,\r\n PullAudioOutputStream,\r\n PushAudioOutputStreamCallback,\r\n SpeechConfig,\r\n SpeechSynthesisEventArgs,\r\n SpeechSynthesisOutputFormat,\r\n SpeechSynthesisResult,\r\n SpeechSynthesisWordBoundaryEventArgs,\r\n} from \"./Exports\";\r\nimport { SpeechConfigImpl } from \"./SpeechConfig\";\r\n\r\n/**\r\n * Defines the class SpeechSynthesizer for text to speech.\r\n * Added in version 1.11.0\r\n * @class SpeechSynthesizer\r\n */\r\nexport class SpeechSynthesizer {\r\n protected audioConfig: AudioConfig;\r\n protected privAdapter: SynthesisAdapterBase;\r\n protected privProperties: PropertyCollection;\r\n protected synthesisRequestQueue: Queue;\r\n\r\n /**\r\n * Defines event handler for synthesis start events.\r\n * @member SpeechSynthesizer.prototype.synthesisStarted\r\n * @function\r\n * @public\r\n */\r\n public synthesisStarted: (sender: SpeechSynthesizer, event: SpeechSynthesisEventArgs) => void;\r\n\r\n /**\r\n * Defines event handler for synthesizing events.\r\n * @member SpeechSynthesizer.prototype.synthesizing\r\n * @function\r\n * @public\r\n */\r\n public synthesizing: (sender: SpeechSynthesizer, event: SpeechSynthesisEventArgs) => void;\r\n\r\n /**\r\n * Defines event handler for synthesis completed events.\r\n * @member SpeechSynthesizer.prototype.synthesisCompleted\r\n * @function\r\n * @public\r\n */\r\n public synthesisCompleted: (sender: SpeechSynthesizer, event: SpeechSynthesisEventArgs) => void;\r\n\r\n /**\r\n * Defines event handler for synthesis cancelled events.\r\n * @member SpeechSynthesizer.prototype.SynthesisCanceled\r\n * @function\r\n * @public\r\n */\r\n public SynthesisCanceled: (sender: SpeechSynthesizer, event: SpeechSynthesisEventArgs) => void;\r\n\r\n /**\r\n * Defines event handler for word boundary events\r\n * @member SpeechSynthesizer.prototype.wordBoundary\r\n * @function\r\n * @public\r\n */\r\n public wordBoundary: (sender: SpeechSynthesizer, event: SpeechSynthesisWordBoundaryEventArgs) => void;\r\n\r\n /**\r\n * Gets the authorization token used to communicate with the service.\r\n * @member SpeechSynthesizer.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @returns {string} Authorization token.\r\n */\r\n public get authorizationToken(): string {\r\n return this.properties.getProperty(PropertyId.SpeechServiceAuthorization_Token);\r\n }\r\n\r\n /**\r\n * Gets/Sets the authorization token used to communicate with the service.\r\n * @member SpeechSynthesizer.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @param {string} token - Authorization token.\r\n */\r\n public set authorizationToken(token: string) {\r\n Contracts.throwIfNullOrWhitespace(token, \"token\");\r\n this.properties.setProperty(PropertyId.SpeechServiceAuthorization_Token, token);\r\n }\r\n\r\n /**\r\n * The collection of properties and their values defined for this SpeechSynthesizer.\r\n * @member SpeechSynthesizer.prototype.properties\r\n * @function\r\n * @public\r\n * @returns {PropertyCollection} The collection of properties and their values defined for this SpeechSynthesizer.\r\n */\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n /**\r\n * Indicates if auto detect source language is enabled\r\n * @member SpeechSynthesizer.prototype.properties\r\n * @function\r\n * @public\r\n * @returns {boolean} if auto detect source language is enabled\r\n */\r\n public get autoDetectSourceLanguage(): boolean {\r\n return this.properties.getProperty(PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages) === AutoDetectSourceLanguagesOpenRangeOptionName;\r\n }\r\n\r\n private privDisposed: boolean;\r\n private privConnectionFactory: ISynthesisConnectionFactory;\r\n private privSynthesizing: boolean;\r\n\r\n /**\r\n * SpeechSynthesizer constructor.\r\n * @constructor\r\n * @param {SpeechConfig} speechConfig - An set of initial properties for this synthesizer\r\n * @param {AudioConfig} audioConfig - An optional audio configuration associated with the synthesizer\r\n */\r\n public constructor(speechConfig: SpeechConfig, audioConfig?: AudioConfig) {\r\n const speechConfigImpl: SpeechConfigImpl = speechConfig as SpeechConfigImpl;\r\n Contracts.throwIfNull(speechConfigImpl, \"speechConfig\");\r\n\r\n if (audioConfig !== null) {\r\n this.audioConfig = (audioConfig !== undefined) ? audioConfig : AudioConfig.fromDefaultSpeakerOutput();\r\n }\r\n this.privProperties = speechConfigImpl.properties.clone();\r\n this.privDisposed = false;\r\n this.privSynthesizing = false;\r\n this.privConnectionFactory = new SpeechSynthesisConnectionFactory();\r\n this.synthesisRequestQueue = new Queue();\r\n this.implCommonSynthesizeSetup();\r\n }\r\n\r\n /**\r\n * SpeechSynthesizer constructor.\r\n * @constructor\r\n * @param {SpeechConfig} speechConfig - an set of initial properties for this synthesizer\r\n * @param {AutoDetectSourceLanguageConfig} autoDetectSourceLanguageConfig - An source language detection configuration associated with the synthesizer\r\n * @param {AudioConfig} audioConfig - An optional audio configuration associated with the synthesizer\r\n */\r\n public static FromConfig(speechConfig: SpeechConfig, autoDetectSourceLanguageConfig: AutoDetectSourceLanguageConfig, audioConfig?: AudioConfig): SpeechSynthesizer {\r\n const speechConfigImpl: SpeechConfigImpl = speechConfig as SpeechConfigImpl;\r\n autoDetectSourceLanguageConfig.properties.mergeTo(speechConfigImpl.properties);\r\n return new SpeechSynthesizer(speechConfig, audioConfig);\r\n }\r\n\r\n public buildSsml(text: string): string {\r\n const languageToDefaultVoice: IStringDictionary = {\r\n [\"ar-EG\"]: \"Microsoft Server Speech Text to Speech Voice (ar-EG, Hoda)\",\r\n [\"ar-SA\"]: \"Microsoft Server Speech Text to Speech Voice (ar-SA, Naayf)\",\r\n [\"bg-BG\"]: \"Microsoft Server Speech Text to Speech Voice (bg-BG, Ivan)\",\r\n [\"ca-ES\"]: \"Microsoft Server Speech Text to Speech Voice (ca-ES, HerenaRUS)\",\r\n [\"cs-CZ\"]: \"Microsoft Server Speech Text to Speech Voice (cs-CZ, Jakub)\",\r\n [\"da-DK\"]: \"Microsoft Server Speech Text to Speech Voice (da-DK, HelleRUS)\",\r\n [\"de-AT\"]: \"Microsoft Server Speech Text to Speech Voice (de-AT, Michael)\",\r\n [\"de-CH\"]: \"Microsoft Server Speech Text to Speech Voice (de-CH, Karsten)\",\r\n [\"de-DE\"]: \"Microsoft Server Speech Text to Speech Voice (de-DE, HeddaRUS)\",\r\n [\"el-GR\"]: \"Microsoft Server Speech Text to Speech Voice (el-GR, Stefanos)\",\r\n [\"en-AU\"]: \"Microsoft Server Speech Text to Speech Voice (en-AU, HayleyRUS)\",\r\n [\"en-CA\"]: \"Microsoft Server Speech Text to Speech Voice (en-CA, HeatherRUS)\",\r\n [\"en-GB\"]: \"Microsoft Server Speech Text to Speech Voice (en-GB, HazelRUS)\",\r\n [\"en-IE\"]: \"Microsoft Server Speech Text to Speech Voice (en-IE, Sean)\",\r\n [\"en-IN\"]: \"Microsoft Server Speech Text to Speech Voice (en-IN, PriyaRUS)\",\r\n [\"en-US\"]: \"Microsoft Server Speech Text to Speech Voice (en-US, AriaRUS)\",\r\n [\"es-ES\"]: \"Microsoft Server Speech Text to Speech Voice (es-ES, HelenaRUS)\",\r\n [\"es-MX\"]: \"Microsoft Server Speech Text to Speech Voice (es-MX, HildaRUS)\",\r\n [\"fi-FI\"]: \"Microsoft Server Speech Text to Speech Voice (fi-FI, HeidiRUS)\",\r\n [\"fr-CA\"]: \"Microsoft Server Speech Text to Speech Voice (fr-CA, HarmonieRUS)\",\r\n [\"fr-CH\"]: \"Microsoft Server Speech Text to Speech Voice (fr-CH, Guillaume)\",\r\n [\"fr-FR\"]: \"Microsoft Server Speech Text to Speech Voice (fr-FR, HortenseRUS)\",\r\n [\"he-IL\"]: \"Microsoft Server Speech Text to Speech Voice (he-IL, Asaf)\",\r\n [\"hi-IN\"]: \"Microsoft Server Speech Text to Speech Voice (hi-IN, Kalpana)\",\r\n [\"hr-HR\"]: \"Microsoft Server Speech Text to Speech Voice (hr-HR, Matej)\",\r\n [\"hu-HU\"]: \"Microsoft Server Speech Text to Speech Voice (hu-HU, Szabolcs)\",\r\n [\"id-ID\"]: \"Microsoft Server Speech Text to Speech Voice (id-ID, Andika)\",\r\n [\"it-IT\"]: \"Microsoft Server Speech Text to Speech Voice (it-IT, LuciaRUS)\",\r\n [\"ja-JP\"]: \"Microsoft Server Speech Text to Speech Voice (ja-JP, HarukaRUS)\",\r\n [\"ko-KR\"]: \"Microsoft Server Speech Text to Speech Voice (ko-KR, HeamiRUS)\",\r\n [\"ms-MY\"]: \"Microsoft Server Speech Text to Speech Voice (ms-MY, Rizwan)\",\r\n [\"nb-NO\"]: \"Microsoft Server Speech Text to Speech Voice (nb-NO, HuldaRUS)\",\r\n [\"nl-NL\"]: \"Microsoft Server Speech Text to Speech Voice (nl-NL, HannaRUS)\",\r\n [\"pl-PL\"]: \"Microsoft Server Speech Text to Speech Voice (pl-PL, PaulinaRUS)\",\r\n [\"pt-BR\"]: \"Microsoft Server Speech Text to Speech Voice (pt-BR, HeloisaRUS)\",\r\n [\"pt-PT\"]: \"Microsoft Server Speech Text to Speech Voice (pt-PT, HeliaRUS)\",\r\n [\"ro-RO\"]: \"Microsoft Server Speech Text to Speech Voice (ro-RO, Andrei)\",\r\n [\"ru-RU\"]: \"Microsoft Server Speech Text to Speech Voice (ru-RU, EkaterinaRUS)\",\r\n [\"sk-SK\"]: \"Microsoft Server Speech Text to Speech Voice (sk-SK, Filip)\",\r\n [\"sl-SI\"]: \"Microsoft Server Speech Text to Speech Voice (sl-SI, Lado)\",\r\n [\"sv-SE\"]: \"Microsoft Server Speech Text to Speech Voice (sv-SE, HedvigRUS)\",\r\n [\"ta-IN\"]: \"Microsoft Server Speech Text to Speech Voice (ta-IN, Valluvar)\",\r\n [\"te-IN\"]: \"Microsoft Server Speech Text to Speech Voice (te-IN, Chitra)\",\r\n [\"th-TH\"]: \"Microsoft Server Speech Text to Speech Voice (th-TH, Pattara)\",\r\n [\"tr-TR\"]: \"Microsoft Server Speech Text to Speech Voice (tr-TR, SedaRUS)\",\r\n [\"vi-VN\"]: \"Microsoft Server Speech Text to Speech Voice (vi-VN, An)\",\r\n [\"zh-CN\"]: \"Microsoft Server Speech Text to Speech Voice (zh-CN, HuihuiRUS)\",\r\n [\"zh-HK\"]: \"Microsoft Server Speech Text to Speech Voice (zh-HK, TracyRUS)\",\r\n [\"zh-TW\"]: \"Microsoft Server Speech Text to Speech Voice (zh-TW, HanHanRUS)\",\r\n };\r\n\r\n let language = this.properties.getProperty(PropertyId.SpeechServiceConnection_SynthLanguage, \"en-US\");\r\n let voice = this.properties.getProperty(PropertyId.SpeechServiceConnection_SynthVoice, \"\");\r\n let ssml: string = SpeechSynthesizer.XMLEncode(text);\r\n if (this.autoDetectSourceLanguage) {\r\n language = \"en-US\";\r\n } else {\r\n voice = voice || languageToDefaultVoice[language];\r\n }\r\n if (voice) {\r\n ssml = `${ssml}`;\r\n }\r\n ssml = `${ssml}`;\r\n return ssml;\r\n }\r\n\r\n /**\r\n * Executes speech synthesis on plain text.\r\n * The task returns the synthesis result.\r\n * @member SpeechSynthesizer.prototype.speakTextAsync\r\n * @function\r\n * @public\r\n * @param text - Text to be synthesized.\r\n * @param cb - Callback that received the SpeechSynthesisResult.\r\n * @param err - Callback invoked in case of an error.\r\n * @param stream - AudioOutputStream to receive the synthesized audio.\r\n */\r\n public speakTextAsync(text: string, cb?: (e: SpeechSynthesisResult) => void, err?: (e: string) => void, stream?: AudioOutputStream | PushAudioOutputStreamCallback | PathLike): void {\r\n this.speakImpl(text, false, cb, err, stream);\r\n }\r\n\r\n /**\r\n * Executes speech synthesis on SSML.\r\n * The task returns the synthesis result.\r\n * @member SpeechSynthesizer.prototype.speakSsmlAsync\r\n * @function\r\n * @public\r\n * @param ssml - SSML to be synthesized.\r\n * @param cb - Callback that received the SpeechSynthesisResult.\r\n * @param err - Callback invoked in case of an error.\r\n * @param stream - AudioOutputStream to receive the synthesized audio.\r\n */\r\n public speakSsmlAsync(ssml: string, cb?: (e: SpeechSynthesisResult) => void, err?: (e: string) => void, stream?: AudioOutputStream | PushAudioOutputStreamCallback | PathLike): void {\r\n this.speakImpl(ssml, true, cb, err, stream);\r\n }\r\n\r\n /**\r\n * Dispose of associated resources.\r\n * @member SpeechSynthesizer.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(): void {\r\n Contracts.throwIfDisposed(this.privDisposed);\r\n\r\n this.dispose(true);\r\n }\r\n\r\n /**\r\n * @Internal\r\n * Do not use externally, object returned will change without warning or notice.\r\n */\r\n public get internalData(): object {\r\n return this.privAdapter;\r\n }\r\n\r\n /**\r\n * This method performs cleanup of resources.\r\n * The Boolean parameter disposing indicates whether the method is called\r\n * from Dispose (if disposing is true) or from the finalizer (if disposing is false).\r\n * Derived classes should override this method to dispose resource if needed.\r\n * @member SpeechSynthesizer.prototype.dispose\r\n * @function\r\n * @public\r\n * @param {boolean} disposing - Flag to request disposal.\r\n */\r\n protected dispose(disposing: boolean): void {\r\n if (this.privDisposed) {\r\n return;\r\n }\r\n\r\n if (disposing) {\r\n if (this.privAdapter) {\r\n this.privAdapter.dispose();\r\n }\r\n }\r\n\r\n this.privDisposed = true;\r\n }\r\n\r\n //\r\n // ################################################################################################################\r\n // IMPLEMENTATION.\r\n // Move to independent class\r\n // ################################################################################################################\r\n //\r\n protected createSynthesizerConfig(speechConfig: SpeechServiceConfig): SynthesizerConfig {\r\n return new SynthesizerConfig(\r\n speechConfig,\r\n this.privProperties);\r\n }\r\n\r\n // Creates the synthesis adapter\r\n protected createSynthesisAdapter(\r\n authentication: IAuthentication,\r\n connectionFactory: ISynthesisConnectionFactory,\r\n audioConfig: AudioConfig,\r\n synthesizerConfig: SynthesizerConfig): SynthesisAdapterBase {\r\n return new SynthesisAdapterBase(authentication, connectionFactory,\r\n synthesizerConfig, this, this.audioConfig as AudioOutputConfigImpl);\r\n }\r\n\r\n protected implCommonSynthesizeSetup(): void {\r\n\r\n let osPlatform = (typeof window !== \"undefined\") ? \"Browser\" : \"Node\";\r\n let osName = \"unknown\";\r\n let osVersion = \"unknown\";\r\n\r\n if (typeof navigator !== \"undefined\") {\r\n osPlatform = osPlatform + \"/\" + navigator.platform;\r\n osName = navigator.userAgent;\r\n osVersion = navigator.appVersion;\r\n }\r\n\r\n const synthesizerConfig = this.createSynthesizerConfig(\r\n new SpeechServiceConfig(\r\n new Context(new OS(osPlatform, osName, osVersion))));\r\n\r\n const subscriptionKey = this.privProperties.getProperty(PropertyId.SpeechServiceConnection_Key, undefined);\r\n const authentication = (subscriptionKey && subscriptionKey !== \"\") ?\r\n new CognitiveSubscriptionKeyAuthentication(subscriptionKey) :\r\n new CognitiveTokenAuthentication(\r\n (authFetchEventId: string): Promise => {\r\n const authorizationToken = this.privProperties.getProperty(PropertyId.SpeechServiceAuthorization_Token, undefined);\r\n return PromiseHelper.fromResult(authorizationToken);\r\n },\r\n (authFetchEventId: string): Promise => {\r\n const authorizationToken = this.privProperties.getProperty(PropertyId.SpeechServiceAuthorization_Token, undefined);\r\n return PromiseHelper.fromResult(authorizationToken);\r\n });\r\n\r\n this.privAdapter = this.createSynthesisAdapter(\r\n authentication,\r\n this.privConnectionFactory,\r\n this.audioConfig,\r\n synthesizerConfig);\r\n\r\n this.privAdapter.audioOutputFormat = AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(\r\n (SpeechSynthesisOutputFormat as any)[this.properties.getProperty(PropertyId.SpeechServiceConnection_SynthOutputFormat, undefined)]\r\n );\r\n }\r\n\r\n protected speakImpl(text: string, IsSsml: boolean, cb?: (e: SpeechSynthesisResult) => void, err?: (e: string) => void, dataStream?: AudioOutputStream | PushAudioOutputStreamCallback | PathLike): void {\r\n try {\r\n Contracts.throwIfDisposed(this.privDisposed);\r\n const requestId = createNoDashGuid();\r\n let audioDestination;\r\n if (dataStream instanceof PushAudioOutputStreamCallback) {\r\n audioDestination = new PushAudioOutputStreamImpl(dataStream);\r\n } else if (dataStream instanceof PullAudioOutputStream) {\r\n audioDestination = dataStream as PullAudioOutputStreamImpl;\r\n } else if (dataStream !== undefined) {\r\n audioDestination = new AudioFileWriter(dataStream as PathLike);\r\n } else {\r\n audioDestination = undefined;\r\n }\r\n this.synthesisRequestQueue.enqueue(new SynthesisRequest(requestId, text, IsSsml, (e: SpeechSynthesisResult): void => {\r\n this.privSynthesizing = false;\r\n if (!!cb) {\r\n try {\r\n cb(e);\r\n } catch (e) {\r\n if (!!err) {\r\n err(e);\r\n }\r\n }\r\n }\r\n cb = undefined;\r\n this.adapterSpeak();\r\n }, (e: string): void => {\r\n if (!!err) {\r\n err(e);\r\n }\r\n }, audioDestination));\r\n\r\n this.adapterSpeak();\r\n\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error);\r\n }\r\n }\r\n\r\n // Destroy the synthesizer.\r\n this.dispose(true);\r\n }\r\n }\r\n\r\n protected adapterSpeak(): Promise {\r\n if (!this.privDisposed && !this.privSynthesizing) {\r\n this.privSynthesizing = true;\r\n return this.synthesisRequestQueue.dequeue().\r\n onSuccessContinueWithPromise((request: SynthesisRequest): Promise => {\r\n return this.privAdapter.Speak(request.text, request.isSSML, request.requestId, request.cb, request.err, request.dataStream);\r\n });\r\n }\r\n return PromiseHelper.fromResult(true);\r\n }\r\n\r\n private static XMLEncode(text: string): string {\r\n return text.replace(/&/g, \"&\")\r\n .replace(//g, \">\")\r\n .replace(/\"/g, \""\")\r\n .replace(/'/g, \"'\");\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class SynthesisRequest {\r\n public requestId: string;\r\n public text: string;\r\n public isSSML: boolean;\r\n public cb: (e: SpeechSynthesisResult) => void;\r\n public err: (e: string) => void;\r\n public dataStream: IAudioDestination;\r\n\r\n constructor(requestId: string, text: string, isSSML: boolean, cb?: (e: SpeechSynthesisResult) => void, err?: (e: string) => void, dataStream?: IAudioDestination) {\r\n this.requestId = requestId;\r\n this.text = text;\r\n this.isSSML = isSSML;\r\n this.cb = cb;\r\n this.err = err;\r\n this.dataStream = dataStream;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { PropertyCollection, ResultReason } from \"./Exports\";\r\n\r\n/**\r\n * Defines result of speech synthesis.\r\n * @class SpeechSynthesisResult\r\n * Added in version 1.11.0\r\n */\r\nexport class SpeechSynthesisResult {\r\n private privResultId: string;\r\n private privReason: ResultReason;\r\n private privText: string;\r\n private privAudioData: ArrayBuffer;\r\n private privOffset: number;\r\n private privErrorDetails: string;\r\n private privProperties: PropertyCollection;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {string} resultId - The result id.\r\n * @param {ResultReason} reason - The reason.\r\n * @param {number} audioData - The offset into the stream.\r\n * @param {string} errorDetails - Error details, if provided.\r\n * @param {PropertyCollection} properties - Additional properties, if provided.\r\n */\r\n constructor(resultId?: string, reason?: ResultReason, audioData?: ArrayBuffer,\r\n errorDetails?: string, properties?: PropertyCollection) {\r\n this.privResultId = resultId;\r\n this.privReason = reason;\r\n this.privAudioData = audioData;\r\n this.privErrorDetails = errorDetails;\r\n this.privProperties = properties;\r\n }\r\n\r\n /**\r\n * Specifies the result identifier.\r\n * @member SpeechSynthesisResult.prototype.resultId\r\n * @function\r\n * @public\r\n * @returns {string} Specifies the result identifier.\r\n */\r\n public get resultId(): string {\r\n return this.privResultId;\r\n }\r\n\r\n /**\r\n * Specifies status of the result.\r\n * @member SpeechSynthesisResult.prototype.reason\r\n * @function\r\n * @public\r\n * @returns {ResultReason} Specifies status of the result.\r\n */\r\n public get reason(): ResultReason {\r\n return this.privReason;\r\n }\r\n\r\n /**\r\n * The synthesized audio data\r\n * @member SpeechSynthesisResult.prototype.audioData\r\n * @function\r\n * @public\r\n * @returns {ArrayBuffer} The synthesized audio data.\r\n */\r\n public get audioData(): ArrayBuffer {\r\n return this.privAudioData;\r\n }\r\n\r\n /**\r\n * In case of an unsuccessful synthesis, provides details of the occurred error.\r\n * @member SpeechSynthesisResult.prototype.errorDetails\r\n * @function\r\n * @public\r\n * @returns {string} a brief description of an error.\r\n */\r\n public get errorDetails(): string {\r\n return this.privErrorDetails;\r\n }\r\n\r\n /**\r\n * The set of properties exposed in the result.\r\n * @member SpeechSynthesisResult.prototype.properties\r\n * @function\r\n * @public\r\n * @returns {PropertyCollection} The set of properties exposed in the result.\r\n */\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { SpeechSynthesisResult } from \"./Exports\";\r\n\r\n/**\r\n * Defines contents of speech synthesis events.\r\n * @class SpeechSynthesisEventArgs\r\n * Added in version 1.11.0\r\n */\r\nexport class SpeechSynthesisEventArgs {\r\n private readonly privResult: SpeechSynthesisResult;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {SpeechSynthesisResult} result - The speech synthesis result.\r\n */\r\n public constructor(result: SpeechSynthesisResult) {\r\n this.privResult = result;\r\n }\r\n\r\n /**\r\n * Specifies the synthesis result.\r\n * @member SpeechSynthesisEventArgs.prototype.result\r\n * @function\r\n * @public\r\n * @returns {SpeechSynthesisResult} the synthesis result.\r\n */\r\n public get result(): SpeechSynthesisResult {\r\n return this.privResult;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * Defines contents of speech synthesis word boundary event.\r\n * @class SpeechSynthesisWordBoundaryEventArgs\r\n * Added in version 1.11.0\r\n */\r\nexport class SpeechSynthesisWordBoundaryEventArgs {\r\n private privAduioOffset: number;\r\n private privText: string;\r\n private privWordLength: number;\r\n private privTextOffset: number;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {number} audioOffset - The audio offset.\r\n * @param {string} text - The text.\r\n * @param {number} wordLength - The length of the word.\r\n * @param {number} textOffset - The text offset.\r\n */\r\n public constructor(audioOffset: number, text: string, wordLength: number, textOffset: number) {\r\n this.privAduioOffset = audioOffset;\r\n this.privText = text;\r\n this.privWordLength = wordLength;\r\n this.privTextOffset = textOffset;\r\n }\r\n\r\n /**\r\n * Specifies the audio offset.\r\n * @member SpeechSynthesisWordBoundaryEventArgs.prototype.audioOffset\r\n * @function\r\n * @public\r\n * @returns {number} the audio offset.\r\n */\r\n public get audioOffset(): number {\r\n return this.privAduioOffset;\r\n }\r\n\r\n /**\r\n * Specifies the text of the word boundary event.\r\n * @member SpeechSynthesisWordBoundaryEventArgs.prototype.text\r\n * @function\r\n * @public\r\n * @returns {string} the text.\r\n */\r\n public get text(): string {\r\n return this.privText;\r\n }\r\n\r\n /**\r\n * Specifies the word length\r\n * @member SpeechSynthesisWordBoundaryEventArgs.prototype.wordLength\r\n * @function\r\n * @public\r\n * @returns {number} the word length\r\n */\r\n public get wordLength(): number {\r\n return this.privWordLength;\r\n }\r\n\r\n /**\r\n * Specifies the text offset.\r\n * @member SpeechSynthesisWordBoundaryEventArgs.prototype.textOffset\r\n * @function\r\n * @public\r\n * @returns {number} the text offset.\r\n */\r\n public get textOffset(): number {\r\n return this.privTextOffset;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { SynthesisAdapterBase } from \"../../common.speech/Exports\";\r\nimport {\r\n createNoDashGuid,\r\n IAudioDestination,\r\n INumberDictionary\r\n} from \"../../common/Exports\";\r\nimport { AudioStreamFormat, IPlayer } from \"../Exports\";\r\nimport { AudioFormatTag, AudioOutputFormatImpl } from \"./AudioOutputFormat\";\r\nimport { PullAudioOutputStreamImpl } from \"./AudioOutputStream\";\r\n\r\nconst MediaDurationPlaceholderSeconds = 60 * 30;\r\n\r\nconst AudioFormatToMimeType: INumberDictionary = {\r\n [AudioFormatTag.PCM]: \"audio/wav\",\r\n [AudioFormatTag.MP3]: \"audio/mpeg\",\r\n [AudioFormatTag.Opus]: \"audio/ogg\",\r\n};\r\n\r\n/**\r\n * Represents the speaker playback audio destination, which only works in browser.\r\n * Note: the SDK will try to use Media Source Extensions to play audio.\r\n * Mp3 format has better supports on Microsoft Edge, Chrome and Safari (desktop), so, it's better to specify mp3 format for playback.\r\n * @class SpeakerAudioDestination\r\n * Updated in version 1.12.1\r\n */\r\nexport class SpeakerAudioDestination implements IAudioDestination, IPlayer {\r\n private readonly privId: string;\r\n private privFormat: AudioOutputFormatImpl;\r\n private privAudio: HTMLAudioElement;\r\n private privMediaSource: MediaSource;\r\n private privSourceBuffer: SourceBuffer;\r\n private privPlaybackStarted: boolean = false;\r\n private privAudioBuffer: ArrayBuffer[];\r\n private privAppendingToBuffer: boolean = false;\r\n private privMediaSourceOpened: boolean = false;\r\n private privIsClosed: boolean;\r\n private privIsPaused: boolean;\r\n private privAudioOutputStream: PullAudioOutputStreamImpl;\r\n private privBytesReceived: number = 0;\r\n\r\n public constructor(audioDestinationId?: string) {\r\n this.privId = audioDestinationId ? audioDestinationId : createNoDashGuid();\r\n this.privIsPaused = false;\r\n this.privIsClosed = false;\r\n }\r\n\r\n public id(): string {\r\n return this.privId;\r\n }\r\n\r\n public write(buffer: ArrayBuffer): void {\r\n if (this.privAudioBuffer !== undefined) {\r\n this.privAudioBuffer.push(buffer);\r\n this.updateSourceBuffer();\r\n } else if (this.privAudioOutputStream !== undefined) {\r\n this.privAudioOutputStream.write(buffer);\r\n this.privBytesReceived += buffer.byteLength;\r\n }\r\n }\r\n\r\n public close(): void {\r\n this.privIsClosed = true;\r\n if (this.privSourceBuffer !== undefined) {\r\n this.handleSourceBufferUpdateEnd();\r\n } else if (this.privAudioOutputStream !== undefined) {\r\n let receivedAudio = new ArrayBuffer(this.privBytesReceived);\r\n this.privAudioOutputStream.read(receivedAudio);\r\n if (this.privFormat.hasHeader) {\r\n receivedAudio = SynthesisAdapterBase.addHeader(receivedAudio, this.privFormat);\r\n }\r\n const audioBlob = new Blob([receivedAudio], { type: AudioFormatToMimeType[this.privFormat.formatTag] });\r\n this.privAudio.src = window.URL.createObjectURL(audioBlob);\r\n this.notifyPlayback();\r\n }\r\n }\r\n\r\n set format(format: AudioStreamFormat) {\r\n if (typeof (AudioContext) !== \"undefined\" || typeof ((window as any).webkitAudioContext) !== \"undefined\") {\r\n this.privFormat = format as AudioOutputFormatImpl;\r\n const mimeType: string = AudioFormatToMimeType[this.privFormat.formatTag];\r\n if (mimeType === undefined) {\r\n // tslint:disable-next-line:no-console\r\n console.warn(\r\n `Unknown mimeType for format ${AudioFormatTag[this.privFormat.formatTag]}.`);\r\n\r\n } else if (typeof(MediaSource) !== \"undefined\" && MediaSource.isTypeSupported(mimeType)) {\r\n this.privAudio = new Audio();\r\n this.privAudioBuffer = [];\r\n this.privMediaSource = new MediaSource();\r\n this.privAudio.src = URL.createObjectURL(this.privMediaSource);\r\n this.privAudio.load();\r\n this.privMediaSource.onsourceopen = (event: Event): void => {\r\n this.privMediaSourceOpened = true;\r\n this.privMediaSource.duration = MediaDurationPlaceholderSeconds;\r\n this.privSourceBuffer = this.privMediaSource.addSourceBuffer(mimeType);\r\n this.privSourceBuffer.onupdate = (_: Event) => {\r\n this.updateSourceBuffer();\r\n };\r\n this.privSourceBuffer.onupdateend = (_: Event) => {\r\n this.handleSourceBufferUpdateEnd();\r\n };\r\n this.privSourceBuffer.onupdatestart = (_: Event) => {\r\n this.privAppendingToBuffer = false;\r\n };\r\n };\r\n this.updateSourceBuffer();\r\n } else {\r\n // tslint:disable-next-line:no-console\r\n console.warn(\r\n `Format ${AudioFormatTag[this.privFormat.formatTag]} could not be played by MSE, streaming playback is not enabled.`);\r\n this.privAudioOutputStream = new PullAudioOutputStreamImpl();\r\n this.privAudioOutputStream.format = this.privFormat;\r\n this.privAudio = new Audio();\r\n }\r\n }\r\n }\r\n\r\n public get isClosed(): boolean {\r\n return this.privIsClosed;\r\n }\r\n\r\n public get currentTime(): number {\r\n if (this.privAudio !== undefined) {\r\n return this.privAudio.currentTime;\r\n }\r\n return -1;\r\n }\r\n\r\n public pause(): void {\r\n if (!this.privIsPaused && this.privAudio !== undefined) {\r\n this.privAudio.pause();\r\n this.privIsPaused = true;\r\n }\r\n }\r\n\r\n public resume(): void {\r\n if (this.privIsPaused && this.privAudio !== undefined) {\r\n this.privAudio.play();\r\n this.privIsPaused = false;\r\n }\r\n }\r\n\r\n public onAudioEnd: (sender: IPlayer) => void;\r\n\r\n public get internalAudio(): HTMLAudioElement {\r\n return this.privAudio;\r\n }\r\n\r\n private updateSourceBuffer(): void {\r\n if (this.privAudioBuffer !== undefined && (this.privAudioBuffer.length > 0) && this.sourceBufferAvailable()) {\r\n this.privAppendingToBuffer = true;\r\n const binary = this.privAudioBuffer.shift();\r\n try {\r\n this.privSourceBuffer.appendBuffer(binary);\r\n } catch (error) {\r\n this.privAudioBuffer.unshift(binary);\r\n // tslint:disable-next-line:no-console\r\n console.log(\r\n \"buffer filled, pausing addition of binaries until space is made\");\r\n return;\r\n }\r\n this.notifyPlayback();\r\n } else if (this.canEndStream()) {\r\n this.handleSourceBufferUpdateEnd();\r\n }\r\n }\r\n\r\n private handleSourceBufferUpdateEnd(): void {\r\n if (this.canEndStream() && this.sourceBufferAvailable()) {\r\n this.privMediaSource.endOfStream();\r\n this.notifyPlayback();\r\n }\r\n }\r\n\r\n private notifyPlayback(): void {\r\n if (!this.privPlaybackStarted && this.privAudio !== undefined) {\r\n this.privAudio.onended = (): void => {\r\n if (!!this.onAudioEnd) {\r\n this.onAudioEnd(this);\r\n }\r\n };\r\n if (!this.privIsPaused) {\r\n this.privAudio.play();\r\n }\r\n this.privPlaybackStarted = true;\r\n }\r\n }\r\n\r\n private canEndStream(): boolean {\r\n return (this.isClosed && this.privSourceBuffer !== undefined && (this.privAudioBuffer.length === 0)\r\n && this.privMediaSourceOpened && !this.privAppendingToBuffer && this.privMediaSource.readyState === \"open\");\r\n }\r\n\r\n private sourceBufferAvailable(): boolean {\r\n return (this.privSourceBuffer !== undefined && !this.privSourceBuffer.updating);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { EventType, PlatformEvent } from \"../common/Exports\";\r\n\r\nexport class SpeechRecognitionEvent extends PlatformEvent {\r\n private privRequestId: string;\r\n private privSessionId: string;\r\n\r\n constructor(eventName: string, requestId: string, sessionId: string, eventType: EventType = EventType.Info) {\r\n super(eventName, eventType);\r\n\r\n this.privRequestId = requestId;\r\n this.privSessionId = sessionId;\r\n }\r\n\r\n public get requestId(): string {\r\n return this.privRequestId;\r\n }\r\n\r\n public get sessionId(): string {\r\n return this.privSessionId;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class RecognitionTriggeredEvent extends SpeechRecognitionEvent {\r\n private privAudioSourceId: string;\r\n private privAudioNodeId: string;\r\n\r\n constructor(requestId: string, sessionId: string, audioSourceId: string, audioNodeId: string) {\r\n super(\"RecognitionTriggeredEvent\", requestId, sessionId);\r\n\r\n this.privAudioSourceId = audioSourceId;\r\n this.privAudioNodeId = audioNodeId;\r\n }\r\n\r\n public get audioSourceId(): string {\r\n return this.privAudioSourceId;\r\n }\r\n\r\n public get audioNodeId(): string {\r\n return this.privAudioNodeId;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class ListeningStartedEvent extends SpeechRecognitionEvent {\r\n private privAudioSourceId: string;\r\n private privAudioNodeId: string;\r\n\r\n constructor(requestId: string, sessionId: string, audioSourceId: string, audioNodeId: string) {\r\n super(\"ListeningStartedEvent\", requestId, sessionId);\r\n this.privAudioSourceId = audioSourceId;\r\n this.privAudioNodeId = audioNodeId;\r\n }\r\n\r\n public get audioSourceId(): string {\r\n return this.privAudioSourceId;\r\n }\r\n\r\n public get audioNodeId(): string {\r\n return this.privAudioNodeId;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class ConnectingToServiceEvent extends SpeechRecognitionEvent {\r\n private privAuthFetchEventid: string;\r\n\r\n constructor(requestId: string, authFetchEventid: string, sessionId: string) {\r\n super(\"ConnectingToServiceEvent\", requestId, sessionId);\r\n this.privAuthFetchEventid = authFetchEventid;\r\n }\r\n\r\n public get authFetchEventid(): string {\r\n return this.privAuthFetchEventid;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class RecognitionStartedEvent extends SpeechRecognitionEvent {\r\n private privAudioSourceId: string;\r\n private privAudioNodeId: string;\r\n private privAuthFetchEventId: string;\r\n\r\n constructor(requestId: string, audioSourceId: string, audioNodeId: string, authFetchEventId: string, sessionId: string) {\r\n super(\"RecognitionStartedEvent\", requestId, sessionId);\r\n\r\n this.privAudioSourceId = audioSourceId;\r\n this.privAudioNodeId = audioNodeId;\r\n this.privAuthFetchEventId = authFetchEventId;\r\n }\r\n\r\n public get audioSourceId(): string {\r\n return this.privAudioSourceId;\r\n }\r\n\r\n public get audioNodeId(): string {\r\n return this.privAudioNodeId;\r\n }\r\n\r\n public get authFetchEventId(): string {\r\n return this.privAuthFetchEventId;\r\n }\r\n}\r\n\r\nexport enum RecognitionCompletionStatus {\r\n Success,\r\n AudioSourceError,\r\n AudioSourceTimeout,\r\n AuthTokenFetchError,\r\n AuthTokenFetchTimeout,\r\n UnAuthorized,\r\n ConnectTimeout,\r\n ConnectError,\r\n ClientRecognitionActivityTimeout,\r\n UnknownError,\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class RecognitionEndedEvent extends SpeechRecognitionEvent {\r\n private privAudioSourceId: string;\r\n private privAudioNodeId: string;\r\n private privAuthFetchEventId: string;\r\n private privServiceTag: string;\r\n private privStatus: RecognitionCompletionStatus;\r\n private privError: string;\r\n\r\n constructor(\r\n requestId: string,\r\n audioSourceId: string,\r\n audioNodeId: string,\r\n authFetchEventId: string,\r\n sessionId: string,\r\n serviceTag: string,\r\n status: RecognitionCompletionStatus,\r\n error: string) {\r\n\r\n super(\"RecognitionEndedEvent\", requestId, sessionId, status === RecognitionCompletionStatus.Success ? EventType.Info : EventType.Error);\r\n\r\n this.privAudioSourceId = audioSourceId;\r\n this.privAudioNodeId = audioNodeId;\r\n this.privAuthFetchEventId = authFetchEventId;\r\n this.privStatus = status;\r\n this.privError = error;\r\n this.privServiceTag = serviceTag;\r\n }\r\n\r\n public get audioSourceId(): string {\r\n return this.privAudioSourceId;\r\n }\r\n\r\n public get audioNodeId(): string {\r\n return this.privAudioNodeId;\r\n }\r\n\r\n public get authFetchEventId(): string {\r\n return this.privAuthFetchEventId;\r\n }\r\n\r\n public get serviceTag(): string {\r\n return this.privServiceTag;\r\n }\r\n\r\n public get status(): RecognitionCompletionStatus {\r\n return this.privStatus;\r\n }\r\n\r\n public get error(): string {\r\n return this.privError;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ReplayableAudioNode } from \"../common.browser/Exports\";\r\nimport {\r\n ArgumentNullError,\r\n ConnectionClosedEvent,\r\n ConnectionEvent,\r\n ConnectionMessage,\r\n ConnectionOpenResponse,\r\n ConnectionState,\r\n createGuid,\r\n createNoDashGuid,\r\n Deferred,\r\n EventSource,\r\n IAudioSource,\r\n IAudioStreamNode,\r\n IConnection,\r\n IDisposable,\r\n IStreamChunk,\r\n MessageType,\r\n Promise,\r\n PromiseHelper,\r\n PromiseResult,\r\n ServiceEvent,\r\n Timeout\r\n} from \"../common/Exports\";\r\nimport { AudioStreamFormatImpl } from \"../sdk/Audio/AudioStreamFormat\";\r\nimport {\r\n CancellationErrorCode,\r\n CancellationReason,\r\n PropertyId,\r\n RecognitionEventArgs,\r\n Recognizer,\r\n SessionEventArgs,\r\n SpeechRecognitionResult,\r\n} from \"../sdk/Exports\";\r\nimport { Callback } from \"../sdk/Transcription/IConversation\";\r\nimport {\r\n AgentConfig,\r\n DynamicGrammarBuilder,\r\n ISpeechConfigAudio,\r\n ISpeechConfigAudioDevice,\r\n RecognitionMode,\r\n RequestSession,\r\n SpeechContext,\r\n SpeechDetected,\r\n} from \"./Exports\";\r\nimport {\r\n AuthInfo,\r\n IAuthentication,\r\n} from \"./IAuthentication\";\r\nimport { IConnectionFactory } from \"./IConnectionFactory\";\r\nimport { RecognizerConfig } from \"./RecognizerConfig\";\r\nimport { SpeechConnectionMessage } from \"./SpeechConnectionMessage.Internal\";\r\n\r\nexport abstract class ServiceRecognizerBase implements IDisposable {\r\n private privAuthentication: IAuthentication;\r\n private privConnectionFactory: IConnectionFactory;\r\n private privAudioSource: IAudioSource;\r\n\r\n // A promise for a configured connection.\r\n // Do not consume directly, call fetchConnection instead.\r\n private privConnectionConfigurationPromise: Promise;\r\n\r\n // A promise for a connection, but one that has not had the speech context sent yet.\r\n // Do not consume directly, call fetchConnection instead.\r\n private privConnectionPromise: Promise;\r\n private privAuthFetchEventId: string;\r\n private privIsDisposed: boolean;\r\n private privMustReportEndOfStream: boolean;\r\n private privConnectionEvents: EventSource;\r\n private privServiceEvents: EventSource;\r\n private privDynamicGrammar: DynamicGrammarBuilder;\r\n private privAgentConfig: AgentConfig;\r\n private privServiceHasSentMessage: boolean;\r\n private privActivityTemplate: string;\r\n private privSetTimeout: (cb: () => void, delay: number) => number = setTimeout;\r\n protected privSpeechContext: SpeechContext;\r\n protected privRequestSession: RequestSession;\r\n protected privConnectionId: string;\r\n protected privRecognizerConfig: RecognizerConfig;\r\n protected privRecognizer: Recognizer;\r\n protected privSuccessCallback: (e: SpeechRecognitionResult) => void;\r\n protected privErrorCallback: (e: string) => void;\r\n\r\n public constructor(\r\n authentication: IAuthentication,\r\n connectionFactory: IConnectionFactory,\r\n audioSource: IAudioSource,\r\n recognizerConfig: RecognizerConfig,\r\n recognizer: Recognizer) {\r\n\r\n if (!authentication) {\r\n throw new ArgumentNullError(\"authentication\");\r\n }\r\n\r\n if (!connectionFactory) {\r\n throw new ArgumentNullError(\"connectionFactory\");\r\n }\r\n\r\n if (!audioSource) {\r\n throw new ArgumentNullError(\"audioSource\");\r\n }\r\n\r\n if (!recognizerConfig) {\r\n throw new ArgumentNullError(\"recognizerConfig\");\r\n }\r\n\r\n this.privMustReportEndOfStream = false;\r\n this.privAuthentication = authentication;\r\n this.privConnectionFactory = connectionFactory;\r\n this.privAudioSource = audioSource;\r\n this.privRecognizerConfig = recognizerConfig;\r\n this.privIsDisposed = false;\r\n this.privRecognizer = recognizer;\r\n this.privRequestSession = new RequestSession(this.privAudioSource.id());\r\n this.privConnectionEvents = new EventSource();\r\n this.privServiceEvents = new EventSource();\r\n this.privDynamicGrammar = new DynamicGrammarBuilder();\r\n this.privSpeechContext = new SpeechContext(this.privDynamicGrammar);\r\n this.privAgentConfig = new AgentConfig();\r\n if (typeof (Blob) !== \"undefined\" && typeof (Worker) !== \"undefined\") {\r\n this.privSetTimeout = Timeout.setTimeout;\r\n }\r\n }\r\n\r\n public get audioSource(): IAudioSource {\r\n return this.privAudioSource;\r\n }\r\n\r\n public get speechContext(): SpeechContext {\r\n return this.privSpeechContext;\r\n }\r\n\r\n public get dynamicGrammar(): DynamicGrammarBuilder {\r\n return this.privDynamicGrammar;\r\n }\r\n\r\n public get agentConfig(): AgentConfig {\r\n return this.privAgentConfig;\r\n }\r\n\r\n public set conversationTranslatorToken(token: string) {\r\n this.privRecognizerConfig.parameters.setProperty(PropertyId.ConversationTranslator_Token, token);\r\n }\r\n\r\n public isDisposed(): boolean {\r\n return this.privIsDisposed;\r\n }\r\n\r\n public dispose(reason?: string): void {\r\n this.privIsDisposed = true;\r\n if (this.privConnectionConfigurationPromise) {\r\n this.privConnectionConfigurationPromise.onSuccessContinueWith((connection: IConnection) => {\r\n connection.dispose(reason);\r\n });\r\n }\r\n }\r\n\r\n public get connectionEvents(): EventSource {\r\n return this.privConnectionEvents;\r\n }\r\n\r\n public get serviceEvents(): EventSource {\r\n return this.privServiceEvents;\r\n }\r\n\r\n public get recognitionMode(): RecognitionMode {\r\n return this.privRecognizerConfig.recognitionMode;\r\n }\r\n\r\n protected recognizeOverride: (recoMode: RecognitionMode, sc: (e: SpeechRecognitionResult) => void, ec: (e: string) => void) => any = undefined;\r\n\r\n public recognize(\r\n recoMode: RecognitionMode,\r\n successCallback: (e: SpeechRecognitionResult) => void,\r\n errorCallBack: (e: string) => void,\r\n ): Promise {\r\n\r\n if (this.recognizeOverride !== undefined) {\r\n return this.recognizeOverride(recoMode, successCallback, errorCallBack);\r\n }\r\n\r\n // Clear the existing configuration promise to force a re-transmission of config and context.\r\n this.privConnectionConfigurationPromise = null;\r\n this.privRecognizerConfig.recognitionMode = recoMode;\r\n\r\n this.privSuccessCallback = successCallback;\r\n this.privErrorCallback = errorCallBack;\r\n\r\n this.privRequestSession.startNewRecognition();\r\n this.privRequestSession.listenForServiceTelemetry(this.privAudioSource.events);\r\n\r\n // Start the connection to the service. The promise this will create is stored and will be used by configureConnection().\r\n this.connectImpl();\r\n\r\n return this.audioSource\r\n .attach(this.privRequestSession.audioNodeId)\r\n .onSuccessContinueWithPromise((result: IAudioStreamNode) => {\r\n let audioNode: ReplayableAudioNode;\r\n\r\n return this.audioSource.format.onSuccessContinueWithPromise((format: AudioStreamFormatImpl) => {\r\n audioNode = new ReplayableAudioNode(result, format.avgBytesPerSec);\r\n this.privRequestSession.onAudioSourceAttachCompleted(audioNode, false);\r\n\r\n return this.audioSource.deviceInfo.onSuccessContinueWithPromise((deviceInfo: ISpeechConfigAudioDevice): Promise => {\r\n this.privRecognizerConfig.SpeechServiceConfig.Context.audio = { source: deviceInfo };\r\n\r\n return this.configureConnection()\r\n .continueWithPromise((result: PromiseResult): Promise => {\r\n if (result.isError) {\r\n this.cancelRecognitionLocal(CancellationReason.Error, CancellationErrorCode.ConnectionFailure, result.error);\r\n return PromiseHelper.fromError(result.error);\r\n }\r\n\r\n const sessionStartEventArgs: SessionEventArgs = new SessionEventArgs(this.privRequestSession.sessionId);\r\n\r\n if (!!this.privRecognizer.sessionStarted) {\r\n this.privRecognizer.sessionStarted(this.privRecognizer, sessionStartEventArgs);\r\n }\r\n\r\n const messageRetrievalPromise = this.receiveMessage();\r\n const audioSendPromise = this.sendAudio(audioNode);\r\n\r\n /* tslint:disable:no-empty */\r\n audioSendPromise.on((_: boolean) => { }, (error: string) => {\r\n this.cancelRecognitionLocal(CancellationReason.Error, CancellationErrorCode.RuntimeError, error);\r\n });\r\n return PromiseHelper.fromResult(true);\r\n });\r\n });\r\n });\r\n });\r\n }\r\n\r\n public stopRecognizing(): Promise {\r\n if (this.privRequestSession.isRecognizing) {\r\n this.audioSource.turnOff();\r\n return this.sendFinalAudio().onSuccessContinueWithPromise((_: boolean) => {\r\n this.privRequestSession.onStopRecognizing();\r\n return this.privRequestSession.turnCompletionPromise.onSuccessContinueWith((_: boolean) => {\r\n this.privRequestSession.onStopRecognizing();\r\n this.privRequestSession.dispose();\r\n return true;\r\n });\r\n });\r\n }\r\n\r\n return PromiseHelper.fromResult(true);\r\n }\r\n\r\n public connect(): void {\r\n this.connectImpl().result();\r\n }\r\n\r\n public connectAsync(cb?: Callback, err?: Callback): void {\r\n this.connectImpl().continueWith((promiseResult: PromiseResult) => {\r\n try {\r\n if (promiseResult.isError) {\r\n if (!!err) {\r\n err(promiseResult.error);\r\n }\r\n } else if (promiseResult.isCompleted) {\r\n if (!!cb) {\r\n cb();\r\n }\r\n }\r\n } catch (e) {\r\n if (!!err) {\r\n err(e);\r\n }\r\n }\r\n });\r\n }\r\n\r\n protected disconnectOverride: () => any = undefined;\r\n\r\n public disconnect(): void {\r\n if (this.disconnectOverride !== undefined) {\r\n this.disconnectOverride();\r\n return;\r\n }\r\n\r\n this.cancelRecognitionLocal(CancellationReason.Error,\r\n CancellationErrorCode.NoError,\r\n \"Disconnecting\");\r\n\r\n if (this.privConnectionPromise.result().isCompleted) {\r\n if (!this.privConnectionPromise.result().isError) {\r\n this.privConnectionPromise.result().result.dispose();\r\n this.privConnectionPromise = null;\r\n }\r\n } else {\r\n this.privConnectionPromise.onSuccessContinueWith((connection: IConnection) => {\r\n connection.dispose();\r\n });\r\n }\r\n }\r\n\r\n public disconnectAsync(cb?: Callback, err?: Callback): void {\r\n try {\r\n if (this.disconnectOverride !== undefined) {\r\n this.disconnectOverride();\r\n if (!!cb) {\r\n cb();\r\n }\r\n return;\r\n }\r\n\r\n this.cancelRecognitionLocal(CancellationReason.Error,\r\n CancellationErrorCode.NoError,\r\n \"Disconnecting\");\r\n\r\n this.privConnectionPromise.continueWith((result: PromiseResult): void => {\r\n try {\r\n if (result.isError) {\r\n if (!!err) {\r\n err(result.error);\r\n }\r\n } else if (result.isCompleted) {\r\n result.result.dispose();\r\n\r\n if (!!cb) {\r\n cb();\r\n }\r\n }\r\n } catch (e) {\r\n if (!!err) {\r\n err(e);\r\n }\r\n }\r\n });\r\n } catch (e) {\r\n if (!!err) {\r\n err(e);\r\n }\r\n }\r\n }\r\n\r\n // Called when telemetry data is sent to the service.\r\n // Used for testing Telemetry capture.\r\n public static telemetryData: (json: string) => void;\r\n public static telemetryDataEnabled: boolean = true;\r\n\r\n public sendMessage(message: string): void { }\r\n\r\n public sendNetworkMessage(path: string, payload: string | ArrayBuffer, success?: () => void, err?: (error: string) => void): void {\r\n const type: MessageType = typeof payload === \"string\" ? MessageType.Text : MessageType.Binary;\r\n const contentType: string = typeof payload === \"string\" ? \"application/json\" : \"\";\r\n\r\n this.fetchConnection().on((connection: IConnection) => {\r\n connection.send(new SpeechConnectionMessage(type, path, this.privRequestSession.requestId, contentType, payload)).on(() => {\r\n if (!!success) {\r\n success();\r\n }\r\n }, (error: string) => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n }, (error: string) => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n }\r\n\r\n public set activityTemplate(messagePayload: string) { this.privActivityTemplate = messagePayload; }\r\n public get activityTemplate(): string { return this.privActivityTemplate; }\r\n\r\n protected abstract processTypeSpecificMessages(\r\n connectionMessage: SpeechConnectionMessage,\r\n successCallback?: (e: SpeechRecognitionResult) => void,\r\n errorCallBack?: (e: string) => void): boolean;\r\n\r\n protected sendTelemetryData = () => {\r\n const telemetryData = this.privRequestSession.getTelemetry();\r\n if (ServiceRecognizerBase.telemetryDataEnabled !== true ||\r\n this.privIsDisposed ||\r\n null === telemetryData) {\r\n return PromiseHelper.fromResult(true);\r\n }\r\n\r\n if (!!ServiceRecognizerBase.telemetryData) {\r\n try {\r\n ServiceRecognizerBase.telemetryData(telemetryData);\r\n /* tslint:disable:no-empty */\r\n } catch { }\r\n }\r\n\r\n return this.fetchConnection().onSuccessContinueWith((connection: IConnection): Promise => {\r\n return connection.send(new SpeechConnectionMessage(\r\n MessageType.Text,\r\n \"telemetry\",\r\n this.privRequestSession.requestId,\r\n \"application/json\",\r\n telemetryData));\r\n });\r\n }\r\n\r\n // Cancels recognition.\r\n protected abstract cancelRecognition(\r\n sessionId: string,\r\n requestId: string,\r\n cancellationReason: CancellationReason,\r\n errorCode: CancellationErrorCode,\r\n error: string): void;\r\n\r\n // Cancels recognition.\r\n protected cancelRecognitionLocal(\r\n cancellationReason: CancellationReason,\r\n errorCode: CancellationErrorCode,\r\n error: string): void {\r\n\r\n if (!!this.privRequestSession.isRecognizing) {\r\n this.privRequestSession.onStopRecognizing();\r\n\r\n this.cancelRecognition(\r\n this.privRequestSession.sessionId,\r\n this.privRequestSession.requestId,\r\n cancellationReason,\r\n errorCode,\r\n error);\r\n }\r\n }\r\n\r\n protected receiveMessageOverride: () => any = undefined;\r\n\r\n protected receiveMessage = (): Promise => {\r\n return this.fetchConnection().on((connection: IConnection): Promise => {\r\n return connection.read()\r\n .onSuccessContinueWithPromise((message: ConnectionMessage) => {\r\n\r\n if (this.receiveMessageOverride !== undefined) {\r\n return this.receiveMessageOverride();\r\n }\r\n if (this.privIsDisposed) {\r\n // We're done.\r\n return PromiseHelper.fromResult(undefined);\r\n }\r\n\r\n // indicates we are draining the queue and it came with no message;\r\n if (!message) {\r\n if (!this.privRequestSession.isRecognizing) {\r\n return PromiseHelper.fromResult(true);\r\n } else {\r\n return this.receiveMessage();\r\n }\r\n }\r\n\r\n this.privServiceHasSentMessage = true;\r\n\r\n const connectionMessage = SpeechConnectionMessage.fromConnectionMessage(message);\r\n\r\n if (connectionMessage.requestId.toLowerCase() === this.privRequestSession.requestId.toLowerCase()) {\r\n switch (connectionMessage.path.toLowerCase()) {\r\n case \"turn.start\":\r\n this.privMustReportEndOfStream = true;\r\n this.privRequestSession.onServiceTurnStartResponse();\r\n break;\r\n case \"speech.startdetected\":\r\n const speechStartDetected: SpeechDetected = SpeechDetected.fromJSON(connectionMessage.textBody);\r\n\r\n const speechStartEventArgs = new RecognitionEventArgs(speechStartDetected.Offset, this.privRequestSession.sessionId);\r\n\r\n if (!!this.privRecognizer.speechStartDetected) {\r\n this.privRecognizer.speechStartDetected(this.privRecognizer, speechStartEventArgs);\r\n }\r\n\r\n break;\r\n case \"speech.enddetected\":\r\n\r\n let json: string;\r\n\r\n if (connectionMessage.textBody.length > 0) {\r\n json = connectionMessage.textBody;\r\n } else {\r\n // If the request was empty, the JSON returned is empty.\r\n json = \"{ Offset: 0 }\";\r\n }\r\n\r\n const speechStopDetected: SpeechDetected = SpeechDetected.fromJSON(json);\r\n\r\n // Only shrink the buffers for continuous recognition.\r\n // For single shot, the speech.phrase message will come after the speech.end and it should own buffer shrink.\r\n if (this.privRecognizerConfig.isContinuousRecognition) {\r\n this.privRequestSession.onServiceRecognized(speechStopDetected.Offset + this.privRequestSession.currentTurnAudioOffset);\r\n }\r\n\r\n const speechStopEventArgs = new RecognitionEventArgs(speechStopDetected.Offset + this.privRequestSession.currentTurnAudioOffset, this.privRequestSession.sessionId);\r\n\r\n if (!!this.privRecognizer.speechEndDetected) {\r\n this.privRecognizer.speechEndDetected(this.privRecognizer, speechStopEventArgs);\r\n }\r\n break;\r\n case \"turn.end\":\r\n this.sendTelemetryData();\r\n\r\n if (this.privRequestSession.isSpeechEnded && this.privMustReportEndOfStream) {\r\n this.privMustReportEndOfStream = false;\r\n this.cancelRecognitionLocal(CancellationReason.EndOfStream, CancellationErrorCode.NoError, undefined);\r\n }\r\n\r\n const sessionStopEventArgs: SessionEventArgs = new SessionEventArgs(this.privRequestSession.sessionId);\r\n this.privRequestSession.onServiceTurnEndResponse(this.privRecognizerConfig.isContinuousRecognition);\r\n\r\n if (!this.privRecognizerConfig.isContinuousRecognition || this.privRequestSession.isSpeechEnded || !this.privRequestSession.isRecognizing) {\r\n if (!!this.privRecognizer.sessionStopped) {\r\n this.privRecognizer.sessionStopped(this.privRecognizer, sessionStopEventArgs);\r\n }\r\n\r\n return PromiseHelper.fromResult(true);\r\n } else {\r\n this.fetchConnection().onSuccessContinueWith((connection: IConnection) => {\r\n this.sendSpeechContext(connection);\r\n this.sendWaveHeader(connection);\r\n });\r\n }\r\n break;\r\n\r\n default:\r\n\r\n if (!this.processTypeSpecificMessages(connectionMessage)) {\r\n // here are some messages that the derived class has not processed, dispatch them to connect class\r\n if (!!this.privServiceEvents) {\r\n this.serviceEvents.onEvent(new ServiceEvent(connectionMessage.path.toLowerCase(), connectionMessage.textBody));\r\n }\r\n }\r\n\r\n }\r\n }\r\n\r\n return this.receiveMessage();\r\n });\r\n }, (error: string) => {\r\n });\r\n }\r\n\r\n protected sendSpeechContext = (connection: IConnection): Promise => {\r\n const speechContextJson = this.speechContext.toJSON();\r\n\r\n if (speechContextJson) {\r\n return connection.send(new SpeechConnectionMessage(\r\n MessageType.Text,\r\n \"speech.context\",\r\n this.privRequestSession.requestId,\r\n \"application/json\",\r\n speechContextJson));\r\n }\r\n return PromiseHelper.fromResult(true);\r\n }\r\n\r\n protected sendWaveHeader(connection: IConnection): Promise {\r\n return this.audioSource.format.onSuccessContinueWithPromise((format: AudioStreamFormatImpl) => {\r\n // this.writeBufferToConsole(format.header);\r\n return connection.send(new SpeechConnectionMessage(\r\n MessageType.Binary,\r\n \"audio\",\r\n this.privRequestSession.requestId,\r\n \"audio/x-wav\",\r\n format.header\r\n ));\r\n });\r\n }\r\n\r\n protected connectImplOverride: (isUnAuthorized: boolean) => any = undefined;\r\n\r\n // Establishes a websocket connection to the end point.\r\n protected connectImpl(isUnAuthorized: boolean = false): Promise {\r\n\r\n if (this.connectImplOverride !== undefined) {\r\n return this.connectImplOverride(isUnAuthorized);\r\n }\r\n\r\n if (this.privConnectionPromise) {\r\n if (this.privConnectionPromise.result().isCompleted &&\r\n (this.privConnectionPromise.result().isError\r\n || this.privConnectionPromise.result().result.state() === ConnectionState.Disconnected) &&\r\n this.privServiceHasSentMessage === true) {\r\n this.privConnectionId = null;\r\n this.privConnectionPromise = null;\r\n this.privServiceHasSentMessage = false;\r\n return this.connectImpl();\r\n } else {\r\n return this.privConnectionPromise;\r\n }\r\n }\r\n\r\n this.privAuthFetchEventId = createNoDashGuid();\r\n this.privConnectionId = createNoDashGuid();\r\n\r\n this.privRequestSession.onPreConnectionStart(this.privAuthFetchEventId, this.privConnectionId);\r\n\r\n const authPromise = isUnAuthorized ? this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId) : this.privAuthentication.fetch(this.privAuthFetchEventId);\r\n\r\n this.privConnectionPromise = authPromise\r\n .continueWithPromise((result: PromiseResult) => {\r\n if (result.isError) {\r\n this.privRequestSession.onAuthCompleted(true, result.error);\r\n throw new Error(result.error);\r\n } else {\r\n this.privRequestSession.onAuthCompleted(false);\r\n }\r\n\r\n const connection: IConnection = this.privConnectionFactory.create(this.privRecognizerConfig, result.result, this.privConnectionId);\r\n\r\n this.privRequestSession.listenForServiceTelemetry(connection.events);\r\n\r\n // Attach to the underlying event. No need to hold onto the detach pointers as in the event the connection goes away,\r\n // it'll stop sending events.\r\n connection.events.attach((event: ConnectionEvent) => {\r\n this.connectionEvents.onEvent(event);\r\n });\r\n\r\n return connection.open().onSuccessContinueWithPromise((response: ConnectionOpenResponse): Promise => {\r\n if (response.statusCode === 200) {\r\n this.privRequestSession.onPreConnectionStart(this.privAuthFetchEventId, this.privConnectionId);\r\n this.privRequestSession.onConnectionEstablishCompleted(response.statusCode);\r\n\r\n return PromiseHelper.fromResult(connection);\r\n } else if (response.statusCode === 403 && !isUnAuthorized) {\r\n return this.connectImpl(true);\r\n } else {\r\n this.privRequestSession.onConnectionEstablishCompleted(response.statusCode, response.reason);\r\n return PromiseHelper.fromError(`Unable to contact server. StatusCode: ${response.statusCode}, ${this.privRecognizerConfig.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint)} Reason: ${response.reason}`);\r\n }\r\n });\r\n });\r\n\r\n return this.privConnectionPromise;\r\n }\r\n\r\n protected configConnectionOverride: () => any = undefined;\r\n\r\n protected fetchConnectionOverride: () => any = undefined;\r\n\r\n protected sendSpeechServiceConfig = (connection: IConnection, requestSession: RequestSession, SpeechServiceConfigJson: string): Promise => {\r\n // filter out anything that is not required for the service to work.\r\n if (ServiceRecognizerBase.telemetryDataEnabled !== true) {\r\n const withTelemetry = JSON.parse(SpeechServiceConfigJson);\r\n\r\n const replacement: any = {\r\n context: {\r\n system: withTelemetry.context.system,\r\n },\r\n };\r\n\r\n SpeechServiceConfigJson = JSON.stringify(replacement);\r\n }\r\n\r\n if (SpeechServiceConfigJson) { // && this.privConnectionId !== this.privSpeechServiceConfigConnectionId) {\r\n // this.privSpeechServiceConfigConnectionId = this.privConnectionId;\r\n return connection.send(new SpeechConnectionMessage(\r\n MessageType.Text,\r\n \"speech.config\",\r\n requestSession.requestId,\r\n \"application/json\",\r\n SpeechServiceConfigJson));\r\n }\r\n\r\n return PromiseHelper.fromResult(true);\r\n }\r\n\r\n protected sendAudio = (\r\n audioStreamNode: IAudioStreamNode): Promise => {\r\n return this.audioSource.format.onSuccessContinueWithPromise((audioFormat: AudioStreamFormatImpl) => {\r\n // NOTE: Home-baked promises crash ios safari during the invocation\r\n // of the error callback chain (looks like the recursion is way too deep, and\r\n // it blows up the stack). The following construct is a stop-gap that does not\r\n // bubble the error up the callback chain and hence circumvents this problem.\r\n // TODO: rewrite with ES6 promises.\r\n const deferred = new Deferred();\r\n\r\n // The time we last sent data to the service.\r\n let nextSendTime: number = Date.now();\r\n\r\n // Max amount to send before we start to throttle\r\n const fastLaneSizeMs: string = this.privRecognizerConfig.parameters.getProperty(\"SPEECH-TransmitLengthBeforThrottleMs\", \"5000\");\r\n const maxSendUnthrottledBytes: number = audioFormat.avgBytesPerSec / 1000 * parseInt(fastLaneSizeMs, 10);\r\n const startRecogNumber: number = this.privRequestSession.recogNumber;\r\n\r\n const readAndUploadCycle = () => {\r\n\r\n // If speech is done, stop sending audio.\r\n if (!this.privIsDisposed &&\r\n !this.privRequestSession.isSpeechEnded &&\r\n this.privRequestSession.isRecognizing &&\r\n this.privRequestSession.recogNumber === startRecogNumber) {\r\n this.fetchConnection().on((connection: IConnection) => {\r\n audioStreamNode.read().on(\r\n (audioStreamChunk: IStreamChunk) => {\r\n // we have a new audio chunk to upload.\r\n if (this.privRequestSession.isSpeechEnded) {\r\n // If service already recognized audio end then don't send any more audio\r\n deferred.resolve(true);\r\n return;\r\n }\r\n\r\n let payload: ArrayBuffer;\r\n let sendDelay: number;\r\n\r\n if (!audioStreamChunk || audioStreamChunk.isEnd) {\r\n payload = null;\r\n sendDelay = 0;\r\n } else {\r\n payload = audioStreamChunk.buffer;\r\n this.privRequestSession.onAudioSent(payload.byteLength);\r\n\r\n if (maxSendUnthrottledBytes >= this.privRequestSession.bytesSent) {\r\n sendDelay = 0;\r\n } else {\r\n sendDelay = Math.max(0, nextSendTime - Date.now());\r\n }\r\n }\r\n\r\n // Are we ready to send, or need we delay more?\r\n this.privSetTimeout(() => {\r\n if (payload !== null) {\r\n nextSendTime = Date.now() + (payload.byteLength * 1000 / (audioFormat.avgBytesPerSec * 2));\r\n }\r\n\r\n const uploaded: Promise = connection.send(\r\n new SpeechConnectionMessage(\r\n MessageType.Binary, \"audio\", this.privRequestSession.requestId, null, payload));\r\n\r\n if (!audioStreamChunk?.isEnd) {\r\n uploaded.continueWith((_: PromiseResult) => {\r\n // this.writeBufferToConsole(payload);\r\n // Regardless of success or failure, schedule the next upload.\r\n // If the underlying connection was broken, the next cycle will\r\n // get a new connection and re-transmit missing audio automatically.\r\n readAndUploadCycle();\r\n });\r\n } else {\r\n // the audio stream has been closed, no need to schedule next\r\n // read-upload cycle.\r\n this.privRequestSession.onSpeechEnded();\r\n deferred.resolve(true);\r\n }\r\n }, sendDelay);\r\n },\r\n (error: string) => {\r\n if (this.privRequestSession.isSpeechEnded) {\r\n // For whatever reason, Reject is used to remove queue subscribers inside\r\n // the Queue.DrainAndDispose invoked from DetachAudioNode down below, which\r\n // means that sometimes things can be rejected in normal circumstances, without\r\n // any errors.\r\n deferred.resolve(true); // TODO: remove the argument, it's is completely meaningless.\r\n } else {\r\n // Only reject, if there was a proper error.\r\n deferred.reject(error);\r\n }\r\n });\r\n }, (error: string) => {\r\n deferred.reject(error);\r\n });\r\n }\r\n };\r\n\r\n readAndUploadCycle();\r\n\r\n return deferred.promise();\r\n });\r\n }\r\n\r\n private writeBufferToConsole(buffer: ArrayBuffer): void {\r\n let out: string = \"Buffer Size: \";\r\n if (null === buffer) {\r\n out += \"null\";\r\n } else {\r\n const readView: Uint8Array = new Uint8Array(buffer);\r\n out += buffer.byteLength + \"\\r\\n\";\r\n for (let i: number = 0; i < buffer.byteLength; i++) {\r\n out += readView[i].toString(16).padStart(2, \"0\") + \" \";\r\n }\r\n }\r\n // tslint:disable-next-line:no-console\r\n console.info(out);\r\n }\r\n\r\n private sendFinalAudio(): Promise {\r\n const deferred = new Deferred();\r\n\r\n this.fetchConnection().on((connection: IConnection) => {\r\n connection.send(new SpeechConnectionMessage(MessageType.Binary, \"audio\", this.privRequestSession.requestId, null, null)).on((_: boolean) => {\r\n deferred.resolve(true);\r\n }, (error: string) => {\r\n deferred.reject(error);\r\n });\r\n }, (error: string) => {\r\n deferred.reject(error);\r\n });\r\n\r\n return deferred.promise();\r\n }\r\n\r\n private fetchConnection = (): Promise => {\r\n if (this.fetchConnectionOverride !== undefined) {\r\n return this.fetchConnectionOverride();\r\n }\r\n\r\n return this.configureConnection();\r\n }\r\n\r\n // Takes an established websocket connection to the endpoint and sends speech configuration information.\r\n private configureConnection(): Promise {\r\n if (this.configConnectionOverride !== undefined) {\r\n return this.configConnectionOverride();\r\n }\r\n\r\n if (this.privConnectionConfigurationPromise) {\r\n if (this.privConnectionConfigurationPromise.result().isCompleted &&\r\n (this.privConnectionConfigurationPromise.result().isError\r\n || this.privConnectionConfigurationPromise.result().result.state() === ConnectionState.Disconnected)) {\r\n\r\n this.privConnectionConfigurationPromise = null;\r\n return this.configureConnection();\r\n } else {\r\n return this.privConnectionConfigurationPromise;\r\n }\r\n }\r\n\r\n this.privConnectionConfigurationPromise = this.connectImpl().onSuccessContinueWithPromise((connection: IConnection): Promise => {\r\n return this.sendSpeechServiceConfig(connection, this.privRequestSession, this.privRecognizerConfig.SpeechServiceConfig.serialize())\r\n .onSuccessContinueWithPromise((_: boolean) => {\r\n return this.sendSpeechContext(connection).onSuccessContinueWithPromise((_: boolean) => {\r\n return this.sendWaveHeader(connection).onSuccessContinueWith((_: boolean) => {\r\n return connection;\r\n });\r\n });\r\n });\r\n });\r\n\r\n return this.privConnectionConfigurationPromise;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ArgumentNullError, ConnectionMessage, IStringDictionary, MessageType } from \"../common/Exports\";\r\n\r\nconst PathHeaderName: string = \"Path\";\r\nconst ContentTypeHeaderName: string = \"Content-Type\";\r\nconst RequestIdHeaderName: string = \"X-RequestId\";\r\nconst RequestTimestampHeaderName: string = \"X-Timestamp\";\r\nconst RequestStreamIdHeaderName: string = \"x-streamid\";\r\n\r\nexport class SpeechConnectionMessage extends ConnectionMessage {\r\n\r\n private privPath: string;\r\n private privRequestId: string;\r\n private privContentType: string;\r\n private privStreamId: string;\r\n private privAdditionalHeaders: IStringDictionary;\r\n\r\n public constructor(\r\n messageType: MessageType,\r\n path: string,\r\n requestId: string,\r\n contentType: string,\r\n body: any,\r\n streamId?: string,\r\n additionalHeaders?: IStringDictionary,\r\n id?: string) {\r\n\r\n if (!path) {\r\n throw new ArgumentNullError(\"path\");\r\n }\r\n\r\n if (!requestId) {\r\n throw new ArgumentNullError(\"requestId\");\r\n }\r\n\r\n const headers: IStringDictionary = {};\r\n headers[PathHeaderName] = path;\r\n headers[RequestIdHeaderName] = requestId;\r\n headers[RequestTimestampHeaderName] = new Date().toISOString();\r\n if (contentType) {\r\n headers[ContentTypeHeaderName] = contentType;\r\n }\r\n\r\n if (streamId) {\r\n headers[RequestStreamIdHeaderName] = streamId;\r\n }\r\n\r\n if (additionalHeaders) {\r\n for (const headerName in additionalHeaders) {\r\n if (headerName) {\r\n headers[headerName] = additionalHeaders[headerName];\r\n }\r\n\r\n }\r\n }\r\n\r\n if (id) {\r\n super(messageType, body, headers, id);\r\n } else {\r\n super(messageType, body, headers);\r\n }\r\n\r\n this.privPath = path;\r\n this.privRequestId = requestId;\r\n this.privContentType = contentType;\r\n this.privStreamId = streamId;\r\n this.privAdditionalHeaders = additionalHeaders;\r\n }\r\n\r\n public get path(): string {\r\n return this.privPath;\r\n }\r\n\r\n public get requestId(): string {\r\n return this.privRequestId;\r\n }\r\n\r\n public get contentType(): string {\r\n return this.privContentType;\r\n }\r\n\r\n public get streamId(): string {\r\n return this.privStreamId;\r\n }\r\n\r\n public get additionalHeaders(): IStringDictionary {\r\n return this.privAdditionalHeaders;\r\n }\r\n\r\n public static fromConnectionMessage = (message: ConnectionMessage): SpeechConnectionMessage => {\r\n let path = null;\r\n let requestId = null;\r\n let contentType = null;\r\n let requestTimestamp = null;\r\n let streamId = null;\r\n const additionalHeaders: IStringDictionary = {};\r\n\r\n if (message.headers) {\r\n for (const headerName in message.headers) {\r\n if (headerName) {\r\n if (headerName.toLowerCase() === PathHeaderName.toLowerCase()) {\r\n path = message.headers[headerName];\r\n } else if (headerName.toLowerCase() === RequestIdHeaderName.toLowerCase()) {\r\n requestId = message.headers[headerName];\r\n } else if (headerName.toLowerCase() === RequestTimestampHeaderName.toLowerCase()) {\r\n requestTimestamp = message.headers[headerName];\r\n } else if (headerName.toLowerCase() === ContentTypeHeaderName.toLowerCase()) {\r\n contentType = message.headers[headerName];\r\n } else if (headerName.toLowerCase() === RequestStreamIdHeaderName.toLowerCase()) {\r\n streamId = message.headers[headerName];\r\n } else {\r\n additionalHeaders[headerName] = message.headers[headerName];\r\n }\r\n }\r\n }\r\n }\r\n\r\n return new SpeechConnectionMessage(\r\n message.messageType,\r\n path,\r\n requestId,\r\n contentType,\r\n message.body,\r\n streamId,\r\n additionalHeaders,\r\n message.id);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { PropertyCollection, PropertyId } from \"../sdk/Exports\";\r\n\r\nexport enum RecognitionMode {\r\n Interactive,\r\n Conversation,\r\n Dictation,\r\n}\r\n\r\nexport enum SpeechResultFormat {\r\n Simple,\r\n Detailed,\r\n}\r\n\r\nexport class RecognizerConfig {\r\n private privRecognitionMode: RecognitionMode = RecognitionMode.Interactive;\r\n private privSpeechServiceConfig: SpeechServiceConfig;\r\n private privRecognitionActivityTimeout: number;\r\n private privParameters: PropertyCollection;\r\n\r\n constructor(\r\n speechServiceConfig: SpeechServiceConfig,\r\n parameters: PropertyCollection) {\r\n this.privSpeechServiceConfig = speechServiceConfig ? speechServiceConfig : new SpeechServiceConfig(new Context(null));\r\n this.privParameters = parameters;\r\n }\r\n\r\n public get parameters(): PropertyCollection {\r\n return this.privParameters;\r\n }\r\n\r\n public get recognitionMode(): RecognitionMode {\r\n return this.privRecognitionMode;\r\n }\r\n\r\n public set recognitionMode(value: RecognitionMode) {\r\n this.privRecognitionMode = value;\r\n this.privRecognitionActivityTimeout = value === RecognitionMode.Interactive ? 8000 : 25000;\r\n this.privSpeechServiceConfig.Recognition = RecognitionMode[value];\r\n }\r\n\r\n public get SpeechServiceConfig(): SpeechServiceConfig {\r\n return this.privSpeechServiceConfig;\r\n }\r\n\r\n public get recognitionActivityTimeout(): number {\r\n return this.privRecognitionActivityTimeout;\r\n }\r\n\r\n public get isContinuousRecognition(): boolean {\r\n return this.privRecognitionMode !== RecognitionMode.Interactive;\r\n }\r\n\r\n public get autoDetectSourceLanguages(): string {\r\n return this.parameters.getProperty(PropertyId.SpeechServiceConnection_AutoDetectSourceLanguages, undefined);\r\n }\r\n}\r\n\r\n// The config is serialized and sent as the Speech.Config\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class SpeechServiceConfig {\r\n private context: Context;\r\n private recognition: string;\r\n\r\n constructor(context: Context) {\r\n this.context = context;\r\n }\r\n\r\n public serialize = (): string => {\r\n return JSON.stringify(this, (key: any, value: any): any => {\r\n if (value && typeof value === \"object\") {\r\n const replacement: any = {};\r\n for (const k in value) {\r\n if (Object.hasOwnProperty.call(value, k)) {\r\n replacement[k && k.charAt(0).toLowerCase() + k.substring(1)] = value[k];\r\n }\r\n }\r\n return replacement;\r\n }\r\n return value;\r\n });\r\n }\r\n\r\n public get Context(): Context {\r\n return this.context;\r\n }\r\n\r\n public get Recognition(): string {\r\n return this.recognition;\r\n }\r\n\r\n public set Recognition(value: string) {\r\n this.recognition = value.toLowerCase();\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class Context {\r\n public system: System;\r\n public os: OS;\r\n public audio: ISpeechConfigAudio;\r\n\r\n constructor(os: OS) {\r\n this.system = new System();\r\n this.os = os;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class System {\r\n public name: string;\r\n public version: string;\r\n public build: string;\r\n public lang: string;\r\n\r\n constructor() {\r\n // Note: below will be patched for official builds.\r\n const SPEECHSDK_CLIENTSDK_VERSION = \"1.13.0\";\r\n\r\n this.name = \"SpeechSDK\";\r\n this.version = SPEECHSDK_CLIENTSDK_VERSION;\r\n this.build = \"JavaScript\";\r\n this.lang = \"JavaScript\";\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class OS {\r\n public platform: string;\r\n public name: string;\r\n public version: string;\r\n\r\n constructor(platform: string, name: string, version: string) {\r\n this.platform = platform;\r\n this.name = name;\r\n this.version = version;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class Device {\r\n public manufacturer: string;\r\n public model: string;\r\n public version: string;\r\n\r\n constructor(manufacturer: string, model: string, version: string) {\r\n this.manufacturer = manufacturer;\r\n this.model = model;\r\n this.version = version;\r\n }\r\n}\r\n\r\nexport interface ISpeechConfigAudio {\r\n source?: ISpeechConfigAudioDevice;\r\n playback?: ISpeechConfigAudioDevice;\r\n}\r\n\r\nexport interface ISpeechConfigAudioDevice {\r\n manufacturer: string;\r\n model: string;\r\n connectivity: connectivity;\r\n type: type;\r\n samplerate: number;\r\n bitspersample: number;\r\n channelcount: number;\r\n}\r\n\r\nexport enum connectivity {\r\n Bluetooth = \"Bluetooth\",\r\n Wired = \"Wired\",\r\n WiFi = \"WiFi\",\r\n Cellular = \"Cellular\",\r\n InBuilt = \"InBuilt\",\r\n Unknown = \"Unknown\",\r\n}\r\n\r\nexport enum type {\r\n Phone = \"Phone\",\r\n Speaker = \"Speaker\",\r\n Car = \"Car\",\r\n Headset = \"Headset\",\r\n Thermostat = \"Thermostat\",\r\n Microphones = \"Microphones\",\r\n Deskphone = \"Deskphone\",\r\n RemoteControl = \"RemoteControl\",\r\n Unknown = \"Unknown\",\r\n File = \"File\",\r\n Stream = \"Stream\",\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n ConnectionMessage,\r\n Deferred,\r\n IStringDictionary,\r\n IWebsocketMessageFormatter,\r\n MessageType,\r\n Promise,\r\n RawWebsocketMessage,\r\n} from \"../common/Exports\";\r\n\r\nconst CRLF: string = \"\\r\\n\";\r\n\r\nexport class WebsocketMessageFormatter implements IWebsocketMessageFormatter {\r\n\r\n public toConnectionMessage = (message: RawWebsocketMessage): Promise => {\r\n const deferral = new Deferred();\r\n\r\n try {\r\n if (message.messageType === MessageType.Text) {\r\n const textMessage: string = message.textContent;\r\n let headers: IStringDictionary = {};\r\n let body: string = null;\r\n\r\n if (textMessage) {\r\n const headerBodySplit = textMessage.split(\"\\r\\n\\r\\n\");\r\n if (headerBodySplit && headerBodySplit.length > 0) {\r\n headers = this.parseHeaders(headerBodySplit[0]);\r\n if (headerBodySplit.length > 1) {\r\n body = headerBodySplit[1];\r\n }\r\n }\r\n }\r\n\r\n deferral.resolve(new ConnectionMessage(message.messageType, body, headers, message.id));\r\n } else if (message.messageType === MessageType.Binary) {\r\n const binaryMessage: ArrayBuffer = message.binaryContent;\r\n let headers: IStringDictionary = {};\r\n let body: ArrayBuffer = null;\r\n\r\n if (!binaryMessage || binaryMessage.byteLength < 2) {\r\n throw new Error(\"Invalid binary message format. Header length missing.\");\r\n }\r\n\r\n const dataView = new DataView(binaryMessage);\r\n const headerLength = dataView.getInt16(0);\r\n\r\n if (binaryMessage.byteLength < headerLength + 2) {\r\n throw new Error(\"Invalid binary message format. Header content missing.\");\r\n }\r\n\r\n let headersString = \"\";\r\n for (let i = 0; i < headerLength; i++) {\r\n headersString += String.fromCharCode((dataView).getInt8(i + 2));\r\n }\r\n\r\n headers = this.parseHeaders(headersString);\r\n\r\n if (binaryMessage.byteLength > headerLength + 2) {\r\n body = binaryMessage.slice(2 + headerLength);\r\n }\r\n\r\n deferral.resolve(new ConnectionMessage(message.messageType, body, headers, message.id));\r\n }\r\n } catch (e) {\r\n deferral.reject(`Error formatting the message. Error: ${e}`);\r\n }\r\n\r\n return deferral.promise();\r\n }\r\n\r\n public fromConnectionMessage = (message: ConnectionMessage): Promise => {\r\n const deferral = new Deferred();\r\n\r\n try {\r\n if (message.messageType === MessageType.Text) {\r\n const payload = `${this.makeHeaders(message)}${CRLF}${message.textBody ? message.textBody : \"\"}`;\r\n\r\n deferral.resolve(new RawWebsocketMessage(MessageType.Text, payload, message.id));\r\n\r\n } else if (message.messageType === MessageType.Binary) {\r\n const headersString = this.makeHeaders(message);\r\n const content = message.binaryBody;\r\n\r\n const headerInt8Array = new Int8Array(this.stringToArrayBuffer(headersString));\r\n\r\n const payload = new ArrayBuffer(2 + headerInt8Array.byteLength + (content ? content.byteLength : 0));\r\n const dataView = new DataView(payload);\r\n\r\n dataView.setInt16(0, headerInt8Array.length);\r\n\r\n for (let i = 0; i < headerInt8Array.byteLength; i++) {\r\n dataView.setInt8(2 + i, headerInt8Array[i]);\r\n }\r\n\r\n if (content) {\r\n const bodyInt8Array = new Int8Array(content);\r\n for (let i = 0; i < bodyInt8Array.byteLength; i++) {\r\n dataView.setInt8(2 + headerInt8Array.byteLength + i, bodyInt8Array[i]);\r\n }\r\n }\r\n\r\n deferral.resolve(new RawWebsocketMessage(MessageType.Binary, payload, message.id));\r\n }\r\n } catch (e) {\r\n deferral.reject(`Error formatting the message. ${e}`);\r\n }\r\n\r\n return deferral.promise();\r\n }\r\n\r\n private makeHeaders = (message: ConnectionMessage): string => {\r\n let headersString: string = \"\";\r\n\r\n if (message.headers) {\r\n for (const header in message.headers) {\r\n if (header) {\r\n headersString += `${header}: ${message.headers[header]}${CRLF}`;\r\n }\r\n }\r\n }\r\n\r\n return headersString;\r\n }\r\n\r\n private parseHeaders = (headersString: string): IStringDictionary => {\r\n const headers: IStringDictionary = {};\r\n\r\n if (headersString) {\r\n const headerMatches = headersString.match(/[^\\r\\n]+/g);\r\n if (headers) {\r\n for (const header of headerMatches) {\r\n if (header) {\r\n const separatorIndex = header.indexOf(\":\");\r\n const headerName = separatorIndex > 0 ? header.substr(0, separatorIndex).trim().toLowerCase() : header;\r\n const headerValue =\r\n separatorIndex > 0 && header.length > (separatorIndex + 1) ?\r\n header.substr(separatorIndex + 1).trim() :\r\n \"\";\r\n\r\n headers[headerName] = headerValue;\r\n }\r\n }\r\n }\r\n }\r\n\r\n return headers;\r\n }\r\n\r\n private stringToArrayBuffer = (str: string): ArrayBuffer => {\r\n const buffer = new ArrayBuffer(str.length);\r\n const view = new DataView(buffer);\r\n for (let i = 0; i < str.length; i++) {\r\n view.setUint8(i, str.charCodeAt(i));\r\n }\r\n return buffer;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n ProxyInfo,\r\n WebsocketConnection,\r\n} from \"../common.browser/Exports\";\r\nimport {\r\n IConnection,\r\n IStringDictionary,\r\n} from \"../common/Exports\";\r\nimport {\r\n PropertyId\r\n} from \"../sdk/Exports\";\r\nimport {\r\n ConnectionFactoryBase\r\n} from \"./ConnectionFactoryBase\";\r\nimport {\r\n AuthInfo,\r\n IConnectionFactory,\r\n RecognizerConfig,\r\n WebsocketMessageFormatter,\r\n} from \"./Exports\";\r\nimport { QueryParameterNames } from \"./QueryParameterNames\";\r\n\r\nconst TestHooksParamName: string = \"testhooks\";\r\nconst ConnectionIdHeader: string = \"X-ConnectionId\";\r\n\r\nexport class TranslationConnectionFactory extends ConnectionFactoryBase {\r\n\r\n public create = (\r\n config: RecognizerConfig,\r\n authInfo: AuthInfo,\r\n connectionId?: string): IConnection => {\r\n\r\n let endpoint: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint, undefined);\r\n if (!endpoint) {\r\n const region: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Region, undefined);\r\n const hostSuffix: string = (region && region.toLowerCase().startsWith(\"china\")) ? \".azure.cn\" : \".microsoft.com\";\r\n const host: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, \"wss://\" + region + \".s2s.speech\" + hostSuffix);\r\n endpoint = host + \"/speech/translation/cognitiveservices/v1\";\r\n }\r\n\r\n const queryParams: IStringDictionary = {\r\n from: config.parameters.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage),\r\n to: config.parameters.getProperty(PropertyId.SpeechServiceConnection_TranslationToLanguages),\r\n };\r\n\r\n this.setCommonUrlParams(config, queryParams, endpoint);\r\n this.setUrlParameter(\r\n PropertyId.SpeechServiceResponse_TranslationRequestStablePartialResult,\r\n QueryParameterNames.StableTranslation,\r\n config,\r\n queryParams,\r\n endpoint\r\n );\r\n\r\n const voiceName: string = \"voice\";\r\n const featureName: string = \"features\";\r\n\r\n if (config.parameters.getProperty(PropertyId.SpeechServiceConnection_TranslationVoice, undefined) !== undefined) {\r\n queryParams[voiceName] = config.parameters.getProperty(PropertyId.SpeechServiceConnection_TranslationVoice);\r\n queryParams[featureName] = \"texttospeech\";\r\n }\r\n\r\n const headers: IStringDictionary = {};\r\n if (authInfo.token !== undefined && authInfo.token !== \"\") {\r\n headers[authInfo.headerName] = authInfo.token;\r\n }\r\n headers[ConnectionIdHeader] = connectionId;\r\n\r\n config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, endpoint);\r\n\r\n return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), connectionId);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n ProxyInfo,\r\n WebsocketConnection, WebsocketMessageAdapter,\r\n} from \"../common.browser/Exports\";\r\nimport {\r\n IConnection,\r\n IStringDictionary\r\n} from \"../common/Exports\";\r\nimport { PropertyId } from \"../sdk/Exports\";\r\nimport {\r\n AuthInfo,\r\n SynthesizerConfig,\r\n WebsocketMessageFormatter\r\n} from \"./Exports\";\r\nimport { ISynthesisConnectionFactory } from \"./ISynthesisConnectionFactory\";\r\nimport {\r\n QueryParameterNames\r\n} from \"./QueryParameterNames\";\r\n\r\nexport class SpeechSynthesisConnectionFactory implements ISynthesisConnectionFactory {\r\n\r\n private readonly synthesisUri: string = \"/cognitiveservices/websocket/v1\";\r\n\r\n public create = (\r\n config: SynthesizerConfig,\r\n authInfo: AuthInfo,\r\n connectionId?: string): IConnection => {\r\n\r\n let endpoint: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint, undefined);\r\n const region: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Region, undefined);\r\n const hostSuffix = (region && region.toLowerCase().startsWith(\"china\")) ? \".azure.cn\" : \".microsoft.com\";\r\n const host: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, \"wss://\" + region + \".tts.speech\" + hostSuffix);\r\n\r\n const queryParams: IStringDictionary = {};\r\n\r\n if (!endpoint) {\r\n endpoint = host + this.synthesisUri;\r\n }\r\n\r\n const headers: IStringDictionary = {};\r\n if (authInfo.token !== undefined && authInfo.token !== \"\") {\r\n headers[authInfo.headerName] = authInfo.token;\r\n }\r\n headers[QueryParameterNames.ConnectionIdHeader] = connectionId;\r\n\r\n config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, endpoint);\r\n\r\n return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromParameters(config.parameters), connectionId);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n CancellationErrorCode,\r\n CancellationReason,\r\n ResultReason\r\n} from \"../sdk/Exports\";\r\nimport { RecognitionStatus } from \"./Exports\";\r\n\r\nexport class EnumTranslation {\r\n public static implTranslateRecognitionResult(recognitionStatus: RecognitionStatus): ResultReason {\r\n let reason = ResultReason.Canceled;\r\n switch (recognitionStatus) {\r\n case RecognitionStatus.Success:\r\n reason = ResultReason.RecognizedSpeech;\r\n break;\r\n case RecognitionStatus.NoMatch:\r\n case RecognitionStatus.InitialSilenceTimeout:\r\n case RecognitionStatus.BabbleTimeout:\r\n case RecognitionStatus.EndOfDictation:\r\n reason = ResultReason.NoMatch;\r\n break;\r\n case RecognitionStatus.Error:\r\n default:\r\n reason = ResultReason.Canceled;\r\n break;\r\n }\r\n return reason;\r\n }\r\n\r\n public static implTranslateCancelResult(recognitionStatus: RecognitionStatus): CancellationReason {\r\n let reason = CancellationReason.EndOfStream;\r\n switch (recognitionStatus) {\r\n case RecognitionStatus.Success:\r\n case RecognitionStatus.EndOfDictation:\r\n case RecognitionStatus.NoMatch:\r\n reason = CancellationReason.EndOfStream;\r\n break;\r\n case RecognitionStatus.InitialSilenceTimeout:\r\n case RecognitionStatus.BabbleTimeout:\r\n case RecognitionStatus.Error:\r\n default:\r\n reason = CancellationReason.Error;\r\n break;\r\n }\r\n return reason;\r\n }\r\n\r\n public static implTranslateCancelErrorCode(recognitionStatus: RecognitionStatus): CancellationErrorCode {\r\n let reason: CancellationErrorCode = CancellationErrorCode.NoError;\r\n switch (recognitionStatus) {\r\n case RecognitionStatus.Error:\r\n reason = CancellationErrorCode.ServiceError;\r\n break;\r\n case RecognitionStatus.TooManyRequests:\r\n reason = CancellationErrorCode.TooManyRequests;\r\n break;\r\n default:\r\n reason = CancellationErrorCode.NoError;\r\n break;\r\n }\r\n\r\n return reason;\r\n\r\n }\r\n\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * @class SynthesisStatus\r\n * @private\r\n */\r\nexport enum SynthesisStatus {\r\n /**\r\n * The response contains valid audio data.\r\n * @member SynthesisStatus.Success\r\n */\r\n Success,\r\n\r\n /**\r\n * Indicates the end of audio data. No valid audio data is included in the message.\r\n * @member SynthesisStatus.SynthesisEnd\r\n */\r\n SynthesisEnd,\r\n\r\n /**\r\n * Indicates an error occurred during synthesis data processing.\r\n * @member SynthesisStatus.Error\r\n */\r\n Error,\r\n}\r\n\r\nexport enum RecognitionStatus {\r\n Success,\r\n NoMatch,\r\n InitialSilenceTimeout,\r\n BabbleTimeout,\r\n Error,\r\n EndOfDictation,\r\n TooManyRequests,\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { SynthesisStatus } from \"../Exports\";\r\n\r\n// translation.synthesis.end\r\nexport interface ITranslationSynthesisEnd {\r\n SynthesisStatus: SynthesisStatus;\r\n FailureReason: string;\r\n}\r\n\r\nexport class TranslationSynthesisEnd implements ITranslationSynthesisEnd {\r\n private privSynthesisEnd: ITranslationSynthesisEnd;\r\n\r\n private constructor(json: string) {\r\n this.privSynthesisEnd = JSON.parse(json);\r\n this.privSynthesisEnd.SynthesisStatus = (SynthesisStatus as any)[this.privSynthesisEnd.SynthesisStatus];\r\n }\r\n\r\n public static fromJSON(json: string): TranslationSynthesisEnd {\r\n return new TranslationSynthesisEnd(json);\r\n }\r\n\r\n public get SynthesisStatus(): SynthesisStatus {\r\n return this.privSynthesisEnd.SynthesisStatus;\r\n }\r\n\r\n public get FailureReason(): string {\r\n return this.privSynthesisEnd.FailureReason;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ITranslations } from \"../Exports\";\r\nimport { TranslationStatus } from \"../TranslationStatus\";\r\n\r\n// translation.hypothesis\r\nexport interface ITranslationHypothesis {\r\n Duration: number;\r\n Offset: number;\r\n Text: string;\r\n Translation: ITranslations;\r\n}\r\n\r\nexport class TranslationHypothesis implements ITranslationHypothesis {\r\n private privTranslationHypothesis: ITranslationHypothesis;\r\n\r\n private constructor(json: string) {\r\n this.privTranslationHypothesis = JSON.parse(json);\r\n this.privTranslationHypothesis.Translation.TranslationStatus = (TranslationStatus as any)[this.privTranslationHypothesis.Translation.TranslationStatus];\r\n }\r\n\r\n public static fromJSON(json: string): TranslationHypothesis {\r\n return new TranslationHypothesis(json);\r\n }\r\n\r\n public get Duration(): number {\r\n return this.privTranslationHypothesis.Duration;\r\n }\r\n\r\n public get Offset(): number {\r\n return this.privTranslationHypothesis.Offset;\r\n }\r\n\r\n public get Text(): string {\r\n return this.privTranslationHypothesis.Text;\r\n }\r\n\r\n public get Translation(): ITranslations {\r\n return this.privTranslationHypothesis.Translation;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ITranslations, RecognitionStatus } from \"../Exports\";\r\nimport { TranslationStatus } from \"../TranslationStatus\";\r\n\r\n// translation.phrase\r\nexport interface ITranslationPhrase {\r\n RecognitionStatus: RecognitionStatus;\r\n Offset: number;\r\n Duration: number;\r\n Text: string;\r\n Translation: ITranslations;\r\n}\r\n\r\nexport class TranslationPhrase implements ITranslationPhrase {\r\n private privTranslationPhrase: ITranslationPhrase;\r\n\r\n private constructor(json: string) {\r\n this.privTranslationPhrase = JSON.parse(json);\r\n this.privTranslationPhrase.RecognitionStatus = (RecognitionStatus as any)[this.privTranslationPhrase.RecognitionStatus];\r\n if (this.privTranslationPhrase.Translation !== undefined) {\r\n this.privTranslationPhrase.Translation.TranslationStatus = (TranslationStatus as any)[this.privTranslationPhrase.Translation.TranslationStatus];\r\n }\r\n }\r\n\r\n public static fromJSON(json: string): TranslationPhrase {\r\n return new TranslationPhrase(json);\r\n }\r\n\r\n public get RecognitionStatus(): RecognitionStatus {\r\n return this.privTranslationPhrase.RecognitionStatus;\r\n }\r\n\r\n public get Offset(): number {\r\n return this.privTranslationPhrase.Offset;\r\n }\r\n\r\n public get Duration(): number {\r\n return this.privTranslationPhrase.Duration;\r\n }\r\n\r\n public get Text(): string {\r\n return this.privTranslationPhrase.Text;\r\n }\r\n\r\n public get Translation(): ITranslations {\r\n return this.privTranslationPhrase.Translation;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n IAudioSource,\r\n MessageType,\r\n TranslationStatus,\r\n} from \"../common/Exports\";\r\nimport {\r\n CancellationErrorCode,\r\n CancellationReason,\r\n PropertyCollection,\r\n PropertyId,\r\n ResultReason,\r\n SpeechRecognitionResult,\r\n TranslationRecognitionCanceledEventArgs,\r\n TranslationRecognitionEventArgs,\r\n TranslationRecognitionResult,\r\n TranslationRecognizer,\r\n Translations,\r\n TranslationSynthesisEventArgs,\r\n TranslationSynthesisResult,\r\n} from \"../sdk/Exports\";\r\nimport {\r\n CancellationErrorCodePropertyName,\r\n EnumTranslation,\r\n RecognitionStatus,\r\n ServiceRecognizerBase,\r\n SynthesisStatus,\r\n TranslationHypothesis,\r\n TranslationPhrase,\r\n TranslationSynthesisEnd,\r\n} from \"./Exports\";\r\nimport { IAuthentication } from \"./IAuthentication\";\r\nimport { IConnectionFactory } from \"./IConnectionFactory\";\r\nimport { RecognizerConfig } from \"./RecognizerConfig\";\r\nimport { SpeechConnectionMessage } from \"./SpeechConnectionMessage.Internal\";\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class TranslationServiceRecognizer extends ServiceRecognizerBase {\r\n private privTranslationRecognizer: TranslationRecognizer;\r\n\r\n public constructor(\r\n authentication: IAuthentication,\r\n connectionFactory: IConnectionFactory,\r\n audioSource: IAudioSource,\r\n recognizerConfig: RecognizerConfig,\r\n translationRecognizer: TranslationRecognizer) {\r\n\r\n super(authentication, connectionFactory, audioSource, recognizerConfig, translationRecognizer);\r\n this.privTranslationRecognizer = translationRecognizer;\r\n\r\n }\r\n\r\n protected processTypeSpecificMessages(connectionMessage: SpeechConnectionMessage): boolean {\r\n\r\n const resultProps: PropertyCollection = new PropertyCollection();\r\n let processed: boolean = false;\r\n\r\n if (connectionMessage.messageType === MessageType.Text) {\r\n resultProps.setProperty(PropertyId.SpeechServiceResponse_JsonResult, connectionMessage.textBody);\r\n }\r\n\r\n switch (connectionMessage.path.toLowerCase()) {\r\n case \"translation.hypothesis\":\r\n\r\n const result: TranslationRecognitionEventArgs = this.fireEventForResult(TranslationHypothesis.fromJSON(connectionMessage.textBody), resultProps);\r\n this.privRequestSession.onHypothesis(this.privRequestSession.currentTurnAudioOffset + result.offset);\r\n\r\n if (!!this.privTranslationRecognizer.recognizing) {\r\n try {\r\n this.privTranslationRecognizer.recognizing(this.privTranslationRecognizer, result);\r\n /* tslint:disable:no-empty */\r\n } catch (error) {\r\n // Not going to let errors in the event handler\r\n // trip things up.\r\n }\r\n }\r\n processed = true;\r\n break;\r\n case \"translation.phrase\":\r\n const translatedPhrase: TranslationPhrase = TranslationPhrase.fromJSON(connectionMessage.textBody);\r\n\r\n this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset + translatedPhrase.Offset + translatedPhrase.Duration);\r\n\r\n if (translatedPhrase.RecognitionStatus === RecognitionStatus.Success) {\r\n\r\n // OK, the recognition was successful. How'd the translation do?\r\n const result: TranslationRecognitionEventArgs = this.fireEventForResult(translatedPhrase, resultProps);\r\n if (!!this.privTranslationRecognizer.recognized) {\r\n try {\r\n this.privTranslationRecognizer.recognized(this.privTranslationRecognizer, result);\r\n /* tslint:disable:no-empty */\r\n } catch (error) {\r\n // Not going to let errors in the event handler\r\n // trip things up.\r\n }\r\n }\r\n\r\n // report result to promise.\r\n if (!!this.privSuccessCallback) {\r\n try {\r\n this.privSuccessCallback(result.result);\r\n } catch (e) {\r\n if (!!this.privErrorCallback) {\r\n this.privErrorCallback(e);\r\n }\r\n }\r\n // Only invoke the call back once.\r\n // and if it's successful don't invoke the\r\n // error after that.\r\n this.privSuccessCallback = undefined;\r\n this.privErrorCallback = undefined;\r\n }\r\n\r\n break;\r\n } else {\r\n const reason: ResultReason = EnumTranslation.implTranslateRecognitionResult(translatedPhrase.RecognitionStatus);\r\n\r\n const result = new TranslationRecognitionResult(\r\n undefined,\r\n this.privRequestSession.requestId,\r\n reason,\r\n translatedPhrase.Text,\r\n translatedPhrase.Duration,\r\n this.privRequestSession.currentTurnAudioOffset + translatedPhrase.Offset,\r\n undefined,\r\n connectionMessage.textBody,\r\n resultProps);\r\n\r\n if (reason === ResultReason.Canceled) {\r\n const cancelReason: CancellationReason = EnumTranslation.implTranslateCancelResult(translatedPhrase.RecognitionStatus);\r\n\r\n this.cancelRecognitionLocal(\r\n cancelReason,\r\n EnumTranslation.implTranslateCancelErrorCode(translatedPhrase.RecognitionStatus),\r\n undefined);\r\n } else {\r\n if (!(this.privRequestSession.isSpeechEnded && reason === ResultReason.NoMatch && translatedPhrase.RecognitionStatus !== RecognitionStatus.InitialSilenceTimeout)) {\r\n const ev = new TranslationRecognitionEventArgs(result, result.offset, this.privRequestSession.sessionId);\r\n\r\n if (!!this.privTranslationRecognizer.recognized) {\r\n try {\r\n this.privTranslationRecognizer.recognized(this.privTranslationRecognizer, ev);\r\n /* tslint:disable:no-empty */\r\n } catch (error) {\r\n // Not going to let errors in the event handler\r\n // trip things up.\r\n }\r\n }\r\n }\r\n\r\n // report result to promise.\r\n if (!!this.privSuccessCallback) {\r\n try {\r\n this.privSuccessCallback(result);\r\n } catch (e) {\r\n if (!!this.privErrorCallback) {\r\n this.privErrorCallback(e);\r\n }\r\n }\r\n // Only invoke the call back once.\r\n // and if it's successful don't invoke the\r\n // error after that.\r\n this.privSuccessCallback = undefined;\r\n this.privErrorCallback = undefined;\r\n }\r\n }\r\n }\r\n processed = true;\r\n break;\r\n\r\n case \"translation.synthesis\":\r\n this.sendSynthesisAudio(connectionMessage.binaryBody, this.privRequestSession.sessionId);\r\n processed = true;\r\n break;\r\n\r\n case \"translation.synthesis.end\":\r\n const synthEnd: TranslationSynthesisEnd = TranslationSynthesisEnd.fromJSON(connectionMessage.textBody);\r\n\r\n switch (synthEnd.SynthesisStatus) {\r\n case SynthesisStatus.Error:\r\n if (!!this.privTranslationRecognizer.synthesizing) {\r\n const result = new TranslationSynthesisResult(ResultReason.Canceled, undefined);\r\n const retEvent: TranslationSynthesisEventArgs = new TranslationSynthesisEventArgs(result, this.privRequestSession.sessionId);\r\n\r\n try {\r\n this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer, retEvent);\r\n /* tslint:disable:no-empty */\r\n } catch (error) {\r\n // Not going to let errors in the event handler\r\n // trip things up.\r\n }\r\n }\r\n\r\n if (!!this.privTranslationRecognizer.canceled) {\r\n // And raise a canceled event to send the rich(er) error message back.\r\n const canceledResult: TranslationRecognitionCanceledEventArgs = new TranslationRecognitionCanceledEventArgs(\r\n this.privRequestSession.sessionId,\r\n CancellationReason.Error,\r\n synthEnd.FailureReason,\r\n CancellationErrorCode.ServiceError,\r\n null);\r\n\r\n try {\r\n this.privTranslationRecognizer.canceled(this.privTranslationRecognizer, canceledResult);\r\n /* tslint:disable:no-empty */\r\n } catch (error) {\r\n // Not going to let errors in the event handler\r\n // trip things up.\r\n }\r\n }\r\n break;\r\n case SynthesisStatus.Success:\r\n this.sendSynthesisAudio(undefined, this.privRequestSession.sessionId);\r\n break;\r\n default:\r\n break;\r\n }\r\n processed = true;\r\n break;\r\n default:\r\n break;\r\n }\r\n return processed;\r\n }\r\n\r\n // Cancels recognition.\r\n protected cancelRecognition(\r\n sessionId: string,\r\n requestId: string,\r\n cancellationReason: CancellationReason,\r\n errorCode: CancellationErrorCode,\r\n error: string): void {\r\n\r\n const properties: PropertyCollection = new PropertyCollection();\r\n properties.setProperty(CancellationErrorCodePropertyName, CancellationErrorCode[errorCode]);\r\n\r\n if (!!this.privTranslationRecognizer.canceled) {\r\n\r\n const cancelEvent: TranslationRecognitionCanceledEventArgs = new TranslationRecognitionCanceledEventArgs(\r\n sessionId,\r\n cancellationReason,\r\n error,\r\n errorCode,\r\n undefined);\r\n\r\n try {\r\n this.privTranslationRecognizer.canceled(this.privTranslationRecognizer, cancelEvent);\r\n /* tslint:disable:no-empty */\r\n } catch { }\r\n }\r\n\r\n if (!!this.privSuccessCallback) {\r\n const result: TranslationRecognitionResult = new TranslationRecognitionResult(\r\n undefined, // Translations\r\n requestId,\r\n ResultReason.Canceled,\r\n undefined, // Text\r\n undefined, // Druation\r\n undefined, // Offset\r\n error,\r\n undefined, // Json\r\n properties);\r\n try {\r\n this.privSuccessCallback(result);\r\n /* tslint:disable:no-empty */\r\n this.privSuccessCallback = undefined;\r\n } catch { }\r\n }\r\n }\r\n\r\n private fireEventForResult(serviceResult: TranslationHypothesis | TranslationPhrase, properties: PropertyCollection): TranslationRecognitionEventArgs {\r\n let translations: Translations;\r\n\r\n if (undefined !== serviceResult.Translation.Translations) {\r\n translations = new Translations();\r\n for (const translation of serviceResult.Translation.Translations) {\r\n translations.set(translation.Language, translation.Text);\r\n }\r\n }\r\n\r\n let resultReason: ResultReason;\r\n if (serviceResult instanceof TranslationPhrase) {\r\n if (serviceResult.Translation.TranslationStatus === TranslationStatus.Success) {\r\n resultReason = ResultReason.TranslatedSpeech;\r\n } else {\r\n resultReason = ResultReason.RecognizedSpeech;\r\n }\r\n } else {\r\n resultReason = ResultReason.TranslatingSpeech;\r\n }\r\n\r\n const offset: number = serviceResult.Offset + this.privRequestSession.currentTurnAudioOffset;\r\n\r\n const result = new TranslationRecognitionResult(\r\n translations,\r\n this.privRequestSession.requestId,\r\n resultReason,\r\n serviceResult.Text,\r\n serviceResult.Duration,\r\n offset,\r\n serviceResult.Translation.FailureReason,\r\n JSON.stringify(serviceResult),\r\n properties);\r\n\r\n const ev = new TranslationRecognitionEventArgs(result, offset, this.privRequestSession.sessionId);\r\n return ev;\r\n }\r\n\r\n private sendSynthesisAudio(audio: ArrayBuffer, sessionId: string): void {\r\n const reason = (undefined === audio) ? ResultReason.SynthesizingAudioCompleted : ResultReason.SynthesizingAudio;\r\n const result = new TranslationSynthesisResult(reason, audio);\r\n const retEvent: TranslationSynthesisEventArgs = new TranslationSynthesisEventArgs(result, sessionId);\r\n\r\n if (!!this.privTranslationRecognizer.synthesizing) {\r\n try {\r\n this.privTranslationRecognizer.synthesizing(this.privTranslationRecognizer, retEvent);\r\n /* tslint:disable:no-empty */\r\n } catch (error) {\r\n // Not going to let errors in the event handler\r\n // trip things up.\r\n }\r\n }\r\n\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n// speech.endDetected\r\nexport interface ISpeechDetected {\r\n Offset: number;\r\n}\r\n\r\nexport class SpeechDetected implements ISpeechDetected {\r\n private privSpeechStartDetected: ISpeechDetected;\r\n\r\n private constructor(json: string) {\r\n this.privSpeechStartDetected = JSON.parse(json);\r\n }\r\n\r\n public static fromJSON(json: string): SpeechDetected {\r\n return new SpeechDetected(json);\r\n }\r\n\r\n public get Offset(): number {\r\n return this.privSpeechStartDetected.Offset;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { IPrimaryLanguage } from \"./SimpleSpeechPhrase\";\r\n\r\n// speech.hypothesis\r\nexport interface ISpeechHypothesis {\r\n Text: string;\r\n Offset: number;\r\n Duration: number;\r\n PrimaryLanguage?: IPrimaryLanguage;\r\n}\r\n\r\nexport class SpeechHypothesis implements ISpeechHypothesis {\r\n private privSpeechHypothesis: ISpeechHypothesis;\r\n\r\n private constructor(json: string) {\r\n this.privSpeechHypothesis = JSON.parse(json);\r\n }\r\n\r\n public static fromJSON(json: string): SpeechHypothesis {\r\n return new SpeechHypothesis(json);\r\n }\r\n\r\n public get Text(): string {\r\n return this.privSpeechHypothesis.Text;\r\n }\r\n\r\n public get Offset(): number {\r\n return this.privSpeechHypothesis.Offset;\r\n }\r\n\r\n public get Duration(): number {\r\n return this.privSpeechHypothesis.Duration;\r\n }\r\n\r\n public get Language(): string {\r\n return this.privSpeechHypothesis.PrimaryLanguage === undefined ? undefined : this.privSpeechHypothesis.PrimaryLanguage.Language;\r\n }\r\n\r\n public get LanguageDetectionConfidence(): string {\r\n return this.privSpeechHypothesis.PrimaryLanguage === undefined ? undefined : this.privSpeechHypothesis.PrimaryLanguage.Confidence;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { IAudioSource } from \"../common/Exports\";\r\nimport {\r\n CancellationErrorCode,\r\n CancellationReason,\r\n OutputFormat,\r\n PropertyCollection,\r\n PropertyId,\r\n ResultReason,\r\n SpeechRecognitionCanceledEventArgs,\r\n SpeechRecognitionEventArgs,\r\n SpeechRecognitionResult,\r\n SpeechRecognizer,\r\n} from \"../sdk/Exports\";\r\nimport {\r\n CancellationErrorCodePropertyName,\r\n DetailedSpeechPhrase,\r\n EnumTranslation,\r\n OutputFormatPropertyName,\r\n RecognitionStatus,\r\n RequestSession,\r\n ServiceRecognizerBase,\r\n SimpleSpeechPhrase,\r\n SpeechHypothesis,\r\n} from \"./Exports\";\r\nimport { IAuthentication } from \"./IAuthentication\";\r\nimport { IConnectionFactory } from \"./IConnectionFactory\";\r\nimport { RecognizerConfig } from \"./RecognizerConfig\";\r\nimport { SpeechConnectionMessage } from \"./SpeechConnectionMessage.Internal\";\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class SpeechServiceRecognizer extends ServiceRecognizerBase {\r\n\r\n private privSpeechRecognizer: SpeechRecognizer;\r\n\r\n public constructor(\r\n authentication: IAuthentication,\r\n connectionFactory: IConnectionFactory,\r\n audioSource: IAudioSource,\r\n recognizerConfig: RecognizerConfig,\r\n speechRecognizer: SpeechRecognizer) {\r\n super(authentication, connectionFactory, audioSource, recognizerConfig, speechRecognizer);\r\n this.privSpeechRecognizer = speechRecognizer;\r\n if (recognizerConfig.autoDetectSourceLanguages !== undefined) {\r\n const sourceLanguages: string[] = recognizerConfig.autoDetectSourceLanguages.split(\",\");\r\n this.privSpeechContext.setSection(\"languageId\", {\r\n languages: sourceLanguages,\r\n onSuccess: { action: \"Recognize\" },\r\n onUnknown: { action: \"None\" }\r\n });\r\n this.privSpeechContext.setSection(\"phraseOutput\", {\r\n interimResults: {\r\n resultType: \"Auto\"\r\n },\r\n phraseResults: {\r\n resultType: \"Always\"\r\n }\r\n });\r\n }\r\n }\r\n\r\n protected processTypeSpecificMessages(connectionMessage: SpeechConnectionMessage): boolean {\r\n\r\n let result: SpeechRecognitionResult;\r\n const resultProps: PropertyCollection = new PropertyCollection();\r\n resultProps.setProperty(PropertyId.SpeechServiceResponse_JsonResult, connectionMessage.textBody);\r\n let processed: boolean = false;\r\n\r\n switch (connectionMessage.path.toLowerCase()) {\r\n case \"speech.hypothesis\":\r\n case \"speech.fragment\":\r\n const hypothesis: SpeechHypothesis = SpeechHypothesis.fromJSON(connectionMessage.textBody);\r\n const offset: number = hypothesis.Offset + this.privRequestSession.currentTurnAudioOffset;\r\n\r\n result = new SpeechRecognitionResult(\r\n this.privRequestSession.requestId,\r\n ResultReason.RecognizingSpeech,\r\n hypothesis.Text,\r\n hypothesis.Duration,\r\n offset,\r\n hypothesis.Language,\r\n hypothesis.LanguageDetectionConfidence,\r\n undefined,\r\n connectionMessage.textBody,\r\n resultProps);\r\n\r\n this.privRequestSession.onHypothesis(offset);\r\n\r\n const ev = new SpeechRecognitionEventArgs(result, hypothesis.Duration, this.privRequestSession.sessionId);\r\n\r\n if (!!this.privSpeechRecognizer.recognizing) {\r\n try {\r\n this.privSpeechRecognizer.recognizing(this.privSpeechRecognizer, ev);\r\n /* tslint:disable:no-empty */\r\n } catch (error) {\r\n // Not going to let errors in the event handler\r\n // trip things up.\r\n }\r\n }\r\n processed = true;\r\n break;\r\n case \"speech.phrase\":\r\n const simple: SimpleSpeechPhrase = SimpleSpeechPhrase.fromJSON(connectionMessage.textBody);\r\n const resultReason: ResultReason = EnumTranslation.implTranslateRecognitionResult(simple.RecognitionStatus);\r\n\r\n this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset + simple.Offset + simple.Duration);\r\n\r\n if (ResultReason.Canceled === resultReason) {\r\n const cancelReason: CancellationReason = EnumTranslation.implTranslateCancelResult(simple.RecognitionStatus);\r\n\r\n this.cancelRecognitionLocal(\r\n cancelReason,\r\n EnumTranslation.implTranslateCancelErrorCode(simple.RecognitionStatus),\r\n undefined);\r\n\r\n } else {\r\n if (!(this.privRequestSession.isSpeechEnded && resultReason === ResultReason.NoMatch && simple.RecognitionStatus !== RecognitionStatus.InitialSilenceTimeout)) {\r\n if (this.privRecognizerConfig.parameters.getProperty(OutputFormatPropertyName) === OutputFormat[OutputFormat.Simple]) {\r\n result = new SpeechRecognitionResult(\r\n this.privRequestSession.requestId,\r\n resultReason,\r\n simple.DisplayText,\r\n simple.Duration,\r\n simple.Offset + this.privRequestSession.currentTurnAudioOffset,\r\n simple.Language,\r\n simple.LanguageDetectionConfidence,\r\n undefined,\r\n connectionMessage.textBody,\r\n resultProps);\r\n } else {\r\n const detailed: DetailedSpeechPhrase = DetailedSpeechPhrase.fromJSON(connectionMessage.textBody);\r\n\r\n result = new SpeechRecognitionResult(\r\n this.privRequestSession.requestId,\r\n resultReason,\r\n detailed.RecognitionStatus === RecognitionStatus.Success ? detailed.NBest[0].Display : undefined,\r\n detailed.Duration,\r\n detailed.Offset + this.privRequestSession.currentTurnAudioOffset,\r\n detailed.Language,\r\n detailed.LanguageDetectionConfidence,\r\n undefined,\r\n connectionMessage.textBody,\r\n resultProps);\r\n }\r\n\r\n const event: SpeechRecognitionEventArgs = new SpeechRecognitionEventArgs(result, result.offset, this.privRequestSession.sessionId);\r\n\r\n if (!!this.privSpeechRecognizer.recognized) {\r\n try {\r\n this.privSpeechRecognizer.recognized(this.privSpeechRecognizer, event);\r\n /* tslint:disable:no-empty */\r\n } catch (error) {\r\n // Not going to let errors in the event handler\r\n // trip things up.\r\n }\r\n }\r\n }\r\n\r\n if (!!this.privSuccessCallback) {\r\n try {\r\n this.privSuccessCallback(result);\r\n } catch (e) {\r\n if (!!this.privErrorCallback) {\r\n this.privErrorCallback(e);\r\n }\r\n }\r\n // Only invoke the call back once.\r\n // and if it's successful don't invoke the\r\n // error after that.\r\n this.privSuccessCallback = undefined;\r\n this.privErrorCallback = undefined;\r\n }\r\n }\r\n processed = true;\r\n break;\r\n default:\r\n break;\r\n }\r\n return processed;\r\n }\r\n\r\n // Cancels recognition.\r\n protected cancelRecognition(\r\n sessionId: string,\r\n requestId: string,\r\n cancellationReason: CancellationReason,\r\n errorCode: CancellationErrorCode,\r\n error: string): void {\r\n\r\n const properties: PropertyCollection = new PropertyCollection();\r\n properties.setProperty(CancellationErrorCodePropertyName, CancellationErrorCode[errorCode]);\r\n\r\n if (!!this.privSpeechRecognizer.canceled) {\r\n const cancelEvent: SpeechRecognitionCanceledEventArgs = new SpeechRecognitionCanceledEventArgs(\r\n cancellationReason,\r\n error,\r\n errorCode,\r\n undefined,\r\n sessionId);\r\n try {\r\n this.privSpeechRecognizer.canceled(this.privSpeechRecognizer, cancelEvent);\r\n /* tslint:disable:no-empty */\r\n } catch { }\r\n }\r\n\r\n if (!!this.privSuccessCallback) {\r\n const result: SpeechRecognitionResult = new SpeechRecognitionResult(\r\n requestId,\r\n ResultReason.Canceled,\r\n undefined, // Text\r\n undefined, // Duration\r\n undefined, // Offset\r\n undefined, // Language\r\n undefined, // Language Detection Confidence\r\n error,\r\n undefined, // Json\r\n properties);\r\n try {\r\n this.privSuccessCallback(result);\r\n this.privSuccessCallback = undefined;\r\n /* tslint:disable:no-empty */\r\n } catch { }\r\n }\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { IPrimaryLanguage, RecognitionStatus } from \"../Exports\";\r\n\r\n// speech.phrase for detailed\r\nexport interface IDetailedSpeechPhrase {\r\n RecognitionStatus: RecognitionStatus;\r\n NBest: IPhrase[];\r\n Duration?: number;\r\n Offset?: number;\r\n PrimaryLanguage?: IPrimaryLanguage;\r\n}\r\n\r\nexport interface IPhrase {\r\n Confidence?: number;\r\n Lexical: string;\r\n ITN: string;\r\n MaskedITN: string;\r\n Display: string;\r\n}\r\n\r\nexport class DetailedSpeechPhrase implements IDetailedSpeechPhrase {\r\n private privDetailedSpeechPhrase: IDetailedSpeechPhrase;\r\n\r\n private constructor(json: string) {\r\n this.privDetailedSpeechPhrase = JSON.parse(json);\r\n this.privDetailedSpeechPhrase.RecognitionStatus = (RecognitionStatus as any)[this.privDetailedSpeechPhrase.RecognitionStatus];\r\n }\r\n\r\n public static fromJSON(json: string): DetailedSpeechPhrase {\r\n return new DetailedSpeechPhrase(json);\r\n }\r\n\r\n public get RecognitionStatus(): RecognitionStatus {\r\n return this.privDetailedSpeechPhrase.RecognitionStatus;\r\n }\r\n public get NBest(): IPhrase[] {\r\n return this.privDetailedSpeechPhrase.NBest;\r\n }\r\n public get Duration(): number {\r\n return this.privDetailedSpeechPhrase.Duration;\r\n }\r\n public get Offset(): number {\r\n return this.privDetailedSpeechPhrase.Offset;\r\n }\r\n public get Language(): string {\r\n return this.privDetailedSpeechPhrase.PrimaryLanguage === undefined ? undefined : this.privDetailedSpeechPhrase.PrimaryLanguage.Language;\r\n }\r\n public get LanguageDetectionConfidence(): string {\r\n return this.privDetailedSpeechPhrase.PrimaryLanguage === undefined ? undefined : this.privDetailedSpeechPhrase.PrimaryLanguage.Confidence;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { RecognitionStatus } from \"../Exports\";\r\n\r\n// speech.phrase\r\nexport interface ISimpleSpeechPhrase {\r\n RecognitionStatus: RecognitionStatus;\r\n DisplayText: string;\r\n Offset?: number;\r\n Duration?: number;\r\n PrimaryLanguage?: IPrimaryLanguage;\r\n}\r\n\r\nexport interface IPrimaryLanguage {\r\n Language: string;\r\n Confidence: string;\r\n}\r\n\r\nexport class SimpleSpeechPhrase implements ISimpleSpeechPhrase {\r\n private privSimpleSpeechPhrase: ISimpleSpeechPhrase;\r\n\r\n private constructor(json: string) {\r\n this.privSimpleSpeechPhrase = JSON.parse(json);\r\n this.privSimpleSpeechPhrase.RecognitionStatus = (RecognitionStatus as any)[this.privSimpleSpeechPhrase.RecognitionStatus];\r\n }\r\n\r\n public static fromJSON(json: string): SimpleSpeechPhrase {\r\n return new SimpleSpeechPhrase(json);\r\n }\r\n\r\n public get RecognitionStatus(): RecognitionStatus {\r\n return this.privSimpleSpeechPhrase.RecognitionStatus;\r\n }\r\n\r\n public get DisplayText(): string {\r\n return this.privSimpleSpeechPhrase.DisplayText;\r\n }\r\n\r\n public get Offset(): number {\r\n return this.privSimpleSpeechPhrase.Offset;\r\n }\r\n\r\n public get Duration(): number {\r\n return this.privSimpleSpeechPhrase.Duration;\r\n }\r\n\r\n public get Language(): string {\r\n return this.privSimpleSpeechPhrase.PrimaryLanguage === undefined ? undefined : this.privSimpleSpeechPhrase.PrimaryLanguage.Language;\r\n }\r\n\r\n public get LanguageDetectionConfidence(): string {\r\n return this.privSimpleSpeechPhrase.PrimaryLanguage === undefined ? undefined : this.privSimpleSpeechPhrase.PrimaryLanguage.Confidence;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { LanguageUnderstandingModelImpl } from \"../sdk/LanguageUnderstandingModel\";\r\n\r\n/**\r\n * @class AddedLmIntent\r\n */\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class AddedLmIntent {\r\n public modelImpl: LanguageUnderstandingModelImpl;\r\n public intentName: string;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param modelImpl - The model.\r\n * @param intentName - The intent name.\r\n */\r\n public constructor(modelImpl: LanguageUnderstandingModelImpl, intentName: string) {\r\n this.modelImpl = modelImpl;\r\n this.intentName = intentName;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n IAudioSource,\r\n MessageType,\r\n} from \"../common/Exports\";\r\nimport {\r\n CancellationErrorCode,\r\n CancellationReason,\r\n IntentRecognitionCanceledEventArgs,\r\n IntentRecognitionEventArgs,\r\n IntentRecognitionResult,\r\n IntentRecognizer,\r\n PropertyCollection,\r\n PropertyId,\r\n ResultReason,\r\n SpeechRecognitionResult,\r\n} from \"../sdk/Exports\";\r\nimport {\r\n AddedLmIntent,\r\n CancellationErrorCodePropertyName,\r\n EnumTranslation,\r\n IntentResponse,\r\n ServiceRecognizerBase,\r\n SimpleSpeechPhrase,\r\n SpeechHypothesis,\r\n} from \"./Exports\";\r\nimport { IAuthentication } from \"./IAuthentication\";\r\nimport { IConnectionFactory } from \"./IConnectionFactory\";\r\nimport { RecognizerConfig } from \"./RecognizerConfig\";\r\nimport { SpeechConnectionMessage } from \"./SpeechConnectionMessage.Internal\";\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class IntentServiceRecognizer extends ServiceRecognizerBase {\r\n private privIntentRecognizer: IntentRecognizer;\r\n private privAddedLmIntents: { [id: string]: AddedLmIntent; };\r\n private privIntentDataSent: boolean;\r\n private privUmbrellaIntent: AddedLmIntent;\r\n private privPendingIntentArgs: IntentRecognitionEventArgs;\r\n\r\n public constructor(\r\n authentication: IAuthentication,\r\n connectionFactory: IConnectionFactory,\r\n audioSource: IAudioSource,\r\n recognizerConfig: RecognizerConfig,\r\n recognizer: IntentRecognizer) {\r\n super(authentication, connectionFactory, audioSource, recognizerConfig, recognizer);\r\n this.privIntentRecognizer = recognizer;\r\n this.privIntentDataSent = false;\r\n }\r\n\r\n public setIntents(addedIntents: { [id: string]: AddedLmIntent; }, umbrellaIntent: AddedLmIntent): void {\r\n this.privAddedLmIntents = addedIntents;\r\n this.privUmbrellaIntent = umbrellaIntent;\r\n this.privIntentDataSent = true;\r\n }\r\n\r\n protected processTypeSpecificMessages(connectionMessage: SpeechConnectionMessage): boolean {\r\n\r\n let result: IntentRecognitionResult;\r\n let ev: IntentRecognitionEventArgs;\r\n let processed: boolean = false;\r\n\r\n const resultProps: PropertyCollection = new PropertyCollection();\r\n if (connectionMessage.messageType === MessageType.Text) {\r\n resultProps.setProperty(PropertyId.SpeechServiceResponse_JsonResult, connectionMessage.textBody);\r\n }\r\n\r\n switch (connectionMessage.path.toLowerCase()) {\r\n case \"speech.hypothesis\":\r\n const speechHypothesis: SpeechHypothesis = SpeechHypothesis.fromJSON(connectionMessage.textBody);\r\n\r\n result = new IntentRecognitionResult(\r\n undefined,\r\n this.privRequestSession.requestId,\r\n ResultReason.RecognizingIntent,\r\n speechHypothesis.Text,\r\n speechHypothesis.Duration,\r\n speechHypothesis.Offset + this.privRequestSession.currentTurnAudioOffset,\r\n speechHypothesis.Language,\r\n speechHypothesis.LanguageDetectionConfidence,\r\n undefined,\r\n connectionMessage.textBody,\r\n resultProps);\r\n\r\n this.privRequestSession.onHypothesis(result.offset);\r\n\r\n ev = new IntentRecognitionEventArgs(result, speechHypothesis.Offset + this.privRequestSession.currentTurnAudioOffset, this.privRequestSession.sessionId);\r\n\r\n if (!!this.privIntentRecognizer.recognizing) {\r\n try {\r\n this.privIntentRecognizer.recognizing(this.privIntentRecognizer, ev);\r\n /* tslint:disable:no-empty */\r\n } catch (error) {\r\n // Not going to let errors in the event handler\r\n // trip things up.\r\n }\r\n }\r\n processed = true;\r\n break;\r\n case \"speech.phrase\":\r\n const simple: SimpleSpeechPhrase = SimpleSpeechPhrase.fromJSON(connectionMessage.textBody);\r\n result = new IntentRecognitionResult(\r\n undefined,\r\n this.privRequestSession.requestId,\r\n EnumTranslation.implTranslateRecognitionResult(simple.RecognitionStatus),\r\n simple.DisplayText,\r\n simple.Duration,\r\n simple.Offset + this.privRequestSession.currentTurnAudioOffset,\r\n simple.Language,\r\n simple.LanguageDetectionConfidence,\r\n undefined,\r\n connectionMessage.textBody,\r\n resultProps);\r\n\r\n ev = new IntentRecognitionEventArgs(result, result.offset, this.privRequestSession.sessionId);\r\n\r\n const sendEvent: () => void = () => {\r\n if (!!this.privIntentRecognizer.recognized) {\r\n try {\r\n this.privIntentRecognizer.recognized(this.privIntentRecognizer, ev);\r\n /* tslint:disable:no-empty */\r\n } catch (error) {\r\n // Not going to let errors in the event handler\r\n // trip things up.\r\n }\r\n }\r\n\r\n // report result to promise.\r\n if (!!this.privSuccessCallback) {\r\n try {\r\n this.privSuccessCallback(result);\r\n } catch (e) {\r\n if (!!this.privErrorCallback) {\r\n this.privErrorCallback(e);\r\n }\r\n }\r\n // Only invoke the call back once.\r\n // and if it's successful don't invoke the\r\n // error after that.\r\n this.privSuccessCallback = undefined;\r\n this.privErrorCallback = undefined;\r\n }\r\n };\r\n\r\n // If intent data was sent, the terminal result for this recognizer is an intent being found.\r\n // If no intent data was sent, the terminal event is speech recognition being successful.\r\n if (false === this.privIntentDataSent || ResultReason.NoMatch === ev.result.reason) {\r\n // Advance the buffers.\r\n this.privRequestSession.onPhraseRecognized(ev.offset + ev.result.duration);\r\n sendEvent();\r\n } else {\r\n // Squirrel away the args, when the response event arrives it will build upon them\r\n // and then return\r\n this.privPendingIntentArgs = ev;\r\n }\r\n processed = true;\r\n break;\r\n case \"response\":\r\n // Response from LUIS\r\n ev = this.privPendingIntentArgs;\r\n this.privPendingIntentArgs = undefined;\r\n\r\n if (undefined === ev) {\r\n if (\"\" === connectionMessage.textBody) {\r\n // This condition happens if there is nothing but silence in the\r\n // audio sent to the service.\r\n return;\r\n }\r\n\r\n // Odd... Not sure this can happen\r\n ev = new IntentRecognitionEventArgs(new IntentRecognitionResult(), 0 /*TODO*/, this.privRequestSession.sessionId);\r\n }\r\n\r\n const intentResponse: IntentResponse = IntentResponse.fromJSON(connectionMessage.textBody);\r\n\r\n // If LUIS didn't return anything, send the existing event, else\r\n // modify it to show the match.\r\n // See if the intent found is in the list of intents asked for.\r\n let addedIntent: AddedLmIntent = this.privAddedLmIntents[intentResponse.topScoringIntent.intent];\r\n\r\n if (this.privUmbrellaIntent !== undefined) {\r\n addedIntent = this.privUmbrellaIntent;\r\n }\r\n\r\n if (null !== intentResponse && addedIntent !== undefined) {\r\n const intentId = addedIntent.intentName === undefined ? intentResponse.topScoringIntent.intent : addedIntent.intentName;\r\n let reason = ev.result.reason;\r\n\r\n if (undefined !== intentId) {\r\n reason = ResultReason.RecognizedIntent;\r\n }\r\n\r\n // make sure, properties is set.\r\n const properties = (undefined !== ev.result.properties) ?\r\n ev.result.properties : new PropertyCollection();\r\n\r\n properties.setProperty(PropertyId.LanguageUnderstandingServiceResponse_JsonResult, connectionMessage.textBody);\r\n\r\n ev = new IntentRecognitionEventArgs(\r\n new IntentRecognitionResult(\r\n intentId,\r\n ev.result.resultId,\r\n reason,\r\n ev.result.text,\r\n ev.result.duration,\r\n ev.result.offset,\r\n undefined,\r\n undefined,\r\n ev.result.errorDetails,\r\n ev.result.json,\r\n properties),\r\n ev.offset,\r\n ev.sessionId);\r\n }\r\n this.privRequestSession.onPhraseRecognized(ev.offset + ev.result.duration);\r\n\r\n if (!!this.privIntentRecognizer.recognized) {\r\n try {\r\n this.privIntentRecognizer.recognized(this.privIntentRecognizer, ev);\r\n /* tslint:disable:no-empty */\r\n } catch (error) {\r\n // Not going to let errors in the event handler\r\n // trip things up.\r\n }\r\n }\r\n\r\n // report result to promise.\r\n if (!!this.privSuccessCallback) {\r\n try {\r\n this.privSuccessCallback(ev.result);\r\n } catch (e) {\r\n if (!!this.privErrorCallback) {\r\n this.privErrorCallback(e);\r\n }\r\n }\r\n // Only invoke the call back once.\r\n // and if it's successful don't invoke the\r\n // error after that.\r\n this.privSuccessCallback = undefined;\r\n this.privErrorCallback = undefined;\r\n }\r\n processed = true;\r\n break;\r\n default:\r\n break;\r\n }\r\n return processed;\r\n }\r\n\r\n // Cancels recognition.\r\n protected cancelRecognition(\r\n sessionId: string,\r\n requestId: string,\r\n cancellationReason: CancellationReason,\r\n errorCode: CancellationErrorCode,\r\n error: string): void {\r\n\r\n const properties: PropertyCollection = new PropertyCollection();\r\n properties.setProperty(CancellationErrorCodePropertyName, CancellationErrorCode[errorCode]);\r\n\r\n if (!!this.privIntentRecognizer.canceled) {\r\n\r\n const cancelEvent: IntentRecognitionCanceledEventArgs = new IntentRecognitionCanceledEventArgs(\r\n cancellationReason,\r\n error,\r\n errorCode,\r\n undefined,\r\n undefined,\r\n sessionId);\r\n try {\r\n this.privIntentRecognizer.canceled(this.privIntentRecognizer, cancelEvent);\r\n /* tslint:disable:no-empty */\r\n } catch { }\r\n }\r\n\r\n if (!!this.privSuccessCallback) {\r\n const result: IntentRecognitionResult = new IntentRecognitionResult(\r\n undefined, // Intent Id\r\n requestId,\r\n ResultReason.Canceled,\r\n undefined, // Text\r\n undefined, // Duration\r\n undefined, // Offset\r\n undefined, // Language\r\n undefined, // LanguageDetectionConfidence\r\n error,\r\n undefined, // Json\r\n properties);\r\n try {\r\n this.privSuccessCallback(result);\r\n this.privSuccessCallback = undefined;\r\n /* tslint:disable:no-empty */\r\n } catch { }\r\n }\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n// response\r\n\r\nexport interface IIntentResponse {\r\n query: string;\r\n topScoringIntent: ISingleIntent;\r\n entities: IIntentEntity[];\r\n}\r\n\r\nexport interface IIntentEntity {\r\n entity: string;\r\n type: string;\r\n startIndex: number;\r\n endIndex: number;\r\n score: number;\r\n}\r\n\r\nexport interface ISingleIntent {\r\n intent: string;\r\n score: number;\r\n}\r\n\r\nexport class IntentResponse implements IIntentResponse {\r\n private privIntentResponse: IIntentResponse;\r\n\r\n private constructor(json: string) {\r\n this.privIntentResponse = JSON.parse(json);\r\n }\r\n\r\n public static fromJSON(json: string): IntentResponse {\r\n return new IntentResponse(json);\r\n }\r\n\r\n public get query(): string {\r\n return this.privIntentResponse.query;\r\n }\r\n\r\n public get topScoringIntent(): ISingleIntent {\r\n return this.privIntentResponse.topScoringIntent;\r\n }\r\n\r\n public get entities(): IIntentEntity[] {\r\n return this.privIntentResponse.entities;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ReplayableAudioNode } from \"../common.browser/Exports\";\r\nimport {\r\n createNoDashGuid,\r\n Deferred,\r\n Events,\r\n IDetachable,\r\n IEventSource,\r\n PlatformEvent,\r\n Promise,\r\n PromiseState\r\n} from \"../common/Exports\";\r\nimport {\r\n ConnectingToServiceEvent,\r\n ListeningStartedEvent,\r\n RecognitionStartedEvent,\r\n RecognitionTriggeredEvent,\r\n SpeechRecognitionEvent,\r\n} from \"./RecognitionEvents\";\r\nimport { ServiceTelemetryListener } from \"./ServiceTelemetryListener.Internal\";\r\n\r\nexport class RequestSession {\r\n private privIsDisposed: boolean = false;\r\n private privServiceTelemetryListener: ServiceTelemetryListener;\r\n private privDetachables: IDetachable[] = new Array();\r\n private privRequestId: string;\r\n private privAudioSourceId: string;\r\n private privAudioNodeId: string;\r\n private privAudioNode: ReplayableAudioNode;\r\n private privAuthFetchEventId: string;\r\n private privIsAudioNodeDetached: boolean = false;\r\n private privIsRecognizing: boolean = false;\r\n private privIsSpeechEnded: boolean = false;\r\n private privTurnStartAudioOffset: number = 0;\r\n private privLastRecoOffset: number = 0;\r\n private privHypothesisReceived: boolean = false;\r\n private privBytesSent: number = 0;\r\n private privRecogNumber: number = 0;\r\n private privSessionId: string;\r\n private privTurnDeferral: Deferred;\r\n\r\n constructor(audioSourceId: string) {\r\n this.privAudioSourceId = audioSourceId;\r\n this.privRequestId = createNoDashGuid();\r\n this.privAudioNodeId = createNoDashGuid();\r\n this.privTurnDeferral = new Deferred();\r\n\r\n // We're not in a turn, so resolve.\r\n this.privTurnDeferral.resolve(true);\r\n }\r\n\r\n public get sessionId(): string {\r\n return this.privSessionId;\r\n }\r\n\r\n public get requestId(): string {\r\n return this.privRequestId;\r\n }\r\n\r\n public get audioNodeId(): string {\r\n return this.privAudioNodeId;\r\n }\r\n\r\n public get turnCompletionPromise(): Promise {\r\n return this.privTurnDeferral.promise();\r\n }\r\n\r\n public get isSpeechEnded(): boolean {\r\n return this.privIsSpeechEnded;\r\n }\r\n\r\n public get isRecognizing(): boolean {\r\n return this.privIsRecognizing;\r\n }\r\n\r\n public get currentTurnAudioOffset(): number {\r\n return this.privTurnStartAudioOffset;\r\n }\r\n\r\n public get recogNumber(): number {\r\n return this.privRecogNumber;\r\n }\r\n\r\n // The number of bytes sent for the current connection.\r\n // Counter is reset to 0 each time a connection is established.\r\n public get bytesSent(): number {\r\n return this.privBytesSent;\r\n }\r\n public listenForServiceTelemetry(eventSource: IEventSource): void {\r\n if (!!this.privServiceTelemetryListener) {\r\n this.privDetachables.push(eventSource.attachListener(this.privServiceTelemetryListener));\r\n }\r\n }\r\n\r\n public startNewRecognition(): void {\r\n this.privIsSpeechEnded = false;\r\n this.privIsRecognizing = true;\r\n this.privTurnStartAudioOffset = 0;\r\n this.privLastRecoOffset = 0;\r\n this.privRequestId = createNoDashGuid();\r\n this.privRecogNumber++;\r\n this.privServiceTelemetryListener = new ServiceTelemetryListener(this.privRequestId, this.privAudioSourceId, this.privAudioNodeId);\r\n this.onEvent(new RecognitionTriggeredEvent(this.requestId, this.privSessionId, this.privAudioSourceId, this.privAudioNodeId));\r\n }\r\n\r\n public onAudioSourceAttachCompleted = (audioNode: ReplayableAudioNode, isError: boolean, error?: string): void => {\r\n this.privAudioNode = audioNode;\r\n this.privIsAudioNodeDetached = false;\r\n\r\n if (isError) {\r\n this.onComplete();\r\n } else {\r\n this.onEvent(new ListeningStartedEvent(this.privRequestId, this.privSessionId, this.privAudioSourceId, this.privAudioNodeId));\r\n }\r\n }\r\n\r\n public onPreConnectionStart = (authFetchEventId: string, connectionId: string): void => {\r\n this.privAuthFetchEventId = authFetchEventId;\r\n this.privSessionId = connectionId;\r\n this.onEvent(new ConnectingToServiceEvent(this.privRequestId, this.privAuthFetchEventId, this.privSessionId));\r\n }\r\n\r\n public onAuthCompleted = (isError: boolean, error?: string): void => {\r\n if (isError) {\r\n this.onComplete();\r\n }\r\n }\r\n\r\n public onConnectionEstablishCompleted = (statusCode: number, reason?: string): void => {\r\n if (statusCode === 200) {\r\n this.onEvent(new RecognitionStartedEvent(this.requestId, this.privAudioSourceId, this.privAudioNodeId, this.privAuthFetchEventId, this.privSessionId));\r\n if (!!this.privAudioNode) {\r\n this.privAudioNode.replay();\r\n }\r\n this.privTurnStartAudioOffset = this.privLastRecoOffset;\r\n this.privBytesSent = 0;\r\n return;\r\n } else if (statusCode === 403) {\r\n this.onComplete();\r\n }\r\n }\r\n\r\n public onServiceTurnEndResponse = (continuousRecognition: boolean): void => {\r\n this.privTurnDeferral.resolve(true);\r\n\r\n if (!continuousRecognition || this.isSpeechEnded) {\r\n this.onComplete();\r\n } else {\r\n // Start a new request set.\r\n this.privTurnStartAudioOffset = this.privLastRecoOffset;\r\n this.privRequestId = createNoDashGuid();\r\n this.privAudioNode.replay();\r\n }\r\n }\r\n\r\n public onServiceTurnStartResponse = (): void => {\r\n if (this.privTurnDeferral.state() === PromiseState.None) {\r\n // What? How are we starting a turn with another not done?\r\n this.privTurnDeferral.reject(\"Another turn started before current completed.\");\r\n }\r\n\r\n this.privTurnDeferral = new Deferred();\r\n }\r\n\r\n public onHypothesis(offset: number): void {\r\n if (!this.privHypothesisReceived) {\r\n this.privHypothesisReceived = true;\r\n this.privServiceTelemetryListener.hypothesisReceived(this.privAudioNode.findTimeAtOffset(offset));\r\n }\r\n }\r\n\r\n public onPhraseRecognized(offset: number): void {\r\n this.privServiceTelemetryListener.phraseReceived(this.privAudioNode.findTimeAtOffset(offset));\r\n this.onServiceRecognized(offset);\r\n }\r\n\r\n public onServiceRecognized(offset: number): void {\r\n this.privLastRecoOffset = offset;\r\n this.privHypothesisReceived = false;\r\n this.privAudioNode.shrinkBuffers(offset);\r\n }\r\n\r\n public onAudioSent(bytesSent: number): void {\r\n this.privBytesSent += bytesSent;\r\n }\r\n\r\n public dispose = (error?: string): void => {\r\n if (!this.privIsDisposed) {\r\n // we should have completed by now. If we did not its an unknown error.\r\n this.privIsDisposed = true;\r\n for (const detachable of this.privDetachables) {\r\n detachable.detach();\r\n }\r\n\r\n this.privServiceTelemetryListener.dispose();\r\n }\r\n }\r\n\r\n public getTelemetry = (): string => {\r\n if (this.privServiceTelemetryListener.hasTelemetry) {\r\n return this.privServiceTelemetryListener.getTelemetry();\r\n } else {\r\n return null;\r\n }\r\n }\r\n\r\n public onStopRecognizing(): void {\r\n this.onComplete();\r\n }\r\n\r\n // Should be called with the audioNode for this session has indicated that it is out of speech.\r\n public onSpeechEnded(): void {\r\n this.privIsSpeechEnded = true;\r\n }\r\n\r\n protected onEvent = (event: SpeechRecognitionEvent): void => {\r\n if (!!this.privServiceTelemetryListener) {\r\n this.privServiceTelemetryListener.onEvent(event);\r\n }\r\n Events.instance.onEvent(event);\r\n }\r\n\r\n private onComplete = (): void => {\r\n if (!!this.privIsRecognizing) {\r\n this.privIsRecognizing = false;\r\n this.detachAudioNode();\r\n }\r\n }\r\n\r\n private detachAudioNode = (): void => {\r\n if (!this.privIsAudioNodeDetached) {\r\n this.privIsAudioNodeDetached = true;\r\n if (this.privAudioNode) {\r\n this.privAudioNode.detach();\r\n }\r\n }\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n AudioSourceErrorEvent,\r\n AudioStreamNodeAttachedEvent,\r\n AudioStreamNodeAttachingEvent,\r\n AudioStreamNodeDetachedEvent,\r\n AudioStreamNodeErrorEvent,\r\n ConnectionEstablishedEvent,\r\n ConnectionEstablishErrorEvent,\r\n ConnectionMessageReceivedEvent,\r\n ConnectionStartEvent,\r\n IEventListener,\r\n IStringDictionary,\r\n PlatformEvent,\r\n} from \"../common/Exports\";\r\nimport { ConnectingToServiceEvent, RecognitionTriggeredEvent } from \"./RecognitionEvents\";\r\n\r\nexport interface ITelemetry {\r\n Metrics: IMetric[];\r\n ReceivedMessages: IStringDictionary;\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport interface IMetric {\r\n End?: string;\r\n Error?: string;\r\n Id?: string;\r\n Name?: string;\r\n Start?: string;\r\n PhraseLatencyMs?: number[];\r\n FirstHypothesisLatencyMs?: number[];\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class ServiceTelemetryListener implements IEventListener {\r\n private privIsDisposed: boolean = false;\r\n\r\n private privRequestId: string;\r\n private privAudioSourceId: string;\r\n private privAudioNodeId: string;\r\n\r\n private privListeningTriggerMetric: IMetric = null;\r\n private privMicMetric: IMetric = null;\r\n private privConnectionEstablishMetric: IMetric = null;\r\n\r\n private privMicStartTime: string;\r\n\r\n private privConnectionId: string;\r\n private privConnectionStartTime: string;\r\n\r\n private privReceivedMessages: IStringDictionary;\r\n private privPhraseLatencies: number[];\r\n private privHypothesisLatencies: number[];\r\n\r\n constructor(requestId: string, audioSourceId: string, audioNodeId: string) {\r\n this.privRequestId = requestId;\r\n this.privAudioSourceId = audioSourceId;\r\n this.privAudioNodeId = audioNodeId;\r\n\r\n this.privReceivedMessages = {};\r\n this.privPhraseLatencies = [];\r\n this.privHypothesisLatencies = [];\r\n }\r\n\r\n public phraseReceived(audioReceivedTime: number): void {\r\n if (audioReceivedTime > 0) { // 0 indicates the time is unknown. Drop it.\r\n this.privPhraseLatencies.push(Date.now() - audioReceivedTime);\r\n }\r\n }\r\n\r\n public hypothesisReceived(audioReceivedTime: number): void {\r\n if (audioReceivedTime > 0) { // 0 indicates the time is unknown. Drop it.\r\n this.privHypothesisLatencies.push(Date.now() - audioReceivedTime);\r\n }\r\n }\r\n\r\n public onEvent = (e: PlatformEvent): void => {\r\n if (this.privIsDisposed) {\r\n return;\r\n }\r\n\r\n if (e instanceof RecognitionTriggeredEvent && e.requestId === this.privRequestId) {\r\n this.privListeningTriggerMetric = {\r\n End: e.eventTime,\r\n Name: \"ListeningTrigger\",\r\n Start: e.eventTime,\r\n };\r\n }\r\n\r\n if (e instanceof AudioStreamNodeAttachingEvent && e.audioSourceId === this.privAudioSourceId && e.audioNodeId === this.privAudioNodeId) {\r\n this.privMicStartTime = e.eventTime;\r\n }\r\n\r\n if (e instanceof AudioStreamNodeAttachedEvent && e.audioSourceId === this.privAudioSourceId && e.audioNodeId === this.privAudioNodeId) {\r\n this.privMicStartTime = e.eventTime;\r\n }\r\n\r\n if (e instanceof AudioSourceErrorEvent && e.audioSourceId === this.privAudioSourceId) {\r\n if (!this.privMicMetric) {\r\n this.privMicMetric = {\r\n End: e.eventTime,\r\n Error: e.error,\r\n Name: \"Microphone\",\r\n Start: this.privMicStartTime,\r\n };\r\n }\r\n }\r\n\r\n if (e instanceof AudioStreamNodeErrorEvent && e.audioSourceId === this.privAudioSourceId && e.audioNodeId === this.privAudioNodeId) {\r\n if (!this.privMicMetric) {\r\n this.privMicMetric = {\r\n End: e.eventTime,\r\n Error: e.error,\r\n Name: \"Microphone\",\r\n Start: this.privMicStartTime,\r\n };\r\n }\r\n }\r\n\r\n if (e instanceof AudioStreamNodeDetachedEvent && e.audioSourceId === this.privAudioSourceId && e.audioNodeId === this.privAudioNodeId) {\r\n if (!this.privMicMetric) {\r\n this.privMicMetric = {\r\n End: e.eventTime,\r\n Name: \"Microphone\",\r\n Start: this.privMicStartTime,\r\n };\r\n }\r\n }\r\n\r\n if (e instanceof ConnectingToServiceEvent && e.requestId === this.privRequestId) {\r\n this.privConnectionId = e.sessionId;\r\n }\r\n\r\n if (e instanceof ConnectionStartEvent && e.connectionId === this.privConnectionId) {\r\n this.privConnectionStartTime = e.eventTime;\r\n }\r\n\r\n if (e instanceof ConnectionEstablishedEvent && e.connectionId === this.privConnectionId) {\r\n if (!this.privConnectionEstablishMetric) {\r\n this.privConnectionEstablishMetric = {\r\n End: e.eventTime,\r\n Id: this.privConnectionId,\r\n Name: \"Connection\",\r\n Start: this.privConnectionStartTime,\r\n };\r\n }\r\n }\r\n\r\n if (e instanceof ConnectionEstablishErrorEvent && e.connectionId === this.privConnectionId) {\r\n if (!this.privConnectionEstablishMetric) {\r\n this.privConnectionEstablishMetric = {\r\n End: e.eventTime,\r\n Error: this.getConnectionError(e.statusCode),\r\n Id: this.privConnectionId,\r\n Name: \"Connection\",\r\n Start: this.privConnectionStartTime,\r\n };\r\n }\r\n }\r\n\r\n if (e instanceof ConnectionMessageReceivedEvent && e.connectionId === this.privConnectionId) {\r\n if (e.message && e.message.headers && e.message.headers.path) {\r\n if (!this.privReceivedMessages[e.message.headers.path]) {\r\n this.privReceivedMessages[e.message.headers.path] = new Array();\r\n }\r\n\r\n this.privReceivedMessages[e.message.headers.path].push(e.networkReceivedTime);\r\n }\r\n }\r\n }\r\n\r\n public getTelemetry = (): string => {\r\n const metrics = new Array();\r\n\r\n if (this.privListeningTriggerMetric) {\r\n metrics.push(this.privListeningTriggerMetric);\r\n }\r\n\r\n if (this.privMicMetric) {\r\n metrics.push(this.privMicMetric);\r\n }\r\n\r\n if (this.privConnectionEstablishMetric) {\r\n metrics.push(this.privConnectionEstablishMetric);\r\n }\r\n\r\n if (this.privPhraseLatencies.length > 0) {\r\n metrics.push({\r\n PhraseLatencyMs: this.privPhraseLatencies,\r\n });\r\n }\r\n\r\n if (this.privHypothesisLatencies.length > 0) {\r\n metrics.push({\r\n FirstHypothesisLatencyMs: this.privHypothesisLatencies,\r\n });\r\n }\r\n\r\n const telemetry: ITelemetry = {\r\n Metrics: metrics,\r\n ReceivedMessages: this.privReceivedMessages,\r\n };\r\n\r\n const json = JSON.stringify(telemetry);\r\n\r\n // We dont want to send the same telemetry again. So clean those out.\r\n this.privReceivedMessages = {};\r\n this.privListeningTriggerMetric = null;\r\n this.privMicMetric = null;\r\n this.privConnectionEstablishMetric = null;\r\n this.privPhraseLatencies = [];\r\n this.privHypothesisLatencies = [];\r\n return json;\r\n }\r\n\r\n // Determines if there are any telemetry events to send to the service.\r\n public get hasTelemetry(): boolean {\r\n return (Object.keys(this.privReceivedMessages).length !== 0 ||\r\n this.privListeningTriggerMetric !== null ||\r\n this.privMicMetric !== null ||\r\n this.privConnectionEstablishMetric !== null ||\r\n this.privPhraseLatencies.length !== 0 ||\r\n this.privHypothesisLatencies.length !== 0);\r\n }\r\n\r\n public dispose = (): void => {\r\n this.privIsDisposed = true;\r\n }\r\n\r\n private getConnectionError = (statusCode: number): string => {\r\n /*\r\n -- Websocket status codes --\r\n NormalClosure = 1000,\r\n EndpointUnavailable = 1001,\r\n ProtocolError = 1002,\r\n InvalidMessageType = 1003,\r\n Empty = 1005,\r\n InvalidPayloadData = 1007,\r\n PolicyViolation = 1008,\r\n MessageTooBig = 1009,\r\n MandatoryExtension = 1010,\r\n InternalServerError = 1011\r\n */\r\n\r\n switch (statusCode) {\r\n case 400:\r\n case 1002:\r\n case 1003:\r\n case 1005:\r\n case 1007:\r\n case 1008:\r\n case 1009: return \"BadRequest\";\r\n case 401: return \"Unauthorized\";\r\n case 403: return \"Forbidden\";\r\n case 503:\r\n case 1001: return \"ServerUnavailable\";\r\n case 500:\r\n case 1011: return \"ServerError\";\r\n case 408:\r\n case 504: return \"Timeout\";\r\n default: return \"statuscode:\" + statusCode.toString();\r\n }\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n DynamicGrammarBuilder,\r\n IDynamicGrammar,\r\n} from \"./Exports\";\r\n\r\n/**\r\n * Represents the JSON used in the speech.context message sent to the speech service.\r\n * The dynamic grammar is always refreshed from the encapsulated dynamic grammar object.\r\n */\r\nexport class SpeechContext {\r\n private privContext: { [section: string]: any } = {};\r\n private privDynamicGrammar: DynamicGrammarBuilder;\r\n\r\n constructor(dynamicGrammar: DynamicGrammarBuilder) {\r\n this.privDynamicGrammar = dynamicGrammar;\r\n }\r\n\r\n /**\r\n * Adds a section to the speech.context object.\r\n * @param sectionName Name of the section to add.\r\n * @param value JSON serializable object that represents the value.\r\n */\r\n public setSection(sectionName: string, value: any): void {\r\n this.privContext[sectionName] = value;\r\n }\r\n\r\n public toJSON(): string {\r\n\r\n const dgi: IDynamicGrammar = this.privDynamicGrammar.generateGrammarObject();\r\n this.setSection(\"dgi\", dgi);\r\n\r\n const ret: string = JSON.stringify(this.privContext);\r\n return ret;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n IDynamicGrammar,\r\n IDynamicGrammarGeneric,\r\n} from \"./Exports\";\r\n\r\n/**\r\n * Responsible for building the object to be sent to the speech service to support dynamic grammars.\r\n * @class DynamicGrammarBuilder\r\n */\r\nexport class DynamicGrammarBuilder {\r\n\r\n private privPhrases: string[];\r\n private privGrammars: string[];\r\n\r\n // Adds one more reference phrases to the dynamic grammar to send.\r\n // All added phrases are generic phrases.\r\n public addPhrase(phrase: string | string[]): void {\r\n if (!this.privPhrases) {\r\n this.privPhrases = [];\r\n }\r\n\r\n if (phrase instanceof Array) {\r\n this.privPhrases = this.privPhrases.concat(phrase as string[]);\r\n } else {\r\n this.privPhrases.push(phrase as string);\r\n }\r\n }\r\n\r\n // Clears all phrases stored in the current object.\r\n public clearPhrases(): void {\r\n this.privPhrases = undefined;\r\n }\r\n\r\n // Adds one or more reference grammars to the current grammar.\r\n public addReferenceGrammar(grammar: string | string[]): void {\r\n if (!this.privGrammars) {\r\n this.privGrammars = [];\r\n }\r\n\r\n if (grammar instanceof Array) {\r\n this.privGrammars = this.privGrammars.concat(grammar as string[]);\r\n } else {\r\n this.privGrammars.push(grammar as string);\r\n }\r\n }\r\n\r\n // clears all grammars stored on the recognizer.\r\n public clearGrammars(): void {\r\n this.privGrammars = undefined;\r\n }\r\n\r\n // Generates an object that represents the dynamic grammar used by the Speech Service.\r\n // This is done by building an object with the correct layout based on the phrases and reference grammars added to this instance\r\n // of a DynamicGrammarBuilder\r\n public generateGrammarObject(): IDynamicGrammar {\r\n if (this.privGrammars === undefined && this.privPhrases === undefined) {\r\n return undefined;\r\n }\r\n\r\n const retObj: IDynamicGrammar = {};\r\n retObj.ReferenceGrammars = this.privGrammars;\r\n\r\n if (undefined !== this.privPhrases && 0 !== this.privPhrases.length) {\r\n const retPhrases: IDynamicGrammarGeneric[] = [];\r\n\r\n this.privPhrases.forEach((value: string, index: number, array: string[]): void => {\r\n retPhrases.push({\r\n Text: value,\r\n });\r\n });\r\n\r\n retObj.Groups = [{ Type: \"Generic\", Items: retPhrases }];\r\n }\r\n\r\n return retObj;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ReplayableAudioNode } from \"../common.browser/Exports\";\r\nimport {\r\n ConnectionEvent,\r\n ConnectionMessage,\r\n ConnectionOpenResponse,\r\n ConnectionState,\r\n createGuid,\r\n createNoDashGuid,\r\n Deferred,\r\n IAudioSource,\r\n IAudioStreamNode,\r\n IConnection,\r\n IStreamChunk,\r\n MessageType,\r\n Promise,\r\n PromiseHelper,\r\n PromiseResult,\r\n ServiceEvent,\r\n} from \"../common/Exports\";\r\nimport { AudioOutputFormatImpl } from \"../sdk/Audio/AudioOutputFormat\";\r\nimport { PullAudioOutputStreamImpl } from \"../sdk/Audio/AudioOutputStream\";\r\nimport { AudioStreamFormatImpl } from \"../sdk/Audio/AudioStreamFormat\";\r\nimport {\r\n ActivityReceivedEventArgs,\r\n AudioOutputStream,\r\n CancellationErrorCode,\r\n CancellationReason,\r\n DialogServiceConnector,\r\n PropertyCollection,\r\n PropertyId,\r\n PullAudioOutputStream,\r\n RecognitionEventArgs,\r\n ResultReason,\r\n SessionEventArgs,\r\n SpeechRecognitionCanceledEventArgs,\r\n SpeechRecognitionEventArgs,\r\n SpeechRecognitionResult,\r\n SpeechSynthesisOutputFormat,\r\n} from \"../sdk/Exports\";\r\nimport { DialogServiceTurnStateManager } from \"./DialogServiceTurnStateManager\";\r\nimport {\r\n AgentConfig,\r\n CancellationErrorCodePropertyName,\r\n EnumTranslation,\r\n ISpeechConfigAudioDevice,\r\n RecognitionStatus,\r\n RequestSession,\r\n ServiceRecognizerBase,\r\n SimpleSpeechPhrase,\r\n SpeechDetected,\r\n SpeechHypothesis,\r\n} from \"./Exports\";\r\nimport { AuthInfo, IAuthentication } from \"./IAuthentication\";\r\nimport { IConnectionFactory } from \"./IConnectionFactory\";\r\nimport { RecognitionMode, RecognizerConfig } from \"./RecognizerConfig\";\r\nimport { ActivityPayloadResponse } from \"./ServiceMessages/ActivityResponsePayload\";\r\nimport { SpeechConnectionMessage } from \"./SpeechConnectionMessage.Internal\";\r\n\r\nexport class DialogServiceAdapter extends ServiceRecognizerBase {\r\n private privDialogServiceConnector: DialogServiceConnector;\r\n private privDialogConnectionFactory: IConnectionFactory;\r\n private privDialogAuthFetchEventId: string;\r\n private privDialogIsDisposed: boolean;\r\n private privDialogAuthentication: IAuthentication;\r\n private privDialogAudioSource: IAudioSource;\r\n private privDialogRequestSession: RequestSession;\r\n\r\n // A promise for a configured connection.\r\n // Do not consume directly, call fetchDialogConnection instead.\r\n private privConnectionConfigPromise: Promise;\r\n\r\n // A promise for a connection, but one that has not had the speech context sent yet.\r\n // Do not consume directly, call fetchDialogConnection instead.\r\n private privDialogConnectionPromise: Promise;\r\n\r\n private privConnectionLoop: Promise;\r\n private terminateMessageLoop: boolean;\r\n private agentConfigSent: boolean;\r\n private privLastResult: SpeechRecognitionResult;\r\n\r\n // Turns are of two kinds:\r\n // 1: SR turns, end when the SR result is returned and then turn end.\r\n // 2: Service turns where an activity is sent by the service along with the audio.\r\n private privTurnStateManager: DialogServiceTurnStateManager;\r\n\r\n public constructor(\r\n authentication: IAuthentication,\r\n connectionFactory: IConnectionFactory,\r\n audioSource: IAudioSource,\r\n recognizerConfig: RecognizerConfig,\r\n dialogServiceConnector: DialogServiceConnector) {\r\n\r\n super(authentication, connectionFactory, audioSource, recognizerConfig, dialogServiceConnector);\r\n\r\n this.privDialogServiceConnector = dialogServiceConnector;\r\n this.privDialogAuthentication = authentication;\r\n this.receiveMessageOverride = this.receiveDialogMessageOverride;\r\n this.privTurnStateManager = new DialogServiceTurnStateManager();\r\n this.recognizeOverride = this.listenOnce;\r\n this.connectImplOverride = this.dialogConnectImpl;\r\n this.configConnectionOverride = this.configConnection;\r\n this.fetchConnectionOverride = this.fetchDialogConnection;\r\n this.disconnectOverride = this.privDisconnect;\r\n this.privDialogAudioSource = audioSource;\r\n this.privDialogRequestSession = new RequestSession(audioSource.id());\r\n this.privDialogConnectionFactory = connectionFactory;\r\n this.privDialogIsDisposed = false;\r\n this.agentConfigSent = false;\r\n this.privLastResult = null;\r\n }\r\n\r\n public isDisposed(): boolean {\r\n return this.privDialogIsDisposed;\r\n }\r\n\r\n public dispose(reason?: string): void {\r\n this.privDialogIsDisposed = true;\r\n if (this.privConnectionConfigPromise) {\r\n this.privConnectionConfigPromise.onSuccessContinueWith((connection: IConnection) => {\r\n connection.dispose(reason);\r\n });\r\n }\r\n }\r\n\r\n public sendMessage = (message: string): void => {\r\n const interactionGuid: string = createGuid();\r\n const requestId: string = createNoDashGuid();\r\n\r\n const agentMessage: any = {\r\n context: {\r\n interactionId: interactionGuid\r\n },\r\n messagePayload: JSON.parse(message),\r\n version: 0.5\r\n };\r\n\r\n const agentMessageJson = JSON.stringify(agentMessage);\r\n\r\n this.fetchDialogConnection().onSuccessContinueWith((connection: IConnection) => {\r\n connection.send(new SpeechConnectionMessage(\r\n MessageType.Text,\r\n \"agent\",\r\n requestId,\r\n \"application/json\",\r\n agentMessageJson));\r\n });\r\n }\r\n\r\n protected privDisconnect(): void {\r\n this.cancelRecognition(this.privDialogRequestSession.sessionId,\r\n this.privDialogRequestSession.requestId,\r\n CancellationReason.Error,\r\n CancellationErrorCode.NoError,\r\n \"Disconnecting\");\r\n\r\n this.terminateMessageLoop = true;\r\n this.agentConfigSent = false;\r\n if (this.privDialogConnectionPromise.result().isCompleted) {\r\n if (!this.privDialogConnectionPromise.result().isError) {\r\n this.privDialogConnectionPromise.result().result.dispose();\r\n this.privDialogConnectionPromise = null;\r\n }\r\n } else {\r\n this.privDialogConnectionPromise.onSuccessContinueWith((connection: IConnection) => {\r\n connection.dispose();\r\n });\r\n }\r\n }\r\n\r\n protected processTypeSpecificMessages(connectionMessage: SpeechConnectionMessage): boolean {\r\n\r\n const resultProps: PropertyCollection = new PropertyCollection();\r\n if (connectionMessage.messageType === MessageType.Text) {\r\n resultProps.setProperty(PropertyId.SpeechServiceResponse_JsonResult, connectionMessage.textBody);\r\n }\r\n\r\n let result: SpeechRecognitionResult;\r\n let processed: boolean;\r\n\r\n switch (connectionMessage.path.toLowerCase()) {\r\n case \"speech.phrase\":\r\n const speechPhrase: SimpleSpeechPhrase = SimpleSpeechPhrase.fromJSON(connectionMessage.textBody);\r\n\r\n this.privDialogRequestSession.onPhraseRecognized(this.privDialogRequestSession.currentTurnAudioOffset + speechPhrase.Offset + speechPhrase.Duration);\r\n\r\n if (speechPhrase.RecognitionStatus === RecognitionStatus.Success) {\r\n const args: SpeechRecognitionEventArgs = this.fireEventForResult(speechPhrase, resultProps);\r\n this.privLastResult = args.result;\r\n\r\n if (!!this.privDialogServiceConnector.recognized) {\r\n try {\r\n this.privDialogServiceConnector.recognized(this.privDialogServiceConnector, args);\r\n /* tslint:disable:no-empty */\r\n } catch (error) {\r\n // Not going to let errors in the event handler\r\n // trip things up.\r\n }\r\n }\r\n }\r\n processed = true;\r\n break;\r\n case \"speech.hypothesis\":\r\n const hypothesis: SpeechHypothesis = SpeechHypothesis.fromJSON(connectionMessage.textBody);\r\n const offset: number = hypothesis.Offset + this.privDialogRequestSession.currentTurnAudioOffset;\r\n\r\n result = new SpeechRecognitionResult(\r\n this.privDialogRequestSession.requestId,\r\n ResultReason.RecognizingSpeech,\r\n hypothesis.Text,\r\n hypothesis.Duration,\r\n offset,\r\n hypothesis.Language,\r\n hypothesis.LanguageDetectionConfidence,\r\n undefined,\r\n connectionMessage.textBody,\r\n resultProps);\r\n\r\n this.privDialogRequestSession.onHypothesis(offset);\r\n\r\n const ev = new SpeechRecognitionEventArgs(result, hypothesis.Duration, this.privDialogRequestSession.sessionId);\r\n\r\n if (!!this.privDialogServiceConnector.recognizing) {\r\n try {\r\n this.privDialogServiceConnector.recognizing(this.privDialogServiceConnector, ev);\r\n /* tslint:disable:no-empty */\r\n } catch (error) {\r\n // Not going to let errors in the event handler\r\n // trip things up.\r\n }\r\n }\r\n processed = true;\r\n break;\r\n\r\n case \"audio\":\r\n {\r\n const audioRequestId = connectionMessage.requestId.toUpperCase();\r\n const turn = this.privTurnStateManager.GetTurn(audioRequestId);\r\n try {\r\n // Empty binary message signals end of stream.\r\n if (!connectionMessage.binaryBody) {\r\n turn.endAudioStream();\r\n } else {\r\n turn.audioStream.write(connectionMessage.binaryBody);\r\n }\r\n } catch (error) {\r\n // Not going to let errors in the event handler\r\n // trip things up.\r\n }\r\n }\r\n processed = true;\r\n break;\r\n\r\n case \"response\":\r\n {\r\n const responseRequestId = connectionMessage.requestId.toUpperCase();\r\n const activityPayload: ActivityPayloadResponse = ActivityPayloadResponse.fromJSON(connectionMessage.textBody);\r\n const turn = this.privTurnStateManager.GetTurn(responseRequestId);\r\n\r\n // update the conversation Id\r\n if (activityPayload.conversationId) {\r\n const updateAgentConfig = this.agentConfig.get();\r\n updateAgentConfig.botInfo.conversationId = activityPayload.conversationId;\r\n this.agentConfig.set(updateAgentConfig);\r\n }\r\n\r\n const pullAudioOutputStream: PullAudioOutputStreamImpl = turn.processActivityPayload(activityPayload, (SpeechSynthesisOutputFormat as any)[this.privDialogServiceConnector.properties.getProperty(PropertyId.SpeechServiceConnection_SynthOutputFormat, undefined)]);\r\n const activity = new ActivityReceivedEventArgs(activityPayload.messagePayload, pullAudioOutputStream);\r\n if (!!this.privDialogServiceConnector.activityReceived) {\r\n try {\r\n this.privDialogServiceConnector.activityReceived(this.privDialogServiceConnector, activity);\r\n /* tslint:disable:no-empty */\r\n } catch (error) {\r\n // Not going to let errors in the event handler\r\n // trip things up.\r\n }\r\n }\r\n }\r\n processed = true;\r\n break;\r\n\r\n default:\r\n break;\r\n }\r\n return processed;\r\n }\r\n\r\n // Cancels recognition.\r\n protected cancelRecognition(\r\n sessionId: string,\r\n requestId: string,\r\n cancellationReason: CancellationReason,\r\n errorCode: CancellationErrorCode,\r\n error: string): void {\r\n\r\n this.terminateMessageLoop = true;\r\n\r\n if (!!this.privDialogRequestSession.isRecognizing) {\r\n this.privDialogRequestSession.onStopRecognizing();\r\n }\r\n\r\n if (!!this.privDialogServiceConnector.canceled) {\r\n const properties: PropertyCollection = new PropertyCollection();\r\n properties.setProperty(CancellationErrorCodePropertyName, CancellationErrorCode[errorCode]);\r\n\r\n const cancelEvent: SpeechRecognitionCanceledEventArgs = new SpeechRecognitionCanceledEventArgs(\r\n cancellationReason,\r\n error,\r\n errorCode,\r\n undefined,\r\n sessionId);\r\n\r\n try {\r\n this.privDialogServiceConnector.canceled(this.privDialogServiceConnector, cancelEvent);\r\n /* tslint:disable:no-empty */\r\n } catch { }\r\n\r\n if (!!this.privSuccessCallback) {\r\n const result: SpeechRecognitionResult = new SpeechRecognitionResult(\r\n undefined, // ResultId\r\n ResultReason.Canceled,\r\n undefined, // Text\r\n undefined, // Druation\r\n undefined, // Offset\r\n undefined, // Language\r\n undefined, // Language Detection Confidence\r\n error,\r\n undefined, // Json\r\n properties);\r\n try {\r\n this.privSuccessCallback(result);\r\n this.privSuccessCallback = undefined;\r\n /* tslint:disable:no-empty */\r\n } catch { }\r\n }\r\n }\r\n }\r\n\r\n protected listenOnce = (\r\n recoMode: RecognitionMode,\r\n successCallback: (e: SpeechRecognitionResult) => void,\r\n errorCallback: (e: string) => void\r\n ): Promise => {\r\n this.privRecognizerConfig.recognitionMode = recoMode;\r\n\r\n this.privSuccessCallback = successCallback;\r\n this.privErrorCallback = errorCallback;\r\n\r\n this.privDialogRequestSession.startNewRecognition();\r\n this.privDialogRequestSession.listenForServiceTelemetry(this.privDialogAudioSource.events);\r\n\r\n // Start the connection to the service. The promise this will create is stored and will be used by configureConnection().\r\n this.dialogConnectImpl();\r\n\r\n this.sendPreAudioMessages();\r\n\r\n return this.privDialogAudioSource\r\n .attach(this.privDialogRequestSession.audioNodeId)\r\n .continueWithPromise((result: PromiseResult) => {\r\n let audioNode: ReplayableAudioNode;\r\n\r\n if (result.isError) {\r\n this.cancelRecognition(this.privDialogRequestSession.sessionId, this.privDialogRequestSession.requestId, CancellationReason.Error, CancellationErrorCode.ConnectionFailure, result.error);\r\n return PromiseHelper.fromError(result.error);\r\n }\r\n\r\n return this.privDialogAudioSource.format.onSuccessContinueWithPromise((format: AudioStreamFormatImpl) => {\r\n audioNode = new ReplayableAudioNode(result.result, format.avgBytesPerSec);\r\n this.privDialogRequestSession.onAudioSourceAttachCompleted(audioNode, false);\r\n\r\n return this.privDialogAudioSource.deviceInfo.onSuccessContinueWithPromise((deviceInfo: ISpeechConfigAudioDevice): Promise => {\r\n this.privRecognizerConfig.SpeechServiceConfig.Context.audio = { source: deviceInfo };\r\n\r\n return this.configConnection()\r\n .continueWithPromise((result: PromiseResult): Promise => {\r\n if (result.isError) {\r\n this.cancelRecognitionLocal(CancellationReason.Error, CancellationErrorCode.ConnectionFailure, result.error);\r\n return PromiseHelper.fromError(result.error);\r\n }\r\n\r\n const sessionStartEventArgs: SessionEventArgs = new SessionEventArgs(this.privDialogRequestSession.sessionId);\r\n\r\n if (!!this.privRecognizer.sessionStarted) {\r\n this.privRecognizer.sessionStarted(this.privRecognizer, sessionStartEventArgs);\r\n }\r\n\r\n const audioSendPromise = this.sendAudio(audioNode);\r\n\r\n // /* tslint:disable:no-empty */\r\n audioSendPromise.on((_: boolean) => { /*add? return true;*/ }, (error: string) => {\r\n this.cancelRecognition(this.privDialogRequestSession.sessionId, this.privDialogRequestSession.requestId, CancellationReason.Error, CancellationErrorCode.RuntimeError, error);\r\n });\r\n\r\n return PromiseHelper.fromResult(true);\r\n });\r\n });\r\n });\r\n });\r\n }\r\n\r\n protected sendAudio = (audioStreamNode: IAudioStreamNode): Promise => {\r\n return this.privDialogAudioSource.format.onSuccessContinueWithPromise((audioFormat: AudioStreamFormatImpl) => {\r\n // NOTE: Home-baked promises crash ios safari during the invocation\r\n // of the error callback chain (looks like the recursion is way too deep, and\r\n // it blows up the stack). The following construct is a stop-gap that does not\r\n // bubble the error up the callback chain and hence circumvents this problem.\r\n // TODO: rewrite with ES6 promises.\r\n const deferred = new Deferred();\r\n\r\n // The time we last sent data to the service.\r\n let nextSendTime: number = Date.now();\r\n\r\n // Max amount to send before we start to throttle\r\n const fastLaneSizeMs: string = this.privRecognizerConfig.parameters.getProperty(\"SPEECH-TransmitLengthBeforThrottleMs\", \"5000\");\r\n const maxSendUnthrottledBytes: number = audioFormat.avgBytesPerSec / 1000 * parseInt(fastLaneSizeMs, 10);\r\n const startRecogNumber: number = this.privDialogRequestSession.recogNumber;\r\n\r\n const readAndUploadCycle = () => {\r\n\r\n // If speech is done, stop sending audio.\r\n if (!this.privDialogIsDisposed &&\r\n !this.privDialogRequestSession.isSpeechEnded &&\r\n this.privDialogRequestSession.isRecognizing &&\r\n this.privDialogRequestSession.recogNumber === startRecogNumber) {\r\n this.fetchDialogConnection().on((connection: IConnection) => {\r\n audioStreamNode.read().on(\r\n (audioStreamChunk: IStreamChunk) => {\r\n // we have a new audio chunk to upload.\r\n if (this.privDialogRequestSession.isSpeechEnded) {\r\n // If service already recognized audio end then don't send any more audio\r\n deferred.resolve(true);\r\n return;\r\n }\r\n\r\n let payload: ArrayBuffer;\r\n let sendDelay: number;\r\n\r\n if (!audioStreamChunk || audioStreamChunk.isEnd) {\r\n payload = null;\r\n sendDelay = 0;\r\n } else {\r\n payload = audioStreamChunk.buffer;\r\n this.privDialogRequestSession.onAudioSent(payload.byteLength);\r\n\r\n if (maxSendUnthrottledBytes >= this.privDialogRequestSession.bytesSent) {\r\n sendDelay = 0;\r\n } else {\r\n sendDelay = Math.max(0, nextSendTime - Date.now());\r\n }\r\n }\r\n\r\n // Are we ready to send, or need we delay more?\r\n setTimeout(() => {\r\n if (payload !== null) {\r\n nextSendTime = Date.now() + (payload.byteLength * 1000 / (audioFormat.avgBytesPerSec * 2));\r\n }\r\n\r\n const uploaded: Promise = connection.send(\r\n new SpeechConnectionMessage(\r\n MessageType.Binary, \"audio\", this.privDialogRequestSession.requestId, null, payload));\r\n\r\n if (audioStreamChunk && !audioStreamChunk.isEnd) {\r\n uploaded.continueWith((_: PromiseResult) => {\r\n\r\n // Regardless of success or failure, schedule the next upload.\r\n // If the underlying connection was broken, the next cycle will\r\n // get a new connection and re-transmit missing audio automatically.\r\n readAndUploadCycle();\r\n });\r\n } else {\r\n // the audio stream has been closed, no need to schedule next\r\n // read-upload cycle.\r\n this.privDialogRequestSession.onSpeechEnded();\r\n deferred.resolve(true);\r\n }\r\n }, sendDelay);\r\n },\r\n (error: string) => {\r\n if (this.privDialogRequestSession.isSpeechEnded) {\r\n // For whatever reason, Reject is used to remove queue subscribers inside\r\n // the Queue.DrainAndDispose invoked from DetachAudioNode down below, which\r\n // means that sometimes things can be rejected in normal circumstances, without\r\n // any errors.\r\n deferred.resolve(true); // TODO: remove the argument, it's is completely meaningless.\r\n } else {\r\n // Only reject, if there was a proper error.\r\n deferred.reject(error);\r\n }\r\n });\r\n }, (error: string) => {\r\n deferred.reject(error);\r\n });\r\n }\r\n };\r\n\r\n readAndUploadCycle();\r\n\r\n return deferred.promise();\r\n });\r\n }\r\n\r\n protected sendWaveHeader(connection: IConnection): Promise {\r\n return this.audioSource.format.onSuccessContinueWithPromise((format: AudioStreamFormatImpl) => {\r\n return connection.send(new SpeechConnectionMessage(\r\n MessageType.Binary,\r\n \"audio\",\r\n this.privDialogRequestSession.requestId,\r\n \"audio/x-wav\",\r\n format.header));\r\n });\r\n }\r\n\r\n // Establishes a websocket connection to the end point.\r\n private dialogConnectImpl(isUnAuthorized: boolean = false): Promise {\r\n if (this.privDialogConnectionPromise) {\r\n if (this.privDialogConnectionPromise.result().isCompleted &&\r\n (this.privDialogConnectionPromise.result().isError\r\n || this.privDialogConnectionPromise.result().result.state() === ConnectionState.Disconnected)) {\r\n this.agentConfigSent = false;\r\n this.privDialogConnectionPromise = null;\r\n this.terminateMessageLoop = true;\r\n return this.configConnection();\r\n } else {\r\n return this.privDialogConnectionPromise;\r\n }\r\n }\r\n\r\n this.privDialogAuthFetchEventId = createNoDashGuid();\r\n\r\n // keep the connectionId for reconnect events\r\n if (this.privConnectionId === undefined) {\r\n this.privConnectionId = createNoDashGuid();\r\n }\r\n\r\n this.privDialogRequestSession.onPreConnectionStart(this.privDialogAuthFetchEventId, this.privConnectionId);\r\n\r\n const authPromise = isUnAuthorized ? this.privDialogAuthentication.fetchOnExpiry(this.privDialogAuthFetchEventId) : this.privDialogAuthentication.fetch(this.privDialogAuthFetchEventId);\r\n\r\n this.privDialogConnectionPromise = authPromise\r\n .continueWithPromise((result: PromiseResult) => {\r\n if (result.isError) {\r\n this.privDialogRequestSession.onAuthCompleted(true, result.error);\r\n throw new Error(result.error);\r\n } else {\r\n this.privDialogRequestSession.onAuthCompleted(false);\r\n }\r\n\r\n const connection: IConnection = this.privDialogConnectionFactory.create(this.privRecognizerConfig, result.result, this.privConnectionId);\r\n\r\n this.privDialogRequestSession.listenForServiceTelemetry(connection.events);\r\n\r\n // Attach to the underlying event. No need to hold onto the detach pointers as in the event the connection goes away,\r\n // it'll stop sending events.\r\n connection.events.attach((event: ConnectionEvent) => {\r\n this.connectionEvents.onEvent(event);\r\n });\r\n\r\n return connection.open().onSuccessContinueWithPromise((response: ConnectionOpenResponse): Promise => {\r\n if (response.statusCode === 200) {\r\n this.privDialogRequestSession.onPreConnectionStart(this.privDialogAuthFetchEventId, this.privConnectionId);\r\n this.privDialogRequestSession.onConnectionEstablishCompleted(response.statusCode);\r\n\r\n return PromiseHelper.fromResult(connection);\r\n } else if (response.statusCode === 403 && !isUnAuthorized) {\r\n return this.dialogConnectImpl(true);\r\n } else {\r\n this.privDialogRequestSession.onConnectionEstablishCompleted(response.statusCode, response.reason);\r\n return PromiseHelper.fromError(`Unable to contact server. StatusCode: ${response.statusCode}, ${this.privRecognizerConfig.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint)} Reason: ${response.reason}`);\r\n }\r\n });\r\n });\r\n\r\n this.privConnectionLoop = this.startMessageLoop();\r\n return this.privDialogConnectionPromise;\r\n }\r\n\r\n private receiveDialogMessageOverride = (): Promise => {\r\n\r\n // we won't rely on the cascading promises of the connection since we want to continually be available to receive messages\r\n const communicationCustodian: Deferred = new Deferred();\r\n\r\n this.fetchDialogConnection().on((connection: IConnection): Promise => {\r\n return connection.read()\r\n .onSuccessContinueWithPromise((message: ConnectionMessage): Promise => {\r\n const isDisposed: boolean = this.isDisposed();\r\n const terminateMessageLoop = (!this.isDisposed() && this.terminateMessageLoop);\r\n if (isDisposed || terminateMessageLoop) {\r\n // We're done.\r\n communicationCustodian.resolve(undefined);\r\n return PromiseHelper.fromResult(undefined);\r\n }\r\n\r\n if (!message) {\r\n return this.receiveDialogMessageOverride();\r\n }\r\n\r\n const connectionMessage = SpeechConnectionMessage.fromConnectionMessage(message);\r\n\r\n switch (connectionMessage.path.toLowerCase()) {\r\n case \"turn.start\":\r\n {\r\n const turnRequestId = connectionMessage.requestId.toUpperCase();\r\n const audioSessionReqId = this.privDialogRequestSession.requestId.toUpperCase();\r\n\r\n // turn started by the service\r\n if (turnRequestId !== audioSessionReqId) {\r\n this.privTurnStateManager.StartTurn(turnRequestId);\r\n } else {\r\n this.privDialogRequestSession.onServiceTurnStartResponse();\r\n }\r\n }\r\n break;\r\n case \"speech.startdetected\":\r\n const speechStartDetected: SpeechDetected = SpeechDetected.fromJSON(connectionMessage.textBody);\r\n\r\n const speechStartEventArgs = new RecognitionEventArgs(speechStartDetected.Offset, this.privDialogRequestSession.sessionId);\r\n\r\n if (!!this.privRecognizer.speechStartDetected) {\r\n this.privRecognizer.speechStartDetected(this.privRecognizer, speechStartEventArgs);\r\n }\r\n\r\n break;\r\n case \"speech.enddetected\":\r\n\r\n let json: string;\r\n\r\n if (connectionMessage.textBody.length > 0) {\r\n json = connectionMessage.textBody;\r\n } else {\r\n // If the request was empty, the JSON returned is empty.\r\n json = \"{ Offset: 0 }\";\r\n }\r\n\r\n const speechStopDetected: SpeechDetected = SpeechDetected.fromJSON(json);\r\n\r\n this.privDialogRequestSession.onServiceRecognized(speechStopDetected.Offset + this.privDialogRequestSession.currentTurnAudioOffset);\r\n\r\n const speechStopEventArgs = new RecognitionEventArgs(speechStopDetected.Offset + this.privDialogRequestSession.currentTurnAudioOffset, this.privDialogRequestSession.sessionId);\r\n\r\n if (!!this.privRecognizer.speechEndDetected) {\r\n this.privRecognizer.speechEndDetected(this.privRecognizer, speechStopEventArgs);\r\n }\r\n break;\r\n\r\n case \"turn.end\":\r\n {\r\n const turnEndRequestId = connectionMessage.requestId.toUpperCase();\r\n\r\n const audioSessionReqId = this.privDialogRequestSession.requestId.toUpperCase();\r\n\r\n // turn started by the service\r\n if (turnEndRequestId !== audioSessionReqId) {\r\n this.privTurnStateManager.CompleteTurn(turnEndRequestId);\r\n } else {\r\n // Audio session turn\r\n\r\n const sessionStopEventArgs: SessionEventArgs = new SessionEventArgs(this.privDialogRequestSession.sessionId);\r\n this.privDialogRequestSession.onServiceTurnEndResponse(false);\r\n\r\n if (this.privDialogRequestSession.isSpeechEnded) {\r\n if (!!this.privRecognizer.sessionStopped) {\r\n this.privRecognizer.sessionStopped(this.privRecognizer, sessionStopEventArgs);\r\n }\r\n }\r\n\r\n // report result to promise.\r\n if (!!this.privSuccessCallback && this.privLastResult) {\r\n try {\r\n this.privSuccessCallback(this.privLastResult);\r\n this.privLastResult = null;\r\n } catch (e) {\r\n if (!!this.privErrorCallback) {\r\n this.privErrorCallback(e);\r\n }\r\n }\r\n // Only invoke the call back once.\r\n // and if it's successful don't invoke the\r\n // error after that.\r\n this.privSuccessCallback = undefined;\r\n this.privErrorCallback = undefined;\r\n }\r\n }\r\n }\r\n break;\r\n\r\n default:\r\n if (!this.processTypeSpecificMessages(connectionMessage)) {\r\n if (!!this.serviceEvents) {\r\n this.serviceEvents.onEvent(new ServiceEvent(connectionMessage.path.toLowerCase(), connectionMessage.textBody));\r\n }\r\n }\r\n }\r\n\r\n return this.receiveDialogMessageOverride();\r\n });\r\n }, (error: string) => {\r\n this.terminateMessageLoop = true;\r\n communicationCustodian.resolve(undefined);\r\n return PromiseHelper.fromResult(undefined);\r\n });\r\n\r\n return communicationCustodian.promise();\r\n }\r\n\r\n private startMessageLoop(): Promise {\r\n\r\n this.terminateMessageLoop = false;\r\n\r\n const messageRetrievalPromise = this.receiveDialogMessageOverride();\r\n\r\n return messageRetrievalPromise.on((r: IConnection) => {\r\n return true;\r\n }, (error: string) => {\r\n this.cancelRecognition(this.privDialogRequestSession.sessionId, this.privDialogRequestSession.requestId, CancellationReason.Error, CancellationErrorCode.RuntimeError, error);\r\n });\r\n }\r\n\r\n // Takes an established websocket connection to the endpoint and sends speech configuration information.\r\n private configConnection(): Promise {\r\n if (this.privConnectionConfigPromise) {\r\n if (this.privConnectionConfigPromise.result().isCompleted &&\r\n (this.privConnectionConfigPromise.result().isError\r\n || this.privConnectionConfigPromise.result().result.state() === ConnectionState.Disconnected)) {\r\n\r\n this.privConnectionConfigPromise = null;\r\n return this.configConnection();\r\n } else {\r\n return this.privConnectionConfigPromise;\r\n }\r\n }\r\n\r\n if (this.terminateMessageLoop) {\r\n this.terminateMessageLoop = false;\r\n return PromiseHelper.fromError(`Connection to service terminated.`);\r\n }\r\n\r\n this.privConnectionConfigPromise = this.dialogConnectImpl().onSuccessContinueWithPromise((connection: IConnection): Promise => {\r\n return this.sendSpeechServiceConfig(connection, this.privDialogRequestSession, this.privRecognizerConfig.SpeechServiceConfig.serialize())\r\n .onSuccessContinueWithPromise((_: boolean) => {\r\n return this.sendAgentConfig(connection).onSuccessContinueWith((_: boolean) => {\r\n return connection;\r\n });\r\n });\r\n });\r\n\r\n return this.privConnectionConfigPromise;\r\n }\r\n\r\n private fetchDialogConnection = (): Promise => {\r\n return this.configConnection();\r\n }\r\n\r\n private sendPreAudioMessages(): void {\r\n this.fetchDialogConnection().onSuccessContinueWith((connection: IConnection): void => {\r\n this.sendAgentContext(connection);\r\n this.sendWaveHeader(connection);\r\n });\r\n }\r\n\r\n private sendAgentConfig = (connection: IConnection): Promise => {\r\n if (this.agentConfig && !this.agentConfigSent) {\r\n\r\n if (this.privRecognizerConfig.parameters.getProperty(PropertyId.Conversation_DialogType) === \"custom_commands\") {\r\n const config = this.agentConfig.get();\r\n config.botInfo.commandsCulture = this.privRecognizerConfig.parameters.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage, \"en-us\");\r\n this.agentConfig.set(config);\r\n }\r\n const agentConfigJson = this.agentConfig.toJsonString();\r\n\r\n // guard against sending this multiple times on one connection\r\n this.agentConfigSent = true;\r\n\r\n return connection.send(new SpeechConnectionMessage(\r\n MessageType.Text,\r\n \"agent.config\",\r\n this.privDialogRequestSession.requestId,\r\n \"application/json\",\r\n agentConfigJson));\r\n }\r\n\r\n return PromiseHelper.fromResult(true);\r\n }\r\n\r\n private sendAgentContext = (connection: IConnection): Promise => {\r\n const guid: string = createGuid();\r\n\r\n const speechActivityTemplate = this.privDialogServiceConnector.properties.getProperty(PropertyId.Conversation_Speech_Activity_Template);\r\n\r\n const agentContext: any = {\r\n channelData: \"\",\r\n context: {\r\n interactionId: guid\r\n },\r\n messagePayload: typeof speechActivityTemplate === undefined ? undefined : speechActivityTemplate,\r\n version: 0.5\r\n };\r\n\r\n const agentContextJson = JSON.stringify(agentContext);\r\n\r\n return connection.send(new SpeechConnectionMessage(\r\n MessageType.Text,\r\n \"speech.agent.context\",\r\n this.privDialogRequestSession.requestId,\r\n \"application/json\",\r\n agentContextJson));\r\n }\r\n\r\n private fireEventForResult(serviceResult: SimpleSpeechPhrase, properties: PropertyCollection): SpeechRecognitionEventArgs {\r\n const resultReason: ResultReason = EnumTranslation.implTranslateRecognitionResult(serviceResult.RecognitionStatus);\r\n\r\n const offset: number = serviceResult.Offset + this.privDialogRequestSession.currentTurnAudioOffset;\r\n\r\n const result = new SpeechRecognitionResult(\r\n this.privDialogRequestSession.requestId,\r\n resultReason,\r\n serviceResult.DisplayText,\r\n serviceResult.Duration,\r\n offset,\r\n serviceResult.Language,\r\n serviceResult.LanguageDetectionConfidence,\r\n undefined,\r\n JSON.stringify(serviceResult),\r\n properties);\r\n\r\n const ev = new SpeechRecognitionEventArgs(result, offset, this.privDialogRequestSession.sessionId);\r\n return ev;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { InvalidOperationError } from \"../common/Error\";\r\nimport { AudioOutputStream, PullAudioOutputStreamImpl } from \"../sdk/Audio/AudioOutputStream\";\r\nimport { DialogServiceTurnState } from \"./DialogServiceTurnState\";\r\nimport { ActivityPayloadResponse } from \"./ServiceMessages/ActivityResponsePayload\";\r\n\r\nexport class DialogServiceTurnStateManager {\r\n private privTurnMap: Map;\r\n\r\n constructor() {\r\n this.privTurnMap = new Map();\r\n return;\r\n }\r\n\r\n public StartTurn(id: string): DialogServiceTurnState {\r\n if (this.privTurnMap.has(id)) {\r\n throw new InvalidOperationError(\"Service error: There is already a turn with id:\" + id);\r\n }\r\n const turnState: DialogServiceTurnState = new DialogServiceTurnState(this, id);\r\n this.privTurnMap.set(id, turnState);\r\n return this.privTurnMap.get(id);\r\n }\r\n\r\n public GetTurn(id: string): DialogServiceTurnState {\r\n return this.privTurnMap.get(id);\r\n }\r\n\r\n public CompleteTurn(id: string): DialogServiceTurnState {\r\n if (!this.privTurnMap.has(id)) {\r\n throw new InvalidOperationError(\"Service error: Received turn end for an unknown turn id:\" + id);\r\n }\r\n const turnState = this.privTurnMap.get(id);\r\n turnState.complete();\r\n this.privTurnMap.delete(id);\r\n return turnState;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { AudioOutputFormatImpl } from \"../sdk/Audio/AudioOutputFormat\";\r\nimport { AudioOutputStream, PullAudioOutputStreamImpl } from \"../sdk/Audio/AudioOutputStream\";\r\nimport { DialogServiceTurnStateManager } from \"./DialogServiceTurnStateManager\";\r\nimport { ActivityPayloadResponse, MessageDataStreamType } from \"./ServiceMessages/ActivityResponsePayload\";\r\n\r\nexport class DialogServiceTurnState {\r\n private privRequestId: string;\r\n private privIsCompleted: boolean;\r\n private privAudioStream: PullAudioOutputStreamImpl;\r\n private privTimeoutToken: any;\r\n private privTurnManager: DialogServiceTurnStateManager;\r\n\r\n constructor(manager: DialogServiceTurnStateManager, requestId: string) {\r\n this.privRequestId = requestId;\r\n this.privIsCompleted = false;\r\n this.privAudioStream = null;\r\n this.privTurnManager = manager;\r\n this.resetTurnEndTimeout();\r\n // tslint:disable-next-line:no-console\r\n // console.info(\"DialogServiceTurnState debugturn start:\" + this.privRequestId);\r\n }\r\n\r\n public get audioStream(): PullAudioOutputStreamImpl {\r\n // Called when is needed to stream.\r\n this.resetTurnEndTimeout();\r\n return this.privAudioStream;\r\n }\r\n\r\n public processActivityPayload(payload: ActivityPayloadResponse, audioFormat?: AudioOutputFormatImpl): PullAudioOutputStreamImpl {\r\n if (payload.messageDataStreamType === MessageDataStreamType.TextToSpeechAudio) {\r\n this.privAudioStream = AudioOutputStream.createPullStream() as PullAudioOutputStreamImpl;\r\n this.privAudioStream.format = (audioFormat !== undefined) ? audioFormat : AudioOutputFormatImpl.getDefaultOutputFormat();\r\n // tslint:disable-next-line:no-console\r\n // console.info(\"Audio start debugturn:\" + this.privRequestId);\r\n }\r\n return this.privAudioStream;\r\n }\r\n\r\n public endAudioStream(): void {\r\n if (this.privAudioStream !== null && !this.privAudioStream.isClosed) {\r\n this.privAudioStream.close();\r\n }\r\n }\r\n\r\n public complete(): void {\r\n if (this.privTimeoutToken !== undefined) {\r\n clearTimeout(this.privTimeoutToken);\r\n }\r\n this.endAudioStream();\r\n }\r\n\r\n private resetTurnEndTimeout(): void {\r\n if (this.privTimeoutToken !== undefined) {\r\n clearTimeout(this.privTimeoutToken);\r\n }\r\n // tslint:disable-next-line:no-console\r\n // console.info(\"Timeout reset debugturn:\" + this.privRequestId);\r\n\r\n this.privTimeoutToken = setTimeout((): void => {\r\n // tslint:disable-next-line:no-console\r\n // console.info(\"Timeout complete debugturn:\" + this.privRequestId);\r\n\r\n this.privTurnManager.CompleteTurn(this.privRequestId);\r\n return;\r\n }, 2000);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n// response\r\n\r\nexport interface IActivityPayloadResponse {\r\n conversationId: string;\r\n messageDataStreamType: number;\r\n messagePayload: any;\r\n version: number;\r\n}\r\n\r\nexport class ActivityPayloadResponse implements IActivityPayloadResponse {\r\n private privActivityResponse: IActivityPayloadResponse;\r\n\r\n private constructor(json: string) {\r\n this.privActivityResponse = JSON.parse(json);\r\n }\r\n\r\n public static fromJSON(json: string): ActivityPayloadResponse {\r\n return new ActivityPayloadResponse(json);\r\n }\r\n\r\n public get conversationId(): string {\r\n return this.privActivityResponse.conversationId;\r\n }\r\n\r\n public get messageDataStreamType(): number {\r\n return this.privActivityResponse.messageDataStreamType;\r\n }\r\n\r\n public get messagePayload(): any {\r\n return this.privActivityResponse.messagePayload;\r\n }\r\n\r\n public get version(): number {\r\n return this.privActivityResponse.version;\r\n }\r\n}\r\n\r\nexport enum MessageDataStreamType {\r\n None = 0,\r\n TextToSpeechAudio = 1,\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * Represents the JSON used in the agent.config message sent to the speech service.\r\n */\r\nexport class AgentConfig {\r\n private iPrivConfig: IAgentConfig;\r\n\r\n public toJsonString(): string {\r\n return JSON.stringify(this.iPrivConfig);\r\n }\r\n\r\n public get(): IAgentConfig {\r\n return this.iPrivConfig;\r\n }\r\n\r\n /**\r\n * Setter for the agent.config object.\r\n * @param value a JSON serializable object.\r\n */\r\n public set(value: IAgentConfig): void {\r\n this.iPrivConfig = value;\r\n }\r\n}\r\n\r\nexport interface IAgentConfig {\r\n botInfo: {\r\n commType: string,\r\n connectionId: string,\r\n conversationId: string,\r\n fromId: string\r\n commandsCulture: string,\r\n ttsAudioFormat: string\r\n };\r\n version: number;\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nexport { ConversationManager } from \"./ConversationManager\";\r\nexport { ConversationTranslatorRecognizer } from \"./ConversationTranslatorRecognizer\";\r\nexport { ConversationConnectionConfig } from \"./ConversationConnectionConfig\";\r\nexport {\r\n ConversationReceivedTranslationEventArgs,\r\n LockRoomEventArgs,\r\n MuteAllEventArgs,\r\n ParticipantAttributeEventArgs,\r\n ParticipantEventArgs,\r\n ParticipantsListEventArgs } from \"./ConversationTranslatorEventArgs\";\r\nexport {\r\n ConversationTranslatorCommandTypes,\r\n ConversationTranslatorMessageTypes,\r\n IInternalConversation,\r\n IInternalParticipant,\r\n InternalParticipants} from \"./ConversationTranslatorInterfaces\";\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n IRequestOptions,\r\n IRestParams,\r\n} from \"../../common.browser/RestConfigBase\";\r\nimport { IErrorMessages, IStringDictionary } from \"../../common/Exports\";\r\nimport { Contracts } from \"../../sdk/Contracts\";\r\nimport { PropertyCollection, PropertyId } from \"../../sdk/Exports\";\r\nimport { ConversationConnectionConfig } from \"./ConversationConnectionConfig\";\r\nimport { IConversationResponseError, IInternalConversation, IResponse } from \"./ConversationTranslatorInterfaces\";\r\nimport { extractHeaderValue, request } from \"./ConversationUtils\";\r\n\r\nexport class ConversationManager {\r\n\r\n private privRequestParams: IRestParams;\r\n private privErrors: IErrorMessages;\r\n private privHost: string;\r\n private privApiVersion: string;\r\n private privRestPath: string;\r\n\r\n public constructor() {\r\n //\r\n this.privRequestParams = ConversationConnectionConfig.configParams;\r\n this.privErrors = ConversationConnectionConfig.restErrors;\r\n this.privHost = ConversationConnectionConfig.host;\r\n this.privApiVersion = ConversationConnectionConfig.apiVersion;\r\n this.privRestPath = ConversationConnectionConfig.restPath;\r\n }\r\n\r\n /**\r\n * Make a POST request to the Conversation Manager service endpoint to create or join a conversation.\r\n * @param args\r\n * @param conversationCode\r\n * @param callback\r\n * @param errorCallback\r\n */\r\n public createOrJoin(args: PropertyCollection, conversationCode: string, cb?: any, err?: any): void {\r\n\r\n try {\r\n\r\n Contracts.throwIfNullOrUndefined(args, \"args\");\r\n\r\n const languageCode: string = args.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage, ConversationConnectionConfig.defaultLanguageCode);\r\n const nickname: string = args.getProperty(PropertyId.ConversationTranslator_Name);\r\n const endpointHost: string = args.getProperty(PropertyId.ConversationTranslator_Host, this.privHost);\r\n const correlationId: string = args.getProperty(PropertyId.ConversationTranslator_CorrelationId);\r\n const subscriptionKey: string = args.getProperty(PropertyId.SpeechServiceConnection_Key);\r\n const subscriptionRegion: string = args.getProperty(PropertyId.SpeechServiceConnection_Region);\r\n const authToken: string = args.getProperty(PropertyId.SpeechServiceAuthorization_Token);\r\n\r\n Contracts.throwIfNullOrWhitespace(languageCode, \"languageCode\");\r\n Contracts.throwIfNullOrWhitespace(nickname, \"nickname\");\r\n Contracts.throwIfNullOrWhitespace(endpointHost, \"endpointHost\");\r\n\r\n const queryParams: IStringDictionary = {};\r\n queryParams[this.privRequestParams.apiVersion] = this.privApiVersion;\r\n queryParams[this.privRequestParams.languageCode] = languageCode;\r\n queryParams[this.privRequestParams.nickname] = nickname;\r\n\r\n const headers: IStringDictionary = {};\r\n if (correlationId) {\r\n headers[this.privRequestParams.correlationId] = correlationId;\r\n }\r\n headers[this.privRequestParams.clientAppId] = ConversationConnectionConfig.clientAppId;\r\n\r\n if (conversationCode !== undefined) {\r\n queryParams[this.privRequestParams.roomId] = conversationCode;\r\n } else {\r\n Contracts.throwIfNullOrUndefined(subscriptionRegion, this.privErrors.authInvalidSubscriptionRegion);\r\n headers[this.privRequestParams.subscriptionRegion] = subscriptionRegion;\r\n if (subscriptionKey) {\r\n headers[this.privRequestParams.subscriptionKey] = subscriptionKey;\r\n } else if (authToken) {\r\n headers[this.privRequestParams.authorization] = `Bearer ${authToken}`;\r\n } else {\r\n Contracts.throwIfNullOrUndefined(subscriptionKey, this.privErrors.authInvalidSubscriptionKey);\r\n }\r\n }\r\n\r\n const config: IRequestOptions = {};\r\n config.headers = headers;\r\n\r\n const endpoint: string = `https://${endpointHost}${this.privRestPath}`;\r\n\r\n // TODO: support a proxy and certificate validation\r\n request(\"post\", endpoint, queryParams, null, config, (response: IResponse) => {\r\n\r\n const requestId: string = extractHeaderValue(this.privRequestParams.requestId, response.headers);\r\n\r\n if (!response.ok) {\r\n if (!!err) {\r\n // get the error\r\n let errorMessage: string = this.privErrors.invalidCreateJoinConversationResponse.replace(\"{status}\", response.status.toString());\r\n let errMessageRaw: IConversationResponseError;\r\n try {\r\n errMessageRaw = JSON.parse(response.data) as IConversationResponseError;\r\n errorMessage += ` [${errMessageRaw.error.code}: ${errMessageRaw.error.message}]`;\r\n } catch (e) {\r\n errorMessage += ` [${response.data}]`;\r\n }\r\n if (requestId) {\r\n errorMessage += ` ${requestId}`;\r\n }\r\n\r\n err(errorMessage);\r\n }\r\n return;\r\n }\r\n const conversation: IInternalConversation = JSON.parse(response.data) as IInternalConversation;\r\n if (conversation) {\r\n conversation.requestId = requestId;\r\n }\r\n if (!!cb) {\r\n try {\r\n cb(conversation);\r\n } catch (e) {\r\n if (!!err) {\r\n err(e);\r\n }\r\n }\r\n cb = undefined;\r\n }\r\n\r\n });\r\n\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n err(typedError.name + \": \" + typedError.message);\r\n\r\n } else {\r\n err(error);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Make a DELETE request to the Conversation Manager service endpoint to leave the conversation.\r\n * @param args\r\n * @param sessionToken\r\n * @param callback\r\n */\r\n public leave(args: PropertyCollection, sessionToken: string, cb?: any, err?: any): void {\r\n\r\n try {\r\n\r\n Contracts.throwIfNullOrUndefined(args, this.privErrors.invalidArgs.replace(\"{arg}\", \"config\"));\r\n Contracts.throwIfNullOrWhitespace(sessionToken, this.privErrors.invalidArgs.replace(\"{arg}\", \"token\"));\r\n\r\n const endpointHost: string = args.getProperty(PropertyId.ConversationTranslator_Host, this.privHost);\r\n const correlationId: string = args.getProperty(PropertyId.ConversationTranslator_CorrelationId);\r\n\r\n const queryParams: IStringDictionary = {};\r\n queryParams[this.privRequestParams.apiVersion] = this.privApiVersion;\r\n queryParams[this.privRequestParams.sessionToken] = sessionToken;\r\n\r\n const headers: IStringDictionary = {};\r\n if (correlationId) {\r\n headers[this.privRequestParams.correlationId] = correlationId;\r\n }\r\n\r\n const config: IRequestOptions = {};\r\n config.headers = headers;\r\n\r\n const endpoint: string = `https://${endpointHost}${this.privRestPath}`;\r\n\r\n // TODO: support a proxy and certificate validation\r\n request(\"delete\", endpoint, queryParams, null, config, (response: IResponse) => {\r\n\r\n if (!response.ok) {\r\n // ignore errors on delete\r\n }\r\n\r\n if (!!cb) {\r\n try {\r\n cb();\r\n } catch (e) {\r\n if (!!err) {\r\n err(e);\r\n }\r\n }\r\n cb = undefined;\r\n }\r\n });\r\n\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n err(typedError.name + \": \" + typedError.message);\r\n\r\n } else {\r\n err(error);\r\n }\r\n }\r\n }\r\n }\r\n\r\n}\r\n","\r\n// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n RestConfigBase\r\n} from \"../../common.browser/RestConfigBase\";\r\n\r\nexport class ConversationConnectionConfig extends RestConfigBase {\r\n\r\n private static readonly privHost: string = \"dev.microsofttranslator.com\";\r\n private static readonly privRestPath: string = \"/capito/room\";\r\n private static readonly privApiVersion: string = \"2.0\";\r\n private static readonly privDefaultLanguageCode: string = \"en-US\";\r\n private static readonly privClientAppId: string = \"FC539C22-1767-4F1F-84BC-B4D811114F15\";\r\n private static readonly privWebSocketPath: string = \"/capito/translate\";\r\n private static readonly privSpeechHost: string = \"{region}.s2s.speech.microsoft.com\";\r\n private static readonly privSpeechPath: string = \"/speech/translation/cognitiveservices/v1\";\r\n\r\n public static get host(): string {\r\n return ConversationConnectionConfig.privHost;\r\n }\r\n\r\n public static get apiVersion(): string {\r\n return ConversationConnectionConfig.privApiVersion;\r\n }\r\n\r\n public static get clientAppId(): string {\r\n return ConversationConnectionConfig.privClientAppId;\r\n }\r\n\r\n public static get defaultLanguageCode(): string {\r\n return ConversationConnectionConfig.privDefaultLanguageCode;\r\n }\r\n\r\n public static get restPath(): string {\r\n return ConversationConnectionConfig.privRestPath;\r\n }\r\n\r\n public static get webSocketPath(): string {\r\n return ConversationConnectionConfig.privWebSocketPath;\r\n }\r\n\r\n public static get speechHost(): string {\r\n return ConversationConnectionConfig.privSpeechHost;\r\n }\r\n\r\n public static get speechPath(): string {\r\n return ConversationConnectionConfig.privSpeechPath;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { IErrorMessages } from \"../common/Exports\";\r\n/**\r\n * HTTP request helper\r\n */\r\nexport interface IRequestOptions {\r\n headers?: {[key: string]: string};\r\n ignoreCache?: boolean;\r\n timeout?: number;\r\n}\r\n\r\nexport interface IRestParams {\r\n apiVersion: string;\r\n authorization: string;\r\n clientAppId: string;\r\n contentTypeKey: string;\r\n correlationId: string;\r\n languageCode: string;\r\n nickname: string;\r\n profanity: string;\r\n requestId: string;\r\n roomId: string;\r\n sessionToken: string;\r\n subscriptionKey: string;\r\n subscriptionRegion: string;\r\n token: string;\r\n}\r\n\r\nexport class RestConfigBase {\r\n\r\n public static get requestOptions(): IRequestOptions {\r\n return RestConfigBase.privDefaultRequestOptions;\r\n }\r\n\r\n public static get configParams(): IRestParams {\r\n return RestConfigBase.privDefaultParams;\r\n }\r\n\r\n public static get restErrors(): IErrorMessages {\r\n return RestConfigBase.privRestErrors;\r\n }\r\n\r\n private static readonly privDefaultRequestOptions: IRequestOptions = {\r\n headers: {\r\n Accept: \"application/json\",\r\n },\r\n ignoreCache: false,\r\n timeout: 10000,\r\n };\r\n\r\n private static readonly privRestErrors: IErrorMessages = {\r\n authInvalidSubscriptionKey: \"You must specify either an authentication token to use, or a Cognitive Speech subscription key.\",\r\n authInvalidSubscriptionRegion: \"You must specify the Cognitive Speech region to use.\",\r\n invalidArgs: \"Required input not found: {arg}.\",\r\n invalidCreateJoinConversationResponse: \"Creating/Joining conversation failed with HTTP {status}.\",\r\n invalidParticipantRequest: \"The requested participant was not found.\",\r\n permissionDeniedConnect: \"Required credentials not found.\",\r\n permissionDeniedConversation: \"Invalid operation: only the host can {command} the conversation.\",\r\n permissionDeniedParticipant: \"Invalid operation: only the host can {command} a participant.\",\r\n permissionDeniedSend: \"Invalid operation: the conversation is not in a connected state.\",\r\n permissionDeniedStart: \"Invalid operation: there is already an active conversation.\",\r\n };\r\n\r\n private static readonly privDefaultParams: IRestParams = {\r\n apiVersion: \"api-version\",\r\n authorization: \"Authorization\",\r\n clientAppId: \"X-ClientAppId\",\r\n contentTypeKey: \"Content-Type\",\r\n correlationId: \"X-CorrelationId\",\r\n languageCode: \"language\",\r\n nickname: \"nickname\",\r\n profanity: \"profanity\",\r\n requestId: \"X-RequestId\",\r\n roomId: \"roomid\",\r\n sessionToken: \"token\",\r\n subscriptionKey: \"Ocp-Apim-Subscription-Key\",\r\n subscriptionRegion: \"Ocp-Apim-Subscription-Region\",\r\n token: \"X-CapitoToken\",\r\n };\r\n\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { IRequestOptions, RestConfigBase } from \"../../common.browser/RestConfigBase\";\r\nimport { Promise, PromiseResult } from \"../../common/Promise\";\r\nimport { Callback } from \"../../sdk/Transcription/IConversation\";\r\nimport { IResponse } from \"./ConversationTranslatorInterfaces\";\r\n\r\n/**\r\n * Config settings for Conversation Translator\r\n */\r\n/**\r\n * Helpers for sending / receiving HTTPS requests / responses.\r\n * @param params\r\n */\r\nfunction queryParams(params: any = {}): any {\r\n return Object.keys(params)\r\n .map((k: any) => encodeURIComponent(k) + \"=\" + encodeURIComponent(params[k]))\r\n .join(\"&\");\r\n}\r\n\r\nfunction withQuery(url: string, params: any = {}): any {\r\n const queryString = queryParams(params);\r\n return queryString ? url + (url.indexOf(\"?\") === -1 ? \"?\" : \"&\") + queryString : url;\r\n}\r\n\r\nfunction parseXHRResult(xhr: XMLHttpRequest): IResponse {\r\n return {\r\n data: xhr.responseText,\r\n headers: xhr.getAllResponseHeaders(),\r\n json: () => JSON.parse(xhr.responseText) as T,\r\n ok: xhr.status >= 200 && xhr.status < 300,\r\n status: xhr.status,\r\n statusText: xhr.statusText,\r\n };\r\n}\r\n\r\nfunction errorResponse(xhr: XMLHttpRequest, message: string | null = null): IResponse {\r\n return {\r\n data: message || xhr.statusText,\r\n headers: xhr.getAllResponseHeaders(),\r\n json: () => JSON.parse(message || (\"\\\"\" + xhr.statusText + \"\\\"\")) as T,\r\n ok: false,\r\n status: xhr.status,\r\n statusText: xhr.statusText,\r\n };\r\n}\r\n\r\nexport function extractHeaderValue(headerKey: string, headers: string): string {\r\n\r\n let headerValue: string = \"\";\r\n\r\n try {\r\n const arr = headers.trim().split(/[\\r\\n]+/);\r\n const headerMap: any = {};\r\n arr.forEach((line: any) => {\r\n const parts = line.split(\": \");\r\n const header = parts.shift().toLowerCase();\r\n const value = parts.join(\": \");\r\n headerMap[header] = value;\r\n });\r\n\r\n headerValue = headerMap[headerKey.toLowerCase()];\r\n } catch (e) {\r\n // ignore the error\r\n }\r\n\r\n return headerValue;\r\n}\r\n\r\nexport function request(method: \"get\" | \"post\" | \"delete\",\r\n url: string,\r\n queryParams: any = {},\r\n body: any = null,\r\n options: IRequestOptions = {},\r\n callback: any): any {\r\n\r\n const defaultRequestOptions = RestConfigBase.requestOptions;\r\n\r\n const ignoreCache = options.ignoreCache || defaultRequestOptions.ignoreCache;\r\n const headers = options.headers || defaultRequestOptions.headers;\r\n const timeout = options.timeout || defaultRequestOptions.timeout;\r\n\r\n const xhr = new XMLHttpRequest();\r\n xhr.open(method, withQuery(url, queryParams), true);\r\n\r\n if (headers) {\r\n Object.keys(headers).forEach((key: any) => xhr.setRequestHeader(key, headers[key]));\r\n }\r\n\r\n if (ignoreCache) {\r\n xhr.setRequestHeader(\"Cache-Control\", \"no-cache\");\r\n }\r\n\r\n xhr.timeout = timeout;\r\n\r\n xhr.onload = (evt: any) => {\r\n callback(parseXHRResult(xhr));\r\n };\r\n\r\n xhr.onerror = (evt: any) => {\r\n callback(errorResponse(xhr, \"Failed to make request.\"));\r\n };\r\n\r\n xhr.ontimeout = (evt: any) => {\r\n callback(errorResponse(xhr, \"Request took longer than expected.\"));\r\n };\r\n\r\n if (method === \"post\" && body) {\r\n xhr.setRequestHeader(\"Content-Type\", \"application/json\");\r\n xhr.send(JSON.stringify(body));\r\n } else {\r\n xhr.send();\r\n }\r\n}\r\n\r\nexport function PromiseToEmptyCallback(promise: Promise, cb?: Callback, err?: Callback): void {\r\n if (!!promise) {\r\n promise.continueWith((antecedent: PromiseResult): void => {\r\n try {\r\n if (antecedent.isError) {\r\n if (!!err) {\r\n err(antecedent.error);\r\n }\r\n } else {\r\n if (!!cb) {\r\n cb();\r\n }\r\n }\r\n } catch (e) {\r\n if (!!err) {\r\n err(`'Unhandled error on promise callback: ${e}. InnerError: ${antecedent.error}'`);\r\n }\r\n }\r\n });\r\n } else {\r\n if (!!err) {\r\n err(\"Null promise\");\r\n }\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n IAuthentication,\r\n IConnectionFactory,\r\n RecognizerConfig,\r\n ServiceRecognizerBase,\r\n SpeechServiceConfig\r\n} from \"../../common.speech/Exports\";\r\nimport { AudioConfigImpl } from \"../../sdk/Audio/AudioConfig\";\r\nimport { Contracts } from \"../../sdk/Contracts\";\r\nimport { AudioConfig,\r\n ConversationExpirationEventArgs,\r\n ConversationParticipantsChangedEventArgs,\r\n ConversationTranslationCanceledEventArgs,\r\n PropertyCollection,\r\n Recognizer,\r\n SessionEventArgs,\r\n SpeechTranslationConfig} from \"../../sdk/Exports\";\r\nimport { SpeechTranslationConfigImpl } from \"../../sdk/SpeechTranslationConfig\";\r\nimport { Callback } from \"../../sdk/Transcription/IConversation\";\r\nimport { ConversationConnectionFactory } from \"./ConversationConnectionFactory\";\r\nimport { ConversationServiceAdapter } from \"./ConversationServiceAdapter\";\r\nimport {\r\n ConversationReceivedTranslationEventArgs,\r\n LockRoomEventArgs,\r\n MuteAllEventArgs,\r\n ParticipantAttributeEventArgs,\r\n ParticipantEventArgs,\r\n ParticipantsListEventArgs } from \"./ConversationTranslatorEventArgs\";\r\nimport {\r\n ConversationTranslatorCommandTypes,\r\n ConversationTranslatorMessageTypes,\r\n IChangeNicknameCommand,\r\n IConversationTranslatorRecognizer,\r\n IEjectParticipantCommand,\r\n IInstantMessageCommand,\r\n IInternalConversation,\r\n ILockConversationCommand,\r\n IMuteAllCommand,\r\n IMuteCommand} from \"./ConversationTranslatorInterfaces\";\r\nimport { PromiseToEmptyCallback } from \"./ConversationUtils\";\r\n\r\n/**\r\n * Sends messages to the Conversation Translator websocket and listens for incoming events containing websocket messages.\r\n * Based off the recognizers in the SDK folder.\r\n */\r\nexport class ConversationTranslatorRecognizer extends Recognizer implements IConversationTranslatorRecognizer {\r\n\r\n private privIsDisposed: boolean;\r\n private privSpeechRecognitionLanguage: string;\r\n private privRoom: IInternalConversation;\r\n\r\n public constructor(speechConfig: SpeechTranslationConfig, audioConfig?: AudioConfig) {\r\n const serviceConfigImpl = speechConfig as SpeechTranslationConfigImpl;\r\n Contracts.throwIfNull(serviceConfigImpl, \"speechConfig\");\r\n\r\n super(audioConfig, serviceConfigImpl.properties, new ConversationConnectionFactory());\r\n\r\n this.privIsDisposed = false;\r\n this.privProperties = serviceConfigImpl.properties.clone();\r\n\r\n }\r\n\r\n public canceled: (sender: IConversationTranslatorRecognizer, event: ConversationTranslationCanceledEventArgs) => void;\r\n public conversationExpiration: (sender: IConversationTranslatorRecognizer, event: ConversationExpirationEventArgs) => void;\r\n public lockRoomCommandReceived: (sender: IConversationTranslatorRecognizer, event: LockRoomEventArgs) => void;\r\n public muteAllCommandReceived: (sender: IConversationTranslatorRecognizer, event: MuteAllEventArgs) => void;\r\n public participantJoinCommandReceived: (sender: IConversationTranslatorRecognizer, event: ParticipantEventArgs) => void;\r\n public participantLeaveCommandReceived: (sender: IConversationTranslatorRecognizer, event: ParticipantEventArgs) => void;\r\n public participantUpdateCommandReceived: (sender: IConversationTranslatorRecognizer, event: ParticipantAttributeEventArgs) => void;\r\n public connectionOpened: (sender: IConversationTranslatorRecognizer, event: SessionEventArgs) => void;\r\n public connectionClosed: (sender: IConversationTranslatorRecognizer, event: SessionEventArgs) => void;\r\n public translationReceived: (sender: IConversationTranslatorRecognizer, event: ConversationReceivedTranslationEventArgs) => void;\r\n public participantsListReceived: (sender: IConversationTranslatorRecognizer, event: ParticipantsListEventArgs) => void;\r\n public participantsChanged: (sender: IConversationTranslatorRecognizer, event: ConversationParticipantsChangedEventArgs) => void;\r\n\r\n public set conversation(value: IInternalConversation) {\r\n this.privRoom = value;\r\n }\r\n\r\n /**\r\n * Return the speech language used by the recognizer\r\n */\r\n public get speechRecognitionLanguage(): string {\r\n return this.privSpeechRecognitionLanguage;\r\n }\r\n\r\n /**\r\n * Return the properties for the recognizer\r\n */\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n public isDisposed(): boolean {\r\n return this.privIsDisposed;\r\n }\r\n\r\n /**\r\n * Connect to the recognizer\r\n * @param token\r\n */\r\n public connect(token: string, cb?: () => void, err?: (e: string) => void): void {\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n Contracts.throwIfNullOrWhitespace(token, \"token\");\r\n this.privReco.conversationTranslatorToken = token;\r\n this.privReco.connectAsync(cb, err);\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Disconnect from the recognizer\r\n */\r\n public disconnect(cb?: () => void, err?: (e: string) => void): void {\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n this.privRoom = undefined;\r\n this.privReco.disconnectAsync(cb, err);\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error);\r\n }\r\n }\r\n // Destroy the recognizer.\r\n this.dispose(true);\r\n }\r\n }\r\n\r\n /**\r\n * Send the text message command to the websocket\r\n * @param conversationId\r\n * @param participantId\r\n * @param message\r\n */\r\n public sendMessageRequest(message: string, cb?: () => void, err?: (e: string) => void): void {\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"conversationId\");\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, \"participantId\");\r\n Contracts.throwIfNullOrWhitespace(message, \"message\");\r\n\r\n const command: IInstantMessageCommand = {\r\n // tslint:disable-next-line: object-literal-shorthand\r\n participantId: this.privRoom.participantId,\r\n roomId: this.privRoom.roomId,\r\n text: message,\r\n type: ConversationTranslatorMessageTypes.instantMessage\r\n };\r\n\r\n this.sendMessage(JSON.stringify(command), cb, err);\r\n\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error);\r\n }\r\n }\r\n\r\n // Destroy the recognizer.\r\n this.dispose(true);\r\n }\r\n }\r\n\r\n /**\r\n * Send the lock conversation command to the websocket\r\n * @param conversationId\r\n * @param participantId\r\n * @param isLocked\r\n */\r\n public sendLockRequest(isLocked: boolean, cb?: () => void, err?: (e: string) => void): void {\r\n\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"conversationId\");\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, \"participantId\");\r\n Contracts.throwIfNullOrUndefined(isLocked, \"isLocked\");\r\n\r\n const command: ILockConversationCommand = {\r\n command: ConversationTranslatorCommandTypes.setLockState,\r\n // tslint:disable-next-line: object-literal-shorthand\r\n participantId: this.privRoom.participantId,\r\n roomid: this.privRoom.roomId,\r\n type: ConversationTranslatorMessageTypes.participantCommand,\r\n value: isLocked\r\n };\r\n\r\n this.sendMessage(JSON.stringify(command), cb, err);\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error);\r\n }\r\n }\r\n\r\n // Destroy the recognizer.\r\n this.dispose(true);\r\n }\r\n }\r\n\r\n /**\r\n * Send the mute all participants command to the websocket\r\n * @param conversationId\r\n * @param participantId\r\n * @param isMuted\r\n */\r\n public sendMuteAllRequest(isMuted: boolean, cb?: () => void, err?: (e: string) => void): void {\r\n\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"conversationId\");\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, \"participantId\");\r\n Contracts.throwIfNullOrUndefined(isMuted, \"isMuted\");\r\n\r\n const command: IMuteAllCommand = {\r\n command: ConversationTranslatorCommandTypes.setMuteAll,\r\n // tslint:disable-next-line: object-literal-shorthand\r\n participantId: this.privRoom.participantId, // the id of the host\r\n roomid: this.privRoom.roomId,\r\n type: ConversationTranslatorMessageTypes.participantCommand,\r\n value: isMuted\r\n };\r\n\r\n this.sendMessage(JSON.stringify(command), cb, err);\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error);\r\n }\r\n }\r\n\r\n // Destroy the recognizer.\r\n this.dispose(true);\r\n }\r\n }\r\n\r\n /**\r\n * Send the mute participant command to the websocket\r\n * @param conversationId\r\n * @param participantId\r\n * @param isMuted\r\n */\r\n public sendMuteRequest(participantId: string, isMuted: boolean, cb?: () => void, err?: (e: string) => void): void {\r\n\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"conversationId\");\r\n Contracts.throwIfNullOrWhitespace(participantId, \"participantId\");\r\n Contracts.throwIfNullOrUndefined(isMuted, \"isMuted\");\r\n\r\n const command: IMuteCommand = {\r\n command: ConversationTranslatorCommandTypes.setMute,\r\n // tslint:disable-next-line: object-literal-shorthand\r\n participantId: participantId, // the id of the participant\r\n roomid: this.privRoom.roomId,\r\n type: ConversationTranslatorMessageTypes.participantCommand,\r\n value: isMuted\r\n };\r\n\r\n this.sendMessage(JSON.stringify(command), cb, err);\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error);\r\n }\r\n }\r\n\r\n // Destroy the recognizer.\r\n this.dispose(true);\r\n }\r\n }\r\n\r\n /**\r\n * Send the eject participant command to the websocket\r\n * @param conversationId\r\n * @param participantId\r\n */\r\n public sendEjectRequest(participantId: string, cb?: () => void, err?: (e: string) => void): void {\r\n\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"conversationId\");\r\n Contracts.throwIfNullOrWhitespace(participantId, \"participantId\");\r\n\r\n const command: IEjectParticipantCommand = {\r\n command: ConversationTranslatorCommandTypes.ejectParticipant,\r\n // tslint:disable-next-line: object-literal-shorthand\r\n participantId: participantId,\r\n roomid: this.privRoom.roomId,\r\n type: ConversationTranslatorMessageTypes.participantCommand,\r\n };\r\n\r\n this.sendMessage(JSON.stringify(command), cb, err);\r\n\r\n if (!!cb) {\r\n try {\r\n cb();\r\n } catch (e) {\r\n if (!!err) {\r\n err(e);\r\n }\r\n }\r\n }\r\n\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error);\r\n }\r\n }\r\n\r\n // Destroy the recognizer.\r\n this.dispose(true);\r\n }\r\n }\r\n\r\n /**\r\n * Send the mute participant command to the websocket\r\n * @param conversationId\r\n * @param participantId\r\n * @param isMuted\r\n */\r\n public sendChangeNicknameRequest(nickname: string, cb?: () => void, err?: (e: string) => void): void {\r\n\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"conversationId\");\r\n Contracts.throwIfNullOrWhitespace(nickname, \"nickname\");\r\n\r\n const command: IChangeNicknameCommand = {\r\n command: ConversationTranslatorCommandTypes.changeNickname,\r\n nickname,\r\n // tslint:disable-next-line: object-literal-shorthand\r\n participantId: this.privRoom.participantId, // the id of the host\r\n roomid: this.privRoom.roomId,\r\n type: ConversationTranslatorMessageTypes.participantCommand,\r\n value: nickname\r\n };\r\n\r\n this.sendMessage(JSON.stringify(command), cb, err);\r\n\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error as Error;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error);\r\n }\r\n }\r\n\r\n // Destroy the recognizer.\r\n this.dispose(true);\r\n }\r\n }\r\n\r\n /**\r\n * Close and dispose the recognizer\r\n */\r\n public close(): void {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n this.dispose(true);\r\n }\r\n\r\n /**\r\n * Dispose the recognizer\r\n * @param disposing\r\n */\r\n protected dispose(disposing: boolean): boolean {\r\n if (this.privIsDisposed) {\r\n return;\r\n }\r\n if (disposing) {\r\n this.privIsDisposed = true;\r\n super.dispose(disposing);\r\n }\r\n }\r\n\r\n /**\r\n * Create the config for the recognizer\r\n * @param speechConfig\r\n */\r\n protected createRecognizerConfig(speechConfig: SpeechServiceConfig): RecognizerConfig {\r\n return new RecognizerConfig(speechConfig, this.privProperties);\r\n }\r\n\r\n /**\r\n * Create the service recognizer.\r\n * The audio source is redundnant here but is required by the implementation.\r\n * @param authentication\r\n * @param connectionFactory\r\n * @param audioConfig\r\n * @param recognizerConfig\r\n */\r\n protected createServiceRecognizer(\r\n authentication: IAuthentication,\r\n connectionFactory: IConnectionFactory,\r\n audioConfig: AudioConfig,\r\n recognizerConfig: RecognizerConfig): ServiceRecognizerBase {\r\n\r\n const audioSource: AudioConfigImpl = audioConfig as AudioConfigImpl;\r\n\r\n return new ConversationServiceAdapter(authentication, connectionFactory, audioSource, recognizerConfig, this);\r\n }\r\n\r\n private sendMessage(msg: string, cb?: Callback, err?: Callback): void {\r\n const withAsync = this.privReco as ConversationServiceAdapter;\r\n PromiseToEmptyCallback(withAsync.sendMessageAsync(msg), cb, err);\r\n }\r\n\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ProxyInfo, WebsocketConnection } from \"../../common.browser/Exports\";\r\nimport { createGuid, IConnection, IStringDictionary } from \"../../common/Exports\";\r\nimport { Contracts } from \"../../sdk/Contracts\";\r\nimport { PropertyId } from \"../../sdk/Exports\";\r\nimport { ConnectionFactoryBase } from \"../ConnectionFactoryBase\";\r\nimport { AuthInfo, RecognizerConfig } from \"../Exports\";\r\nimport { ConversationConnectionConfig } from \"./ConversationConnectionConfig\";\r\nimport { ConversationWebsocketMessageFormatter } from \"./ConversationWebsocketMessageFormatter\";\r\n\r\n/**\r\n * Create a connection to the Conversation Translator websocket for sending instant messages and commands, and for receiving translated messages.\r\n * The conversation must already have been started or joined.\r\n */\r\nexport class ConversationConnectionFactory extends ConnectionFactoryBase {\r\n\r\n public create(config: RecognizerConfig, authInfo: AuthInfo, connectionId?: string): IConnection {\r\n\r\n const endpointHost: string = config.parameters.getProperty(PropertyId.ConversationTranslator_Host, ConversationConnectionConfig.host);\r\n const correlationId: string = config.parameters.getProperty(PropertyId.ConversationTranslator_CorrelationId, createGuid());\r\n\r\n const endpoint: string = `wss://${endpointHost}${ConversationConnectionConfig.webSocketPath}`;\r\n const token: string = config.parameters.getProperty(PropertyId.ConversationTranslator_Token, undefined);\r\n Contracts.throwIfNullOrUndefined(token, \"token\");\r\n\r\n const queryParams: IStringDictionary = {};\r\n queryParams[ConversationConnectionConfig.configParams.apiVersion] = ConversationConnectionConfig.apiVersion;\r\n queryParams[ConversationConnectionConfig.configParams.token] = token;\r\n queryParams[ConversationConnectionConfig.configParams.correlationId] = correlationId;\r\n return new WebsocketConnection(endpoint, queryParams, {}, new ConversationWebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), connectionId);\r\n }\r\n\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n ConnectionMessage,\r\n Deferred,\r\n IStringDictionary,\r\n IWebsocketMessageFormatter,\r\n MessageType,\r\n Promise,\r\n RawWebsocketMessage,\r\n} from \"../../common/Exports\";\r\nimport { ConversationConnectionMessage } from \"./ConversationConnectionMessage\";\r\n\r\n/**\r\n * Based off WebsocketMessageFormatter. The messages for Conversation Translator have some variations from the Speech messages.\r\n */\r\nexport class ConversationWebsocketMessageFormatter implements IWebsocketMessageFormatter {\r\n\r\n /**\r\n * Format incoming messages: text (speech partial/final, IM) or binary (tts)\r\n */\r\n public toConnectionMessage = (message: RawWebsocketMessage): Promise => {\r\n const deferral = new Deferred();\r\n\r\n try {\r\n if (message.messageType === MessageType.Text) {\r\n const incomingMessage: ConversationConnectionMessage = new ConversationConnectionMessage(message.messageType, message.textContent, {}, message.id);\r\n deferral.resolve(incomingMessage);\r\n } else if (message.messageType === MessageType.Binary) {\r\n deferral.resolve(new ConversationConnectionMessage(message.messageType, message.binaryContent, undefined, message.id));\r\n }\r\n } catch (e) {\r\n deferral.reject(`Error formatting the message. Error: ${e}`);\r\n }\r\n\r\n return deferral.promise();\r\n }\r\n\r\n /**\r\n * Format outgoing messages: text (commands or IM)\r\n */\r\n public fromConnectionMessage = (message: ConnectionMessage): Promise => {\r\n\r\n const deferral = new Deferred();\r\n\r\n try {\r\n if (message.messageType === MessageType.Text) {\r\n const payload = `${message.textBody ? message.textBody : \"\"}`;\r\n deferral.resolve(new RawWebsocketMessage(MessageType.Text, payload, message.id));\r\n }\r\n } catch (e) {\r\n deferral.reject(`Error formatting the message. ${e}`);\r\n }\r\n\r\n return deferral.promise();\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ConnectionMessage, IStringDictionary, MessageType } from \"../../common/Exports\";\r\n\r\nexport class ConversationConnectionMessage extends ConnectionMessage {\r\n private privConversationMessageType: string;\r\n\r\n public constructor(\r\n messageType: MessageType,\r\n body: any,\r\n headers?: IStringDictionary,\r\n id?: string) {\r\n super(messageType, body, headers, id);\r\n const json = JSON.parse(this.textBody);\r\n if (json.type !== undefined) {\r\n this.privConversationMessageType = json.type;\r\n }\r\n }\r\n\r\n public get conversationMessageType(): string {\r\n return this.privConversationMessageType;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n ConnectionEvent,\r\n ConnectionMessage,\r\n ConnectionOpenResponse,\r\n ConnectionState,\r\n createNoDashGuid,\r\n Deferred,\r\n IAudioSource,\r\n IConnection,\r\n MessageType,\r\n Promise,\r\n PromiseHelper,\r\n PromiseResult\r\n} from \"../../common/Exports\";\r\nimport { Sink } from \"../../common/Promise\";\r\nimport {\r\n CancellationErrorCode,\r\n CancellationReason,\r\n ConversationExpirationEventArgs,\r\n ConversationTranslationCanceledEventArgs,\r\n ConversationTranslationResult,\r\n PropertyId,\r\n SessionEventArgs,\r\n SpeechRecognitionResult,\r\n Translations\r\n} from \"../../sdk/Exports\";\r\nimport {\r\n AuthInfo, IAuthentication, IConnectionFactory, RecognizerConfig, ServiceRecognizerBase\r\n} from \"../Exports\";\r\nimport { ConversationConnectionMessage } from \"./ConversationConnectionMessage\";\r\nimport { ConversationRequestSession } from \"./ConversationRequestSession\";\r\nimport {\r\n ConversationReceivedTranslationEventArgs,\r\n LockRoomEventArgs,\r\n MuteAllEventArgs,\r\n ParticipantAttributeEventArgs,\r\n ParticipantEventArgs,\r\n ParticipantsListEventArgs\r\n} from \"./ConversationTranslatorEventArgs\";\r\nimport { ConversationTranslatorCommandTypes, ConversationTranslatorMessageTypes, IInternalParticipant } from \"./ConversationTranslatorInterfaces\";\r\nimport { ConversationTranslatorRecognizer } from \"./ConversationTranslatorRecognizer\";\r\nimport {\r\n CommandResponsePayload,\r\n IParticipantPayloadResponse,\r\n IParticipantsListPayloadResponse,\r\n ITranslationResponsePayload,\r\n ParticipantPayloadResponse,\r\n ParticipantsListPayloadResponse,\r\n SpeechResponsePayload,\r\n TextResponsePayload\r\n} from \"./ServiceMessages/Exports\";\r\n\r\n/***\r\n * The service adapter handles sending and receiving messages to the Conversation Translator websocket.\r\n */\r\nexport class ConversationServiceAdapter extends ServiceRecognizerBase {\r\n private privConversationServiceConnector: ConversationTranslatorRecognizer;\r\n private privConversationConnectionFactory: IConnectionFactory;\r\n private privConversationAuthFetchEventId: string;\r\n private privConversationAuthentication: IAuthentication;\r\n private privConversationRequestSession: ConversationRequestSession;\r\n private privConnectionConfigPromise: Promise;\r\n private privConversationConnectionPromise: Promise;\r\n private privConnectionLoop: Promise;\r\n private terminateMessageLoop: boolean;\r\n private privLastPartialUtteranceId: string = \"\";\r\n private privConversationIsDisposed: boolean;\r\n\r\n public constructor(\r\n authentication: IAuthentication,\r\n connectionFactory: IConnectionFactory,\r\n audioSource: IAudioSource,\r\n recognizerConfig: RecognizerConfig,\r\n conversationServiceConnector: ConversationTranslatorRecognizer) {\r\n\r\n super(authentication, connectionFactory, audioSource, recognizerConfig, conversationServiceConnector);\r\n\r\n this.privConversationServiceConnector = conversationServiceConnector;\r\n this.privConversationAuthentication = authentication;\r\n this.receiveMessageOverride = this.receiveConversationMessageOverride;\r\n this.recognizeOverride = this.noOp;\r\n this.connectImplOverride = this.conversationConnectImpl;\r\n this.configConnectionOverride = this.configConnection;\r\n this.fetchConnectionOverride = this.fetchConversationConnection;\r\n this.disconnectOverride = this.privDisconnect;\r\n this.privConversationRequestSession = new ConversationRequestSession(createNoDashGuid());\r\n this.privConversationConnectionFactory = connectionFactory;\r\n this.privConversationIsDisposed = false;\r\n }\r\n\r\n public isDisposed(): boolean {\r\n return this.privConversationIsDisposed;\r\n }\r\n\r\n public dispose(reason?: string): void {\r\n this.privConversationIsDisposed = true;\r\n if (this.privConnectionConfigPromise) {\r\n this.privConnectionConfigPromise.onSuccessContinueWith((connection: IConnection) => {\r\n connection.dispose(reason);\r\n });\r\n }\r\n }\r\n\r\n public sendMessage(message: string): void {\r\n this.fetchConversationConnection().onSuccessContinueWith((connection: IConnection) => {\r\n connection.send(new ConversationConnectionMessage(\r\n MessageType.Text,\r\n message));\r\n });\r\n }\r\n\r\n public sendMessageAsync = (message: string): Promise => {\r\n const sink: Sink = new Sink();\r\n\r\n this.fetchConversationConnection().continueWith((antecedent: PromiseResult): void => {\r\n try {\r\n if (antecedent.isError) {\r\n sink.reject(antecedent.error);\r\n } else {\r\n antecedent.result.send(new ConversationConnectionMessage(MessageType.Text, message))\r\n .continueWith((innerAntecedent: PromiseResult): void => {\r\n try {\r\n if (innerAntecedent.isError) {\r\n sink.reject(innerAntecedent.error);\r\n } else {\r\n sink.resolve(innerAntecedent.result);\r\n }\r\n } catch (e) {\r\n sink.reject(`Unhandled inner error: ${e}`);\r\n }\r\n });\r\n }\r\n } catch (e) {\r\n sink.reject(`Unhandled error: ${e}`);\r\n }\r\n });\r\n\r\n return new Promise(sink);\r\n }\r\n\r\n protected privDisconnect(): void {\r\n if (this.terminateMessageLoop) {\r\n return;\r\n }\r\n this.cancelRecognition(this.privConversationRequestSession.sessionId,\r\n this.privConversationRequestSession.requestId,\r\n CancellationReason.Error,\r\n CancellationErrorCode.NoError,\r\n \"Disconnecting\");\r\n\r\n this.terminateMessageLoop = true;\r\n if (this.privConversationConnectionPromise.result().isCompleted) {\r\n if (!this.privConversationConnectionPromise.result().isError) {\r\n this.privConversationConnectionPromise.result().result.dispose();\r\n this.privConversationConnectionPromise = null;\r\n }\r\n } else {\r\n this.privConversationConnectionPromise.onSuccessContinueWith((connection: IConnection) => {\r\n connection.dispose();\r\n });\r\n }\r\n }\r\n\r\n protected processTypeSpecificMessages(\r\n connectionMessage: ConnectionMessage,\r\n successCallback?: (e: any) => void,\r\n errorCallBack?: (e: string) => void): boolean {\r\n return true;\r\n }\r\n\r\n // Cancels recognition.\r\n protected cancelRecognition(\r\n sessionId: string,\r\n requestId: string,\r\n cancellationReason: CancellationReason,\r\n errorCode: CancellationErrorCode,\r\n error: string): void {\r\n\r\n this.terminateMessageLoop = true;\r\n\r\n const cancelEvent: ConversationTranslationCanceledEventArgs = new ConversationTranslationCanceledEventArgs(\r\n cancellationReason,\r\n error,\r\n errorCode,\r\n undefined,\r\n sessionId);\r\n\r\n try {\r\n if (!!this.privConversationServiceConnector.canceled) {\r\n this.privConversationServiceConnector.canceled(this.privConversationServiceConnector, cancelEvent);\r\n }\r\n } catch {\r\n // continue on error\r\n }\r\n }\r\n\r\n protected noOp = (): any => {\r\n // operation not supported\r\n }\r\n\r\n /**\r\n * Establishes a websocket connection to the end point.\r\n * @param isUnAuthorized\r\n */\r\n protected conversationConnectImpl(isUnAuthorized: boolean = false): Promise {\r\n\r\n if (this.privConversationConnectionPromise) {\r\n if (this.privConversationConnectionPromise.result().isCompleted &&\r\n (this.privConversationConnectionPromise.result().isError\r\n || this.privConversationConnectionPromise.result().result.state() === ConnectionState.Disconnected)) {\r\n this.privConnectionId = null;\r\n this.privConversationConnectionPromise = null;\r\n this.terminateMessageLoop = true;\r\n return this.conversationConnectImpl();\r\n } else {\r\n return this.privConversationConnectionPromise;\r\n }\r\n }\r\n\r\n this.privConversationAuthFetchEventId = createNoDashGuid();\r\n\r\n // keep the connectionId for reconnect events\r\n if (this.privConnectionId === undefined) {\r\n this.privConnectionId = createNoDashGuid();\r\n }\r\n\r\n this.privConversationRequestSession.onPreConnectionStart(this.privConversationAuthFetchEventId, this.privConnectionId);\r\n\r\n const authPromise = isUnAuthorized ? this.privConversationAuthentication.fetchOnExpiry(this.privConversationAuthFetchEventId) : this.privConversationAuthentication.fetch(this.privConversationAuthFetchEventId);\r\n\r\n this.privConversationConnectionPromise = authPromise\r\n .continueWithPromise((result: PromiseResult) => {\r\n if (result.isError) {\r\n this.privConversationRequestSession.onAuthCompleted(true, result.error);\r\n throw new Error(result.error);\r\n } else {\r\n this.privConversationRequestSession.onAuthCompleted(false);\r\n }\r\n\r\n const connection: IConnection = this.privConversationConnectionFactory.create(this.privRecognizerConfig, result.result, this.privConnectionId);\r\n\r\n // Attach to the underlying event. No need to hold onto the detach pointers as in the event the connection goes away,\r\n // it'll stop sending events.\r\n connection.events.attach((event: ConnectionEvent) => {\r\n this.connectionEvents.onEvent(event);\r\n });\r\n\r\n return connection.open().onSuccessContinueWithPromise((response: ConnectionOpenResponse): Promise => {\r\n if (response.statusCode === 200) {\r\n this.privConversationRequestSession.onPreConnectionStart(this.privConversationAuthFetchEventId, this.privConnectionId);\r\n this.privConversationRequestSession.onConnectionEstablishCompleted(response.statusCode);\r\n const sessionStartEventArgs: SessionEventArgs = new SessionEventArgs(this.privConversationRequestSession.sessionId);\r\n if (!!this.privConversationServiceConnector.connectionOpened) {\r\n this.privConversationServiceConnector.connectionOpened(this.privConversationServiceConnector, sessionStartEventArgs);\r\n }\r\n return PromiseHelper.fromResult(connection);\r\n } else if (response.statusCode === 403 && !isUnAuthorized) {\r\n return this.conversationConnectImpl(true);\r\n } else {\r\n this.privConversationRequestSession.onConnectionEstablishCompleted(response.statusCode, response.reason);\r\n return PromiseHelper.fromError(`Unable to contact server. StatusCode: ${response.statusCode}, ${this.privRecognizerConfig.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint)} Reason: ${response.reason}`);\r\n }\r\n });\r\n });\r\n\r\n this.privConnectionLoop = this.startMessageLoop();\r\n return this.privConversationConnectionPromise;\r\n }\r\n\r\n /**\r\n * Process incoming websocket messages\r\n */\r\n private receiveConversationMessageOverride = (\r\n successCallback?: (e: any) => void,\r\n errorCallBack?: (e: string) => void\r\n ): Promise => {\r\n\r\n // we won't rely on the cascading promises of the connection since we want to continually be available to receive messages\r\n const communicationCustodian: Deferred = new Deferred();\r\n\r\n this.fetchConversationConnection().on((connection: IConnection): Promise => {\r\n return connection.read().onSuccessContinueWithPromise((message: ConversationConnectionMessage): Promise => {\r\n const isDisposed: boolean = this.isDisposed();\r\n const terminateMessageLoop = (!this.isDisposed() && this.terminateMessageLoop);\r\n const sessionId: string = this.privConversationRequestSession.sessionId;\r\n let sendFinal: boolean = false;\r\n if (isDisposed || terminateMessageLoop) {\r\n // We're done.\r\n communicationCustodian.resolve(undefined);\r\n return PromiseHelper.fromResult(undefined);\r\n }\r\n\r\n if (!message) {\r\n return this.receiveConversationMessageOverride();\r\n }\r\n\r\n try {\r\n switch (message.conversationMessageType.toLowerCase()) {\r\n case \"info\":\r\n case \"participant_command\":\r\n case \"command\":\r\n const commandPayload: CommandResponsePayload = CommandResponsePayload.fromJSON(message.textBody);\r\n switch (commandPayload.command.toLowerCase()) {\r\n\r\n /**\r\n * 'ParticpantList' is the first message sent to the user after the websocket connection has opened.\r\n * The consuming client must wait for this message to arrive\r\n * before starting to send their own data.\r\n */\r\n case \"participantlist\":\r\n\r\n const participantsPayload: IParticipantsListPayloadResponse = ParticipantsListPayloadResponse.fromJSON(message.textBody);\r\n\r\n const participantsResult: IInternalParticipant[] = participantsPayload.participants.map((p: IParticipantPayloadResponse) => {\r\n const participant: IInternalParticipant = {\r\n avatar: p.avatar,\r\n displayName: p.nickname,\r\n id: p.participantId,\r\n isHost: p.ishost,\r\n isMuted: p.ismuted,\r\n isUsingTts: p.usetts,\r\n preferredLanguage: p.locale\r\n };\r\n return participant;\r\n });\r\n\r\n if (!!this.privConversationServiceConnector.participantsListReceived) {\r\n this.privConversationServiceConnector.participantsListReceived(this.privConversationServiceConnector,\r\n new ParticipantsListEventArgs(participantsPayload.roomid, participantsPayload.token,\r\n participantsPayload.translateTo, participantsPayload.profanityFilter,\r\n participantsPayload.roomProfanityFilter, participantsPayload.roomLocked,\r\n participantsPayload.muteAll, participantsResult, sessionId));\r\n }\r\n break;\r\n\r\n /**\r\n * 'SetTranslateToLanguages' represents the list of languages being used in the Conversation by all users(?).\r\n * This is sent at the start of the Conversation\r\n */\r\n case \"settranslatetolanguages\":\r\n\r\n if (!!this.privConversationServiceConnector.participantUpdateCommandReceived) {\r\n this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,\r\n new ParticipantAttributeEventArgs(commandPayload.participantId,\r\n ConversationTranslatorCommandTypes.setTranslateToLanguages,\r\n commandPayload.value, sessionId));\r\n }\r\n\r\n break;\r\n\r\n /**\r\n * 'SetProfanityFiltering' lets the client set the level of profanity filtering.\r\n * If sent by the participant the setting will effect only their own profanity level.\r\n * If sent by the host, the setting will effect all participants including the host.\r\n * Note: the profanity filters differ from Speech Service (?): 'marked', 'raw', 'removed', 'tagged'\r\n */\r\n case \"setprofanityfiltering\":\r\n\r\n if (!!this.privConversationServiceConnector.participantUpdateCommandReceived) {\r\n this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,\r\n new ParticipantAttributeEventArgs(commandPayload.participantId,\r\n ConversationTranslatorCommandTypes.setProfanityFiltering,\r\n commandPayload.value, sessionId));\r\n }\r\n\r\n break;\r\n\r\n /**\r\n * 'SetMute' is sent if the participant has been muted by the host.\r\n * Check the 'participantId' to determine if the current user has been muted.\r\n */\r\n case \"setmute\":\r\n\r\n if (!!this.privConversationServiceConnector.participantUpdateCommandReceived) {\r\n this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,\r\n new ParticipantAttributeEventArgs(commandPayload.participantId,\r\n ConversationTranslatorCommandTypes.setMute,\r\n commandPayload.value, sessionId));\r\n }\r\n\r\n break;\r\n\r\n /**\r\n * 'SetMuteAll' is sent if the Conversation has been muted by the host.\r\n */\r\n case \"setmuteall\":\r\n\r\n if (!!this.privConversationServiceConnector.muteAllCommandReceived) {\r\n this.privConversationServiceConnector.muteAllCommandReceived(this.privConversationServiceConnector,\r\n new MuteAllEventArgs(commandPayload.value as boolean, sessionId));\r\n }\r\n\r\n break;\r\n\r\n /**\r\n * 'RoomExpirationWarning' is sent towards the end of the Conversation session to give a timeout warning.\r\n */\r\n case \"roomexpirationwarning\":\r\n\r\n if (!!this.privConversationServiceConnector.conversationExpiration) {\r\n this.privConversationServiceConnector.conversationExpiration(this.privConversationServiceConnector,\r\n new ConversationExpirationEventArgs(commandPayload.value as number, this.privConversationRequestSession.sessionId));\r\n }\r\n\r\n break;\r\n\r\n /**\r\n * 'SetUseTts' is sent as a confirmation if the user requests TTS to be turned on or off.\r\n */\r\n case \"setusetts\":\r\n\r\n if (!!this.privConversationServiceConnector.participantUpdateCommandReceived) {\r\n this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,\r\n new ParticipantAttributeEventArgs(commandPayload.participantId,\r\n ConversationTranslatorCommandTypes.setUseTTS,\r\n commandPayload.value, sessionId));\r\n }\r\n\r\n break;\r\n\r\n /**\r\n * 'SetLockState' is set if the host has locked or unlocked the Conversation.\r\n */\r\n case \"setlockstate\":\r\n\r\n if (!!this.privConversationServiceConnector.lockRoomCommandReceived) {\r\n this.privConversationServiceConnector.lockRoomCommandReceived(this.privConversationServiceConnector,\r\n new LockRoomEventArgs(commandPayload.value as boolean, sessionId));\r\n }\r\n\r\n break;\r\n\r\n /**\r\n * 'ChangeNickname' is received if a user changes their display name.\r\n * Any cached particpiants list should be updated to reflect the display name.\r\n */\r\n case \"changenickname\":\r\n\r\n if (!!this.privConversationServiceConnector.participantUpdateCommandReceived) {\r\n this.privConversationServiceConnector.participantUpdateCommandReceived(this.privConversationServiceConnector,\r\n new ParticipantAttributeEventArgs(commandPayload.participantId,\r\n ConversationTranslatorCommandTypes.changeNickname,\r\n commandPayload.nickname, sessionId));\r\n }\r\n\r\n break;\r\n\r\n /**\r\n * 'JoinSession' is sent when a user joins the Conversation.\r\n */\r\n case \"joinsession\":\r\n\r\n const joinParticipantPayload: ParticipantPayloadResponse = ParticipantPayloadResponse.fromJSON(message.textBody);\r\n\r\n const joiningParticipant: IInternalParticipant = {\r\n avatar: joinParticipantPayload.avatar,\r\n displayName: joinParticipantPayload.nickname,\r\n id: joinParticipantPayload.participantId,\r\n isHost: joinParticipantPayload.ishost,\r\n isMuted: joinParticipantPayload.ismuted,\r\n isUsingTts: joinParticipantPayload.usetts,\r\n preferredLanguage: joinParticipantPayload.locale,\r\n };\r\n\r\n if (!!this.privConversationServiceConnector.participantJoinCommandReceived) {\r\n this.privConversationServiceConnector.participantJoinCommandReceived(this.privConversationServiceConnector,\r\n new ParticipantEventArgs(\r\n joiningParticipant,\r\n sessionId));\r\n }\r\n\r\n break;\r\n\r\n /**\r\n * 'LeaveSession' is sent when a user leaves the Conversation'.\r\n */\r\n case \"leavesession\":\r\n\r\n const leavingParticipant: IInternalParticipant = {\r\n id: commandPayload.participantId\r\n };\r\n\r\n if (!!this.privConversationServiceConnector.participantLeaveCommandReceived) {\r\n this.privConversationServiceConnector.participantLeaveCommandReceived(this.privConversationServiceConnector,\r\n new ParticipantEventArgs(leavingParticipant, sessionId));\r\n }\r\n\r\n break;\r\n\r\n /**\r\n * 'DisconnectSession' is sent when a user is disconnected from the session (e.g. network problem).\r\n * Check the 'ParticipantId' to check whether the message is for the current user.\r\n */\r\n case \"disconnectsession\":\r\n\r\n const disconnectParticipant: IInternalParticipant = {\r\n id: commandPayload.participantId\r\n };\r\n\r\n break;\r\n\r\n /**\r\n * Message not recognized.\r\n */\r\n default:\r\n break;\r\n }\r\n break;\r\n\r\n /**\r\n * 'partial' (or 'hypothesis') represents a unfinalized speech message.\r\n */\r\n case \"partial\":\r\n\r\n /**\r\n * 'final' (or 'phrase') represents a finalized speech message.\r\n */\r\n case \"final\":\r\n\r\n const speechPayload: SpeechResponsePayload = SpeechResponsePayload.fromJSON(message.textBody);\r\n\r\n const speechResult: ConversationTranslationResult = new ConversationTranslationResult(speechPayload.participantId,\r\n this.getTranslations(speechPayload.translations),\r\n speechPayload.language,\r\n undefined,\r\n undefined,\r\n speechPayload.recognition,\r\n undefined,\r\n undefined,\r\n message.textBody,\r\n undefined);\r\n\r\n if (speechPayload.isFinal) {\r\n // check the length, sometimes empty finals are returned\r\n if (speechResult.text !== undefined && speechResult.text.length > 0) {\r\n sendFinal = true;\r\n } else if (speechPayload.id === this.privLastPartialUtteranceId) {\r\n // send final as normal. We had a non-empty partial for this same utterance\r\n // so sending the empty final is important\r\n sendFinal = true;\r\n } else {\r\n // suppress unneeded final\r\n }\r\n\r\n if (sendFinal) {\r\n if (!!this.privConversationServiceConnector.translationReceived) {\r\n this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,\r\n new ConversationReceivedTranslationEventArgs(ConversationTranslatorMessageTypes.final, speechResult, sessionId));\r\n }\r\n }\r\n } else if (speechResult.text !== undefined) {\r\n this.privLastPartialUtteranceId = speechPayload.id;\r\n if (!!this.privConversationServiceConnector.translationReceived) {\r\n this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,\r\n new ConversationReceivedTranslationEventArgs(ConversationTranslatorMessageTypes.partial, speechResult, sessionId));\r\n }\r\n }\r\n\r\n break;\r\n\r\n /**\r\n * \"translated_message\" is a text message or instant message (IM).\r\n */\r\n case \"translated_message\":\r\n\r\n const textPayload: TextResponsePayload = TextResponsePayload.fromJSON(message.textBody);\r\n\r\n const textResult: ConversationTranslationResult = new ConversationTranslationResult(textPayload.participantId,\r\n this.getTranslations(textPayload.translations),\r\n textPayload.language,\r\n undefined,\r\n undefined,\r\n textPayload.originalText,\r\n undefined,\r\n undefined,\r\n undefined,\r\n message.textBody,\r\n undefined);\r\n\r\n if (!!this.privConversationServiceConnector.translationReceived) {\r\n this.privConversationServiceConnector.translationReceived(this.privConversationServiceConnector,\r\n new ConversationReceivedTranslationEventArgs(ConversationTranslatorMessageTypes.instantMessage, textResult, sessionId));\r\n }\r\n break;\r\n\r\n default:\r\n // ignore any unsupported message types\r\n break;\r\n }\r\n } catch (e) {\r\n // continue\r\n }\r\n return this.receiveConversationMessageOverride();\r\n });\r\n }, (error: string) => {\r\n this.terminateMessageLoop = true;\r\n });\r\n\r\n return communicationCustodian.promise();\r\n }\r\n\r\n private startMessageLoop(): Promise {\r\n\r\n this.terminateMessageLoop = false;\r\n\r\n const messageRetrievalPromise = this.receiveConversationMessageOverride();\r\n\r\n return messageRetrievalPromise.on((r: IConnection) => {\r\n return true;\r\n }, (error: string) => {\r\n this.cancelRecognition(\r\n this.privRequestSession ? this.privRequestSession.sessionId : \"\",\r\n this.privRequestSession ? this.privRequestSession.requestId : \"\",\r\n CancellationReason.Error,\r\n CancellationErrorCode.RuntimeError,\r\n error);\r\n });\r\n }\r\n\r\n // Takes an established websocket connection to the endpoint\r\n private configConnection(): Promise {\r\n if (this.privConnectionConfigPromise) {\r\n if (this.privConnectionConfigPromise.result().isCompleted &&\r\n (this.privConnectionConfigPromise.result().isError\r\n || this.privConnectionConfigPromise.result().result.state() === ConnectionState.Disconnected)) {\r\n\r\n this.privConnectionConfigPromise = null;\r\n return this.configConnection();\r\n } else {\r\n return this.privConnectionConfigPromise;\r\n }\r\n }\r\n\r\n if (this.terminateMessageLoop) {\r\n return PromiseHelper.fromResult(undefined);\r\n }\r\n\r\n this.privConnectionConfigPromise = this.conversationConnectImpl()\r\n .onSuccessContinueWith((connection: IConnection): any => {\r\n return connection;\r\n });\r\n return this.privConnectionConfigPromise;\r\n }\r\n\r\n private getTranslations(serviceResultTranslations: ITranslationResponsePayload[]): Translations {\r\n let translations: Translations;\r\n\r\n if (undefined !== serviceResultTranslations) {\r\n translations = new Translations();\r\n for (const translation of serviceResultTranslations) {\r\n translations.set(translation.lang, translation.translation);\r\n }\r\n }\r\n\r\n return translations;\r\n }\r\n\r\n private fetchConversationConnection = (): Promise => {\r\n return this.configConnection();\r\n }\r\n\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n createNoDashGuid,\r\n Deferred,\r\n IDetachable,\r\n Promise,\r\n} from \"../../common/Exports\";\r\n\r\n/**\r\n * Placeholder class for the Conversation Request Session. Based off RequestSession.\r\n * TODO: define what telemetry is required.\r\n */\r\nexport class ConversationRequestSession {\r\n private privIsDisposed: boolean = false;\r\n private privDetachables: IDetachable[] = new Array();\r\n private privRequestId: string;\r\n private privRequestCompletionDeferral: Deferred;\r\n private privSessionId: string;\r\n\r\n constructor(sessionId: string) {\r\n this.privSessionId = sessionId;\r\n this.privRequestId = createNoDashGuid();\r\n this.privRequestCompletionDeferral = new Deferred();\r\n }\r\n\r\n public get sessionId(): string {\r\n return this.privSessionId;\r\n }\r\n\r\n public get requestId(): string {\r\n return this.privRequestId;\r\n }\r\n\r\n public get completionPromise(): Promise {\r\n return this.privRequestCompletionDeferral.promise();\r\n }\r\n\r\n public onPreConnectionStart = (authFetchEventId: string, connectionId: string): void => {\r\n this.privSessionId = connectionId;\r\n }\r\n\r\n public onAuthCompleted = (isError: boolean, error?: string): void => {\r\n if (isError) {\r\n this.onComplete();\r\n }\r\n }\r\n\r\n public onConnectionEstablishCompleted = (statusCode: number, reason?: string): void => {\r\n if (statusCode === 200) {\r\n return;\r\n } else if (statusCode === 403) {\r\n this.onComplete();\r\n }\r\n }\r\n\r\n public onServiceTurnEndResponse = (continuousRecognition: boolean): void => {\r\n if (!continuousRecognition) {\r\n this.onComplete();\r\n } else {\r\n this.privRequestId = createNoDashGuid();\r\n }\r\n }\r\n\r\n public dispose = (error?: string): void => {\r\n if (!this.privIsDisposed) {\r\n // we should have completed by now. If we did not its an unknown error.\r\n this.privIsDisposed = true;\r\n for (const detachable of this.privDetachables) {\r\n detachable.detach();\r\n }\r\n }\r\n }\r\n\r\n private onComplete = (): void => {\r\n //\r\n }\r\n\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\nimport { SessionEventArgs } from \"../../sdk/Exports\";\r\nimport { IInternalParticipant } from \"./ConversationTranslatorInterfaces\";\r\n\r\nexport class MuteAllEventArgs extends SessionEventArgs {\r\n private privIsMuted: boolean;\r\n\r\n public constructor(isMuted: boolean, sessionId?: string) {\r\n super(sessionId);\r\n\r\n this.privIsMuted = isMuted;\r\n }\r\n\r\n public get isMuted(): boolean {\r\n return this.privIsMuted;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line: max-classes-per-file\r\nexport class LockRoomEventArgs extends SessionEventArgs {\r\n private privIsLocked: boolean;\r\n\r\n public constructor(isLocked: boolean, sessionId?: string) {\r\n super(sessionId);\r\n\r\n this.privIsLocked = isLocked;\r\n }\r\n\r\n public get isMuted(): boolean {\r\n return this.privIsLocked;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line: max-classes-per-file\r\nexport class ParticipantEventArgs extends SessionEventArgs {\r\n private privParticipant: IInternalParticipant;\r\n\r\n public constructor(participant: IInternalParticipant, sessionId?: string) {\r\n super(sessionId);\r\n this.privParticipant = participant;\r\n }\r\n\r\n public get participant(): IInternalParticipant {\r\n return this.privParticipant;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line: max-classes-per-file\r\nexport class ParticipantAttributeEventArgs extends SessionEventArgs {\r\n private privValue: boolean | number | string | string[];\r\n private privKey: string;\r\n private privParticipantId: string;\r\n\r\n public constructor(participantId: string, key: string, value: boolean | number | string | string[], sessionId?: string) {\r\n super(sessionId);\r\n\r\n this.privKey = key;\r\n this.privValue = value;\r\n this.privParticipantId = participantId;\r\n }\r\n\r\n public get value(): boolean | number | string | string[] {\r\n return this.privValue;\r\n }\r\n\r\n public get key(): string {\r\n return this.privKey;\r\n }\r\n public get id(): string {\r\n return this.privParticipantId;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line: max-classes-per-file\r\nexport class ParticipantsListEventArgs extends SessionEventArgs {\r\n\r\n private privRoomId: string;\r\n private privSessionToken: string;\r\n private privTranslateTo: string[];\r\n private privProfanityFilter: string;\r\n private privRoomProfanityFilter: string;\r\n private privIsRoomLocked: boolean;\r\n private privIsMuteAll: boolean;\r\n private privParticipants: IInternalParticipant[];\r\n\r\n public constructor(conversationId: string, token: string, translateTo: string[], profanityFilter: string,\r\n roomProfanityFilter: string, isRoomLocked: boolean, isMuteAll: boolean, participants: IInternalParticipant[], sessionId?: string) {\r\n super(sessionId);\r\n this.privRoomId = conversationId;\r\n this.privSessionToken = token;\r\n this.privTranslateTo = translateTo;\r\n this.privProfanityFilter = profanityFilter;\r\n this.privRoomProfanityFilter = roomProfanityFilter;\r\n this.privIsRoomLocked = isRoomLocked;\r\n this.privIsRoomLocked = isMuteAll;\r\n this.privParticipants = participants;\r\n }\r\n public get sessionToken(): string {\r\n return this.privSessionToken;\r\n }\r\n\r\n public get conversationId(): string {\r\n return this.privRoomId;\r\n }\r\n\r\n public get translateTo(): string[] {\r\n return this.privTranslateTo;\r\n }\r\n\r\n public get profanityFilter(): string {\r\n return this.privProfanityFilter;\r\n }\r\n\r\n public get roomProfanityFilter(): string {\r\n return this.privRoomProfanityFilter;\r\n }\r\n\r\n public get isRoomLocked(): boolean {\r\n return this.privIsRoomLocked;\r\n }\r\n\r\n public get isMuteAll(): boolean {\r\n return this.privIsMuteAll;\r\n }\r\n\r\n public get participants(): IInternalParticipant[] {\r\n return this.privParticipants;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line: max-classes-per-file\r\nexport class ConversationReceivedTranslationEventArgs {\r\n private privPayload: any;\r\n private privCommand: string;\r\n private privSessionId: string;\r\n\r\n public constructor(command: string, payload: any, sessionId?: string) {\r\n this.privPayload = payload;\r\n this.privCommand = command;\r\n this.privSessionId = sessionId;\r\n }\r\n\r\n public get payload(): any {\r\n return this.privPayload;\r\n }\r\n\r\n public get command(): string {\r\n return this.privCommand;\r\n }\r\n\r\n public get sessionId(): string {\r\n return this.privSessionId;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n ConversationExpirationEventArgs,\r\n ConversationParticipantsChangedEventArgs,\r\n ConversationTranslationCanceledEventArgs,\r\n ConversationTranslationEventArgs,\r\n SessionEventArgs } from \"../../sdk/Exports\";\r\n// import { ConversationClient } from \"./ConversationConnection\";\r\nimport {\r\n ConversationReceivedTranslationEventArgs,\r\n LockRoomEventArgs,\r\n MuteAllEventArgs,\r\n ParticipantAttributeEventArgs,\r\n ParticipantEventArgs,\r\n ParticipantsListEventArgs } from \"./ConversationTranslatorEventArgs\";\r\n\r\n/**\r\n * Internal conversation data\r\n */\r\nexport interface IInternalConversation {\r\n // the token to use for connecting to the Speech Service\r\n cognitiveSpeechAuthToken: string;\r\n // the region to use for connecting to the Speech Service\r\n cognitiveSpeechRegion: string;\r\n // the unique id of the user who started or joined the Conversation\r\n participantId: string;\r\n // a descriptive name for the Conversation\r\n name: string;\r\n // a descriptive name for the Conversation\r\n description: string;\r\n // the speech model ID for custom speech\r\n speechModel: string;\r\n // represents the level of speech supported in the Conversation (0: everyone can speak, 2: only host can speak, 3: no-one can speak)\r\n modalities: number;\r\n // ?\r\n isApproved: boolean;\r\n // the mute flag has been set at conversation level and only the host can speak\r\n isMuted: boolean;\r\n // the 5 character conversation Id\r\n roomId: string;\r\n // the hex color string to represent a user. If there are many users this hex color may be reused (?).\r\n avatar: string;\r\n // the token to use when calling the websocket\r\n token: string;\r\n // used for tracking the session and help with troubleshooting problems in the logs\r\n correlationId: string;\r\n // extracted from the headers\r\n requestId: string;\r\n}\r\n\r\n/**\r\n * The user who is participating in the conversation.\r\n */\r\nexport interface IInternalParticipant {\r\n avatar?: string;\r\n displayName?: string;\r\n id?: string;\r\n isHost?: boolean;\r\n isMuted?: boolean;\r\n isUsingTts?: boolean;\r\n preferredLanguage?: string;\r\n}\r\n\r\n/** Users participating in the conversation */\r\nexport class InternalParticipants {\r\n\r\n constructor(public participants: IInternalParticipant[] = [], public meId?: string) {\r\n\r\n }\r\n\r\n /**\r\n * Add or update a participant\r\n * @param value\r\n */\r\n public addOrUpdateParticipant(value: IInternalParticipant): IInternalParticipant {\r\n if (value === undefined) {\r\n return;\r\n }\r\n\r\n const exists: number = this.getParticipantIndex(value.id);\r\n if (exists > -1) {\r\n this.participants.splice(exists, 1, value);\r\n } else {\r\n this.participants.push(value);\r\n }\r\n\r\n // ensure it was added ok\r\n return this.getParticipant(value.id);\r\n }\r\n\r\n /**\r\n * Find the participant's position in the participants list.\r\n * @param id\r\n */\r\n public getParticipantIndex(id: string): number {\r\n return this.participants.findIndex((p: IInternalParticipant) => p.id === id);\r\n }\r\n\r\n /**\r\n * Find the participant by id.\r\n * @param id\r\n */\r\n public getParticipant(id: string): IInternalParticipant {\r\n return this.participants.find((p: IInternalParticipant) => p.id === id);\r\n }\r\n\r\n /***\r\n * Remove a participant from the participants list.\r\n */\r\n public deleteParticipant(id: string): void {\r\n this.participants = this.participants.filter((p: IInternalParticipant) => p.id !== id);\r\n }\r\n\r\n /***\r\n * Helper to return the conversation host.\r\n */\r\n public get host(): IInternalParticipant {\r\n return this.participants.find((p: IInternalParticipant) => p.isHost === true );\r\n }\r\n\r\n /**\r\n * Helper to return the current user.\r\n */\r\n public get me(): IInternalParticipant {\r\n return this.getParticipant(this.meId);\r\n }\r\n}\r\n\r\n/**\r\n * Recognizer for handling Conversation Translator websocket messages\r\n */\r\nexport interface IConversationTranslatorRecognizer {\r\n canceled: (sender: IConversationTranslatorRecognizer, event: ConversationTranslationCanceledEventArgs) => void;\r\n connectionOpened: (sender: IConversationTranslatorRecognizer, event: SessionEventArgs) => void;\r\n connectionClosed: (sender: IConversationTranslatorRecognizer, event: SessionEventArgs) => void;\r\n participantsListReceived: (sender: IConversationTranslatorRecognizer, event: ParticipantsListEventArgs) => void;\r\n translationReceived: (sender: IConversationTranslatorRecognizer, event: ConversationReceivedTranslationEventArgs) => void;\r\n lockRoomCommandReceived: (sender: IConversationTranslatorRecognizer, event: LockRoomEventArgs) => void;\r\n muteAllCommandReceived: (sender: IConversationTranslatorRecognizer, event: MuteAllEventArgs) => void;\r\n participantJoinCommandReceived: (sender: IConversationTranslatorRecognizer, event: ParticipantEventArgs) => void;\r\n participantLeaveCommandReceived: (sender: IConversationTranslatorRecognizer, event: ParticipantEventArgs) => void;\r\n participantUpdateCommandReceived: (sender: IConversationTranslatorRecognizer, event: ParticipantAttributeEventArgs) => void;\r\n}\r\n\r\n/**\r\n * Error message returned from the Conversation Translator websocket\r\n */\r\nexport interface IConversationResponseErrorMessage {\r\n code: string;\r\n message: string;\r\n}\r\n\r\n/**\r\n * Error returned from the Conversation Translator websocket\r\n */\r\nexport interface IConversationResponseError {\r\n error: IConversationResponseErrorMessage;\r\n}\r\n\r\n/**\r\n * Base message command\r\n */\r\nexport interface IClientMessage {\r\n type: any;\r\n}\r\n\r\n/**\r\n * Command message\r\n */\r\nexport interface ICommandMessage extends IClientMessage {\r\n command?: string;\r\n}\r\n\r\n/**\r\n * Text message command\r\n */\r\nexport interface IInstantMessageCommand extends ICommandMessage {\r\n roomId: string;\r\n nickname?: string;\r\n participantId: string;\r\n text: string;\r\n}\r\n\r\n/**\r\n * Lock command\r\n */\r\nexport interface ILockConversationCommand extends ICommandMessage {\r\n id?: string; // incoming ws\r\n nickname?: string; // incoming ws\r\n participantId: string; // host - incoming ws\r\n roomid: string;\r\n value: boolean;\r\n}\r\n\r\n/**\r\n * Mute all command\r\n */\r\nexport interface IMuteAllCommand extends ICommandMessage {\r\n roomid: string;\r\n nickname?: string; // incoming ws\r\n participantId: string; // host\r\n value: boolean;\r\n id?: string; // incoming ws\r\n}\r\n\r\n/**\r\n * Mute participant command\r\n */\r\nexport interface IMuteCommand extends ICommandMessage {\r\n roomid: string;\r\n nickname?: string;\r\n participantId: string; // participant\r\n value: boolean;\r\n id?: string; // incoming ws\r\n}\r\n\r\n/**\r\n * Remove participant command\r\n */\r\nexport interface IEjectParticipantCommand extends ICommandMessage {\r\n roomid: string;\r\n participantId: string; // participant\r\n}\r\n\r\n/**\r\n * Change nickname command\r\n */\r\nexport interface IChangeNicknameCommand extends ICommandMessage {\r\n roomid: string;\r\n participantId: string;\r\n nickname: string;\r\n value: string;\r\n}\r\n\r\n/**\r\n * List of command message types\r\n */\r\nexport const ConversationTranslatorMessageTypes = {\r\n command: \"command\",\r\n final: \"final\",\r\n info: \"info\",\r\n instantMessage: \"instant_message\",\r\n partial: \"partial\",\r\n participantCommand: \"participant_command\",\r\n translatedMessage: \"translated_message\"\r\n};\r\n\r\n/**\r\n * List of command types\r\n */\r\nexport const ConversationTranslatorCommandTypes = {\r\n changeNickname: \"ChangeNickname\",\r\n disconnectSession: \"DisconnectSession\",\r\n ejectParticipant: \"EjectParticipant\",\r\n instant_message: \"instant_message\",\r\n joinSession: \"JoinSession\",\r\n leaveSession: \"LeaveSession\",\r\n participantList: \"ParticipantList\",\r\n roomExpirationWarning: \"RoomExpirationWarning\",\r\n setLockState: \"SetLockState\",\r\n setMute: \"SetMute\",\r\n setMuteAll: \"SetMuteAll\",\r\n setProfanityFiltering: \"SetProfanityFiltering\",\r\n setTranslateToLanguages: \"SetTranslateToLanguages\",\r\n setUseTTS: \"SetUseTTS\"\r\n};\r\n\r\n/**\r\n * HTTP response helper\r\n */\r\nexport interface IResponse {\r\n ok: boolean;\r\n status: number;\r\n statusText: string;\r\n data: string;\r\n json: () => T;\r\n headers: string;\r\n}\r\n","export { CommandResponsePayload } from \"./CommandResponsePayload\";\r\nexport { IParticipantsListPayloadResponse, IParticipantPayloadResponse, ParticipantsListPayloadResponse, ParticipantPayloadResponse } from \"./ParticipantResponsePayload\";\r\nexport { ITranslationResponsePayload, SpeechResponsePayload, TextResponsePayload } from \"./TranslationResponsePayload\";\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * Defines the payload for incoming websocket commands\r\n */\r\nexport interface ICommandResponsePayload {\r\n type: string;\r\n command?: string;\r\n id?: string; // incoming ws\r\n nickname?: string; // incoming ws\r\n participantId?: string;\r\n roomid?: string;\r\n value: boolean | number | string;\r\n}\r\n\r\nexport class CommandResponsePayload implements ICommandResponsePayload {\r\n private privCommandResponse: ICommandResponsePayload;\r\n\r\n public constructor(json: string) {\r\n this.privCommandResponse = JSON.parse(json);\r\n }\r\n\r\n public static fromJSON(json: string): CommandResponsePayload {\r\n return new CommandResponsePayload(json);\r\n }\r\n\r\n public get type(): string {\r\n return this.privCommandResponse.type;\r\n }\r\n public get command(): string {\r\n return this.privCommandResponse.command;\r\n }\r\n public get id(): string {\r\n return this.privCommandResponse.id;\r\n }\r\n public get nickname(): string {\r\n return this.privCommandResponse.nickname;\r\n }\r\n public get participantId(): string {\r\n return this.privCommandResponse.participantId;\r\n }\r\n public get roomid(): string {\r\n return this.privCommandResponse.roomid;\r\n }\r\n public get value(): boolean | number | string {\r\n return this.privCommandResponse.value;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * Defines the payload for incoming list of participants\r\n */\r\nexport interface IParticipantsListPayloadResponse {\r\n roomid: string;\r\n id: string;\r\n command: string;\r\n participants: IParticipantPayloadResponse[];\r\n token: string;\r\n translateTo: string[];\r\n profanityFilter: string;\r\n roomProfanityFilter: string;\r\n roomLocked: boolean;\r\n muteAll: boolean;\r\n type: string;\r\n}\r\n\r\n/**\r\n * Defines the payload for incoming participant\r\n */\r\nexport interface IParticipantPayloadResponse {\r\n nickname: string;\r\n locale: string;\r\n usetts: boolean;\r\n ismuted: boolean;\r\n ishost: boolean;\r\n participantId: string;\r\n avatar?: string;\r\n}\r\n\r\nexport class ParticipantsListPayloadResponse implements IParticipantsListPayloadResponse {\r\n private privParticipantsPayloadResponse: IParticipantsListPayloadResponse;\r\n\r\n private constructor(json: string) {\r\n this.privParticipantsPayloadResponse = JSON.parse(json);\r\n }\r\n\r\n public static fromJSON(json: string): ParticipantsListPayloadResponse {\r\n return new ParticipantsListPayloadResponse(json);\r\n }\r\n\r\n public get roomid(): string {\r\n return this.privParticipantsPayloadResponse.roomid;\r\n }\r\n\r\n public get id(): string {\r\n return this.privParticipantsPayloadResponse.id;\r\n }\r\n\r\n public get command(): string {\r\n return this.privParticipantsPayloadResponse.command;\r\n }\r\n\r\n public get participants(): IParticipantPayloadResponse[] {\r\n return this.privParticipantsPayloadResponse.participants;\r\n }\r\n\r\n public get token(): string {\r\n return this.privParticipantsPayloadResponse.token;\r\n }\r\n\r\n public get translateTo(): string[] {\r\n return this.privParticipantsPayloadResponse.translateTo;\r\n }\r\n\r\n public get profanityFilter(): string {\r\n return this.privParticipantsPayloadResponse.profanityFilter;\r\n }\r\n\r\n public get roomProfanityFilter(): string {\r\n return this.privParticipantsPayloadResponse.roomProfanityFilter;\r\n }\r\n\r\n public get roomLocked(): boolean {\r\n return this.privParticipantsPayloadResponse.roomLocked;\r\n }\r\n\r\n public get muteAll(): boolean {\r\n return this.privParticipantsPayloadResponse.muteAll;\r\n }\r\n\r\n public get type(): string {\r\n return this.privParticipantsPayloadResponse.type;\r\n }\r\n\r\n}\r\n\r\n// tslint:disable-next-line: max-classes-per-file\r\nexport class ParticipantPayloadResponse implements IParticipantPayloadResponse {\r\n\r\n private privParticipantPayloadResponse: IParticipantPayloadResponse;\r\n\r\n private constructor(json: string) {\r\n this.privParticipantPayloadResponse = JSON.parse(json);\r\n }\r\n\r\n public static fromJSON(json: string): ParticipantPayloadResponse {\r\n return new ParticipantPayloadResponse(json);\r\n }\r\n\r\n public get nickname(): string {\r\n return this.privParticipantPayloadResponse.nickname;\r\n }\r\n\r\n public get locale(): string {\r\n return this.privParticipantPayloadResponse.locale;\r\n }\r\n\r\n public get usetts(): boolean {\r\n return this.privParticipantPayloadResponse.usetts;\r\n }\r\n\r\n public get ismuted(): boolean {\r\n return this.privParticipantPayloadResponse.ismuted;\r\n }\r\n\r\n public get ishost(): boolean {\r\n return this.privParticipantPayloadResponse.ishost;\r\n }\r\n\r\n public get participantId(): string {\r\n return this.privParticipantPayloadResponse.participantId;\r\n }\r\n\r\n public get avatar(): string {\r\n return this.privParticipantPayloadResponse.avatar;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/**\r\n * Defines the payload for incoming translation messages\r\n */\r\nexport interface ITranslationResponsePayload {\r\n lang: string;\r\n translation: string;\r\n}\r\n\r\nexport interface ITranslationCommandMessage {\r\n translations: ITranslationResponsePayload[];\r\n id: string;\r\n language: string;\r\n nickname: string;\r\n participantId: string;\r\n roomid: string;\r\n timestamp: string;\r\n type: string;\r\n}\r\n\r\nexport interface ISpeechResponsePayload extends ITranslationCommandMessage {\r\n recognition: string;\r\n isFinal: boolean;\r\n}\r\n\r\nexport interface ITextResponsePayload extends ITranslationCommandMessage {\r\n originalText: string;\r\n}\r\n\r\nexport class SpeechResponsePayload implements ISpeechResponsePayload {\r\n\r\n private privSpeechResponse: ISpeechResponsePayload;\r\n\r\n private constructor(json: string) {\r\n this.privSpeechResponse = JSON.parse(json);\r\n }\r\n\r\n public static fromJSON(json: string): SpeechResponsePayload {\r\n return new SpeechResponsePayload(json);\r\n }\r\n\r\n public get recognition(): string {\r\n return this.privSpeechResponse.recognition;\r\n }\r\n\r\n public get translations(): ITranslationResponsePayload[] {\r\n return this.privSpeechResponse.translations;\r\n }\r\n\r\n public get id(): string {\r\n return this.privSpeechResponse.id;\r\n }\r\n\r\n public get language(): string {\r\n return this.privSpeechResponse.language;\r\n }\r\n\r\n public get nickname(): string {\r\n return this.privSpeechResponse.nickname;\r\n }\r\n\r\n public get participantId(): string {\r\n return this.privSpeechResponse.participantId;\r\n }\r\n\r\n public get roomid(): string {\r\n return this.privSpeechResponse.roomid;\r\n }\r\n\r\n public get timestamp(): string {\r\n return this.privSpeechResponse.timestamp;\r\n }\r\n\r\n public get type(): string {\r\n return this.privSpeechResponse.type;\r\n }\r\n\r\n public get isFinal(): boolean {\r\n return this.privSpeechResponse.type === \"final\";\r\n }\r\n}\r\n\r\n// tslint:disable-next-line: max-classes-per-file\r\nexport class TextResponsePayload implements ITextResponsePayload {\r\n\r\n private privTextResponse: ITextResponsePayload;\r\n\r\n private constructor(json: string) {\r\n this.privTextResponse = JSON.parse(json);\r\n }\r\n\r\n public static fromJSON(json: string): TextResponsePayload {\r\n return new TextResponsePayload(json);\r\n }\r\n\r\n public get originalText(): string {\r\n return this.privTextResponse.originalText;\r\n }\r\n\r\n public get translations(): ITranslationResponsePayload[] {\r\n return this.privTextResponse.translations;\r\n }\r\n\r\n public get id(): string {\r\n return this.privTextResponse.id;\r\n }\r\n\r\n public get language(): string {\r\n return this.privTextResponse.language;\r\n }\r\n\r\n public get nickname(): string {\r\n return this.privTextResponse.nickname;\r\n }\r\n\r\n public get participantId(): string {\r\n return this.privTextResponse.participantId;\r\n }\r\n\r\n public get roomid(): string {\r\n return this.privTextResponse.roomid;\r\n }\r\n\r\n public get timestamp(): string {\r\n return this.privTextResponse.timestamp;\r\n }\r\n\r\n public get type(): string {\r\n return this.privTextResponse.type;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nexport interface ISynthesisMetadata {\r\n Type: string;\r\n Data: {\r\n Offset: number;\r\n text: {\r\n Text: string;\r\n Length: number;\r\n };\r\n };\r\n}\r\n\r\n// audio.metadata\r\nexport interface ISynthesisAudioMetadata {\r\n Metadata: ISynthesisMetadata[];\r\n}\r\n\r\nexport class SynthesisAudioMetadata implements ISynthesisAudioMetadata {\r\n private privSynthesisAudioMetadata: ISynthesisAudioMetadata;\r\n\r\n private constructor(json: string) {\r\n this.privSynthesisAudioMetadata = JSON.parse(json);\r\n }\r\n\r\n public static fromJSON(json: string): SynthesisAudioMetadata {\r\n return new SynthesisAudioMetadata(json);\r\n }\r\n\r\n public get Metadata(): ISynthesisMetadata[] {\r\n return this.privSynthesisAudioMetadata.Metadata;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n createNoDashGuid,\r\n Deferred,\r\n Events, IAudioDestination,\r\n Promise,\r\n PromiseState\r\n} from \"../common/Exports\";\r\nimport { AudioOutputFormatImpl } from \"../sdk/Audio/AudioOutputFormat\";\r\nimport { PullAudioOutputStreamImpl } from \"../sdk/Audio/AudioOutputStream\";\r\nimport {SynthesisAdapterBase} from \"./SynthesisAdapterBase\";\r\nimport {\r\n ConnectingToSynthesisServiceEvent,\r\n SpeechSynthesisEvent,\r\n SynthesisStartedEvent,\r\n SynthesisTriggeredEvent,\r\n} from \"./SynthesisEvents\";\r\n\r\nexport interface ISynthesisResponseContext {\r\n serviceTag: string;\r\n}\r\n\r\nexport interface ISynthesisResponseAudio {\r\n type: string;\r\n streamId: string;\r\n}\r\n\r\nexport interface ISynthesisResponse {\r\n context: ISynthesisResponseContext;\r\n audio: ISynthesisResponseAudio;\r\n}\r\n\r\nexport class SynthesisTurn {\r\n\r\n public get requestId(): string {\r\n return this.privRequestId;\r\n }\r\n\r\n public get streamId(): string {\r\n return this.privStreamId;\r\n }\r\n\r\n public set streamId(value: string) {\r\n this.privStreamId = value;\r\n }\r\n\r\n public get audioOutputFormat(): AudioOutputFormatImpl {\r\n return this.privAudioOutputFormat;\r\n }\r\n\r\n public set audioOutputFormat(format: AudioOutputFormatImpl) {\r\n this.privAudioOutputFormat = format;\r\n }\r\n\r\n public get turnCompletionPromise(): Promise {\r\n return this.privTurnDeferral.promise();\r\n }\r\n\r\n public get isSynthesisEnded(): boolean {\r\n return this.privIsSynthesisEnded;\r\n }\r\n\r\n public get isSynthesizing(): boolean {\r\n return this.privIsSynthesizing;\r\n }\r\n\r\n public get currentTextOffset(): number {\r\n return this.privTextOffset;\r\n }\r\n\r\n // The number of bytes received for current turn\r\n public get bytesReceived(): number {\r\n return this.privBytesReceived;\r\n }\r\n\r\n public get allReceivedAudio(): ArrayBuffer {\r\n if (!!this.privReceivedAudio) {\r\n return this.privReceivedAudio;\r\n }\r\n if (!this.privIsSynthesisEnded) {\r\n return null;\r\n }\r\n this.readAllAudioFromStream();\r\n return this.allReceivedAudio;\r\n }\r\n\r\n public get allReceivedAudioWithHeader(): ArrayBuffer {\r\n if (!!this.privReceivedAudioWithHeader) {\r\n return this.privReceivedAudioWithHeader;\r\n }\r\n if (!this.privIsSynthesisEnded) {\r\n return null;\r\n }\r\n if (this.audioOutputFormat.hasHeader) {\r\n this.privReceivedAudioWithHeader = SynthesisAdapterBase.addHeader(this.allReceivedAudio, this.audioOutputFormat);\r\n return this.allReceivedAudioWithHeader;\r\n } else {\r\n return this.allReceivedAudio;\r\n }\r\n }\r\n private privIsDisposed: boolean = false;\r\n private privAuthFetchEventId: string;\r\n private privIsSynthesizing: boolean = false;\r\n private privIsSynthesisEnded: boolean = false;\r\n private privBytesReceived: number = 0;\r\n private privRequestId: string;\r\n private privStreamId: string;\r\n private privTurnDeferral: Deferred;\r\n private privAudioOutputFormat: AudioOutputFormatImpl;\r\n private privAudioOutputStream: PullAudioOutputStreamImpl;\r\n private privReceivedAudio: ArrayBuffer;\r\n private privReceivedAudioWithHeader: ArrayBuffer;\r\n private privTextOffset: number = 0;\r\n private privNextSearchTextIndex: number = 0;\r\n private privRawText: string;\r\n private privIsSSML: boolean;\r\n private privTurnAudioDestination: IAudioDestination;\r\n\r\n constructor() {\r\n this.privRequestId = createNoDashGuid();\r\n this.privTurnDeferral = new Deferred();\r\n\r\n // We're not in a turn, so resolve.\r\n this.privTurnDeferral.resolve(true);\r\n }\r\n\r\n public startNewSynthesis(requestId: string, rawText: string, isSSML: boolean, audioDestination?: IAudioDestination): void {\r\n this.privIsSynthesisEnded = false;\r\n this.privIsSynthesizing = true;\r\n this.privRequestId = requestId;\r\n this.privRawText = rawText;\r\n this.privIsSSML = isSSML;\r\n this.privAudioOutputStream = new PullAudioOutputStreamImpl();\r\n this.privAudioOutputStream.format = this.privAudioOutputFormat;\r\n this.privReceivedAudio = null;\r\n this.privReceivedAudioWithHeader = null;\r\n this.privBytesReceived = 0;\r\n this.privTextOffset = 0;\r\n this.privNextSearchTextIndex = 0;\r\n if (audioDestination !== undefined) {\r\n this.privTurnAudioDestination = audioDestination;\r\n this.privTurnAudioDestination.format = this.privAudioOutputFormat;\r\n }\r\n this.onEvent(new SynthesisTriggeredEvent(this.requestId, undefined, audioDestination === undefined ? undefined : audioDestination.id()));\r\n }\r\n\r\n public onPreConnectionStart = (authFetchEventId: string, connectionId: string): void => {\r\n this.privAuthFetchEventId = authFetchEventId;\r\n this.onEvent(new ConnectingToSynthesisServiceEvent(this.privRequestId, this.privAuthFetchEventId));\r\n }\r\n\r\n public onAuthCompleted = (isError: boolean, error?: string): void => {\r\n if (isError) {\r\n this.onComplete();\r\n }\r\n }\r\n\r\n public onConnectionEstablishCompleted = (statusCode: number, reason?: string): void => {\r\n if (statusCode === 200) {\r\n this.onEvent(new SynthesisStartedEvent(this.requestId, this.privAuthFetchEventId));\r\n this.privBytesReceived = 0;\r\n return;\r\n } else if (statusCode === 403) {\r\n this.onComplete();\r\n }\r\n }\r\n\r\n public onServiceResponseMessage = (responseJson: string): void => {\r\n const response: ISynthesisResponse = JSON.parse(responseJson);\r\n this.streamId = response.audio.streamId;\r\n }\r\n\r\n public onServiceTurnEndResponse = (): void => {\r\n this.privTurnDeferral.resolve(true);\r\n this.onComplete();\r\n }\r\n\r\n public onServiceTurnStartResponse = (): void => {\r\n if (this.privTurnDeferral.state() === PromiseState.None) {\r\n // What? How are we starting a turn with another not done?\r\n this.privTurnDeferral.reject(\"Another turn started before current completed.\");\r\n }\r\n\r\n this.privTurnDeferral = new Deferred();\r\n }\r\n\r\n public onAudioChunkReceived(data: ArrayBuffer): void {\r\n if (this.isSynthesizing) {\r\n this.privAudioOutputStream.write(data);\r\n this.privBytesReceived += data.byteLength;\r\n if (this.privTurnAudioDestination !== undefined) {\r\n this.privTurnAudioDestination.write(data);\r\n }\r\n }\r\n }\r\n\r\n public onWordBoundaryEvent(text: string): void {\r\n this.updateTextOffset(text);\r\n }\r\n\r\n public dispose = (error?: string): void => {\r\n if (!this.privIsDisposed) {\r\n // we should have completed by now. If we did not its an unknown error.\r\n this.privIsDisposed = true;\r\n }\r\n }\r\n\r\n public onStopSynthesizing(): void {\r\n this.onComplete();\r\n }\r\n\r\n protected onEvent = (event: SpeechSynthesisEvent): void => {\r\n Events.instance.onEvent(event);\r\n }\r\n\r\n private updateTextOffset(text: string): void {\r\n if (this.privTextOffset >= 0) {\r\n this.privTextOffset = this.privRawText.indexOf(text, this.privNextSearchTextIndex);\r\n if (this.privTextOffset >= 0) {\r\n this.privNextSearchTextIndex = this.privTextOffset + text.length;\r\n }\r\n if (this.privIsSSML) {\r\n if (this.privRawText.indexOf(\"<\", this.privTextOffset + 1) > this.privRawText.indexOf(\">\", this.privTextOffset + 1)) {\r\n this.updateTextOffset(text);\r\n }\r\n }\r\n }\r\n }\r\n\r\n private onComplete = (): void => {\r\n if (this.privIsSynthesizing) {\r\n this.privIsSynthesizing = false;\r\n this.privIsSynthesisEnded = true;\r\n this.privAudioOutputStream.close();\r\n if (this.privTurnAudioDestination !== undefined) {\r\n this.privTurnAudioDestination.close();\r\n this.privTurnAudioDestination = undefined;\r\n }\r\n }\r\n }\r\n\r\n private readAllAudioFromStream(): void {\r\n if (this.privIsSynthesisEnded) {\r\n this.privReceivedAudio = new ArrayBuffer(this.bytesReceived);\r\n try {\r\n this.privAudioOutputStream.read(this.privReceivedAudio);\r\n } catch (e) {\r\n this.privReceivedAudio = new ArrayBuffer(0);\r\n }\r\n }\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n ArgumentNullError,\r\n ConnectionClosedEvent,\r\n ConnectionEvent,\r\n ConnectionMessage,\r\n ConnectionOpenResponse,\r\n ConnectionState,\r\n createNoDashGuid,\r\n EventSource,\r\n IAudioDestination,\r\n IConnection,\r\n IDisposable,\r\n MessageType,\r\n Promise,\r\n PromiseHelper,\r\n PromiseResult,\r\n ServiceEvent,\r\n} from \"../common/Exports\";\r\nimport { AudioOutputFormatImpl } from \"../sdk/Audio/AudioOutputFormat\";\r\nimport {\r\n CancellationErrorCode,\r\n CancellationReason,\r\n PropertyCollection,\r\n PropertyId,\r\n ResultReason,\r\n SpeechSynthesisEventArgs,\r\n SpeechSynthesisResult,\r\n SpeechSynthesisWordBoundaryEventArgs,\r\n SpeechSynthesizer,\r\n} from \"../sdk/Exports\";\r\nimport { Callback } from \"../sdk/Transcription/IConversation\";\r\nimport {\r\n AgentConfig,\r\n CancellationErrorCodePropertyName,\r\n ISynthesisConnectionFactory,\r\n SynthesisAudioMetadata,\r\n SynthesisContext,\r\n SynthesisTurn,\r\n SynthesizerConfig\r\n} from \"./Exports\";\r\nimport { AuthInfo, IAuthentication } from \"./IAuthentication\";\r\nimport { SpeechConnectionMessage } from \"./SpeechConnectionMessage.Internal\";\r\n\r\nexport class SynthesisAdapterBase implements IDisposable {\r\n protected privSynthesisTurn: SynthesisTurn;\r\n protected privConnectionId: string;\r\n protected privSynthesizerConfig: SynthesizerConfig;\r\n protected privSpeechSynthesizer: SpeechSynthesizer;\r\n protected privSuccessCallback: (e: SpeechSynthesisResult) => void;\r\n protected privErrorCallback: (e: string) => void;\r\n\r\n public get synthesisContext(): SynthesisContext {\r\n return this.privSynthesisContext;\r\n }\r\n\r\n public get agentConfig(): AgentConfig {\r\n return this.privAgentConfig;\r\n }\r\n\r\n public get connectionEvents(): EventSource {\r\n return this.privConnectionEvents;\r\n }\r\n\r\n public get serviceEvents(): EventSource {\r\n return this.privServiceEvents;\r\n }\r\n\r\n protected speakOverride: (ssml: string, requestId: string, sc: (e: SpeechSynthesisResult) => void, ec: (e: string) => void) => any = undefined;\r\n\r\n // Called when telemetry data is sent to the service.\r\n // Used for testing Telemetry capture.\r\n public static telemetryData: (json: string) => void;\r\n public static telemetryDataEnabled: boolean = true;\r\n\r\n public set activityTemplate(messagePayload: string) { this.privActivityTemplate = messagePayload; }\r\n public get activityTemplate(): string { return this.privActivityTemplate; }\r\n\r\n protected receiveMessageOverride: () => any = undefined;\r\n\r\n protected connectImplOverride: (isUnAuthorized: boolean) => any = undefined;\r\n\r\n protected configConnectionOverride: () => any = undefined;\r\n\r\n protected fetchConnectionOverride: () => any = undefined;\r\n\r\n public set audioOutputFormat(format: AudioOutputFormatImpl) {\r\n this.privAudioOutputFormat = format;\r\n this.privSynthesisTurn.audioOutputFormat = format;\r\n if (this.privSessionAudioDestination !== undefined) {\r\n this.privSessionAudioDestination.format = format;\r\n }\r\n if (this.synthesisContext !== undefined) {\r\n this.synthesisContext.audioOutputFormat = format;\r\n }\r\n }\r\n private privAuthentication: IAuthentication;\r\n private privConnectionFactory: ISynthesisConnectionFactory;\r\n\r\n // A promise for a configured connection.\r\n // Do not consume directly, call fetchConnection instead.\r\n private privConnectionConfigurationPromise: Promise;\r\n\r\n // A promise for a connection, but one that has not had the speech context sent yet.\r\n // Do not consume directly, call fetchConnection instead.\r\n private privConnectionPromise: Promise;\r\n private privAuthFetchEventId: string;\r\n private privIsDisposed: boolean;\r\n private privConnectionEvents: EventSource;\r\n private privServiceEvents: EventSource;\r\n private privSynthesisContext: SynthesisContext;\r\n private privAgentConfig: AgentConfig;\r\n private privServiceHasSentMessage: boolean;\r\n private privActivityTemplate: string;\r\n private privAudioOutputFormat: AudioOutputFormatImpl;\r\n private privSessionAudioDestination: IAudioDestination;\r\n\r\n public constructor(\r\n authentication: IAuthentication,\r\n connectionFactory: ISynthesisConnectionFactory,\r\n synthesizerConfig: SynthesizerConfig,\r\n speechSynthesizer: SpeechSynthesizer,\r\n audioDestination: IAudioDestination) {\r\n\r\n if (!authentication) {\r\n throw new ArgumentNullError(\"authentication\");\r\n }\r\n\r\n if (!connectionFactory) {\r\n throw new ArgumentNullError(\"connectionFactory\");\r\n }\r\n\r\n if (!synthesizerConfig) {\r\n throw new ArgumentNullError(\"synthesizerConfig\");\r\n }\r\n\r\n this.privAuthentication = authentication;\r\n this.privConnectionFactory = connectionFactory;\r\n this.privSynthesizerConfig = synthesizerConfig;\r\n this.privIsDisposed = false;\r\n this.privSpeechSynthesizer = speechSynthesizer;\r\n this.privSessionAudioDestination = audioDestination;\r\n this.privSynthesisTurn = new SynthesisTurn();\r\n this.privConnectionEvents = new EventSource();\r\n this.privServiceEvents = new EventSource();\r\n this.privSynthesisContext = new SynthesisContext(this.privSpeechSynthesizer);\r\n this.privAgentConfig = new AgentConfig();\r\n\r\n this.connectionEvents.attach((connectionEvent: ConnectionEvent): void => {\r\n if (connectionEvent.name === \"ConnectionClosedEvent\") {\r\n const connectionClosedEvent = connectionEvent as ConnectionClosedEvent;\r\n this.cancelSynthesisLocal(CancellationReason.Error,\r\n connectionClosedEvent.statusCode === 1007 ? CancellationErrorCode.BadRequestParameters : CancellationErrorCode.ConnectionFailure,\r\n connectionClosedEvent.reason + \" websocket error code: \" + connectionClosedEvent.statusCode);\r\n }\r\n });\r\n }\r\n\r\n public static addHeader(audio: ArrayBuffer, format: AudioOutputFormatImpl): ArrayBuffer {\r\n if (!format.hasHeader) {\r\n return audio;\r\n }\r\n format.updateHeader(audio.byteLength);\r\n const tmp = new Uint8Array(audio.byteLength + format.header.byteLength);\r\n tmp.set(new Uint8Array(format.header), 0);\r\n tmp.set(new Uint8Array(audio), format.header.byteLength);\r\n return tmp.buffer;\r\n }\r\n\r\n public isDisposed(): boolean {\r\n return this.privIsDisposed;\r\n }\r\n\r\n public dispose(reason?: string): void {\r\n this.privIsDisposed = true;\r\n if (this.privSessionAudioDestination !== undefined) {\r\n this.privSessionAudioDestination.close();\r\n }\r\n if (this.privConnectionConfigurationPromise) {\r\n this.privConnectionConfigurationPromise.onSuccessContinueWith((connection: IConnection) => {\r\n connection.dispose(reason);\r\n });\r\n }\r\n }\r\n\r\n public connect(): void {\r\n this.connectImpl().result();\r\n }\r\n\r\n public connectAsync(cb?: Callback, err?: Callback): void {\r\n this.connectImpl().continueWith((promiseResult: PromiseResult) => {\r\n try {\r\n if (promiseResult.isError) {\r\n if (!!err) {\r\n err(promiseResult.error);\r\n }\r\n } else if (promiseResult.isCompleted) {\r\n if (!!cb) {\r\n cb();\r\n }\r\n }\r\n } catch (e) {\r\n if (!!err) {\r\n err(e);\r\n }\r\n }\r\n });\r\n }\r\n\r\n public sendNetworkMessage(path: string, payload: string | ArrayBuffer, success?: () => void, err?: (error: string) => void): void {\r\n const type: MessageType = typeof payload === \"string\" ? MessageType.Text : MessageType.Binary;\r\n const contentType: string = typeof payload === \"string\" ? \"application/json\" : \"\";\r\n\r\n this.fetchConnection().on((connection: IConnection) => {\r\n connection.send(new SpeechConnectionMessage(type, path, this.privSynthesisTurn.requestId, contentType, payload)).on(() => {\r\n if (!!success) {\r\n success();\r\n }\r\n }, (error: string) => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n }, (error: string) => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n }\r\n\r\n public Speak(\r\n text: string,\r\n isSSML: boolean,\r\n requestId: string,\r\n successCallback: (e: SpeechSynthesisResult) => void,\r\n errorCallBack: (e: string) => void,\r\n audioDestination: IAudioDestination,\r\n ): Promise {\r\n\r\n let ssml: string;\r\n\r\n if (isSSML) {\r\n ssml = text;\r\n } else {\r\n ssml = this.privSpeechSynthesizer.buildSsml(text);\r\n }\r\n\r\n if (this.speakOverride !== undefined) {\r\n return this.speakOverride(ssml, requestId, successCallback, errorCallBack);\r\n }\r\n\r\n this.privSuccessCallback = successCallback;\r\n this.privErrorCallback = errorCallBack;\r\n\r\n this.privSynthesisTurn.startNewSynthesis(requestId, text, isSSML, audioDestination);\r\n\r\n return this.fetchConnection().continueWithPromise((connection: PromiseResult) => {\r\n if (connection.isError) {\r\n this.cancelSynthesisLocal(CancellationReason.Error, CancellationErrorCode.ConnectionFailure, connection.error);\r\n return PromiseHelper.fromError(connection.error);\r\n }\r\n return this.sendSynthesisContext(connection.result).continueWithPromise((result: PromiseResult): Promise => {\r\n if (result.isError) {\r\n this.cancelSynthesisLocal(CancellationReason.Error, CancellationErrorCode.ConnectionFailure, result.error);\r\n return PromiseHelper.fromError(result.error);\r\n }\r\n return this.sendSsmlMessage(connection.result, ssml, requestId).continueWithPromise((result: PromiseResult): Promise => {\r\n if (result.isError) {\r\n this.cancelSynthesisLocal(CancellationReason.Error, CancellationErrorCode.ConnectionFailure, result.error);\r\n return PromiseHelper.fromError(result.error);\r\n }\r\n\r\n const synthesisStartEventArgs: SpeechSynthesisEventArgs = new SpeechSynthesisEventArgs(\r\n new SpeechSynthesisResult(\r\n requestId,\r\n ResultReason.SynthesizingAudioStarted,\r\n )\r\n );\r\n\r\n if (!!this.privSpeechSynthesizer.synthesisStarted) {\r\n this.privSpeechSynthesizer.synthesisStarted(this.privSpeechSynthesizer, synthesisStartEventArgs);\r\n }\r\n\r\n const messageRetrievalPromise = this.receiveMessage();\r\n return PromiseHelper.fromResult(true);\r\n });\r\n });\r\n });\r\n }\r\n\r\n // Cancels synthesis.\r\n protected cancelSynthesis(\r\n requestId: string,\r\n cancellationReason: CancellationReason,\r\n errorCode: CancellationErrorCode,\r\n error: string): void {\r\n const properties: PropertyCollection = new PropertyCollection();\r\n properties.setProperty(CancellationErrorCodePropertyName, CancellationErrorCode[errorCode]);\r\n const result: SpeechSynthesisResult = new SpeechSynthesisResult(\r\n requestId,\r\n ResultReason.Canceled,\r\n undefined,\r\n error,\r\n properties\r\n );\r\n\r\n if (!!this.privSpeechSynthesizer.SynthesisCanceled) {\r\n const cancelEvent: SpeechSynthesisEventArgs = new SpeechSynthesisEventArgs(result);\r\n try {\r\n this.privSpeechSynthesizer.SynthesisCanceled(this.privSpeechSynthesizer, cancelEvent);\r\n /* tslint:disable:no-empty */\r\n } catch { }\r\n }\r\n\r\n if (!!this.privSuccessCallback) {\r\n try {\r\n this.privSuccessCallback(result);\r\n /* tslint:disable:no-empty */\r\n } catch { }\r\n }\r\n }\r\n\r\n // Cancels synthesis.\r\n protected cancelSynthesisLocal(\r\n cancellationReason: CancellationReason,\r\n errorCode: CancellationErrorCode,\r\n error: string): void {\r\n\r\n if (!!this.privSynthesisTurn.isSynthesizing) {\r\n this.privSynthesisTurn.onStopSynthesizing();\r\n\r\n this.cancelSynthesis(\r\n this.privSynthesisTurn.requestId,\r\n cancellationReason,\r\n errorCode,\r\n error);\r\n }\r\n }\r\n\r\n protected processTypeSpecificMessages(\r\n connectionMessage: SpeechConnectionMessage,\r\n successCallback?: (e: SpeechSynthesisResult) => void,\r\n errorCallBack?: (e: string) => void): boolean {\r\n return true;\r\n }\r\n\r\n protected receiveMessage = (): Promise => {\r\n return this.fetchConnection().on((connection: IConnection): Promise => {\r\n return connection.read()\r\n .onSuccessContinueWithPromise((message: ConnectionMessage) => {\r\n\r\n if (this.receiveMessageOverride !== undefined) {\r\n return this.receiveMessageOverride();\r\n }\r\n if (this.privIsDisposed) {\r\n // We're done.\r\n return PromiseHelper.fromResult(undefined);\r\n }\r\n\r\n // indicates we are draining the queue and it came with no message;\r\n if (!message) {\r\n if (!this.privSynthesisTurn.isSynthesizing) {\r\n return PromiseHelper.fromResult(true);\r\n } else {\r\n return this.receiveMessage();\r\n }\r\n }\r\n\r\n this.privServiceHasSentMessage = true;\r\n\r\n const connectionMessage = SpeechConnectionMessage.fromConnectionMessage(message);\r\n\r\n if (connectionMessage.requestId.toLowerCase() === this.privSynthesisTurn.requestId.toLowerCase()) {\r\n switch (connectionMessage.path.toLowerCase()) {\r\n case \"turn.start\":\r\n this.privSynthesisTurn.onServiceTurnStartResponse();\r\n break;\r\n case \"response\":\r\n this.privSynthesisTurn.onServiceResponseMessage(connectionMessage.textBody);\r\n break;\r\n case \"audio\":\r\n if (this.privSynthesisTurn.streamId.toLowerCase() === connectionMessage.streamId.toLowerCase()\r\n && !!connectionMessage.binaryBody) {\r\n this.privSynthesisTurn.onAudioChunkReceived(connectionMessage.binaryBody);\r\n if (!!this.privSpeechSynthesizer.synthesizing) {\r\n try {\r\n const audioWithHeader = SynthesisAdapterBase.addHeader(connectionMessage.binaryBody, this.privSynthesisTurn.audioOutputFormat);\r\n const ev: SpeechSynthesisEventArgs = new SpeechSynthesisEventArgs(\r\n new SpeechSynthesisResult(\r\n this.privSynthesisTurn.requestId,\r\n ResultReason.SynthesizingAudio,\r\n audioWithHeader));\r\n this.privSpeechSynthesizer.synthesizing(this.privSpeechSynthesizer, ev);\r\n } catch (error) {\r\n // Not going to let errors in the event handler\r\n // trip things up.\r\n }\r\n }\r\n if (this.privSessionAudioDestination !== undefined) {\r\n this.privSessionAudioDestination.write(connectionMessage.binaryBody);\r\n }\r\n }\r\n break;\r\n case \"audio.metadata\":\r\n const metadataList = SynthesisAudioMetadata.fromJSON(connectionMessage.textBody).Metadata;\r\n for (const metadata of metadataList) {\r\n if (metadata.Type.toLowerCase() === \"WordBoundary\".toLowerCase()) {\r\n\r\n this.privSynthesisTurn.onWordBoundaryEvent(metadata.Data.text.Text);\r\n\r\n const ev: SpeechSynthesisWordBoundaryEventArgs = new SpeechSynthesisWordBoundaryEventArgs(\r\n metadata.Data.Offset,\r\n metadata.Data.text.Text,\r\n metadata.Data.text.Length,\r\n this.privSynthesisTurn.currentTextOffset);\r\n\r\n if (!!this.privSpeechSynthesizer.wordBoundary) {\r\n try {\r\n this.privSpeechSynthesizer.wordBoundary(this.privSpeechSynthesizer, ev);\r\n } catch (error) {\r\n // Not going to let errors in the event handler\r\n // trip things up.\r\n }\r\n }\r\n }\r\n }\r\n break;\r\n case \"turn.end\":\r\n this.privSynthesisTurn.onServiceTurnEndResponse();\r\n let result: SpeechSynthesisResult;\r\n try {\r\n result = new SpeechSynthesisResult(\r\n this.privSynthesisTurn.requestId,\r\n ResultReason.SynthesizingAudioCompleted,\r\n this.privSynthesisTurn.allReceivedAudioWithHeader\r\n );\r\n if (!!this.privSuccessCallback) {\r\n this.privSuccessCallback(result);\r\n }\r\n } catch (error) {\r\n if (!!this.privErrorCallback) {\r\n this.privErrorCallback(error);\r\n }\r\n }\r\n if (this.privSpeechSynthesizer.synthesisCompleted) {\r\n try {\r\n this.privSpeechSynthesizer.synthesisCompleted(\r\n this.privSpeechSynthesizer,\r\n new SpeechSynthesisEventArgs(result)\r\n );\r\n } catch (e) {\r\n // Not going to let errors in the event handler\r\n // trip things up.\r\n }\r\n }\r\n break;\r\n\r\n default:\r\n\r\n if (!this.processTypeSpecificMessages(connectionMessage)) {\r\n // here are some messages that the derived class has not processed, dispatch them to connect class\r\n if (!!this.privServiceEvents) {\r\n this.serviceEvents.onEvent(new ServiceEvent(connectionMessage.path.toLowerCase(), connectionMessage.textBody));\r\n }\r\n }\r\n\r\n }\r\n }\r\n\r\n return this.receiveMessage();\r\n });\r\n }, (error: string) => {\r\n });\r\n }\r\n\r\n protected sendSynthesisContext = (connection: IConnection): Promise => {\r\n const synthesisContextJson = this.synthesisContext.toJSON();\r\n\r\n if (synthesisContextJson) {\r\n return connection.send(new SpeechConnectionMessage(\r\n MessageType.Text,\r\n \"synthesis.context\",\r\n this.privSynthesisTurn.requestId,\r\n \"application/json\",\r\n synthesisContextJson));\r\n }\r\n return PromiseHelper.fromResult(true);\r\n }\r\n\r\n // Establishes a websocket connection to the end point.\r\n protected connectImpl(isUnAuthorized: boolean = false): Promise {\r\n\r\n if (this.connectImplOverride !== undefined) {\r\n return this.connectImplOverride(isUnAuthorized);\r\n }\r\n\r\n if (this.privConnectionPromise) {\r\n if (this.privConnectionPromise.result().isCompleted &&\r\n (this.privConnectionPromise.result().isError\r\n || this.privConnectionPromise.result().result.state() === ConnectionState.Disconnected) &&\r\n this.privServiceHasSentMessage === true) {\r\n this.privConnectionId = null;\r\n this.privConnectionPromise = null;\r\n this.privServiceHasSentMessage = false;\r\n return this.connectImpl();\r\n } else {\r\n return this.privConnectionPromise;\r\n }\r\n }\r\n\r\n this.privAuthFetchEventId = createNoDashGuid();\r\n this.privConnectionId = createNoDashGuid();\r\n\r\n this.privSynthesisTurn.onPreConnectionStart(this.privAuthFetchEventId, this.privConnectionId);\r\n\r\n const authPromise = isUnAuthorized ? this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId) : this.privAuthentication.fetch(this.privAuthFetchEventId);\r\n\r\n this.privConnectionPromise = authPromise\r\n .continueWithPromise((result: PromiseResult) => {\r\n if (result.isError) {\r\n this.privSynthesisTurn.onAuthCompleted(true, result.error);\r\n throw new Error(result.error);\r\n } else {\r\n this.privSynthesisTurn.onAuthCompleted(false);\r\n }\r\n\r\n const connection: IConnection = this.privConnectionFactory.create(this.privSynthesizerConfig, result.result, this.privConnectionId);\r\n\r\n // Attach to the underlying event. No need to hold onto the detach pointers as in the event the connection goes away,\r\n // it'll stop sending events.\r\n connection.events.attach((event: ConnectionEvent) => {\r\n this.connectionEvents.onEvent(event);\r\n });\r\n\r\n return connection.open().onSuccessContinueWithPromise((response: ConnectionOpenResponse): Promise => {\r\n if (response.statusCode === 200) {\r\n this.privSynthesisTurn.onPreConnectionStart(this.privAuthFetchEventId, this.privConnectionId);\r\n this.privSynthesisTurn.onConnectionEstablishCompleted(response.statusCode);\r\n\r\n return PromiseHelper.fromResult(connection);\r\n } else if (response.statusCode === 403 && !isUnAuthorized) {\r\n return this.connectImpl(true);\r\n } else {\r\n this.privSynthesisTurn.onConnectionEstablishCompleted(response.statusCode, response.reason);\r\n return PromiseHelper.fromError(`Unable to contact server. StatusCode: ${response.statusCode}, ${this.privSynthesizerConfig.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint)} Reason: ${response.reason}`);\r\n }\r\n });\r\n });\r\n\r\n return this.privConnectionPromise;\r\n }\r\n\r\n protected sendSpeechServiceConfig = (connection: IConnection, SpeechServiceConfigJson: string): Promise => {\r\n\r\n if (SpeechServiceConfigJson) {\r\n return connection.send(new SpeechConnectionMessage(\r\n MessageType.Text,\r\n \"speech.config\",\r\n this.privSynthesisTurn.requestId,\r\n \"application/json\",\r\n SpeechServiceConfigJson));\r\n }\r\n\r\n return PromiseHelper.fromResult(true);\r\n }\r\n\r\n protected sendSsmlMessage = (connection: IConnection, ssml: string, requestId: string): Promise => {\r\n return connection.send(new SpeechConnectionMessage(\r\n MessageType.Text,\r\n \"ssml\",\r\n requestId,\r\n \"application/ssml+xml\",\r\n ssml));\r\n }\r\n\r\n private fetchConnection = (): Promise => {\r\n if (this.fetchConnectionOverride !== undefined) {\r\n return this.fetchConnectionOverride();\r\n }\r\n\r\n return this.configureConnection();\r\n }\r\n\r\n // Takes an established websocket connection to the endpoint and sends speech configuration information.\r\n private configureConnection(): Promise {\r\n if (this.configConnectionOverride !== undefined) {\r\n return this.configConnectionOverride();\r\n }\r\n\r\n if (this.privConnectionConfigurationPromise) {\r\n if (this.privConnectionConfigurationPromise.result().isCompleted &&\r\n (this.privConnectionConfigurationPromise.result().isError\r\n || this.privConnectionConfigurationPromise.result().result.state() === ConnectionState.Disconnected)) {\r\n\r\n this.privConnectionConfigurationPromise = null;\r\n return this.configureConnection();\r\n } else {\r\n return this.privConnectionConfigurationPromise;\r\n }\r\n }\r\n\r\n this.privConnectionConfigurationPromise = this.connectImpl().onSuccessContinueWithPromise((connection: IConnection): Promise => {\r\n return this.sendSpeechServiceConfig(connection, this.privSynthesizerConfig.SpeechServiceConfig.serialize())\r\n .onSuccessContinueWith((_: boolean) => {\r\n return connection;\r\n });\r\n });\r\n\r\n return this.privConnectionConfigurationPromise;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { EventType, PlatformEvent } from \"../common/Exports\";\r\n\r\nexport class SpeechSynthesisEvent extends PlatformEvent {\r\n private privRequestId: string;\r\n\r\n constructor(eventName: string, requestId: string, eventType: EventType = EventType.Info) {\r\n super(eventName, eventType);\r\n\r\n this.privRequestId = requestId;\r\n }\r\n\r\n public get requestId(): string {\r\n return this.privRequestId;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class SynthesisTriggeredEvent extends SpeechSynthesisEvent {\r\n private privSessionAudioDestinationId: string;\r\n private privTurnAudioDestinationId: string;\r\n\r\n constructor(requestId: string, sessionAudioDestinationId: string, turnAudioDestinationId: string) {\r\n super(\"SynthesisTriggeredEvent\", requestId);\r\n\r\n this.privSessionAudioDestinationId = sessionAudioDestinationId;\r\n this.privTurnAudioDestinationId = turnAudioDestinationId;\r\n }\r\n\r\n public get audioSessionDestinationId(): string {\r\n return this.privSessionAudioDestinationId;\r\n }\r\n\r\n public get audioTurnDestinationId(): string {\r\n return this.privTurnAudioDestinationId;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class ConnectingToSynthesisServiceEvent extends SpeechSynthesisEvent {\r\n private privAuthFetchEventId: string;\r\n\r\n constructor(requestId: string, authFetchEventId: string) {\r\n super(\"ConnectingToSynthesisServiceEvent\", requestId);\r\n this.privAuthFetchEventId = authFetchEventId;\r\n }\r\n\r\n public get authFetchEventId(): string {\r\n return this.privAuthFetchEventId;\r\n }\r\n}\r\n\r\n// tslint:disable-next-line:max-classes-per-file\r\nexport class SynthesisStartedEvent extends SpeechSynthesisEvent {\r\n private privAuthFetchEventId: string;\r\n\r\n constructor(requestId: string, authFetchEventId: string) {\r\n super(\"SynthesisStartedEvent\", requestId);\r\n\r\n this.privAuthFetchEventId = authFetchEventId;\r\n }\r\n\r\n public get authFetchEventId(): string {\r\n return this.privAuthFetchEventId;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { PropertyCollection } from \"../sdk/Exports\";\r\nimport {Context, SpeechServiceConfig} from \"./Exports\";\r\n\r\nexport enum SynthesisServiceType {\r\n Standard,\r\n Custom,\r\n}\r\n\r\nexport class SynthesizerConfig {\r\n private privSynthesisServiceType: SynthesisServiceType = SynthesisServiceType.Standard;\r\n private privSpeechServiceConfig: SpeechServiceConfig;\r\n private privParameters: PropertyCollection;\r\n\r\n constructor(\r\n speechServiceConfig: SpeechServiceConfig,\r\n parameters: PropertyCollection) {\r\n this.privSpeechServiceConfig = speechServiceConfig ? speechServiceConfig : new SpeechServiceConfig(new Context(null));\r\n this.privParameters = parameters;\r\n }\r\n\r\n public get parameters(): PropertyCollection {\r\n return this.privParameters;\r\n }\r\n\r\n public get synthesisServiceType(): SynthesisServiceType {\r\n return this.privSynthesisServiceType;\r\n }\r\n\r\n public set synthesisServiceType(value: SynthesisServiceType) {\r\n this.privSynthesisServiceType = value;\r\n }\r\n\r\n public get SpeechServiceConfig(): SpeechServiceConfig {\r\n return this.privSpeechServiceConfig;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { AudioOutputFormatImpl } from \"../sdk/Audio/AudioOutputFormat\";\r\nimport { PropertyId, SpeechSynthesizer } from \"../sdk/Exports\";\r\n\r\n/**\r\n * Represents the JSON used in the synthesis.context message sent to the speech service.\r\n * The dynamic grammar is always refreshed from the encapsulated dynamic grammar object.\r\n */\r\nexport class SynthesisContext {\r\n private privContext: { [section: string]: any } = {};\r\n private privSpeechSynthesizer: SpeechSynthesizer;\r\n private privAudioOutputFormat: AudioOutputFormatImpl;\r\n\r\n constructor(speechSynthesizer: SpeechSynthesizer) {\r\n this.privSpeechSynthesizer = speechSynthesizer;\r\n }\r\n\r\n /**\r\n * Adds a section to the synthesis.context object.\r\n * @param sectionName Name of the section to add.\r\n * @param value JSON serializable object that represents the value.\r\n */\r\n public setSection(sectionName: string, value: any): void {\r\n this.privContext[sectionName] = value;\r\n }\r\n\r\n /**\r\n * Sets the audio output format for synthesis context generation.\r\n * @param format {AudioOutputFormatImpl} the output format\r\n */\r\n public set audioOutputFormat(format: AudioOutputFormatImpl) {\r\n this.privAudioOutputFormat = format;\r\n }\r\n\r\n public toJSON(): string {\r\n\r\n const synthesisSection: ISynthesisSection = this.buildSynthesisContext();\r\n this.setSection(\"synthesis\", synthesisSection);\r\n\r\n return JSON.stringify(this.privContext);\r\n }\r\n\r\n private buildSynthesisContext(): ISynthesisSection {\r\n return {\r\n audio: {\r\n metadataOptions: {\r\n sentenceBoundaryEnabled: false,\r\n wordBoundaryEnabled: (!!this.privSpeechSynthesizer.wordBoundary),\r\n },\r\n outputFormat: this.privAudioOutputFormat.requestAudioFormatString,\r\n },\r\n language: {\r\n autoDetection: this.privSpeechSynthesizer.autoDetectSourceLanguage\r\n }\r\n };\r\n }\r\n}\r\n\r\ninterface ISynthesisSection {\r\n audio: {\r\n outputFormat: string,\r\n metadataOptions: {\r\n wordBoundaryEnabled: boolean,\r\n sentenceBoundaryEnabled: boolean,\r\n }\r\n };\r\n language: {\r\n autoDetection: boolean\r\n };\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { PropertyCollection } from \"../sdk/Exports\";\r\nimport { Context } from \"./Exports\";\r\n\r\nexport class SpeakerRecognitionConfig {\r\n private privParameters: PropertyCollection;\r\n private privContext: Context;\r\n\r\n constructor(\r\n context: Context,\r\n parameters: PropertyCollection) {\r\n this.privContext = context ? context : new Context(null);\r\n this.privParameters = parameters;\r\n }\r\n\r\n public get parameters(): PropertyCollection {\r\n return this.privParameters;\r\n }\r\n\r\n public get Context(): Context {\r\n return this.privContext;\r\n }\r\n}\r\n","import {\r\n IRequestOptions,\r\n IRestResponse,\r\n RestConfigBase,\r\n RestMessageAdapter,\r\n RestRequestType,\r\n} from \"../common.browser/Exports\";\r\nimport {\r\n createNoDashGuid,\r\n Deferred,\r\n IAudioSource,\r\n Promise,\r\n PromiseResult,\r\n} from \"../common/Exports\";\r\nimport {\r\n PropertyId,\r\n SpeakerIdentificationModel,\r\n SpeakerVerificationModel,\r\n VoiceProfile,\r\n VoiceProfileType,\r\n} from \"../sdk/Exports\";\r\nimport { SpeakerRecognitionConfig } from \"./Exports\";\r\n\r\n/**\r\n * Implements methods for speaker recognition classes, sending requests to endpoint\r\n * and parsing response into expected format\r\n * @class SpeakerIdMessageAdapter\r\n */\r\nexport class SpeakerIdMessageAdapter {\r\n private privRestAdapter: RestMessageAdapter;\r\n private privUri: string;\r\n\r\n public constructor(config: SpeakerRecognitionConfig) {\r\n\r\n let endpoint = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint, undefined);\r\n if (!endpoint) {\r\n const region: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Region, \"westus\");\r\n const hostSuffix: string = (region && region.toLowerCase().startsWith(\"china\")) ? \".azure.cn\" : \".microsoft.com\";\r\n const host: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, \"https://\" + region + \".api.cognitive\" + hostSuffix + \"/speaker/{mode}/v2.0/{dependency}\");\r\n endpoint = host + \"/profiles\";\r\n }\r\n this.privUri = endpoint;\r\n\r\n const options: IRequestOptions = RestConfigBase.requestOptions;\r\n options.headers[RestConfigBase.configParams.subscriptionKey] = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Key, undefined);\r\n\r\n this.privRestAdapter = new RestMessageAdapter(options);\r\n }\r\n\r\n /**\r\n * Sends create profile request to endpoint.\r\n * @function\r\n * @param {VoiceProfileType} profileType - type of voice profile to create.\r\n * @param {string} lang - language/locale of voice profile\r\n * @public\r\n * @returns {Promise} promised rest response containing id of created profile.\r\n */\r\n public createProfile(profileType: VoiceProfileType, lang: string):\r\n Promise {\r\n\r\n const uri = this.getOperationUri(profileType);\r\n this.privRestAdapter.setHeaders(RestConfigBase.configParams.contentTypeKey, \"application/json\");\r\n return this.privRestAdapter.request(RestRequestType.Post, uri, {}, { locale: lang });\r\n }\r\n\r\n /**\r\n * Sends create enrollment request to endpoint.\r\n * @function\r\n * @param {VoiceProfile} profileType - voice profile for which to create new enrollment.\r\n * @param {IAudioSource} audioSource - audioSource from which to pull data to send\r\n * @public\r\n * @returns {Promise} rest response to enrollment request.\r\n */\r\n public createEnrollment(profile: VoiceProfile, audioSource: IAudioSource):\r\n Promise {\r\n\r\n this.privRestAdapter.setHeaders(RestConfigBase.configParams.contentTypeKey, \"multipart/form-data\");\r\n const uri = this.getOperationUri(profile.profileType) + \"/\" + profile.profileId + \"/enrollments\";\r\n return audioSource.blob.onSuccessContinueWithPromise((result: Blob | Buffer): Promise => {\r\n return this.privRestAdapter.request(RestRequestType.File, uri, { ignoreMinLength: \"true\" }, null, result);\r\n });\r\n }\r\n\r\n /**\r\n * Sends verification request to endpoint.\r\n * @function\r\n * @param {SpeakerVerificationModel} model - voice model to verify against.\r\n * @param {IAudioSource} audioSource - audioSource from which to pull data to send\r\n * @public\r\n * @returns {Promise} rest response to enrollment request.\r\n */\r\n public verifySpeaker(model: SpeakerVerificationModel, audioSource: IAudioSource):\r\n Promise {\r\n\r\n this.privRestAdapter.setHeaders(RestConfigBase.configParams.contentTypeKey, \"multipart/form-data\");\r\n const uri = this.getOperationUri(model.voiceProfile.profileType) + \"/\" + model.voiceProfile.profileId + \"/verify\";\r\n return audioSource.blob.continueWithPromise((result: PromiseResult): Promise => {\r\n if (result.isError) {\r\n const response: Deferred = new Deferred();\r\n response.resolve({ data: result.error } as IRestResponse);\r\n return response.promise();\r\n }\r\n return this.privRestAdapter.request(RestRequestType.File, uri, { ignoreMinLength: \"true\" }, null, result.result);\r\n });\r\n }\r\n\r\n /**\r\n * Sends identification request to endpoint.\r\n * @function\r\n * @param {SpeakerIdentificationModel} model - voice profiles against which to identify.\r\n * @param {IAudioSource} audioSource - audioSource from which to pull data to send\r\n * @public\r\n * @returns {Promise} rest response to enrollment request.\r\n */\r\n public identifySpeaker(model: SpeakerIdentificationModel, audioSource: IAudioSource):\r\n Promise {\r\n\r\n this.privRestAdapter.setHeaders(RestConfigBase.configParams.contentTypeKey, \"multipart/form-data\");\r\n const uri = this.getOperationUri(VoiceProfileType.TextIndependentIdentification) + \"/identifySingleSpeaker\";\r\n return audioSource.blob.continueWithPromise((result: PromiseResult): Promise => {\r\n if (result.isError) {\r\n const response: Deferred = new Deferred();\r\n response.resolve({ data: result.error } as IRestResponse);\r\n return response.promise();\r\n }\r\n return this.privRestAdapter.request(RestRequestType.File, uri, { profileIds: model.voiceProfileIds, ignoreMinLength: \"true\" }, null, result.result);\r\n });\r\n }\r\n /**\r\n * Sends delete profile request to endpoint.\r\n * @function\r\n * @param {VoiceProfile} profile - voice profile to delete.\r\n * @public\r\n * @returns {Promise} rest response to deletion request\r\n */\r\n public deleteProfile(profile: VoiceProfile): Promise {\r\n\r\n const uri = this.getOperationUri(profile.profileType) + \"/\" + profile.profileId;\r\n return this.privRestAdapter.request(RestRequestType.Delete, uri, {});\r\n }\r\n\r\n /**\r\n * Sends reset profile request to endpoint.\r\n * @function\r\n * @param {VoiceProfile} profile - voice profile to reset enrollments for.\r\n * @public\r\n * @returns {Promise} rest response to reset request\r\n */\r\n public resetProfile(profile: VoiceProfile): Promise {\r\n\r\n const uri = this.getOperationUri(profile.profileType) + \"/\" + profile.profileId + \"/reset\";\r\n return this.privRestAdapter.request(RestRequestType.Post, uri, {});\r\n }\r\n\r\n private getOperationUri(profileType: VoiceProfileType): string {\r\n\r\n const mode = profileType === VoiceProfileType.TextIndependentIdentification ? \"identification\" : \"verification\";\r\n const dependency = profileType === VoiceProfileType.TextDependentVerification ? \"text-dependent\" : \"text-independent\";\r\n return this.privUri.replace(\"{mode}\", mode).replace(\"{dependency}\", dependency);\r\n }\r\n\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n connectivity,\r\n ISpeechConfigAudioDevice,\r\n type,\r\n} from \"../common.speech/Exports\";\r\nimport {\r\n AudioSourceErrorEvent,\r\n AudioSourceEvent,\r\n AudioSourceInitializingEvent,\r\n AudioSourceOffEvent,\r\n AudioSourceReadyEvent,\r\n AudioStreamNodeAttachedEvent,\r\n AudioStreamNodeAttachingEvent,\r\n AudioStreamNodeDetachedEvent,\r\n AudioStreamNodeErrorEvent,\r\n ChunkedArrayBufferStream,\r\n createNoDashGuid,\r\n Deferred,\r\n Events,\r\n EventSource,\r\n IAudioSource,\r\n IAudioStreamNode,\r\n IStringDictionary,\r\n Promise,\r\n PromiseHelper,\r\n Stream,\r\n} from \"../common/Exports\";\r\nimport { AudioStreamFormat, AudioStreamFormatImpl } from \"../sdk/Audio/AudioStreamFormat\";\r\n\r\nexport class FileAudioSource implements IAudioSource {\r\n\r\n private privAudioFormatPromise: Promise;\r\n\r\n private privStreams: IStringDictionary> = {};\r\n\r\n private privId: string;\r\n\r\n private privEvents: EventSource;\r\n\r\n private privFile: File;\r\n\r\n public constructor(file: File, audioSourceId?: string) {\r\n this.privId = audioSourceId ? audioSourceId : createNoDashGuid();\r\n this.privEvents = new EventSource();\r\n this.privFile = file;\r\n\r\n // Read the header.\r\n this.privAudioFormatPromise = this.readHeader();\r\n }\r\n\r\n public get format(): Promise {\r\n return this.privAudioFormatPromise;\r\n }\r\n\r\n public get blob(): Promise {\r\n return PromiseHelper.fromResult(this.privFile);\r\n }\r\n\r\n public turnOn = (): Promise => {\r\n if (typeof FileReader === \"undefined\") {\r\n const errorMsg = \"Browser does not support FileReader.\";\r\n this.onEvent(new AudioSourceErrorEvent(errorMsg, \"\")); // initialization error - no streamid at this point\r\n return PromiseHelper.fromError(errorMsg);\r\n } else if (this.privFile.name.lastIndexOf(\".wav\") !== this.privFile.name.length - 4) {\r\n const errorMsg = this.privFile.name + \" is not supported. Only WAVE files are allowed at the moment.\";\r\n this.onEvent(new AudioSourceErrorEvent(errorMsg, \"\"));\r\n return PromiseHelper.fromError(errorMsg);\r\n }\r\n\r\n this.onEvent(new AudioSourceInitializingEvent(this.privId)); // no stream id\r\n this.onEvent(new AudioSourceReadyEvent(this.privId));\r\n return PromiseHelper.fromResult(true);\r\n }\r\n\r\n public id = (): string => {\r\n return this.privId;\r\n }\r\n\r\n public attach = (audioNodeId: string): Promise => {\r\n this.onEvent(new AudioStreamNodeAttachingEvent(this.privId, audioNodeId));\r\n\r\n return this.upload(audioNodeId).onSuccessContinueWith(\r\n (stream: Stream) => {\r\n this.onEvent(new AudioStreamNodeAttachedEvent(this.privId, audioNodeId));\r\n return {\r\n detach: () => {\r\n stream.readEnded();\r\n delete this.privStreams[audioNodeId];\r\n this.onEvent(new AudioStreamNodeDetachedEvent(this.privId, audioNodeId));\r\n this.turnOff();\r\n },\r\n id: () => {\r\n return audioNodeId;\r\n },\r\n read: () => {\r\n return stream.read();\r\n },\r\n };\r\n });\r\n }\r\n\r\n public detach = (audioNodeId: string): void => {\r\n if (audioNodeId && this.privStreams[audioNodeId]) {\r\n this.privStreams[audioNodeId].close();\r\n delete this.privStreams[audioNodeId];\r\n this.onEvent(new AudioStreamNodeDetachedEvent(this.privId, audioNodeId));\r\n }\r\n }\r\n\r\n public turnOff = (): Promise => {\r\n for (const streamId in this.privStreams) {\r\n if (streamId) {\r\n const stream = this.privStreams[streamId];\r\n if (stream && !stream.isClosed) {\r\n stream.close();\r\n }\r\n }\r\n }\r\n\r\n this.onEvent(new AudioSourceOffEvent(this.privId)); // no stream now\r\n return PromiseHelper.fromResult(true);\r\n }\r\n\r\n public get events(): EventSource {\r\n return this.privEvents;\r\n }\r\n\r\n public get deviceInfo(): Promise {\r\n return this.privAudioFormatPromise.onSuccessContinueWithPromise((result: AudioStreamFormatImpl) => {\r\n return PromiseHelper.fromResult({\r\n bitspersample: result.bitsPerSample,\r\n channelcount: result.channels,\r\n connectivity: connectivity.Unknown,\r\n manufacturer: \"Speech SDK\",\r\n model: \"File\",\r\n samplerate: result.samplesPerSec,\r\n type: type.File,\r\n });\r\n });\r\n }\r\n\r\n private readHeader = (): Promise => {\r\n // Read the wave header.\r\n const header: Blob = this.privFile.slice(0, 44);\r\n const headerReader: FileReader = new FileReader();\r\n\r\n const headerResult: Deferred = new Deferred();\r\n\r\n const processHeader = (event: Event): void => {\r\n const header: ArrayBuffer = (event.target as FileReader).result as ArrayBuffer;\r\n\r\n const view: DataView = new DataView(header);\r\n\r\n // RIFF 4 bytes.\r\n const riff: string = String.fromCharCode(view.getUint8(0), view.getUint8(1), view.getUint8(2), view.getUint8(3));\r\n if (\"RIFF\" !== riff) {\r\n headerResult.reject(\"Invalid WAV header in file, RIFF was not found\");\r\n }\r\n\r\n // length, 4 bytes\r\n // RIFF Type & fmt 8 bytes\r\n const type: string = String.fromCharCode(\r\n view.getUint8(8),\r\n view.getUint8(9),\r\n view.getUint8(10),\r\n view.getUint8(11),\r\n view.getUint8(12),\r\n view.getUint8(13),\r\n view.getUint8(14));\r\n if (\"WAVEfmt\" !== type) {\r\n headerResult.reject(\"Invalid WAV header in file, WAVEfmt was not found\");\r\n }\r\n\r\n const channelCount: number = view.getUint16(22, true);\r\n const sampleRate: number = view.getUint32(24, true);\r\n const bitsPerSample: number = view.getUint16(34, true);\r\n\r\n headerResult.resolve(AudioStreamFormat.getWaveFormatPCM(sampleRate, bitsPerSample, channelCount) as AudioStreamFormatImpl);\r\n\r\n };\r\n\r\n headerReader.onload = processHeader;\r\n headerReader.readAsArrayBuffer(header);\r\n return headerResult.promise();\r\n }\r\n\r\n private upload = (audioNodeId: string): Promise> => {\r\n return this.turnOn()\r\n .onSuccessContinueWithPromise>((_: boolean) => {\r\n return this.privAudioFormatPromise.onSuccessContinueWith>((format: AudioStreamFormatImpl) => {\r\n const fileStream: ChunkedArrayBufferStream = new ChunkedArrayBufferStream(3200);\r\n\r\n const reader: FileReader = new FileReader();\r\n\r\n const stream = new ChunkedArrayBufferStream(format.avgBytesPerSec / 10, audioNodeId);\r\n\r\n this.privStreams[audioNodeId] = stream;\r\n\r\n const processFile = (event: Event): void => {\r\n if (stream.isClosed) {\r\n return; // output stream was closed (somebody called TurnOff). We're done here.\r\n }\r\n\r\n stream.writeStreamChunk({\r\n buffer: reader.result as ArrayBuffer,\r\n isEnd: false,\r\n timeReceived: Date.now(),\r\n });\r\n stream.close();\r\n };\r\n\r\n reader.onload = processFile;\r\n\r\n reader.onerror = (event: ProgressEvent) => {\r\n const errorMsg = `Error occurred while processing '${this.privFile.name}'. ${event}`;\r\n this.onEvent(new AudioStreamNodeErrorEvent(this.privId, audioNodeId, errorMsg));\r\n throw new Error(errorMsg);\r\n };\r\n\r\n const chunk = this.privFile.slice(44);\r\n reader.readAsArrayBuffer(chunk);\r\n\r\n return stream;\r\n });\r\n });\r\n\r\n }\r\n\r\n private onEvent = (event: AudioSourceEvent): void => {\r\n this.privEvents.onEvent(event);\r\n Events.instance.onEvent(event);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { RiffPcmEncoder, Stream } from \"../common/Exports\";\r\nimport { IRecorder } from \"./IRecorder\";\r\n\r\nexport class PcmRecorder implements IRecorder {\r\n private privMediaResources: IMediaResources;\r\n private privSpeechProcessorScript: string; // speech-processor.js Url\r\n\r\n public record = (context: AudioContext, mediaStream: MediaStream, outputStream: Stream): void => {\r\n const desiredSampleRate = 16000;\r\n\r\n const scriptNode = (() => {\r\n let bufferSize = 0;\r\n try {\r\n return context.createScriptProcessor(bufferSize, 1, 1);\r\n } catch (error) {\r\n // Webkit (<= version 31) requires a valid bufferSize.\r\n bufferSize = 2048;\r\n let audioSampleRate = context.sampleRate;\r\n while (bufferSize < 16384 && audioSampleRate >= (2 * desiredSampleRate)) {\r\n bufferSize <<= 1;\r\n audioSampleRate >>= 1;\r\n }\r\n return context.createScriptProcessor(bufferSize, 1, 1);\r\n }\r\n })();\r\n\r\n const waveStreamEncoder = new RiffPcmEncoder(context.sampleRate, desiredSampleRate);\r\n let needHeader: boolean = true;\r\n const that = this;\r\n scriptNode.onaudioprocess = (event: AudioProcessingEvent) => {\r\n const inputFrame = event.inputBuffer.getChannelData(0);\r\n\r\n if (outputStream && !outputStream.isClosed) {\r\n const waveFrame = waveStreamEncoder.encode(inputFrame);\r\n if (!!waveFrame) {\r\n outputStream.writeStreamChunk({\r\n buffer: waveFrame,\r\n isEnd: false,\r\n timeReceived: Date.now(),\r\n });\r\n needHeader = false;\r\n }\r\n }\r\n };\r\n\r\n const micInput = context.createMediaStreamSource(mediaStream);\r\n\r\n // https://webaudio.github.io/web-audio-api/#audioworklet\r\n // Using AudioWorklet to improve audio quality and avoid audio glitches due to blocking the UI thread\r\n\r\n if (!!this.privSpeechProcessorScript && !!context.audioWorklet) {\r\n context.audioWorklet\r\n .addModule(this.privSpeechProcessorScript)\r\n .then(() => {\r\n const workletNode = new AudioWorkletNode(context, \"speech-processor\");\r\n workletNode.port.onmessage = (ev: MessageEvent) => {\r\n const inputFrame: Float32Array = ev.data as Float32Array;\r\n\r\n if (outputStream && !outputStream.isClosed) {\r\n const waveFrame = waveStreamEncoder.encode(inputFrame);\r\n if (!!waveFrame) {\r\n outputStream.writeStreamChunk({\r\n buffer: waveFrame,\r\n isEnd: false,\r\n timeReceived: Date.now(),\r\n });\r\n needHeader = false;\r\n }\r\n }\r\n };\r\n micInput.connect(workletNode);\r\n workletNode.connect(context.destination);\r\n this.privMediaResources = {\r\n scriptProcessorNode: workletNode,\r\n source: micInput,\r\n stream: mediaStream,\r\n };\r\n })\r\n .catch(() => {\r\n micInput.connect(scriptNode);\r\n scriptNode.connect(context.destination);\r\n this.privMediaResources = {\r\n scriptProcessorNode: scriptNode,\r\n source: micInput,\r\n stream: mediaStream,\r\n };\r\n });\r\n } else {\r\n micInput.connect(scriptNode);\r\n scriptNode.connect(context.destination);\r\n this.privMediaResources = {\r\n scriptProcessorNode: scriptNode,\r\n source: micInput,\r\n stream: mediaStream,\r\n };\r\n }\r\n }\r\n\r\n public releaseMediaResources = (context: AudioContext): void => {\r\n if (this.privMediaResources) {\r\n if (this.privMediaResources.scriptProcessorNode) {\r\n this.privMediaResources.scriptProcessorNode.disconnect(context.destination);\r\n this.privMediaResources.scriptProcessorNode = null;\r\n }\r\n if (this.privMediaResources.source) {\r\n this.privMediaResources.source.disconnect();\r\n this.privMediaResources.stream.getTracks().forEach((track: any) => track.stop());\r\n this.privMediaResources.source = null;\r\n }\r\n }\r\n }\r\n\r\n public setWorkletUrl(url: string): void {\r\n this.privSpeechProcessorScript = url;\r\n }\r\n}\r\n\r\ninterface IMediaResources {\r\n source: MediaStreamAudioSourceNode;\r\n scriptProcessorNode: ScriptProcessorNode | AudioWorkletNode;\r\n stream: MediaStream;\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n ArgumentNullError,\r\n ConnectionEvent,\r\n ConnectionMessage,\r\n ConnectionOpenResponse,\r\n ConnectionState,\r\n createNoDashGuid,\r\n EventSource,\r\n IConnection,\r\n IStringDictionary,\r\n IWebsocketMessageFormatter,\r\n Promise,\r\n} from \"../common/Exports\";\r\nimport { ProxyInfo } from \"./ProxyInfo\";\r\nimport { WebsocketMessageAdapter } from \"./WebsocketMessageAdapter\";\r\n\r\nexport class WebsocketConnection implements IConnection {\r\n\r\n private privUri: string;\r\n private privMessageFormatter: IWebsocketMessageFormatter;\r\n private privConnectionMessageAdapter: WebsocketMessageAdapter;\r\n private privId: string;\r\n private privIsDisposed: boolean = false;\r\n\r\n public constructor(\r\n uri: string,\r\n queryParameters: IStringDictionary,\r\n headers: IStringDictionary,\r\n messageFormatter: IWebsocketMessageFormatter,\r\n proxyInfo: ProxyInfo,\r\n connectionId?: string) {\r\n\r\n if (!uri) {\r\n throw new ArgumentNullError(\"uri\");\r\n }\r\n\r\n if (!messageFormatter) {\r\n throw new ArgumentNullError(\"messageFormatter\");\r\n }\r\n\r\n this.privMessageFormatter = messageFormatter;\r\n\r\n let queryParams = \"\";\r\n let i = 0;\r\n\r\n if (queryParameters) {\r\n for (const paramName in queryParameters) {\r\n if (paramName) {\r\n queryParams += ((i === 0) && (uri.indexOf(\"?\") === -1)) ? \"?\" : \"&\";\r\n const val = encodeURIComponent(queryParameters[paramName]);\r\n queryParams += `${paramName}=${val}`;\r\n i++;\r\n }\r\n }\r\n }\r\n\r\n if (headers) {\r\n for (const headerName in headers) {\r\n if (headerName) {\r\n queryParams += ((i === 0) && (uri.indexOf(\"?\") === -1)) ? \"?\" : \"&\";\r\n const val = encodeURIComponent(headers[headerName]);\r\n queryParams += `${headerName}=${val}`;\r\n i++;\r\n }\r\n }\r\n }\r\n\r\n this.privUri = uri + queryParams;\r\n this.privId = connectionId ? connectionId : createNoDashGuid();\r\n\r\n this.privConnectionMessageAdapter = new WebsocketMessageAdapter(\r\n this.privUri,\r\n this.id,\r\n this.privMessageFormatter,\r\n proxyInfo,\r\n headers);\r\n }\r\n\r\n public dispose = (): void => {\r\n this.privIsDisposed = true;\r\n\r\n if (this.privConnectionMessageAdapter) {\r\n this.privConnectionMessageAdapter.close();\r\n }\r\n }\r\n\r\n public isDisposed = (): boolean => {\r\n return this.privIsDisposed;\r\n }\r\n\r\n public get id(): string {\r\n return this.privId;\r\n }\r\n\r\n public state = (): ConnectionState => {\r\n return this.privConnectionMessageAdapter.state;\r\n }\r\n\r\n public open = (): Promise => {\r\n return this.privConnectionMessageAdapter.open();\r\n }\r\n\r\n public send = (message: ConnectionMessage): Promise => {\r\n return this.privConnectionMessageAdapter.send(message);\r\n }\r\n\r\n public read = (): Promise => {\r\n return this.privConnectionMessageAdapter.read();\r\n }\r\n\r\n public get events(): EventSource {\r\n return this.privConnectionMessageAdapter.events;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n ArgumentNullError,\r\n ConnectionClosedEvent,\r\n ConnectionErrorEvent,\r\n ConnectionEstablishedEvent,\r\n ConnectionEvent,\r\n ConnectionMessage,\r\n ConnectionMessageReceivedEvent,\r\n ConnectionMessageSentEvent,\r\n ConnectionOpenResponse,\r\n ConnectionStartEvent,\r\n ConnectionState,\r\n Deferred,\r\n Events,\r\n EventSource,\r\n IWebsocketMessageFormatter,\r\n MessageType,\r\n Promise,\r\n PromiseHelper,\r\n Queue,\r\n RawWebsocketMessage,\r\n} from \"../common/Exports\";\r\nimport { ProxyInfo } from \"./ProxyInfo\";\r\n\r\n// Node.JS specific web socket / browser support.\r\nimport ws from \"ws\";\r\nimport { CertCheckAgent } from \"./CertChecks\";\r\n\r\ninterface ISendItem {\r\n Message: ConnectionMessage;\r\n RawWebsocketMessage: RawWebsocketMessage;\r\n sendStatusDeferral: Deferred;\r\n}\r\n\r\nexport class WebsocketMessageAdapter {\r\n private privConnectionState: ConnectionState;\r\n private privMessageFormatter: IWebsocketMessageFormatter;\r\n private privWebsocketClient: WebSocket | ws;\r\n\r\n private privSendMessageQueue: Queue;\r\n private privReceivingMessageQueue: Queue;\r\n private privConnectionEstablishDeferral: Deferred;\r\n private privCertificateValidatedDeferral: Deferred;\r\n private privDisconnectDeferral: Deferred;\r\n private privConnectionEvents: EventSource;\r\n private privConnectionId: string;\r\n private privUri: string;\r\n private proxyInfo: ProxyInfo;\r\n private privHeaders: { [key: string]: string; };\r\n private privLastErrorReceived: string;\r\n\r\n public static forceNpmWebSocket: boolean = false;\r\n\r\n public constructor(\r\n uri: string,\r\n connectionId: string,\r\n messageFormatter: IWebsocketMessageFormatter,\r\n proxyInfo: ProxyInfo,\r\n headers: { [key: string]: string; }) {\r\n\r\n if (!uri) {\r\n throw new ArgumentNullError(\"uri\");\r\n }\r\n\r\n if (!messageFormatter) {\r\n throw new ArgumentNullError(\"messageFormatter\");\r\n }\r\n\r\n this.proxyInfo = proxyInfo;\r\n this.privConnectionEvents = new EventSource();\r\n this.privConnectionId = connectionId;\r\n this.privMessageFormatter = messageFormatter;\r\n this.privConnectionState = ConnectionState.None;\r\n this.privUri = uri;\r\n this.privHeaders = headers;\r\n\r\n // Add the connection ID to the headers\r\n this.privHeaders[\"X-ConnectionId\"] = this.privConnectionId;\r\n\r\n this.privLastErrorReceived = \"\";\r\n }\r\n\r\n public get state(): ConnectionState {\r\n return this.privConnectionState;\r\n }\r\n\r\n public open = (): Promise => {\r\n if (this.privConnectionState === ConnectionState.Disconnected) {\r\n return PromiseHelper.fromError(`Cannot open a connection that is in ${this.privConnectionState} state`);\r\n }\r\n\r\n if (this.privConnectionEstablishDeferral) {\r\n return this.privConnectionEstablishDeferral.promise();\r\n }\r\n\r\n this.privConnectionEstablishDeferral = new Deferred();\r\n this.privCertificateValidatedDeferral = new Deferred();\r\n\r\n this.privConnectionState = ConnectionState.Connecting;\r\n\r\n try {\r\n\r\n if (typeof WebSocket !== \"undefined\" && !WebsocketMessageAdapter.forceNpmWebSocket) {\r\n // Browser handles cert checks.\r\n this.privCertificateValidatedDeferral.resolve(true);\r\n\r\n this.privWebsocketClient = new WebSocket(this.privUri);\r\n } else {\r\n const options: ws.ClientOptions = { headers: this.privHeaders };\r\n // The ocsp library will handle validation for us and fail the connection if needed.\r\n this.privCertificateValidatedDeferral.resolve(true);\r\n const checkAgent: CertCheckAgent = new CertCheckAgent(this.proxyInfo);\r\n\r\n options.agent = checkAgent.GetAgent();\r\n this.privWebsocketClient = new ws(this.privUri, options);\r\n }\r\n\r\n this.privWebsocketClient.binaryType = \"arraybuffer\";\r\n this.privReceivingMessageQueue = new Queue();\r\n this.privDisconnectDeferral = new Deferred();\r\n this.privSendMessageQueue = new Queue();\r\n this.processSendQueue();\r\n } catch (error) {\r\n this.privConnectionEstablishDeferral.resolve(new ConnectionOpenResponse(500, error));\r\n return this.privConnectionEstablishDeferral.promise();\r\n }\r\n\r\n this.onEvent(new ConnectionStartEvent(this.privConnectionId, this.privUri));\r\n\r\n this.privWebsocketClient.onopen = (e: { target: WebSocket | ws }) => {\r\n this.privCertificateValidatedDeferral.promise().on((): void => {\r\n this.privConnectionState = ConnectionState.Connected;\r\n this.onEvent(new ConnectionEstablishedEvent(this.privConnectionId));\r\n this.privConnectionEstablishDeferral.resolve(new ConnectionOpenResponse(200, \"\"));\r\n }, (error: string): void => {\r\n this.privConnectionEstablishDeferral.reject(error);\r\n });\r\n };\r\n\r\n this.privWebsocketClient.onerror = (e: { error: any; message: string; type: string; target: WebSocket | ws }) => {\r\n this.onEvent(new ConnectionErrorEvent(this.privConnectionId, e.message, e.type));\r\n this.privLastErrorReceived = e.message;\r\n };\r\n\r\n this.privWebsocketClient.onclose = (e: { wasClean: boolean; code: number; reason: string; target: WebSocket | ws }) => {\r\n if (this.privConnectionState === ConnectionState.Connecting) {\r\n this.privConnectionState = ConnectionState.Disconnected;\r\n // this.onEvent(new ConnectionEstablishErrorEvent(this.connectionId, e.code, e.reason));\r\n this.privConnectionEstablishDeferral.resolve(new ConnectionOpenResponse(e.code, e.reason + \" \" + this.privLastErrorReceived));\r\n } else {\r\n this.privConnectionState = ConnectionState.Disconnected;\r\n this.onEvent(new ConnectionClosedEvent(this.privConnectionId, e.code, e.reason));\r\n }\r\n\r\n this.onClose(e.code, e.reason);\r\n };\r\n\r\n this.privWebsocketClient.onmessage = (e: { data: ws.Data; type: string; target: WebSocket | ws }) => {\r\n const networkReceivedTime = new Date().toISOString();\r\n if (this.privConnectionState === ConnectionState.Connected) {\r\n const deferred = new Deferred();\r\n // let id = ++this.idCounter;\r\n this.privReceivingMessageQueue.enqueueFromPromise(deferred.promise());\r\n if (e.data instanceof ArrayBuffer) {\r\n const rawMessage = new RawWebsocketMessage(MessageType.Binary, e.data);\r\n this.privMessageFormatter\r\n .toConnectionMessage(rawMessage)\r\n .on((connectionMessage: ConnectionMessage) => {\r\n this.onEvent(new ConnectionMessageReceivedEvent(this.privConnectionId, networkReceivedTime, connectionMessage));\r\n deferred.resolve(connectionMessage);\r\n }, (error: string) => {\r\n // TODO: Events for these ?\r\n deferred.reject(`Invalid binary message format. Error: ${error}`);\r\n });\r\n } else {\r\n const rawMessage = new RawWebsocketMessage(MessageType.Text, e.data);\r\n this.privMessageFormatter\r\n .toConnectionMessage(rawMessage)\r\n .on((connectionMessage: ConnectionMessage) => {\r\n this.onEvent(new ConnectionMessageReceivedEvent(this.privConnectionId, networkReceivedTime, connectionMessage));\r\n deferred.resolve(connectionMessage);\r\n }, (error: string) => {\r\n // TODO: Events for these ?\r\n deferred.reject(`Invalid text message format. Error: ${error}`);\r\n });\r\n }\r\n }\r\n };\r\n\r\n return this.privConnectionEstablishDeferral.promise();\r\n }\r\n\r\n public send = (message: ConnectionMessage): Promise => {\r\n if (this.privConnectionState !== ConnectionState.Connected) {\r\n return PromiseHelper.fromError(`Cannot send on connection that is in ${this.privConnectionState} state`);\r\n }\r\n\r\n const messageSendStatusDeferral = new Deferred();\r\n const messageSendDeferral = new Deferred();\r\n\r\n this.privSendMessageQueue.enqueueFromPromise(messageSendDeferral.promise());\r\n\r\n this.privMessageFormatter\r\n .fromConnectionMessage(message)\r\n .on((rawMessage: RawWebsocketMessage) => {\r\n messageSendDeferral.resolve({\r\n Message: message,\r\n RawWebsocketMessage: rawMessage,\r\n sendStatusDeferral: messageSendStatusDeferral,\r\n });\r\n }, (error: string) => {\r\n messageSendDeferral.reject(`Error formatting the message. ${error}`);\r\n });\r\n\r\n return messageSendStatusDeferral.promise();\r\n }\r\n\r\n public read = (): Promise => {\r\n if (this.privConnectionState !== ConnectionState.Connected) {\r\n return PromiseHelper.fromError(`Cannot read on connection that is in ${this.privConnectionState} state`);\r\n }\r\n\r\n return this.privReceivingMessageQueue.dequeue();\r\n }\r\n\r\n public close = (reason?: string): Promise => {\r\n if (this.privWebsocketClient) {\r\n if (this.privConnectionState !== ConnectionState.Disconnected) {\r\n this.privWebsocketClient.close(1000, reason ? reason : \"Normal closure by client\");\r\n }\r\n } else {\r\n const deferral = new Deferred();\r\n deferral.resolve(true);\r\n return deferral.promise();\r\n }\r\n\r\n return this.privDisconnectDeferral.promise();\r\n }\r\n\r\n public get events(): EventSource {\r\n return this.privConnectionEvents;\r\n }\r\n\r\n private sendRawMessage = (sendItem: ISendItem): Promise => {\r\n try {\r\n // indicates we are draining the queue and it came with no message;\r\n if (!sendItem) {\r\n return PromiseHelper.fromResult(true);\r\n }\r\n\r\n this.onEvent(new ConnectionMessageSentEvent(this.privConnectionId, new Date().toISOString(), sendItem.Message));\r\n\r\n // add a check for the ws readystate in order to stop the red console error 'WebSocket is already in CLOSING or CLOSED state' appearing\r\n if (this.isWebsocketOpen) {\r\n this.privWebsocketClient.send(sendItem.RawWebsocketMessage.payload);\r\n } else {\r\n return PromiseHelper.fromError(\"websocket send error: Websocket not ready\");\r\n }\r\n return PromiseHelper.fromResult(true);\r\n\r\n } catch (e) {\r\n return PromiseHelper.fromError(`websocket send error: ${e}`);\r\n }\r\n }\r\n\r\n private onClose = (code: number, reason: string): void => {\r\n const closeReason = `Connection closed. ${code}: ${reason}`;\r\n this.privConnectionState = ConnectionState.Disconnected;\r\n this.privDisconnectDeferral.resolve(true);\r\n this.privReceivingMessageQueue.dispose(reason);\r\n this.privReceivingMessageQueue.drainAndDispose((pendingReceiveItem: ConnectionMessage) => {\r\n // TODO: Events for these ?\r\n // Logger.instance.onEvent(new LoggingEvent(LogType.Warning, null, `Failed to process received message. Reason: ${closeReason}, Message: ${JSON.stringify(pendingReceiveItem)}`));\r\n }, closeReason);\r\n\r\n this.privSendMessageQueue.drainAndDispose((pendingSendItem: ISendItem) => {\r\n pendingSendItem.sendStatusDeferral.reject(closeReason);\r\n }, closeReason);\r\n }\r\n\r\n private processSendQueue = (): void => {\r\n this.privSendMessageQueue\r\n .dequeue()\r\n .on((sendItem: ISendItem) => {\r\n // indicates we are draining the queue and it came with no message;\r\n if (!sendItem) {\r\n return;\r\n }\r\n\r\n this.sendRawMessage(sendItem)\r\n .on((result: boolean) => {\r\n sendItem.sendStatusDeferral.resolve(result);\r\n this.processSendQueue();\r\n }, (sendError: string) => {\r\n sendItem.sendStatusDeferral.reject(sendError);\r\n this.processSendQueue();\r\n });\r\n }, (error: string) => {\r\n // do nothing\r\n });\r\n }\r\n\r\n private onEvent = (event: ConnectionEvent): void => {\r\n this.privConnectionEvents.onEvent(event);\r\n Events.instance.onEvent(event);\r\n }\r\n\r\n private get isWebsocketOpen(): boolean {\r\n return this.privWebsocketClient && this.privWebsocketClient.readyState === this.privWebsocketClient.OPEN;\r\n }\r\n\r\n}\r\n","/* (ignored) */","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport * as http from \"http\";\r\nimport * as tls from \"tls\";\r\nimport * as url from \"url\";\r\nimport * as ocsp from \"../../external/ocsp/ocsp\";\r\nimport {\r\n Events,\r\n OCSPCacheEntryExpiredEvent,\r\n OCSPCacheEntryNeedsRefreshEvent,\r\n OCSPCacheFetchErrorEvent,\r\n OCSPCacheHitEvent,\r\n OCSPCacheMissEvent,\r\n OCSPCacheUpdatehCompleteEvent,\r\n OCSPCacheUpdateNeededEvent,\r\n OCSPDiskCacheHitEvent,\r\n OCSPDiskCacheStoreEvent,\r\n OCSPEvent,\r\n OCSPMemoryCacheHitEvent,\r\n OCSPMemoryCacheStoreEvent,\r\n OCSPResponseRetrievedEvent,\r\n OCSPStapleReceivedEvent,\r\n OCSPVerificationFailedEvent,\r\n OCSPWSUpgradeStartedEvent\r\n} from \"../common/Exports\";\r\nimport { IStringDictionary } from \"../common/IDictionary\";\r\nimport { ProxyInfo } from \"./ProxyInfo\";\r\n\r\nimport Agent from \"agent-base\";\r\n\r\n// @ts-ignore\r\nimport Cache from \"async-disk-cache\";\r\nimport HttpsProxyAgent from \"https-proxy-agent\";\r\nimport * as net from \"net\";\r\nimport { OCSPCacheUpdateErrorEvent } from \"../common/OCSPEvents\";\r\n\r\nexport class CertCheckAgent {\r\n\r\n // Test hook to enable forcing expiration / refresh to happen.\r\n public static testTimeOffset: number = 0;\r\n\r\n // Test hook to disable stapling for cache testing.\r\n public static forceDisableOCSPStapling: boolean = false;\r\n\r\n // An in memory cache for recived responses.\r\n private static privMemCache: IStringDictionary = {};\r\n\r\n // The on disk cache.\r\n private static privDiskCache: Cache;\r\n\r\n private privProxyInfo: ProxyInfo;\r\n\r\n constructor(proxyInfo?: ProxyInfo) {\r\n if (!!proxyInfo) {\r\n this.privProxyInfo = proxyInfo;\r\n }\r\n\r\n // Initialize this here to allow tests to set the env variable before the cache is constructed.\r\n if (!CertCheckAgent.privDiskCache) {\r\n CertCheckAgent.privDiskCache = new Cache(\"microsoft-cognitiveservices-speech-sdk-cache\", { supportBuffer: true, location: (typeof process !== \"undefined\" && !!process.env.SPEECH_OCSP_CACHE_ROOT) ? process.env.SPEECH_OCSP_CACHE_ROOT : undefined });\r\n }\r\n }\r\n\r\n // Test hook to force the disk cache to be recreated.\r\n public static forceReinitDiskCache(): void {\r\n CertCheckAgent.privDiskCache = undefined;\r\n CertCheckAgent.privMemCache = {};\r\n }\r\n\r\n public GetAgent(disableStapling?: boolean): http.Agent {\r\n const agent: any = new Agent.Agent(this.CreateConnection);\r\n\r\n if (this.privProxyInfo !== undefined &&\r\n this.privProxyInfo.HostName !== undefined &&\r\n this.privProxyInfo.Port > 0) {\r\n const proxyName: string = \"privProxyInfo\";\r\n agent[proxyName] = this.privProxyInfo;\r\n }\r\n\r\n return agent;\r\n }\r\n\r\n private static GetProxyAgent(proxyInfo: ProxyInfo): HttpsProxyAgent {\r\n const httpProxyOptions: HttpsProxyAgent.HttpsProxyAgentOptions = {\r\n host: proxyInfo.HostName,\r\n port: proxyInfo.Port,\r\n };\r\n\r\n if (!!proxyInfo.UserName) {\r\n httpProxyOptions.headers = {\r\n \"Proxy-Authentication\": \"Basic \" + new Buffer(proxyInfo.UserName + \":\" + (proxyInfo.Password === undefined) ? \"\" : proxyInfo.Password).toString(\"base64\"),\r\n };\r\n } else {\r\n httpProxyOptions.headers = {};\r\n }\r\n\r\n httpProxyOptions.headers.requestOCSP = \"true\";\r\n\r\n const httpProxyAgent: HttpsProxyAgent = new HttpsProxyAgent(httpProxyOptions);\r\n return httpProxyAgent;\r\n }\r\n\r\n private static async OCSPCheck(socketPromise: Promise, proxyInfo: ProxyInfo): Promise {\r\n let ocspRequest: ocsp.Request;\r\n let stapling: Buffer;\r\n let resolved: boolean = false;\r\n\r\n const socket: net.Socket = await socketPromise;\r\n socket.cork();\r\n\r\n const tlsSocket: tls.TLSSocket = socket as tls.TLSSocket;\r\n\r\n return new Promise((resolve: (value: net.Socket) => void, reject: (error: string | Error) => void) => {\r\n socket.on(\"OCSPResponse\", (data: Buffer): void => {\r\n if (!!data) {\r\n this.onEvent(new OCSPStapleReceivedEvent());\r\n stapling = data;\r\n }\r\n });\r\n\r\n socket.on(\"error\", (error: Error) => {\r\n if (!resolved) {\r\n resolved = true;\r\n socket.destroy();\r\n reject(error);\r\n }\r\n });\r\n\r\n tlsSocket.on(\"secure\", async () => {\r\n const peer: tls.DetailedPeerCertificate = tlsSocket.getPeerCertificate(true);\r\n try {\r\n const issuer: tls.DetailedPeerCertificate = await this.GetIssuer(peer);\r\n\r\n // We always need a request to verify the response.\r\n ocspRequest = ocsp.request.generate(peer.raw, issuer.raw);\r\n\r\n // Do we have a result for this certificate in our memory cache?\r\n const sig: string = ocspRequest.id.toString(\"hex\");\r\n\r\n // Stapled response trumps cached response.\r\n if (!stapling) {\r\n const cacheEntry: Buffer = await CertCheckAgent.GetResponseFromCache(sig, ocspRequest, proxyInfo);\r\n stapling = cacheEntry;\r\n }\r\n\r\n await this.VerifyOCSPResponse(stapling, ocspRequest, proxyInfo);\r\n\r\n socket.uncork();\r\n resolved = true;\r\n resolve(socket);\r\n } catch (e) {\r\n socket.destroy();\r\n resolved = true;\r\n reject(e);\r\n }\r\n });\r\n });\r\n }\r\n\r\n private static GetIssuer(peer: tls.DetailedPeerCertificate): Promise {\r\n if (peer.issuerCertificate) {\r\n return Promise.resolve(peer.issuerCertificate);\r\n }\r\n\r\n return new Promise((resolve: (value: tls.DetailedPeerCertificate) => void, reject: (reason: string) => void) => {\r\n const ocspAgent: ocsp.Agent = new ocsp.Agent({});\r\n ocspAgent.fetchIssuer(peer, null, (error: string, value: tls.DetailedPeerCertificate): void => {\r\n if (!!error) {\r\n reject(error);\r\n return;\r\n }\r\n\r\n resolve(value);\r\n });\r\n });\r\n }\r\n\r\n private static async GetResponseFromCache(signature: string, ocspRequest: ocsp.Request, proxyInfo: ProxyInfo): Promise {\r\n let cachedResponse: Buffer = CertCheckAgent.privMemCache[signature];\r\n\r\n if (!!cachedResponse) {\r\n this.onEvent(new OCSPMemoryCacheHitEvent(signature));\r\n }\r\n\r\n // Do we have a result for this certificate on disk in %TMP%?\r\n if (!cachedResponse) {\r\n try {\r\n const diskCacheResponse: any = await CertCheckAgent.privDiskCache.get(signature);\r\n if (!!diskCacheResponse.isCached) {\r\n CertCheckAgent.onEvent(new OCSPDiskCacheHitEvent(signature));\r\n CertCheckAgent.StoreMemoryCacheEntry(signature, diskCacheResponse.value);\r\n cachedResponse = diskCacheResponse.value;\r\n }\r\n } catch (error) {\r\n cachedResponse = null;\r\n }\r\n }\r\n\r\n if (!cachedResponse) {\r\n return cachedResponse;\r\n }\r\n\r\n try {\r\n const cachedOcspResponse: ocsp.Response = ocsp.utils.parseResponse(cachedResponse);\r\n const tbsData = cachedOcspResponse.value.tbsResponseData;\r\n if (tbsData.responses.length < 1) {\r\n this.onEvent(new OCSPCacheFetchErrorEvent(signature, \"Not enough data in cached response\"));\r\n return;\r\n }\r\n\r\n const cachedStartTime: number = tbsData.responses[0].thisUpdate;\r\n const cachedNextTime: number = tbsData.responses[0].nextUpdate;\r\n\r\n if (cachedNextTime < (Date.now() + this.testTimeOffset - 60000)) {\r\n // Cached entry has expired.\r\n this.onEvent(new OCSPCacheEntryExpiredEvent(signature, cachedNextTime));\r\n cachedResponse = null;\r\n } else {\r\n // If we're within one day of the next update, or 50% of the way through the validity period,\r\n // background an update to the cache.\r\n\r\n const minUpdate: number = Math.min(24 * 60 * 60 * 1000, (cachedNextTime - cachedStartTime) / 2);\r\n\r\n if ((cachedNextTime - (Date.now() + this.testTimeOffset)) < minUpdate) {\r\n this.onEvent(new OCSPCacheEntryNeedsRefreshEvent(signature, cachedStartTime, cachedNextTime));\r\n this.UpdateCache(ocspRequest, proxyInfo).catch((error: string) => {\r\n // Well, not much we can do here.\r\n this.onEvent(new OCSPCacheUpdateErrorEvent(signature, error.toString()));\r\n });\r\n } else {\r\n this.onEvent(new OCSPCacheHitEvent(signature, cachedStartTime, cachedNextTime));\r\n }\r\n }\r\n } catch (error) {\r\n this.onEvent(new OCSPCacheFetchErrorEvent(signature, error));\r\n cachedResponse = null;\r\n }\r\n if (!cachedResponse) {\r\n this.onEvent(new OCSPCacheMissEvent(signature));\r\n }\r\n return cachedResponse;\r\n }\r\n\r\n private static async VerifyOCSPResponse(cacheValue: Buffer, ocspRequest: ocsp.Request, proxyInfo: ProxyInfo): Promise {\r\n let ocspResponse: Buffer = cacheValue;\r\n const sig: string = ocspRequest.certID.toString(\"hex\");\r\n\r\n // Do we have a valid response?\r\n if (!ocspResponse) {\r\n ocspResponse = await CertCheckAgent.GetOCSPResponse(ocspRequest, proxyInfo);\r\n }\r\n\r\n return new Promise((resolve: () => void, reject: (error: string | Error) => void) => {\r\n ocsp.verify({ request: ocspRequest, response: ocspResponse }, (error: string, result: any): void => {\r\n if (!!error) {\r\n CertCheckAgent.onEvent(new OCSPVerificationFailedEvent(ocspRequest.id.toString(\"hex\"), error));\r\n\r\n // Bad Cached Value? One more try without the cache.\r\n if (!!cacheValue) {\r\n this.VerifyOCSPResponse(null, ocspRequest, proxyInfo).then(() => {\r\n resolve();\r\n }, (error: Error) => {\r\n reject(error);\r\n });\r\n } else {\r\n reject(error);\r\n }\r\n } else {\r\n if (!cacheValue) {\r\n CertCheckAgent.StoreCacheEntry(ocspRequest.id.toString(\"hex\"), ocspResponse);\r\n }\r\n resolve();\r\n }\r\n });\r\n });\r\n }\r\n\r\n private static async UpdateCache(req: ocsp.Request, proxyInfo: ProxyInfo): Promise {\r\n const signature: string = req.id.toString(\"hex\");\r\n this.onEvent(new OCSPCacheUpdateNeededEvent(signature));\r\n\r\n const rawResponse: Buffer = await this.GetOCSPResponse(req, proxyInfo);\r\n this.StoreCacheEntry(signature, rawResponse);\r\n this.onEvent(new OCSPCacheUpdatehCompleteEvent(req.id.toString(\"hex\")));\r\n\r\n }\r\n\r\n private static StoreCacheEntry(sig: string, rawResponse: Buffer): void {\r\n this.StoreMemoryCacheEntry(sig, rawResponse);\r\n this.StoreDiskCacheEntry(sig, rawResponse);\r\n }\r\n\r\n private static StoreMemoryCacheEntry(sig: string, rawResponse: Buffer): void {\r\n this.privMemCache[sig] = rawResponse;\r\n this.onEvent(new OCSPMemoryCacheStoreEvent(sig));\r\n }\r\n\r\n private static StoreDiskCacheEntry(sig: string, rawResponse: Buffer): void {\r\n this.privDiskCache.set(sig, rawResponse).then(() => {\r\n this.onEvent(new OCSPDiskCacheStoreEvent(sig));\r\n });\r\n }\r\n\r\n private static GetOCSPResponse(req: ocsp.Request, proxyInfo: ProxyInfo): Promise {\r\n\r\n const ocspMethod: string = \"1.3.6.1.5.5.7.48.1\";\r\n let options: http.RequestOptions = {};\r\n\r\n if (!!proxyInfo) {\r\n const agent: HttpsProxyAgent = CertCheckAgent.GetProxyAgent(proxyInfo);\r\n options.agent = agent;\r\n }\r\n\r\n return new Promise((resolve: (value: Buffer) => void, reject: (error: string | Error) => void) => {\r\n ocsp.utils.getAuthorityInfo(req.cert, ocspMethod, (error: string, uri: string): void => {\r\n if (error) {\r\n reject(error);\r\n return;\r\n }\r\n\r\n const parsedUri = url.parse(uri);\r\n options = { ...options, ...parsedUri };\r\n\r\n ocsp.utils.getResponse(options, req.data, (error: string, raw: Buffer): void => {\r\n if (error) {\r\n reject(error);\r\n return;\r\n }\r\n\r\n this.onEvent(new OCSPResponseRetrievedEvent(req.certID.toString(\"hex\")));\r\n resolve(raw);\r\n });\r\n });\r\n });\r\n }\r\n\r\n private static onEvent = (event: OCSPEvent): void => {\r\n Events.instance.onEvent(event);\r\n }\r\n\r\n private CreateConnection(request: Agent.ClientRequest, options: Agent.RequestOptions): Promise {\r\n const enableOCSP: boolean = (typeof process !== \"undefined\" && process.env.NODE_TLS_REJECT_UNAUTHORIZED !== \"0\" && process.env.SPEECH_CONDUCT_OCSP_CHECK !== \"0\") && options.secureEndpoint;\r\n let socketPromise: Promise;\r\n\r\n options = {\r\n ...options,\r\n ...{\r\n requestOCSP: !CertCheckAgent.forceDisableOCSPStapling,\r\n servername: options.host\r\n }\r\n };\r\n\r\n if (!!this.privProxyInfo) {\r\n const httpProxyAgent: HttpsProxyAgent = CertCheckAgent.GetProxyAgent(this.privProxyInfo);\r\n const baseAgent: Agent.Agent = httpProxyAgent as unknown as Agent.Agent;\r\n\r\n socketPromise = new Promise((resolve: (value: net.Socket) => void, reject: (error: string | Error) => void) => {\r\n baseAgent.callback(request, options, (error: Error, socket: net.Socket) => {\r\n if (!!error) {\r\n reject(error);\r\n } else {\r\n resolve(socket);\r\n }\r\n });\r\n });\r\n } else {\r\n socketPromise = Promise.resolve(tls.connect(options));\r\n }\r\n\r\n if (!!enableOCSP) {\r\n return CertCheckAgent.OCSPCheck(socketPromise, this.privProxyInfo);\r\n } else {\r\n return socketPromise;\r\n }\r\n }\r\n}\r\n","// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n","/* (ignored) */","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar punycode = require('punycode');\nvar util = require('./util');\n\nexports.parse = urlParse;\nexports.resolve = urlResolve;\nexports.resolveObject = urlResolveObject;\nexports.format = urlFormat;\n\nexports.Url = Url;\n\nfunction Url() {\n this.protocol = null;\n this.slashes = null;\n this.auth = null;\n this.host = null;\n this.port = null;\n this.hostname = null;\n this.hash = null;\n this.search = null;\n this.query = null;\n this.pathname = null;\n this.path = null;\n this.href = null;\n}\n\n// Reference: RFC 3986, RFC 1808, RFC 2396\n\n// define these here so at least they only have to be\n// compiled once on the first module load.\nvar protocolPattern = /^([a-z0-9.+-]+:)/i,\n portPattern = /:[0-9]*$/,\n\n // Special case for a simple path URL\n simplePathPattern = /^(\\/\\/?(?!\\/)[^\\?\\s]*)(\\?[^\\s]*)?$/,\n\n // RFC 2396: characters reserved for delimiting URLs.\n // We actually just auto-escape these.\n delims = ['<', '>', '\"', '`', ' ', '\\r', '\\n', '\\t'],\n\n // RFC 2396: characters not allowed for various reasons.\n unwise = ['{', '}', '|', '\\\\', '^', '`'].concat(delims),\n\n // Allowed by RFCs, but cause of XSS attacks. Always escape these.\n autoEscape = ['\\''].concat(unwise),\n // Characters that are never ever allowed in a hostname.\n // Note that any invalid chars are also handled, but these\n // are the ones that are *expected* to be seen, so we fast-path\n // them.\n nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),\n hostEndingChars = ['/', '?', '#'],\n hostnameMaxLen = 255,\n hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,\n hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,\n // protocols that can allow \"unsafe\" and \"unwise\" chars.\n unsafeProtocol = {\n 'javascript': true,\n 'javascript:': true\n },\n // protocols that never have a hostname.\n hostlessProtocol = {\n 'javascript': true,\n 'javascript:': true\n },\n // protocols that always contain a // bit.\n slashedProtocol = {\n 'http': true,\n 'https': true,\n 'ftp': true,\n 'gopher': true,\n 'file': true,\n 'http:': true,\n 'https:': true,\n 'ftp:': true,\n 'gopher:': true,\n 'file:': true\n },\n querystring = require('querystring');\n\nfunction urlParse(url, parseQueryString, slashesDenoteHost) {\n if (url && util.isObject(url) && url instanceof Url) return url;\n\n var u = new Url;\n u.parse(url, parseQueryString, slashesDenoteHost);\n return u;\n}\n\nUrl.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {\n if (!util.isString(url)) {\n throw new TypeError(\"Parameter 'url' must be a string, not \" + typeof url);\n }\n\n // Copy chrome, IE, opera backslash-handling behavior.\n // Back slashes before the query string get converted to forward slashes\n // See: https://code.google.com/p/chromium/issues/detail?id=25916\n var queryIndex = url.indexOf('?'),\n splitter =\n (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',\n uSplit = url.split(splitter),\n slashRegex = /\\\\/g;\n uSplit[0] = uSplit[0].replace(slashRegex, '/');\n url = uSplit.join(splitter);\n\n var rest = url;\n\n // trim before proceeding.\n // This is to support parse stuff like \" http://foo.com \\n\"\n rest = rest.trim();\n\n if (!slashesDenoteHost && url.split('#').length === 1) {\n // Try fast path regexp\n var simplePath = simplePathPattern.exec(rest);\n if (simplePath) {\n this.path = rest;\n this.href = rest;\n this.pathname = simplePath[1];\n if (simplePath[2]) {\n this.search = simplePath[2];\n if (parseQueryString) {\n this.query = querystring.parse(this.search.substr(1));\n } else {\n this.query = this.search.substr(1);\n }\n } else if (parseQueryString) {\n this.search = '';\n this.query = {};\n }\n return this;\n }\n }\n\n var proto = protocolPattern.exec(rest);\n if (proto) {\n proto = proto[0];\n var lowerProto = proto.toLowerCase();\n this.protocol = lowerProto;\n rest = rest.substr(proto.length);\n }\n\n // figure out if it's got a host\n // user@server is *always* interpreted as a hostname, and url\n // resolution will treat //foo/bar as host=foo,path=bar because that's\n // how the browser resolves relative URLs.\n if (slashesDenoteHost || proto || rest.match(/^\\/\\/[^@\\/]+@[^@\\/]+/)) {\n var slashes = rest.substr(0, 2) === '//';\n if (slashes && !(proto && hostlessProtocol[proto])) {\n rest = rest.substr(2);\n this.slashes = true;\n }\n }\n\n if (!hostlessProtocol[proto] &&\n (slashes || (proto && !slashedProtocol[proto]))) {\n\n // there's a hostname.\n // the first instance of /, ?, ;, or # ends the host.\n //\n // If there is an @ in the hostname, then non-host chars *are* allowed\n // to the left of the last @ sign, unless some host-ending character\n // comes *before* the @-sign.\n // URLs are obnoxious.\n //\n // ex:\n // http://a@b@c/ => user:a@b host:c\n // http://a@b?@c => user:a host:c path:/?@c\n\n // v0.12 TODO(isaacs): This is not quite how Chrome does things.\n // Review our test case against browsers more comprehensively.\n\n // find the first instance of any hostEndingChars\n var hostEnd = -1;\n for (var i = 0; i < hostEndingChars.length; i++) {\n var hec = rest.indexOf(hostEndingChars[i]);\n if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))\n hostEnd = hec;\n }\n\n // at this point, either we have an explicit point where the\n // auth portion cannot go past, or the last @ char is the decider.\n var auth, atSign;\n if (hostEnd === -1) {\n // atSign can be anywhere.\n atSign = rest.lastIndexOf('@');\n } else {\n // atSign must be in auth portion.\n // http://a@b/c@d => host:b auth:a path:/c@d\n atSign = rest.lastIndexOf('@', hostEnd);\n }\n\n // Now we have a portion which is definitely the auth.\n // Pull that off.\n if (atSign !== -1) {\n auth = rest.slice(0, atSign);\n rest = rest.slice(atSign + 1);\n this.auth = decodeURIComponent(auth);\n }\n\n // the host is the remaining to the left of the first non-host char\n hostEnd = -1;\n for (var i = 0; i < nonHostChars.length; i++) {\n var hec = rest.indexOf(nonHostChars[i]);\n if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))\n hostEnd = hec;\n }\n // if we still have not hit it, then the entire thing is a host.\n if (hostEnd === -1)\n hostEnd = rest.length;\n\n this.host = rest.slice(0, hostEnd);\n rest = rest.slice(hostEnd);\n\n // pull out port.\n this.parseHost();\n\n // we've indicated that there is a hostname,\n // so even if it's empty, it has to be present.\n this.hostname = this.hostname || '';\n\n // if hostname begins with [ and ends with ]\n // assume that it's an IPv6 address.\n var ipv6Hostname = this.hostname[0] === '[' &&\n this.hostname[this.hostname.length - 1] === ']';\n\n // validate a little.\n if (!ipv6Hostname) {\n var hostparts = this.hostname.split(/\\./);\n for (var i = 0, l = hostparts.length; i < l; i++) {\n var part = hostparts[i];\n if (!part) continue;\n if (!part.match(hostnamePartPattern)) {\n var newpart = '';\n for (var j = 0, k = part.length; j < k; j++) {\n if (part.charCodeAt(j) > 127) {\n // we replace non-ASCII char with a temporary placeholder\n // we need this to make sure size of hostname is not\n // broken by replacing non-ASCII by nothing\n newpart += 'x';\n } else {\n newpart += part[j];\n }\n }\n // we test again with ASCII char only\n if (!newpart.match(hostnamePartPattern)) {\n var validParts = hostparts.slice(0, i);\n var notHost = hostparts.slice(i + 1);\n var bit = part.match(hostnamePartStart);\n if (bit) {\n validParts.push(bit[1]);\n notHost.unshift(bit[2]);\n }\n if (notHost.length) {\n rest = '/' + notHost.join('.') + rest;\n }\n this.hostname = validParts.join('.');\n break;\n }\n }\n }\n }\n\n if (this.hostname.length > hostnameMaxLen) {\n this.hostname = '';\n } else {\n // hostnames are always lower case.\n this.hostname = this.hostname.toLowerCase();\n }\n\n if (!ipv6Hostname) {\n // IDNA Support: Returns a punycoded representation of \"domain\".\n // It only converts parts of the domain name that\n // have non-ASCII characters, i.e. it doesn't matter if\n // you call it with a domain that already is ASCII-only.\n this.hostname = punycode.toASCII(this.hostname);\n }\n\n var p = this.port ? ':' + this.port : '';\n var h = this.hostname || '';\n this.host = h + p;\n this.href += this.host;\n\n // strip [ and ] from the hostname\n // the host field still retains them, though\n if (ipv6Hostname) {\n this.hostname = this.hostname.substr(1, this.hostname.length - 2);\n if (rest[0] !== '/') {\n rest = '/' + rest;\n }\n }\n }\n\n // now rest is set to the post-host stuff.\n // chop off any delim chars.\n if (!unsafeProtocol[lowerProto]) {\n\n // First, make 100% sure that any \"autoEscape\" chars get\n // escaped, even if encodeURIComponent doesn't think they\n // need to be.\n for (var i = 0, l = autoEscape.length; i < l; i++) {\n var ae = autoEscape[i];\n if (rest.indexOf(ae) === -1)\n continue;\n var esc = encodeURIComponent(ae);\n if (esc === ae) {\n esc = escape(ae);\n }\n rest = rest.split(ae).join(esc);\n }\n }\n\n\n // chop off from the tail first.\n var hash = rest.indexOf('#');\n if (hash !== -1) {\n // got a fragment string.\n this.hash = rest.substr(hash);\n rest = rest.slice(0, hash);\n }\n var qm = rest.indexOf('?');\n if (qm !== -1) {\n this.search = rest.substr(qm);\n this.query = rest.substr(qm + 1);\n if (parseQueryString) {\n this.query = querystring.parse(this.query);\n }\n rest = rest.slice(0, qm);\n } else if (parseQueryString) {\n // no query string, but parseQueryString still requested\n this.search = '';\n this.query = {};\n }\n if (rest) this.pathname = rest;\n if (slashedProtocol[lowerProto] &&\n this.hostname && !this.pathname) {\n this.pathname = '/';\n }\n\n //to support http.request\n if (this.pathname || this.search) {\n var p = this.pathname || '';\n var s = this.search || '';\n this.path = p + s;\n }\n\n // finally, reconstruct the href based on what has been validated.\n this.href = this.format();\n return this;\n};\n\n// format a parsed object into a url string\nfunction urlFormat(obj) {\n // ensure it's an object, and not a string url.\n // If it's an obj, this is a no-op.\n // this way, you can call url_format() on strings\n // to clean up potentially wonky urls.\n if (util.isString(obj)) obj = urlParse(obj);\n if (!(obj instanceof Url)) return Url.prototype.format.call(obj);\n return obj.format();\n}\n\nUrl.prototype.format = function() {\n var auth = this.auth || '';\n if (auth) {\n auth = encodeURIComponent(auth);\n auth = auth.replace(/%3A/i, ':');\n auth += '@';\n }\n\n var protocol = this.protocol || '',\n pathname = this.pathname || '',\n hash = this.hash || '',\n host = false,\n query = '';\n\n if (this.host) {\n host = auth + this.host;\n } else if (this.hostname) {\n host = auth + (this.hostname.indexOf(':') === -1 ?\n this.hostname :\n '[' + this.hostname + ']');\n if (this.port) {\n host += ':' + this.port;\n }\n }\n\n if (this.query &&\n util.isObject(this.query) &&\n Object.keys(this.query).length) {\n query = querystring.stringify(this.query);\n }\n\n var search = this.search || (query && ('?' + query)) || '';\n\n if (protocol && protocol.substr(-1) !== ':') protocol += ':';\n\n // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.\n // unless they had them to begin with.\n if (this.slashes ||\n (!protocol || slashedProtocol[protocol]) && host !== false) {\n host = '//' + (host || '');\n if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;\n } else if (!host) {\n host = '';\n }\n\n if (hash && hash.charAt(0) !== '#') hash = '#' + hash;\n if (search && search.charAt(0) !== '?') search = '?' + search;\n\n pathname = pathname.replace(/[?#]/g, function(match) {\n return encodeURIComponent(match);\n });\n search = search.replace('#', '%23');\n\n return protocol + host + pathname + search + hash;\n};\n\nfunction urlResolve(source, relative) {\n return urlParse(source, false, true).resolve(relative);\n}\n\nUrl.prototype.resolve = function(relative) {\n return this.resolveObject(urlParse(relative, false, true)).format();\n};\n\nfunction urlResolveObject(source, relative) {\n if (!source) return relative;\n return urlParse(source, false, true).resolveObject(relative);\n}\n\nUrl.prototype.resolveObject = function(relative) {\n if (util.isString(relative)) {\n var rel = new Url();\n rel.parse(relative, false, true);\n relative = rel;\n }\n\n var result = new Url();\n var tkeys = Object.keys(this);\n for (var tk = 0; tk < tkeys.length; tk++) {\n var tkey = tkeys[tk];\n result[tkey] = this[tkey];\n }\n\n // hash is always overridden, no matter what.\n // even href=\"\" will remove it.\n result.hash = relative.hash;\n\n // if the relative url is empty, then there's nothing left to do here.\n if (relative.href === '') {\n result.href = result.format();\n return result;\n }\n\n // hrefs like //foo/bar always cut to the protocol.\n if (relative.slashes && !relative.protocol) {\n // take everything except the protocol from relative\n var rkeys = Object.keys(relative);\n for (var rk = 0; rk < rkeys.length; rk++) {\n var rkey = rkeys[rk];\n if (rkey !== 'protocol')\n result[rkey] = relative[rkey];\n }\n\n //urlParse appends trailing / to urls like http://www.example.com\n if (slashedProtocol[result.protocol] &&\n result.hostname && !result.pathname) {\n result.path = result.pathname = '/';\n }\n\n result.href = result.format();\n return result;\n }\n\n if (relative.protocol && relative.protocol !== result.protocol) {\n // if it's a known url protocol, then changing\n // the protocol does weird things\n // first, if it's not file:, then we MUST have a host,\n // and if there was a path\n // to begin with, then we MUST have a path.\n // if it is file:, then the host is dropped,\n // because that's known to be hostless.\n // anything else is assumed to be absolute.\n if (!slashedProtocol[relative.protocol]) {\n var keys = Object.keys(relative);\n for (var v = 0; v < keys.length; v++) {\n var k = keys[v];\n result[k] = relative[k];\n }\n result.href = result.format();\n return result;\n }\n\n result.protocol = relative.protocol;\n if (!relative.host && !hostlessProtocol[relative.protocol]) {\n var relPath = (relative.pathname || '').split('/');\n while (relPath.length && !(relative.host = relPath.shift()));\n if (!relative.host) relative.host = '';\n if (!relative.hostname) relative.hostname = '';\n if (relPath[0] !== '') relPath.unshift('');\n if (relPath.length < 2) relPath.unshift('');\n result.pathname = relPath.join('/');\n } else {\n result.pathname = relative.pathname;\n }\n result.search = relative.search;\n result.query = relative.query;\n result.host = relative.host || '';\n result.auth = relative.auth;\n result.hostname = relative.hostname || relative.host;\n result.port = relative.port;\n // to support http.request\n if (result.pathname || result.search) {\n var p = result.pathname || '';\n var s = result.search || '';\n result.path = p + s;\n }\n result.slashes = result.slashes || relative.slashes;\n result.href = result.format();\n return result;\n }\n\n var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),\n isRelAbs = (\n relative.host ||\n relative.pathname && relative.pathname.charAt(0) === '/'\n ),\n mustEndAbs = (isRelAbs || isSourceAbs ||\n (result.host && relative.pathname)),\n removeAllDots = mustEndAbs,\n srcPath = result.pathname && result.pathname.split('/') || [],\n relPath = relative.pathname && relative.pathname.split('/') || [],\n psychotic = result.protocol && !slashedProtocol[result.protocol];\n\n // if the url is a non-slashed url, then relative\n // links like ../.. should be able\n // to crawl up to the hostname, as well. This is strange.\n // result.protocol has already been set by now.\n // Later on, put the first path part into the host field.\n if (psychotic) {\n result.hostname = '';\n result.port = null;\n if (result.host) {\n if (srcPath[0] === '') srcPath[0] = result.host;\n else srcPath.unshift(result.host);\n }\n result.host = '';\n if (relative.protocol) {\n relative.hostname = null;\n relative.port = null;\n if (relative.host) {\n if (relPath[0] === '') relPath[0] = relative.host;\n else relPath.unshift(relative.host);\n }\n relative.host = null;\n }\n mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');\n }\n\n if (isRelAbs) {\n // it's absolute.\n result.host = (relative.host || relative.host === '') ?\n relative.host : result.host;\n result.hostname = (relative.hostname || relative.hostname === '') ?\n relative.hostname : result.hostname;\n result.search = relative.search;\n result.query = relative.query;\n srcPath = relPath;\n // fall through to the dot-handling below.\n } else if (relPath.length) {\n // it's relative\n // throw away the existing file, and take the new path instead.\n if (!srcPath) srcPath = [];\n srcPath.pop();\n srcPath = srcPath.concat(relPath);\n result.search = relative.search;\n result.query = relative.query;\n } else if (!util.isNullOrUndefined(relative.search)) {\n // just pull out the search.\n // like href='?foo'.\n // Put this after the other two cases because it simplifies the booleans\n if (psychotic) {\n result.hostname = result.host = srcPath.shift();\n //occationaly the auth can get stuck only in host\n //this especially happens in cases like\n //url.resolveObject('mailto:local1@domain1', 'local2@domain2')\n var authInHost = result.host && result.host.indexOf('@') > 0 ?\n result.host.split('@') : false;\n if (authInHost) {\n result.auth = authInHost.shift();\n result.host = result.hostname = authInHost.shift();\n }\n }\n result.search = relative.search;\n result.query = relative.query;\n //to support http.request\n if (!util.isNull(result.pathname) || !util.isNull(result.search)) {\n result.path = (result.pathname ? result.pathname : '') +\n (result.search ? result.search : '');\n }\n result.href = result.format();\n return result;\n }\n\n if (!srcPath.length) {\n // no path at all. easy.\n // we've already handled the other stuff above.\n result.pathname = null;\n //to support http.request\n if (result.search) {\n result.path = '/' + result.search;\n } else {\n result.path = null;\n }\n result.href = result.format();\n return result;\n }\n\n // if a url ENDs in . or .., then it must get a trailing slash.\n // however, if it ends in anything else non-slashy,\n // then it must NOT get a trailing slash.\n var last = srcPath.slice(-1)[0];\n var hasTrailingSlash = (\n (result.host || relative.host || srcPath.length > 1) &&\n (last === '.' || last === '..') || last === '');\n\n // strip single dots, resolve double dots to parent dir\n // if the path tries to go above the root, `up` ends up > 0\n var up = 0;\n for (var i = srcPath.length; i >= 0; i--) {\n last = srcPath[i];\n if (last === '.') {\n srcPath.splice(i, 1);\n } else if (last === '..') {\n srcPath.splice(i, 1);\n up++;\n } else if (up) {\n srcPath.splice(i, 1);\n up--;\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (!mustEndAbs && !removeAllDots) {\n for (; up--; up) {\n srcPath.unshift('..');\n }\n }\n\n if (mustEndAbs && srcPath[0] !== '' &&\n (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {\n srcPath.unshift('');\n }\n\n if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {\n srcPath.push('');\n }\n\n var isAbsolute = srcPath[0] === '' ||\n (srcPath[0] && srcPath[0].charAt(0) === '/');\n\n // put the host back\n if (psychotic) {\n result.hostname = result.host = isAbsolute ? '' :\n srcPath.length ? srcPath.shift() : '';\n //occationaly the auth can get stuck only in host\n //this especially happens in cases like\n //url.resolveObject('mailto:local1@domain1', 'local2@domain2')\n var authInHost = result.host && result.host.indexOf('@') > 0 ?\n result.host.split('@') : false;\n if (authInHost) {\n result.auth = authInHost.shift();\n result.host = result.hostname = authInHost.shift();\n }\n }\n\n mustEndAbs = mustEndAbs || (result.host && srcPath.length);\n\n if (mustEndAbs && !isAbsolute) {\n srcPath.unshift('');\n }\n\n if (!srcPath.length) {\n result.pathname = null;\n result.path = null;\n } else {\n result.pathname = srcPath.join('/');\n }\n\n //to support request.http\n if (!util.isNull(result.pathname) || !util.isNull(result.search)) {\n result.path = (result.pathname ? result.pathname : '') +\n (result.search ? result.search : '');\n }\n result.auth = relative.auth || result.auth;\n result.slashes = result.slashes || relative.slashes;\n result.href = result.format();\n return result;\n};\n\nUrl.prototype.parseHost = function() {\n var host = this.host;\n var port = portPattern.exec(host);\n if (port) {\n port = port[0];\n if (port !== ':') {\n this.port = port.substr(1);\n }\n host = host.substr(0, host.length - port.length);\n }\n if (host) this.hostname = host;\n};\n","/*! https://mths.be/punycode v1.4.1 by @mathias */\n;(function(root) {\n\n\t/** Detect free variables */\n\tvar freeExports = typeof exports == 'object' && exports &&\n\t\t!exports.nodeType && exports;\n\tvar freeModule = typeof module == 'object' && module &&\n\t\t!module.nodeType && module;\n\tvar freeGlobal = typeof global == 'object' && global;\n\tif (\n\t\tfreeGlobal.global === freeGlobal ||\n\t\tfreeGlobal.window === freeGlobal ||\n\t\tfreeGlobal.self === freeGlobal\n\t) {\n\t\troot = freeGlobal;\n\t}\n\n\t/**\n\t * The `punycode` object.\n\t * @name punycode\n\t * @type Object\n\t */\n\tvar punycode,\n\n\t/** Highest positive signed 32-bit float value */\n\tmaxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1\n\n\t/** Bootstring parameters */\n\tbase = 36,\n\ttMin = 1,\n\ttMax = 26,\n\tskew = 38,\n\tdamp = 700,\n\tinitialBias = 72,\n\tinitialN = 128, // 0x80\n\tdelimiter = '-', // '\\x2D'\n\n\t/** Regular expressions */\n\tregexPunycode = /^xn--/,\n\tregexNonASCII = /[^\\x20-\\x7E]/, // unprintable ASCII chars + non-ASCII chars\n\tregexSeparators = /[\\x2E\\u3002\\uFF0E\\uFF61]/g, // RFC 3490 separators\n\n\t/** Error messages */\n\terrors = {\n\t\t'overflow': 'Overflow: input needs wider integers to process',\n\t\t'not-basic': 'Illegal input >= 0x80 (not a basic code point)',\n\t\t'invalid-input': 'Invalid input'\n\t},\n\n\t/** Convenience shortcuts */\n\tbaseMinusTMin = base - tMin,\n\tfloor = Math.floor,\n\tstringFromCharCode = String.fromCharCode,\n\n\t/** Temporary variable */\n\tkey;\n\n\t/*--------------------------------------------------------------------------*/\n\n\t/**\n\t * A generic error utility function.\n\t * @private\n\t * @param {String} type The error type.\n\t * @returns {Error} Throws a `RangeError` with the applicable error message.\n\t */\n\tfunction error(type) {\n\t\tthrow new RangeError(errors[type]);\n\t}\n\n\t/**\n\t * A generic `Array#map` utility function.\n\t * @private\n\t * @param {Array} array The array to iterate over.\n\t * @param {Function} callback The function that gets called for every array\n\t * item.\n\t * @returns {Array} A new array of values returned by the callback function.\n\t */\n\tfunction map(array, fn) {\n\t\tvar length = array.length;\n\t\tvar result = [];\n\t\twhile (length--) {\n\t\t\tresult[length] = fn(array[length]);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * A simple `Array#map`-like wrapper to work with domain name strings or email\n\t * addresses.\n\t * @private\n\t * @param {String} domain The domain name or email address.\n\t * @param {Function} callback The function that gets called for every\n\t * character.\n\t * @returns {Array} A new string of characters returned by the callback\n\t * function.\n\t */\n\tfunction mapDomain(string, fn) {\n\t\tvar parts = string.split('@');\n\t\tvar result = '';\n\t\tif (parts.length > 1) {\n\t\t\t// In email addresses, only the domain name should be punycoded. Leave\n\t\t\t// the local part (i.e. everything up to `@`) intact.\n\t\t\tresult = parts[0] + '@';\n\t\t\tstring = parts[1];\n\t\t}\n\t\t// Avoid `split(regex)` for IE8 compatibility. See #17.\n\t\tstring = string.replace(regexSeparators, '\\x2E');\n\t\tvar labels = string.split('.');\n\t\tvar encoded = map(labels, fn).join('.');\n\t\treturn result + encoded;\n\t}\n\n\t/**\n\t * Creates an array containing the numeric code points of each Unicode\n\t * character in the string. While JavaScript uses UCS-2 internally,\n\t * this function will convert a pair of surrogate halves (each of which\n\t * UCS-2 exposes as separate characters) into a single code point,\n\t * matching UTF-16.\n\t * @see `punycode.ucs2.encode`\n\t * @see \n\t * @memberOf punycode.ucs2\n\t * @name decode\n\t * @param {String} string The Unicode input string (UCS-2).\n\t * @returns {Array} The new array of code points.\n\t */\n\tfunction ucs2decode(string) {\n\t\tvar output = [],\n\t\t counter = 0,\n\t\t length = string.length,\n\t\t value,\n\t\t extra;\n\t\twhile (counter < length) {\n\t\t\tvalue = string.charCodeAt(counter++);\n\t\t\tif (value >= 0xD800 && value <= 0xDBFF && counter < length) {\n\t\t\t\t// high surrogate, and there is a next character\n\t\t\t\textra = string.charCodeAt(counter++);\n\t\t\t\tif ((extra & 0xFC00) == 0xDC00) { // low surrogate\n\t\t\t\t\toutput.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);\n\t\t\t\t} else {\n\t\t\t\t\t// unmatched surrogate; only append this code unit, in case the next\n\t\t\t\t\t// code unit is the high surrogate of a surrogate pair\n\t\t\t\t\toutput.push(value);\n\t\t\t\t\tcounter--;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\toutput.push(value);\n\t\t\t}\n\t\t}\n\t\treturn output;\n\t}\n\n\t/**\n\t * Creates a string based on an array of numeric code points.\n\t * @see `punycode.ucs2.decode`\n\t * @memberOf punycode.ucs2\n\t * @name encode\n\t * @param {Array} codePoints The array of numeric code points.\n\t * @returns {String} The new Unicode string (UCS-2).\n\t */\n\tfunction ucs2encode(array) {\n\t\treturn map(array, function(value) {\n\t\t\tvar output = '';\n\t\t\tif (value > 0xFFFF) {\n\t\t\t\tvalue -= 0x10000;\n\t\t\t\toutput += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);\n\t\t\t\tvalue = 0xDC00 | value & 0x3FF;\n\t\t\t}\n\t\t\toutput += stringFromCharCode(value);\n\t\t\treturn output;\n\t\t}).join('');\n\t}\n\n\t/**\n\t * Converts a basic code point into a digit/integer.\n\t * @see `digitToBasic()`\n\t * @private\n\t * @param {Number} codePoint The basic numeric code point value.\n\t * @returns {Number} The numeric value of a basic code point (for use in\n\t * representing integers) in the range `0` to `base - 1`, or `base` if\n\t * the code point does not represent a value.\n\t */\n\tfunction basicToDigit(codePoint) {\n\t\tif (codePoint - 48 < 10) {\n\t\t\treturn codePoint - 22;\n\t\t}\n\t\tif (codePoint - 65 < 26) {\n\t\t\treturn codePoint - 65;\n\t\t}\n\t\tif (codePoint - 97 < 26) {\n\t\t\treturn codePoint - 97;\n\t\t}\n\t\treturn base;\n\t}\n\n\t/**\n\t * Converts a digit/integer into a basic code point.\n\t * @see `basicToDigit()`\n\t * @private\n\t * @param {Number} digit The numeric value of a basic code point.\n\t * @returns {Number} The basic code point whose value (when used for\n\t * representing integers) is `digit`, which needs to be in the range\n\t * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is\n\t * used; else, the lowercase form is used. The behavior is undefined\n\t * if `flag` is non-zero and `digit` has no uppercase form.\n\t */\n\tfunction digitToBasic(digit, flag) {\n\t\t// 0..25 map to ASCII a..z or A..Z\n\t\t// 26..35 map to ASCII 0..9\n\t\treturn digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);\n\t}\n\n\t/**\n\t * Bias adaptation function as per section 3.4 of RFC 3492.\n\t * https://tools.ietf.org/html/rfc3492#section-3.4\n\t * @private\n\t */\n\tfunction adapt(delta, numPoints, firstTime) {\n\t\tvar k = 0;\n\t\tdelta = firstTime ? floor(delta / damp) : delta >> 1;\n\t\tdelta += floor(delta / numPoints);\n\t\tfor (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {\n\t\t\tdelta = floor(delta / baseMinusTMin);\n\t\t}\n\t\treturn floor(k + (baseMinusTMin + 1) * delta / (delta + skew));\n\t}\n\n\t/**\n\t * Converts a Punycode string of ASCII-only symbols to a string of Unicode\n\t * symbols.\n\t * @memberOf punycode\n\t * @param {String} input The Punycode string of ASCII-only symbols.\n\t * @returns {String} The resulting string of Unicode symbols.\n\t */\n\tfunction decode(input) {\n\t\t// Don't use UCS-2\n\t\tvar output = [],\n\t\t inputLength = input.length,\n\t\t out,\n\t\t i = 0,\n\t\t n = initialN,\n\t\t bias = initialBias,\n\t\t basic,\n\t\t j,\n\t\t index,\n\t\t oldi,\n\t\t w,\n\t\t k,\n\t\t digit,\n\t\t t,\n\t\t /** Cached calculation results */\n\t\t baseMinusT;\n\n\t\t// Handle the basic code points: let `basic` be the number of input code\n\t\t// points before the last delimiter, or `0` if there is none, then copy\n\t\t// the first basic code points to the output.\n\n\t\tbasic = input.lastIndexOf(delimiter);\n\t\tif (basic < 0) {\n\t\t\tbasic = 0;\n\t\t}\n\n\t\tfor (j = 0; j < basic; ++j) {\n\t\t\t// if it's not a basic code point\n\t\t\tif (input.charCodeAt(j) >= 0x80) {\n\t\t\t\terror('not-basic');\n\t\t\t}\n\t\t\toutput.push(input.charCodeAt(j));\n\t\t}\n\n\t\t// Main decoding loop: start just after the last delimiter if any basic code\n\t\t// points were copied; start at the beginning otherwise.\n\n\t\tfor (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {\n\n\t\t\t// `index` is the index of the next character to be consumed.\n\t\t\t// Decode a generalized variable-length integer into `delta`,\n\t\t\t// which gets added to `i`. The overflow checking is easier\n\t\t\t// if we increase `i` as we go, then subtract off its starting\n\t\t\t// value at the end to obtain `delta`.\n\t\t\tfor (oldi = i, w = 1, k = base; /* no condition */; k += base) {\n\n\t\t\t\tif (index >= inputLength) {\n\t\t\t\t\terror('invalid-input');\n\t\t\t\t}\n\n\t\t\t\tdigit = basicToDigit(input.charCodeAt(index++));\n\n\t\t\t\tif (digit >= base || digit > floor((maxInt - i) / w)) {\n\t\t\t\t\terror('overflow');\n\t\t\t\t}\n\n\t\t\t\ti += digit * w;\n\t\t\t\tt = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);\n\n\t\t\t\tif (digit < t) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tbaseMinusT = base - t;\n\t\t\t\tif (w > floor(maxInt / baseMinusT)) {\n\t\t\t\t\terror('overflow');\n\t\t\t\t}\n\n\t\t\t\tw *= baseMinusT;\n\n\t\t\t}\n\n\t\t\tout = output.length + 1;\n\t\t\tbias = adapt(i - oldi, out, oldi == 0);\n\n\t\t\t// `i` was supposed to wrap around from `out` to `0`,\n\t\t\t// incrementing `n` each time, so we'll fix that now:\n\t\t\tif (floor(i / out) > maxInt - n) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\n\t\t\tn += floor(i / out);\n\t\t\ti %= out;\n\n\t\t\t// Insert `n` at position `i` of the output\n\t\t\toutput.splice(i++, 0, n);\n\n\t\t}\n\n\t\treturn ucs2encode(output);\n\t}\n\n\t/**\n\t * Converts a string of Unicode symbols (e.g. a domain name label) to a\n\t * Punycode string of ASCII-only symbols.\n\t * @memberOf punycode\n\t * @param {String} input The string of Unicode symbols.\n\t * @returns {String} The resulting Punycode string of ASCII-only symbols.\n\t */\n\tfunction encode(input) {\n\t\tvar n,\n\t\t delta,\n\t\t handledCPCount,\n\t\t basicLength,\n\t\t bias,\n\t\t j,\n\t\t m,\n\t\t q,\n\t\t k,\n\t\t t,\n\t\t currentValue,\n\t\t output = [],\n\t\t /** `inputLength` will hold the number of code points in `input`. */\n\t\t inputLength,\n\t\t /** Cached calculation results */\n\t\t handledCPCountPlusOne,\n\t\t baseMinusT,\n\t\t qMinusT;\n\n\t\t// Convert the input in UCS-2 to Unicode\n\t\tinput = ucs2decode(input);\n\n\t\t// Cache the length\n\t\tinputLength = input.length;\n\n\t\t// Initialize the state\n\t\tn = initialN;\n\t\tdelta = 0;\n\t\tbias = initialBias;\n\n\t\t// Handle the basic code points\n\t\tfor (j = 0; j < inputLength; ++j) {\n\t\t\tcurrentValue = input[j];\n\t\t\tif (currentValue < 0x80) {\n\t\t\t\toutput.push(stringFromCharCode(currentValue));\n\t\t\t}\n\t\t}\n\n\t\thandledCPCount = basicLength = output.length;\n\n\t\t// `handledCPCount` is the number of code points that have been handled;\n\t\t// `basicLength` is the number of basic code points.\n\n\t\t// Finish the basic string - if it is not empty - with a delimiter\n\t\tif (basicLength) {\n\t\t\toutput.push(delimiter);\n\t\t}\n\n\t\t// Main encoding loop:\n\t\twhile (handledCPCount < inputLength) {\n\n\t\t\t// All non-basic code points < n have been handled already. Find the next\n\t\t\t// larger one:\n\t\t\tfor (m = maxInt, j = 0; j < inputLength; ++j) {\n\t\t\t\tcurrentValue = input[j];\n\t\t\t\tif (currentValue >= n && currentValue < m) {\n\t\t\t\t\tm = currentValue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Increase `delta` enough to advance the decoder's state to ,\n\t\t\t// but guard against overflow\n\t\t\thandledCPCountPlusOne = handledCPCount + 1;\n\t\t\tif (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {\n\t\t\t\terror('overflow');\n\t\t\t}\n\n\t\t\tdelta += (m - n) * handledCPCountPlusOne;\n\t\t\tn = m;\n\n\t\t\tfor (j = 0; j < inputLength; ++j) {\n\t\t\t\tcurrentValue = input[j];\n\n\t\t\t\tif (currentValue < n && ++delta > maxInt) {\n\t\t\t\t\terror('overflow');\n\t\t\t\t}\n\n\t\t\t\tif (currentValue == n) {\n\t\t\t\t\t// Represent delta as a generalized variable-length integer\n\t\t\t\t\tfor (q = delta, k = base; /* no condition */; k += base) {\n\t\t\t\t\t\tt = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);\n\t\t\t\t\t\tif (q < t) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tqMinusT = q - t;\n\t\t\t\t\t\tbaseMinusT = base - t;\n\t\t\t\t\t\toutput.push(\n\t\t\t\t\t\t\tstringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))\n\t\t\t\t\t\t);\n\t\t\t\t\t\tq = floor(qMinusT / baseMinusT);\n\t\t\t\t\t}\n\n\t\t\t\t\toutput.push(stringFromCharCode(digitToBasic(q, 0)));\n\t\t\t\t\tbias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);\n\t\t\t\t\tdelta = 0;\n\t\t\t\t\t++handledCPCount;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t++delta;\n\t\t\t++n;\n\n\t\t}\n\t\treturn output.join('');\n\t}\n\n\t/**\n\t * Converts a Punycode string representing a domain name or an email address\n\t * to Unicode. Only the Punycoded parts of the input will be converted, i.e.\n\t * it doesn't matter if you call it on a string that has already been\n\t * converted to Unicode.\n\t * @memberOf punycode\n\t * @param {String} input The Punycoded domain name or email address to\n\t * convert to Unicode.\n\t * @returns {String} The Unicode representation of the given Punycode\n\t * string.\n\t */\n\tfunction toUnicode(input) {\n\t\treturn mapDomain(input, function(string) {\n\t\t\treturn regexPunycode.test(string)\n\t\t\t\t? decode(string.slice(4).toLowerCase())\n\t\t\t\t: string;\n\t\t});\n\t}\n\n\t/**\n\t * Converts a Unicode string representing a domain name or an email address to\n\t * Punycode. Only the non-ASCII parts of the domain name will be converted,\n\t * i.e. it doesn't matter if you call it with a domain that's already in\n\t * ASCII.\n\t * @memberOf punycode\n\t * @param {String} input The domain name or email address to convert, as a\n\t * Unicode string.\n\t * @returns {String} The Punycode representation of the given domain name or\n\t * email address.\n\t */\n\tfunction toASCII(input) {\n\t\treturn mapDomain(input, function(string) {\n\t\t\treturn regexNonASCII.test(string)\n\t\t\t\t? 'xn--' + encode(string)\n\t\t\t\t: string;\n\t\t});\n\t}\n\n\t/*--------------------------------------------------------------------------*/\n\n\t/** Define the public API */\n\tpunycode = {\n\t\t/**\n\t\t * A string representing the current Punycode.js version number.\n\t\t * @memberOf punycode\n\t\t * @type String\n\t\t */\n\t\t'version': '1.4.1',\n\t\t/**\n\t\t * An object of methods to convert from JavaScript's internal character\n\t\t * representation (UCS-2) to Unicode code points, and back.\n\t\t * @see \n\t\t * @memberOf punycode\n\t\t * @type Object\n\t\t */\n\t\t'ucs2': {\n\t\t\t'decode': ucs2decode,\n\t\t\t'encode': ucs2encode\n\t\t},\n\t\t'decode': decode,\n\t\t'encode': encode,\n\t\t'toASCII': toASCII,\n\t\t'toUnicode': toUnicode\n\t};\n\n\t/** Expose `punycode` */\n\t// Some AMD build optimizers, like r.js, check for specific condition patterns\n\t// like the following:\n\tif (\n\t\ttypeof define == 'function' &&\n\t\ttypeof define.amd == 'object' &&\n\t\tdefine.amd\n\t) {\n\t\tdefine('punycode', function() {\n\t\t\treturn punycode;\n\t\t});\n\t} else if (freeExports && freeModule) {\n\t\tif (module.exports == freeExports) {\n\t\t\t// in Node.js, io.js, or RingoJS v0.8.0+\n\t\t\tfreeModule.exports = punycode;\n\t\t} else {\n\t\t\t// in Narwhal or RingoJS v0.7.0-\n\t\t\tfor (key in punycode) {\n\t\t\t\tpunycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// in Rhino or a web browser\n\t\troot.punycode = punycode;\n\t}\n\n}(this));\n","module.exports = function(module) {\n\tif (!module.webpackPolyfill) {\n\t\tmodule.deprecate = function() {};\n\t\tmodule.paths = [];\n\t\t// module.parent = undefined by default\n\t\tif (!module.children) module.children = [];\n\t\tObject.defineProperty(module, \"loaded\", {\n\t\t\tenumerable: true,\n\t\t\tget: function() {\n\t\t\t\treturn module.l;\n\t\t\t}\n\t\t});\n\t\tObject.defineProperty(module, \"id\", {\n\t\t\tenumerable: true,\n\t\t\tget: function() {\n\t\t\t\treturn module.i;\n\t\t\t}\n\t\t});\n\t\tmodule.webpackPolyfill = 1;\n\t}\n\treturn module;\n};\n","'use strict';\n\nmodule.exports = {\n isString: function(arg) {\n return typeof(arg) === 'string';\n },\n isObject: function(arg) {\n return typeof(arg) === 'object' && arg !== null;\n },\n isNull: function(arg) {\n return arg === null;\n },\n isNullOrUndefined: function(arg) {\n return arg == null;\n }\n};\n","'use strict';\n\nexports.decode = exports.parse = require('./decode');\nexports.encode = exports.stringify = require('./encode');\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\n// If obj.hasOwnProperty has been overridden, then calling\n// obj.hasOwnProperty(prop) will break.\n// See: https://github.com/joyent/node/issues/1707\nfunction hasOwnProperty(obj, prop) {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nmodule.exports = function(qs, sep, eq, options) {\n sep = sep || '&';\n eq = eq || '=';\n var obj = {};\n\n if (typeof qs !== 'string' || qs.length === 0) {\n return obj;\n }\n\n var regexp = /\\+/g;\n qs = qs.split(sep);\n\n var maxKeys = 1000;\n if (options && typeof options.maxKeys === 'number') {\n maxKeys = options.maxKeys;\n }\n\n var len = qs.length;\n // maxKeys <= 0 means that we should not limit keys count\n if (maxKeys > 0 && len > maxKeys) {\n len = maxKeys;\n }\n\n for (var i = 0; i < len; ++i) {\n var x = qs[i].replace(regexp, '%20'),\n idx = x.indexOf(eq),\n kstr, vstr, k, v;\n\n if (idx >= 0) {\n kstr = x.substr(0, idx);\n vstr = x.substr(idx + 1);\n } else {\n kstr = x;\n vstr = '';\n }\n\n k = decodeURIComponent(kstr);\n v = decodeURIComponent(vstr);\n\n if (!hasOwnProperty(obj, k)) {\n obj[k] = v;\n } else if (isArray(obj[k])) {\n obj[k].push(v);\n } else {\n obj[k] = [obj[k], v];\n }\n }\n\n return obj;\n};\n\nvar isArray = Array.isArray || function (xs) {\n return Object.prototype.toString.call(xs) === '[object Array]';\n};\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar stringifyPrimitive = function(v) {\n switch (typeof v) {\n case 'string':\n return v;\n\n case 'boolean':\n return v ? 'true' : 'false';\n\n case 'number':\n return isFinite(v) ? v : '';\n\n default:\n return '';\n }\n};\n\nmodule.exports = function(obj, sep, eq, name) {\n sep = sep || '&';\n eq = eq || '=';\n if (obj === null) {\n obj = undefined;\n }\n\n if (typeof obj === 'object') {\n return map(objectKeys(obj), function(k) {\n var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;\n if (isArray(obj[k])) {\n return map(obj[k], function(v) {\n return ks + encodeURIComponent(stringifyPrimitive(v));\n }).join(sep);\n } else {\n return ks + encodeURIComponent(stringifyPrimitive(obj[k]));\n }\n }).join(sep);\n\n }\n\n if (!name) return '';\n return encodeURIComponent(stringifyPrimitive(name)) + eq +\n encodeURIComponent(stringifyPrimitive(obj));\n};\n\nvar isArray = Array.isArray || function (xs) {\n return Object.prototype.toString.call(xs) === '[object Array]';\n};\n\nfunction map (xs, f) {\n if (xs.map) return xs.map(f);\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n res.push(f(xs[i], i));\n }\n return res;\n}\n\nvar objectKeys = Object.keys || function (obj) {\n var res = [];\n for (var key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);\n }\n return res;\n};\n","/* (ignored) */","/* (ignored) */","/* (ignored) */","/* (ignored) */","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { AudioStreamFormatImpl } from \"../../src/sdk/Audio/AudioStreamFormat\";\r\nimport {\r\n IAudioStreamNode,\r\n IStreamChunk,\r\n Promise,\r\n PromiseHelper,\r\n} from \"../common/Exports\";\r\n\r\nexport class ReplayableAudioNode implements IAudioStreamNode {\r\n private privAudioNode: IAudioStreamNode;\r\n private privBytesPerSecond: number;\r\n private privBuffers: BufferEntry[] = [];\r\n private privReplayOffset: number = 0;\r\n private privLastShrinkOffset: number = 0;\r\n private privBufferStartOffset: number = 0;\r\n private privBufferSerial: number = 0;\r\n private privBufferedBytes: number = 0;\r\n private privReplay: boolean = false;\r\n private privLastChunkAcquiredTime: number = 0;\r\n\r\n public constructor(audioSource: IAudioStreamNode, bytesPerSecond: number) {\r\n this.privAudioNode = audioSource;\r\n this.privBytesPerSecond = bytesPerSecond;\r\n }\r\n\r\n public id = (): string => {\r\n return this.privAudioNode.id();\r\n }\r\n\r\n // Reads and returns the next chunk of audio buffer.\r\n // If replay of existing buffers are needed, read() will first seek and replay\r\n // existing content, and upoin completion it will read new content from the underlying\r\n // audio node, saving that content into the replayable buffers.\r\n public read(): Promise> {\r\n // if there is a replay request to honor.\r\n if (!!this.privReplay && this.privBuffers.length !== 0) {\r\n // Find the start point in the buffers.\r\n // Offsets are in 100ns increments.\r\n // So how many bytes do we need to seek to get the right offset?\r\n const offsetToSeek: number = this.privReplayOffset - this.privBufferStartOffset;\r\n\r\n let bytesToSeek: number = Math.round(offsetToSeek * this.privBytesPerSecond * 1e-7);\r\n if (0 !== (bytesToSeek % 2)) {\r\n bytesToSeek++;\r\n }\r\n\r\n let i: number = 0;\r\n\r\n while (i < this.privBuffers.length && bytesToSeek >= this.privBuffers[i].chunk.buffer.byteLength) {\r\n bytesToSeek -= this.privBuffers[i++].chunk.buffer.byteLength;\r\n }\r\n\r\n const retVal: ArrayBuffer = this.privBuffers[i].chunk.buffer.slice(bytesToSeek);\r\n\r\n this.privReplayOffset += (retVal.byteLength / this.privBytesPerSecond) * 1e+7;\r\n\r\n // If we've reached the end of the buffers, stop replaying.\r\n if (i === this.privBuffers.length - 1) {\r\n this.privReplay = false;\r\n }\r\n\r\n return PromiseHelper.fromResult>({\r\n buffer: retVal,\r\n isEnd: false,\r\n timeReceived: this.privBuffers[i].chunk.timeReceived,\r\n });\r\n }\r\n\r\n return this.privAudioNode.read()\r\n .onSuccessContinueWith((result: IStreamChunk) => {\r\n if (result && result.buffer) {\r\n this.privBuffers.push(new BufferEntry(result, this.privBufferSerial++, this.privBufferedBytes));\r\n this.privBufferedBytes += result.buffer.byteLength;\r\n }\r\n return result;\r\n });\r\n }\r\n\r\n public detach(): void {\r\n this.privAudioNode.detach();\r\n this.privBuffers = undefined;\r\n }\r\n\r\n public replay(): void {\r\n if (this.privBuffers && 0 !== this.privBuffers.length) {\r\n this.privReplay = true;\r\n this.privReplayOffset = this.privLastShrinkOffset;\r\n }\r\n }\r\n\r\n // Shrinks the existing audio buffers to start at the new offset, or at the\r\n // beginning of the buffer closest to the requested offset.\r\n // A replay request will start from the last shrink point.\r\n public shrinkBuffers(offset: number): void {\r\n if (this.privBuffers === undefined) {\r\n return;\r\n }\r\n\r\n this.privLastShrinkOffset = offset;\r\n\r\n // Find the start point in the buffers.\r\n // Offsets are in 100ns increments.\r\n // So how many bytes do we need to seek to get the right offset?\r\n const offsetToSeek: number = offset - this.privBufferStartOffset;\r\n\r\n let bytesToSeek: number = Math.round(offsetToSeek * this.privBytesPerSecond * 1e-7);\r\n\r\n let i: number = 0;\r\n\r\n while (i < this.privBuffers.length && bytesToSeek >= this.privBuffers[i].chunk.buffer.byteLength) {\r\n bytesToSeek -= this.privBuffers[i++].chunk.buffer.byteLength;\r\n }\r\n this.privBufferStartOffset = Math.round(offset - ((bytesToSeek / this.privBytesPerSecond) * 1e+7));\r\n this.privBuffers = this.privBuffers.slice(i);\r\n }\r\n\r\n // Finds the time a buffer of audio was first seen by offset.\r\n public findTimeAtOffset(offset: number): number {\r\n if (offset < this.privBufferStartOffset || this.privBuffers === undefined) {\r\n return 0;\r\n }\r\n\r\n for (const value of this.privBuffers) {\r\n const startOffset: number = (value.byteOffset / this.privBytesPerSecond) * 1e7;\r\n const endOffset: number = startOffset + ((value.chunk.buffer.byteLength / this.privBytesPerSecond) * 1e7);\r\n\r\n if (offset >= startOffset && offset <= endOffset) {\r\n return value.chunk.timeReceived;\r\n }\r\n }\r\n\r\n return 0;\r\n }\r\n}\r\n\r\n// Primary use of this class is to help debugging problems with the replay\r\n// code. If the memory cost of alloc / dealloc gets too much, drop it and just use\r\n// the ArrayBuffer directly.\r\n// tslint:disable-next-line:max-classes-per-file\r\nclass BufferEntry {\r\n public chunk: IStreamChunk;\r\n public serial: number;\r\n public byteOffset: number;\r\n\r\n public constructor(chunk: IStreamChunk, serial: number, byteOffset: number) {\r\n this.chunk = chunk;\r\n this.serial = serial;\r\n this.byteOffset = byteOffset;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { RecognizerConfig } from \"../common.speech/Exports\";\r\nimport { PropertyCollection, PropertyId } from \"../sdk/Exports\";\r\n\r\nexport class ProxyInfo {\r\n private privProxyHostName: string;\r\n private privProxyPort: number;\r\n private privProxyUserName: string;\r\n private privProxyPassword: string;\r\n\r\n private constructor(proxyHostName: string, proxyPort: number, proxyUserName: string, proxyPassword: string) {\r\n this.privProxyHostName = proxyHostName;\r\n this.privProxyPort = proxyPort;\r\n this.privProxyUserName = proxyUserName;\r\n this.privProxyPassword = proxyPassword;\r\n }\r\n\r\n public static fromParameters(parameters: PropertyCollection): ProxyInfo {\r\n return new ProxyInfo(parameters.getProperty(PropertyId.SpeechServiceConnection_ProxyHostName),\r\n parseInt(parameters.getProperty(PropertyId.SpeechServiceConnection_ProxyPort), 10),\r\n parameters.getProperty(PropertyId.SpeechServiceConnection_ProxyUserName),\r\n parameters.getProperty(PropertyId.SpeechServiceConnection_ProxyPassword));\r\n }\r\n\r\n public static fromRecognizerConfig(config: RecognizerConfig): ProxyInfo {\r\n return this.fromParameters(config.parameters);\r\n }\r\n\r\n public get HostName(): string {\r\n return this.privProxyHostName;\r\n }\r\n\r\n public get Port(): number {\r\n return this.privProxyPort;\r\n }\r\n\r\n public get UserName(): string {\r\n return this.privProxyUserName;\r\n }\r\n\r\n public get Password(): string {\r\n return this.privProxyPassword;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n ArgumentNullError,\r\n Deferred,\r\n Promise,\r\n} from \"../common/Exports\";\r\nimport { IRequestOptions } from \"./Exports\";\r\n\r\n// Node.JS specific xmlhttprequest / browser support.\r\nimport * as XHR from \"xmlhttprequest-ts\";\r\n\r\nexport enum RestRequestType {\r\n Get = \"get\",\r\n Post = \"post\",\r\n Delete = \"delete\",\r\n File = \"file\",\r\n}\r\n\r\nexport interface IRestResponse {\r\n ok: boolean;\r\n status: number;\r\n statusText: string;\r\n data: string;\r\n json: () => T;\r\n headers: string;\r\n}\r\n\r\n// accept rest operations via request method and return abstracted objects from server response\r\nexport class RestMessageAdapter {\r\n\r\n private privTimeout: number;\r\n private privIgnoreCache: boolean;\r\n private privHeaders: { [key: string]: string; };\r\n\r\n public constructor(\r\n configParams: IRequestOptions,\r\n connectionId?: string\r\n ) {\r\n\r\n if (!configParams) {\r\n throw new ArgumentNullError(\"configParams\");\r\n }\r\n\r\n this.privHeaders = configParams.headers;\r\n this.privTimeout = configParams.timeout;\r\n this.privIgnoreCache = configParams.ignoreCache;\r\n }\r\n\r\n public setHeaders(key: string, value: string ): void {\r\n this.privHeaders[key] = value;\r\n }\r\n\r\n public request(\r\n method: RestRequestType,\r\n uri: string,\r\n queryParams: any = {},\r\n body: any = null,\r\n binaryBody: Blob | Buffer = null,\r\n ): Promise {\r\n\r\n const responseReceivedDeferral = new Deferred();\r\n\r\n let xhr: XMLHttpRequest | XHR.XMLHttpRequest;\r\n if (typeof (XMLHttpRequest) === \"undefined\") {\r\n xhr = new XHR.XMLHttpRequest();\r\n } else {\r\n xhr = new XMLHttpRequest();\r\n }\r\n const requestCommand = method === RestRequestType.File ? \"post\" : method;\r\n xhr.open(requestCommand, this.withQuery(uri, queryParams), true);\r\n\r\n if (this.privHeaders) {\r\n Object.keys(this.privHeaders).forEach((key: any) => xhr.setRequestHeader(key, this.privHeaders[key]));\r\n }\r\n\r\n if (this.privIgnoreCache) {\r\n xhr.setRequestHeader(\"Cache-Control\", \"no-cache\");\r\n }\r\n\r\n xhr.timeout = this.privTimeout;\r\n\r\n xhr.onload = () => {\r\n responseReceivedDeferral.resolve(this.parseXHRResult(xhr));\r\n };\r\n\r\n xhr.onerror = () => {\r\n responseReceivedDeferral.resolve(this.errorResponse(xhr, \"Failed to make request.\"));\r\n };\r\n\r\n xhr.ontimeout = () => {\r\n responseReceivedDeferral.resolve(this.errorResponse(xhr, \"Request took longer than expected.\"));\r\n };\r\n\r\n if (method === RestRequestType.File && binaryBody) {\r\n xhr.setRequestHeader(\"Content-Type\", \"multipart/form-data\");\r\n xhr.send(binaryBody);\r\n } else if (method === RestRequestType.Post && body) {\r\n xhr.setRequestHeader(\"Content-Type\", \"application/json\");\r\n xhr.send(JSON.stringify(body));\r\n } else {\r\n xhr.send();\r\n }\r\n\r\n return responseReceivedDeferral.promise();\r\n }\r\n\r\n private parseXHRResult(xhr: XMLHttpRequest | XHR.XMLHttpRequest): IRestResponse {\r\n return {\r\n data: xhr.responseText,\r\n headers: xhr.getAllResponseHeaders(),\r\n json: () => JSON.parse(xhr.responseText) as T,\r\n ok: xhr.status >= 200 && xhr.status < 300,\r\n status: xhr.status,\r\n statusText: xhr.statusText,\r\n };\r\n }\r\n\r\n private errorResponse(xhr: XMLHttpRequest | XHR.XMLHttpRequest, message: string | null = null): IRestResponse {\r\n return {\r\n data: message || xhr.statusText,\r\n headers: xhr.getAllResponseHeaders(),\r\n json: () => JSON.parse(message || (\"\\\"\" + xhr.statusText + \"\\\"\")) as T,\r\n ok: false,\r\n status: xhr.status,\r\n statusText: xhr.statusText,\r\n };\r\n }\r\n\r\n private withQuery(url: string, params: any = {}): any {\r\n const queryString = this.queryParams(params);\r\n return queryString ? url + (url.indexOf(\"?\") === -1 ? \"?\" : \"&\") + queryString : url;\r\n }\r\n\r\n private queryParams(params: any = {}): any {\r\n return Object.keys(params)\r\n .map((k: any) => encodeURIComponent(k) + \"=\" + encodeURIComponent(params[k]))\r\n .join(\"&\");\r\n }\r\n}\r\n","/* (ignored) */"],"sourceRoot":""} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..78de12a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,325 @@ +{ + "name": "speech-sdk-quickstart-node", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "agent-base": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.1.tgz", + "integrity": "sha512-01q25QQDwLSsyfhrKbn8yuur+JNw0H+0Y4JiGIKd3z9aYk/w/2kxD/Upc+t2ZBBSUNff50VjPsSW2YxM8QYKVg==", + "requires": { + "debug": "4" + } + }, + "asn1.js": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz", + "integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==", + "requires": { + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "safer-buffer": "^2.1.0" + } + }, + "asn1.js-rfc2560": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/asn1.js-rfc2560/-/asn1.js-rfc2560-5.0.1.tgz", + "integrity": "sha512-1PrVg6kuBziDN3PGFmRk3QrjpKvP9h/Hv5yMrFZvC1kpzP6dQRzf5BpKstANqHBkaOUmTpakJWhicTATOA/SbA==", + "requires": { + "asn1.js-rfc5280": "^3.0.0" + } + }, + "asn1.js-rfc5280": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/asn1.js-rfc5280/-/asn1.js-rfc5280-3.0.0.tgz", + "integrity": "sha512-Y2LZPOWeZ6qehv698ZgOGGCZXBQShObWnGthTrIFlIQjuV1gg2B8QOhWFRExq/MR1VnPpIIe7P9vX2vElxv+Pg==", + "requires": { + "asn1.js": "^5.0.0" + } + }, + "async-disk-cache": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/async-disk-cache/-/async-disk-cache-2.1.0.tgz", + "integrity": "sha512-iH+boep2xivfD9wMaZWkywYIURSmsL96d6MoqrC94BnGSvXE4Quf8hnJiHGFYhw/nLeIa1XyRaf4vvcvkwAefg==", + "requires": { + "debug": "^4.1.1", + "heimdalljs": "^0.2.3", + "istextorbinary": "^2.5.1", + "mkdirp": "^0.5.0", + "rimraf": "^3.0.0", + "rsvp": "^4.8.5", + "username-sync": "^1.0.2" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "binaryextensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binaryextensions/-/binaryextensions-2.3.0.tgz", + "integrity": "sha512-nAihlQsYGyc5Bwq6+EsubvANYGExeJKHDO3RjnvwU042fawQTQfM3Kxn7IHUXQOz4bzfwsGYYHGSvXyW4zOGLg==" + }, + "bn.js": { + "version": "4.11.9", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", + "integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "debug": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz", + "integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==", + "requires": { + "ms": "2.1.2" + } + }, + "editions": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/editions/-/editions-2.3.1.tgz", + "integrity": "sha512-ptGvkwTvGdGfC0hfhKg0MT+TRLRKGtUiWGBInxOm5pz7ssADezahjCUaYuZ8Dr+C05FW0AECIIPt4WBxVINEhA==", + "requires": { + "errlop": "^2.0.0", + "semver": "^6.3.0" + } + }, + "errlop": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/errlop/-/errlop-2.2.0.tgz", + "integrity": "sha512-e64Qj9+4aZzjzzFpZC7p5kmm/ccCrbLhAJplhsDXQFs87XTsXwOpH4s1Io2s90Tau/8r2j9f4l/thhDevRjzxw==" + }, + "es6-promise": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" + }, + "es6-promisify": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", + "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", + "requires": { + "es6-promise": "^4.0.3" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "heimdalljs": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/heimdalljs/-/heimdalljs-0.2.6.tgz", + "integrity": "sha512-o9bd30+5vLBvBtzCPwwGqpry2+n0Hi6H1+qwt6y+0kwRHGGF8TFIhJPmnuM0xO97zaKrDZMwO/V56fAnn8m/tA==", + "requires": { + "rsvp": "~3.2.1" + }, + "dependencies": { + "rsvp": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-3.2.1.tgz", + "integrity": "sha1-B8tKXfJa3Z6Cbrxn3Mn9idsn2Eo=" + } + } + }, + "https-proxy-agent": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-3.0.1.tgz", + "integrity": "sha512-+ML2Rbh6DAuee7d07tYGEKOEi2voWPUGan+ExdPbPW6Z3svq+JCqr0v8WmKPOkz1vOVykPCBSuobe7G8GJUtVg==", + "requires": { + "agent-base": "^4.3.0", + "debug": "^3.1.0" + }, + "dependencies": { + "agent-base": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", + "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", + "requires": { + "es6-promisify": "^5.0.0" + } + }, + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "requires": { + "ms": "^2.1.1" + } + } + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "istextorbinary": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/istextorbinary/-/istextorbinary-2.6.0.tgz", + "integrity": "sha512-+XRlFseT8B3L9KyjxxLjfXSLMuErKDsd8DBNrsaxoViABMEZlOSCstwmw0qpoFX3+U6yWU1yhLudAe6/lETGGA==", + "requires": { + "binaryextensions": "^2.1.2", + "editions": "^2.2.0", + "textextensions": "^2.5.0" + } + }, + "microsoft-cognitiveservices-speech-sdk": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/microsoft-cognitiveservices-speech-sdk/-/microsoft-cognitiveservices-speech-sdk-1.13.1.tgz", + "integrity": "sha512-8Jis9HFYwWxaEpxwnFF6kEBZmEvGxfl3VUUdBXObJ0/WzkbvdTsyORRnHxztdSehiuS1BCq+XpmdpzI67KgZ9g==", + "requires": { + "agent-base": "^6.0.0", + "asn1.js-rfc2560": "^5.0.0", + "asn1.js-rfc5280": "^3.0.0", + "async-disk-cache": "^2.1.0", + "https-proxy-agent": "^3.0.1", + "simple-lru-cache": "0.0.2", + "ws": "^7.2.0", + "xmlhttprequest-ts": "^1.0.1" + } + }, + "minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==" + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "requires": { + "minimist": "^1.2.5" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "requires": { + "glob": "^7.1.3" + } + }, + "rsvp": { + "version": "4.8.5", + "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", + "integrity": "sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" + }, + "simple-lru-cache": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/simple-lru-cache/-/simple-lru-cache-0.0.2.tgz", + "integrity": "sha1-1ZzDoZPBpdAyD4Tucy9uRxPlEd0=" + }, + "textextensions": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/textextensions/-/textextensions-2.6.0.tgz", + "integrity": "sha512-49WtAWS+tcsy93dRt6P0P3AMD2m5PvXRhuEA0kaXos5ZLlujtYmpmFsB+QvWUSxE1ZsstmYXfQ7L40+EcQgpAQ==" + }, + "tslib": { + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.0.tgz", + "integrity": "sha512-+Zw5lu0D9tvBMjGP8LpvMb0u2WW2QV3y+D8mO6J+cNzCYIN4sVy43Bf9vl92nqFahutN0I8zHa7cc4vihIshnw==" + }, + "username-sync": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/username-sync/-/username-sync-1.0.2.tgz", + "integrity": "sha512-ayNkOJdoNSGNDBE46Nkc+l6IXmeugbzahZLSMkwvgRWv5y5ZqNY2IrzcgmkR4z32sj1W3tM3TuTUMqkqBzO+RA==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "ws": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz", + "integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==" + }, + "xmlhttprequest-ts": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/xmlhttprequest-ts/-/xmlhttprequest-ts-1.0.1.tgz", + "integrity": "sha1-ezy0oZeu44zy1PndYYnR0h8INbI=", + "requires": { + "tslib": "^1.9.2" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..984055b --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "private": true, + "name": "speech-sdk-quickstart-node", + "version": "1.0.0", + "description": "Quickstart for the Microsoft Speech SDK on Node.js", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Microsoft", + "license": "MIT", + "dependencies": { + "microsoft-cognitiveservices-speech-sdk": "^1.13.1" + } +}