1 |
- {"ast":null,"code":"\"use strict\";\n\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\nvar _asyncToGenerator = require(\"F:/workspace/202226701027/huinongbao-app/node_modules/@babel/runtime/helpers/asyncToGenerator.js\").default;\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.DialogServiceAdapter = void 0;\nconst Exports_js_1 = require(\"../common.browser/Exports.js\");\nconst DialogEvents_js_1 = require(\"../common/DialogEvents.js\");\nconst Exports_js_2 = require(\"../common/Exports.js\");\nconst AudioOutputFormat_js_1 = require(\"../sdk/Audio/AudioOutputFormat.js\");\nconst Exports_js_3 = require(\"../sdk/Exports.js\");\nconst DialogServiceTurnStateManager_js_1 = require(\"./DialogServiceTurnStateManager.js\");\nconst Exports_js_4 = require(\"./Exports.js\");\nconst ActivityResponsePayload_js_1 = require(\"./ServiceMessages/ActivityResponsePayload.js\");\nconst SpeechConnectionMessage_Internal_js_1 = require(\"./SpeechConnectionMessage.Internal.js\");\nclass DialogServiceAdapter extends Exports_js_4.ServiceRecognizerBase {\n constructor(authentication, connectionFactory, audioSource, recognizerConfig, dialogServiceConnector) {\n super(authentication, connectionFactory, audioSource, recognizerConfig, dialogServiceConnector);\n this.privEvents = new Exports_js_2.EventSource();\n this.privDialogServiceConnector = dialogServiceConnector;\n this.receiveMessageOverride = () => this.receiveDialogMessageOverride();\n this.privTurnStateManager = new DialogServiceTurnStateManager_js_1.DialogServiceTurnStateManager();\n this.recognizeOverride = (recoMode, successCallback, errorCallback) => this.listenOnce(recoMode, successCallback, errorCallback);\n this.postConnectImplOverride = connection => this.dialogConnectImpl(connection);\n this.configConnectionOverride = connection => this.configConnection(connection);\n this.disconnectOverride = () => this.privDisconnect();\n this.privDialogAudioSource = audioSource;\n this.agentConfigSent = false;\n this.privLastResult = null;\n this.connectionEvents.attach(connectionEvent => {\n if (connectionEvent.name === \"ConnectionClosedEvent\") {\n this.terminateMessageLoop = true;\n }\n });\n }\n sendMessage(message) {\n var _this = this;\n return _asyncToGenerator(function* () {\n const interactionGuid = Exports_js_2.createGuid();\n const requestId = Exports_js_2.createNoDashGuid();\n const agentMessage = {\n context: {\n interactionId: interactionGuid\n },\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n messagePayload: JSON.parse(message),\n version: 0.5\n };\n const agentMessageJson = JSON.stringify(agentMessage);\n const connection = yield _this.fetchConnection();\n yield connection.send(new SpeechConnectionMessage_Internal_js_1.SpeechConnectionMessage(Exports_js_2.MessageType.Text, \"agent\", requestId, \"application/json\", agentMessageJson));\n })();\n }\n privDisconnect() {\n var _this2 = this;\n return _asyncToGenerator(function* () {\n yield _this2.cancelRecognition(_this2.privRequestSession.sessionId, _this2.privRequestSession.requestId, Exports_js_3.CancellationReason.Error, Exports_js_3.CancellationErrorCode.NoError, \"Disconnecting\");\n _this2.terminateMessageLoop = true;\n _this2.agentConfigSent = false;\n return;\n })();\n }\n processTypeSpecificMessages(connectionMessage) {\n const resultProps = new Exports_js_3.PropertyCollection();\n if (connectionMessage.messageType === Exports_js_2.MessageType.Text) {\n resultProps.setProperty(Exports_js_3.PropertyId.SpeechServiceResponse_JsonResult, connectionMessage.textBody);\n }\n let result;\n let processed;\n switch (connectionMessage.path.toLowerCase()) {\n case \"speech.phrase\":\n const speechPhrase = Exports_js_4.SimpleSpeechPhrase.fromJSON(connectionMessage.textBody);\n this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset + speechPhrase.Offset + speechPhrase.Duration);\n if (speechPhrase.RecognitionStatus !== Exports_js_4.RecognitionStatus.TooManyRequests && speechPhrase.RecognitionStatus !== Exports_js_4.RecognitionStatus.Error) {\n const args = this.fireEventForResult(speechPhrase, resultProps);\n this.privLastResult = args.result;\n if (!!this.privDialogServiceConnector.recognized) {\n try {\n this.privDialogServiceConnector.recognized(this.privDialogServiceConnector, args);\n /* eslint-disable no-empty */\n } catch (error) {\n // Not going to let errors in the event handler\n // trip things up.\n }\n }\n }\n processed = true;\n break;\n case \"speech.hypothesis\":\n const hypothesis = Exports_js_4.SpeechHypothesis.fromJSON(connectionMessage.textBody);\n const offset = hypothesis.Offset + this.privRequestSession.currentTurnAudioOffset;\n result = new Exports_js_3.SpeechRecognitionResult(this.privRequestSession.requestId, Exports_js_3.ResultReason.RecognizingSpeech, hypothesis.Text, hypothesis.Duration, offset, hypothesis.Language, hypothesis.LanguageDetectionConfidence, undefined, undefined, connectionMessage.textBody, resultProps);\n this.privRequestSession.onHypothesis(offset);\n const ev = new Exports_js_3.SpeechRecognitionEventArgs(result, hypothesis.Duration, this.privRequestSession.sessionId);\n if (!!this.privDialogServiceConnector.recognizing) {\n try {\n this.privDialogServiceConnector.recognizing(this.privDialogServiceConnector, ev);\n /* eslint-disable no-empty */\n } catch (error) {\n // Not going to let errors in the event handler\n // trip things up.\n }\n }\n processed = true;\n break;\n case \"speech.keyword\":\n const keyword = Exports_js_4.SpeechKeyword.fromJSON(connectionMessage.textBody);\n result = new Exports_js_3.SpeechRecognitionResult(this.privRequestSession.requestId, keyword.Status === \"Accepted\" ? Exports_js_3.ResultReason.RecognizedKeyword : Exports_js_3.ResultReason.NoMatch, keyword.Text, keyword.Duration, keyword.Offset, undefined, undefined, undefined, undefined, connectionMessage.textBody, resultProps);\n if (keyword.Status !== \"Accepted\") {\n this.privLastResult = result;\n }\n const event = new Exports_js_3.SpeechRecognitionEventArgs(result, result.duration, result.resultId);\n if (!!this.privDialogServiceConnector.recognized) {\n try {\n this.privDialogServiceConnector.recognized(this.privDialogServiceConnector, event);\n /* eslint-disable no-empty */\n } catch (error) {\n // Not going to let errors in the event handler\n // trip things up.\n }\n }\n processed = true;\n break;\n case \"audio\":\n {\n const audioRequestId = connectionMessage.requestId.toUpperCase();\n const turn = this.privTurnStateManager.GetTurn(audioRequestId);\n try {\n // Empty binary message signals end of stream.\n if (!connectionMessage.binaryBody) {\n turn.endAudioStream();\n } else {\n turn.audioStream.write(connectionMessage.binaryBody);\n }\n } catch (error) {\n // Not going to let errors in the event handler\n // trip things up.\n }\n }\n processed = true;\n break;\n case \"response\":\n {\n this.handleResponseMessage(connectionMessage);\n }\n processed = true;\n break;\n default:\n break;\n }\n const defferal = new Exports_js_2.Deferred();\n defferal.resolve(processed);\n return defferal.promise;\n }\n // Cancels recognition.\n cancelRecognition(sessionId, requestId, cancellationReason, errorCode, error) {\n var _this3 = this;\n return _asyncToGenerator(function* () {\n _this3.terminateMessageLoop = true;\n if (!!_this3.privRequestSession.isRecognizing) {\n yield _this3.privRequestSession.onStopRecognizing();\n }\n if (!!_this3.privDialogServiceConnector.canceled) {\n const properties = new Exports_js_3.PropertyCollection();\n properties.setProperty(Exports_js_4.CancellationErrorCodePropertyName, Exports_js_3.CancellationErrorCode[errorCode]);\n const cancelEvent = new Exports_js_3.SpeechRecognitionCanceledEventArgs(cancellationReason, error, errorCode, undefined, sessionId);\n try {\n _this3.privDialogServiceConnector.canceled(_this3.privDialogServiceConnector, cancelEvent);\n /* eslint-disable no-empty */\n } catch {}\n if (!!_this3.privSuccessCallback) {\n const result = new Exports_js_3.SpeechRecognitionResult(undefined,\n // ResultId\n Exports_js_3.ResultReason.Canceled, undefined,\n // Text\n undefined,\n // Duration\n undefined,\n // Offset\n undefined,\n // Language\n undefined,\n // Language Detection Confidence\n undefined,\n // Speaker Id\n error, undefined,\n // Json\n properties);\n try {\n _this3.privSuccessCallback(result);\n _this3.privSuccessCallback = undefined;\n /* eslint-disable no-empty */\n } catch {}\n }\n }\n })();\n }\n listenOnce(recoMode, successCallback, errorCallback) {\n var _this4 = this;\n return _asyncToGenerator(function* () {\n _this4.privRecognizerConfig.recognitionMode = recoMode;\n _this4.privSuccessCallback = successCallback;\n _this4.privErrorCallback = errorCallback;\n _this4.privRequestSession.startNewRecognition();\n _this4.privRequestSession.listenForServiceTelemetry(_this4.privDialogAudioSource.events);\n _this4.privRecognizerConfig.parameters.setProperty(Exports_js_3.PropertyId.Speech_SessionId, _this4.privRequestSession.sessionId);\n // Start the connection to the service. The promise this will create is stored and will be used by configureConnection().\n const conPromise = _this4.connectImpl();\n const preAudioPromise = _this4.sendPreAudioMessages();\n const node = yield _this4.privDialogAudioSource.attach(_this4.privRequestSession.audioNodeId);\n const format = yield _this4.privDialogAudioSource.format;\n const deviceInfo = yield _this4.privDialogAudioSource.deviceInfo;\n const audioNode = new Exports_js_1.ReplayableAudioNode(node, format.avgBytesPerSec);\n yield _this4.privRequestSession.onAudioSourceAttachCompleted(audioNode, false);\n _this4.privRecognizerConfig.SpeechServiceConfig.Context.audio = {\n source: deviceInfo\n };\n try {\n yield conPromise;\n yield preAudioPromise;\n } catch (error) {\n yield _this4.cancelRecognition(_this4.privRequestSession.sessionId, _this4.privRequestSession.requestId, Exports_js_3.CancellationReason.Error, Exports_js_3.CancellationErrorCode.ConnectionFailure, error);\n return Promise.resolve();\n }\n const sessionStartEventArgs = new Exports_js_3.SessionEventArgs(_this4.privRequestSession.sessionId);\n if (!!_this4.privRecognizer.sessionStarted) {\n _this4.privRecognizer.sessionStarted(_this4.privRecognizer, sessionStartEventArgs);\n }\n const audioSendPromise = _this4.sendAudio(audioNode);\n // /* eslint-disable no-empty */\n audioSendPromise.then(() => {}, /*#__PURE__*/function () {\n var _ref = _asyncToGenerator(function* (error) {\n yield _this4.cancelRecognition(_this4.privRequestSession.sessionId, _this4.privRequestSession.requestId, Exports_js_3.CancellationReason.Error, Exports_js_3.CancellationErrorCode.RuntimeError, error);\n });\n return function (_x) {\n return _ref.apply(this, arguments);\n };\n }());\n })();\n }\n // Establishes a websocket connection to the end point.\n dialogConnectImpl(connection) {\n this.privConnectionLoop = this.startMessageLoop();\n return connection;\n }\n receiveDialogMessageOverride() {\n var _this5 = this;\n // we won't rely on the cascading promises of the connection since we want to continually be available to receive messages\n const communicationCustodian = new Exports_js_2.Deferred();\n const _loop = /*#__PURE__*/function () {\n var _ref2 = _asyncToGenerator(function* () {\n try {\n const isDisposed = _this5.isDisposed();\n const terminateMessageLoop = !_this5.isDisposed() && _this5.terminateMessageLoop;\n if (isDisposed || terminateMessageLoop) {\n // We're done.\n communicationCustodian.resolve(undefined);\n return;\n }\n const connection = yield _this5.fetchConnection();\n const message = yield connection.read();\n if (!message) {\n return _loop();\n }\n const connectionMessage = SpeechConnectionMessage_Internal_js_1.SpeechConnectionMessage.fromConnectionMessage(message);\n switch (connectionMessage.path.toLowerCase()) {\n case \"turn.start\":\n {\n const turnRequestId = connectionMessage.requestId.toUpperCase();\n const audioSessionReqId = _this5.privRequestSession.requestId.toUpperCase();\n // turn started by the service\n if (turnRequestId !== audioSessionReqId) {\n _this5.privTurnStateManager.StartTurn(turnRequestId);\n } else {\n _this5.privRequestSession.onServiceTurnStartResponse();\n }\n }\n break;\n case \"speech.startdetected\":\n const speechStartDetected = Exports_js_4.SpeechDetected.fromJSON(connectionMessage.textBody);\n const speechStartEventArgs = new Exports_js_3.RecognitionEventArgs(speechStartDetected.Offset, _this5.privRequestSession.sessionId);\n if (!!_this5.privRecognizer.speechStartDetected) {\n _this5.privRecognizer.speechStartDetected(_this5.privRecognizer, speechStartEventArgs);\n }\n break;\n case \"speech.enddetected\":\n let json;\n if (connectionMessage.textBody.length > 0) {\n json = connectionMessage.textBody;\n } else {\n // If the request was empty, the JSON returned is empty.\n json = \"{ Offset: 0 }\";\n }\n const speechStopDetected = Exports_js_4.SpeechDetected.fromJSON(json);\n _this5.privRequestSession.onServiceRecognized(speechStopDetected.Offset + _this5.privRequestSession.currentTurnAudioOffset);\n const speechStopEventArgs = new Exports_js_3.RecognitionEventArgs(speechStopDetected.Offset + _this5.privRequestSession.currentTurnAudioOffset, _this5.privRequestSession.sessionId);\n if (!!_this5.privRecognizer.speechEndDetected) {\n _this5.privRecognizer.speechEndDetected(_this5.privRecognizer, speechStopEventArgs);\n }\n break;\n case \"turn.end\":\n {\n const turnEndRequestId = connectionMessage.requestId.toUpperCase();\n const audioSessionReqId = _this5.privRequestSession.requestId.toUpperCase();\n // turn started by the service\n if (turnEndRequestId !== audioSessionReqId) {\n _this5.privTurnStateManager.CompleteTurn(turnEndRequestId);\n } else {\n // Audio session turn\n const sessionStopEventArgs = new Exports_js_3.SessionEventArgs(_this5.privRequestSession.sessionId);\n yield _this5.privRequestSession.onServiceTurnEndResponse(false);\n if (!_this5.privRecognizerConfig.isContinuousRecognition || _this5.privRequestSession.isSpeechEnded || !_this5.privRequestSession.isRecognizing) {\n if (!!_this5.privRecognizer.sessionStopped) {\n _this5.privRecognizer.sessionStopped(_this5.privRecognizer, sessionStopEventArgs);\n }\n }\n // report result to promise.\n if (!!_this5.privSuccessCallback && _this5.privLastResult) {\n try {\n _this5.privSuccessCallback(_this5.privLastResult);\n _this5.privLastResult = null;\n } catch (e) {\n if (!!_this5.privErrorCallback) {\n _this5.privErrorCallback(e);\n }\n }\n // Only invoke the call back once.\n // and if it's successful don't invoke the\n // error after that.\n _this5.privSuccessCallback = undefined;\n _this5.privErrorCallback = undefined;\n }\n }\n }\n break;\n default:\n try {\n const processed = yield _this5.processTypeSpecificMessages(connectionMessage);\n if (!processed) {\n if (!!_this5.serviceEvents) {\n _this5.serviceEvents.onEvent(new Exports_js_2.ServiceEvent(connectionMessage.path.toLowerCase(), connectionMessage.textBody));\n }\n }\n } catch (e) {\n //\n }\n }\n const ret = _loop();\n return ret;\n } catch (error) {\n _this5.terminateMessageLoop = true;\n communicationCustodian.resolve();\n }\n });\n return function loop() {\n return _ref2.apply(this, arguments);\n };\n }();\n _loop().catch(reason => {\n Exports_js_2.Events.instance.onEvent(new Exports_js_2.BackgroundEvent(reason));\n });\n return communicationCustodian.promise;\n }\n startMessageLoop() {\n var _this6 = this;\n return _asyncToGenerator(function* () {\n _this6.terminateMessageLoop = false;\n try {\n yield _this6.receiveDialogMessageOverride();\n } catch (error) {\n yield _this6.cancelRecognition(_this6.privRequestSession.sessionId, _this6.privRequestSession.requestId, Exports_js_3.CancellationReason.Error, Exports_js_3.CancellationErrorCode.RuntimeError, error);\n }\n return Promise.resolve();\n })();\n }\n // Takes an established websocket connection to the endpoint and sends speech configuration information.\n configConnection(connection) {\n var _this7 = this;\n return _asyncToGenerator(function* () {\n if (_this7.terminateMessageLoop) {\n _this7.terminateMessageLoop = false;\n return Promise.reject(\"Connection to service terminated.\");\n }\n yield _this7.sendSpeechServiceConfig(connection, _this7.privRequestSession, _this7.privRecognizerConfig.SpeechServiceConfig.serialize());\n yield _this7.sendAgentConfig(connection);\n return connection;\n })();\n }\n sendPreAudioMessages() {\n var _this8 = this;\n return _asyncToGenerator(function* () {\n const connection = yield _this8.fetchConnection();\n _this8.addKeywordContextData();\n yield _this8.sendSpeechContext(connection, true);\n yield _this8.sendAgentContext(connection);\n yield _this8.sendWaveHeader(connection);\n })();\n }\n sendAgentConfig(connection) {\n if (this.agentConfig && !this.agentConfigSent) {\n if (this.privRecognizerConfig.parameters.getProperty(Exports_js_3.PropertyId.Conversation_DialogType) === Exports_js_3.DialogServiceConfig.DialogTypes.CustomCommands) {\n const config = this.agentConfig.get();\n config.botInfo.commandsCulture = this.privRecognizerConfig.parameters.getProperty(Exports_js_3.PropertyId.SpeechServiceConnection_RecoLanguage, \"en-us\");\n this.agentConfig.set(config);\n }\n this.onEvent(new DialogEvents_js_1.SendingAgentContextMessageEvent(this.agentConfig));\n const agentConfigJson = this.agentConfig.toJsonString();\n // guard against sending this multiple times on one connection\n this.agentConfigSent = true;\n return connection.send(new SpeechConnectionMessage_Internal_js_1.SpeechConnectionMessage(Exports_js_2.MessageType.Text, \"agent.config\", this.privRequestSession.requestId, \"application/json\", agentConfigJson));\n }\n return;\n }\n sendAgentContext(connection) {\n const guid = Exports_js_2.createGuid();\n const speechActivityTemplate = this.privDialogServiceConnector.properties.getProperty(Exports_js_3.PropertyId.Conversation_Speech_Activity_Template);\n const agentContext = {\n channelData: \"\",\n context: {\n interactionId: guid\n },\n messagePayload: typeof speechActivityTemplate === undefined ? undefined : speechActivityTemplate,\n version: 0.5\n };\n const agentContextJson = JSON.stringify(agentContext);\n return connection.send(new SpeechConnectionMessage_Internal_js_1.SpeechConnectionMessage(Exports_js_2.MessageType.Text, \"speech.agent.context\", this.privRequestSession.requestId, \"application/json\", agentContextJson));\n }\n fireEventForResult(serviceResult, properties) {\n const resultReason = Exports_js_4.EnumTranslation.implTranslateRecognitionResult(serviceResult.RecognitionStatus);\n const offset = serviceResult.Offset + this.privRequestSession.currentTurnAudioOffset;\n const result = new Exports_js_3.SpeechRecognitionResult(this.privRequestSession.requestId, resultReason, serviceResult.DisplayText, serviceResult.Duration, offset, serviceResult.Language, serviceResult.LanguageDetectionConfidence, undefined, undefined, JSON.stringify(serviceResult), properties);\n const ev = new Exports_js_3.SpeechRecognitionEventArgs(result, offset, this.privRequestSession.sessionId);\n return ev;\n }\n handleResponseMessage(responseMessage) {\n // \"response\" messages can contain either \"message\" (activity) or \"MessageStatus\" data. Fire the appropriate\n // event according to the message type that's specified.\n const responsePayload = JSON.parse(responseMessage.textBody);\n switch (responsePayload.messageType.toLowerCase()) {\n case \"message\":\n const responseRequestId = responseMessage.requestId.toUpperCase();\n const activityPayload = ActivityResponsePayload_js_1.ActivityPayloadResponse.fromJSON(responseMessage.textBody);\n const turn = this.privTurnStateManager.GetTurn(responseRequestId);\n // update the conversation Id\n if (activityPayload.conversationId) {\n const updateAgentConfig = this.agentConfig.get();\n updateAgentConfig.botInfo.conversationId = activityPayload.conversationId;\n this.agentConfig.set(updateAgentConfig);\n }\n const pullAudioOutputStream = turn.processActivityPayload(activityPayload, AudioOutputFormat_js_1.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString(this.privDialogServiceConnector.properties.getProperty(Exports_js_3.PropertyId.SpeechServiceConnection_SynthOutputFormat, undefined)));\n const activity = new Exports_js_3.ActivityReceivedEventArgs(activityPayload.messagePayload, pullAudioOutputStream);\n if (!!this.privDialogServiceConnector.activityReceived) {\n try {\n this.privDialogServiceConnector.activityReceived(this.privDialogServiceConnector, activity);\n /* eslint-disable-next-line no-empty */\n } catch (error) {\n // Not going to let errors in the event handler\n // trip things up.\n }\n }\n break;\n case \"messagestatus\":\n if (!!this.privDialogServiceConnector.turnStatusReceived) {\n try {\n this.privDialogServiceConnector.turnStatusReceived(this.privDialogServiceConnector, new Exports_js_3.TurnStatusReceivedEventArgs(responseMessage.textBody));\n /* eslint-disable-next-line no-empty */\n } catch (error) {\n // Not going to let errors in the event handler\n // trip things up.\n }\n }\n break;\n default:\n Exports_js_2.Events.instance.onEvent(new Exports_js_2.BackgroundEvent(`Unexpected response of type ${responsePayload.messageType}. Ignoring.`));\n break;\n }\n }\n onEvent(event) {\n this.privEvents.onEvent(event);\n Exports_js_2.Events.instance.onEvent(event);\n }\n addKeywordContextData() {\n const keywordPropertyValue = this.privRecognizerConfig.parameters.getProperty(\"SPEECH-KeywordsToDetect\");\n if (keywordPropertyValue === undefined) {\n return;\n }\n const keywordOffsetPropertyValue = this.privRecognizerConfig.parameters.getProperty(\"SPEECH-KeywordsToDetect-Offsets\");\n const keywordDurationPropertyValue = this.privRecognizerConfig.parameters.getProperty(\"SPEECH-KeywordsToDetect-Durations\");\n const keywords = keywordPropertyValue.split(\";\");\n const keywordOffsets = keywordOffsetPropertyValue === undefined ? [] : keywordOffsetPropertyValue.split(\";\");\n const keywordDurations = keywordDurationPropertyValue === undefined ? [] : keywordDurationPropertyValue.split(\";\");\n const keywordDefinitionArray = [];\n for (let i = 0; i < keywords.length; i++) {\n const definition = {};\n definition.text = keywords[i];\n if (i < keywordOffsets.length) {\n definition.offset = Number(keywordOffsets[i]);\n }\n if (i < keywordDurations.length) {\n definition.duration = Number(keywordDurations[i]);\n }\n keywordDefinitionArray.push(definition);\n }\n this.speechContext.setSection(\"invocationSource\", \"VoiceActivationWithKeyword\");\n this.speechContext.setSection(\"keywordDetection\", [{\n clientDetectedKeywords: keywordDefinitionArray,\n onReject: {\n action: \"EndOfTurn\"\n },\n type: \"startTrigger\"\n }]);\n }\n}\nexports.DialogServiceAdapter = DialogServiceAdapter;","map":{"version":3,"names":["_asyncToGenerator","require","default","Object","defineProperty","exports","value","DialogServiceAdapter","Exports_js_1","DialogEvents_js_1","Exports_js_2","AudioOutputFormat_js_1","Exports_js_3","DialogServiceTurnStateManager_js_1","Exports_js_4","ActivityResponsePayload_js_1","SpeechConnectionMessage_Internal_js_1","ServiceRecognizerBase","constructor","authentication","connectionFactory","audioSource","recognizerConfig","dialogServiceConnector","privEvents","EventSource","privDialogServiceConnector","receiveMessageOverride","receiveDialogMessageOverride","privTurnStateManager","DialogServiceTurnStateManager","recognizeOverride","recoMode","successCallback","errorCallback","listenOnce","postConnectImplOverride","connection","dialogConnectImpl","configConnectionOverride","configConnection","disconnectOverride","privDisconnect","privDialogAudioSource","agentConfigSent","privLastResult","connectionEvents","attach","connectionEvent","name","terminateMessageLoop","sendMessage","message","_this","interactionGuid","createGuid","requestId","createNoDashGuid","agentMessage","context","interactionId","messagePayload","JSON","parse","version","agentMessageJson","stringify","fetchConnection","send","SpeechConnectionMessage","MessageType","Text","_this2","cancelRecognition","privRequestSession","sessionId","CancellationReason","Error","CancellationErrorCode","NoError","processTypeSpecificMessages","connectionMessage","resultProps","PropertyCollection","messageType","setProperty","PropertyId","SpeechServiceResponse_JsonResult","textBody","result","processed","path","toLowerCase","speechPhrase","SimpleSpeechPhrase","fromJSON","onPhraseRecognized","currentTurnAudioOffset","Offset","Duration","RecognitionStatus","TooManyRequests","args","fireEventForResult","recognized","error","hypothesis","SpeechHypothesis","offset","SpeechRecognitionResult","ResultReason","RecognizingSpeech","Language","LanguageDetectionConfidence","undefined","onHypothesis","ev","SpeechRecognitionEventArgs","recognizing","keyword","SpeechKeyword","Status","RecognizedKeyword","NoMatch","event","duration","resultId","audioRequestId","toUpperCase","turn","GetTurn","binaryBody","endAudioStream","audioStream","write","handleResponseMessage","defferal","Deferred","resolve","promise","cancellationReason","errorCode","_this3","isRecognizing","onStopRecognizing","canceled","properties","CancellationErrorCodePropertyName","cancelEvent","SpeechRecognitionCanceledEventArgs","privSuccessCallback","Canceled","_this4","privRecognizerConfig","recognitionMode","privErrorCallback","startNewRecognition","listenForServiceTelemetry","events","parameters","Speech_SessionId","conPromise","connectImpl","preAudioPromise","sendPreAudioMessages","node","audioNodeId","format","deviceInfo","audioNode","ReplayableAudioNode","avgBytesPerSec","onAudioSourceAttachCompleted","SpeechServiceConfig","Context","audio","source","ConnectionFailure","Promise","sessionStartEventArgs","SessionEventArgs","privRecognizer","sessionStarted","audioSendPromise","sendAudio","then","_ref","RuntimeError","_x","apply","arguments","privConnectionLoop","startMessageLoop","_this5","communicationCustodian","loop","_ref2","isDisposed","read","fromConnectionMessage","turnRequestId","audioSessionReqId","StartTurn","onServiceTurnStartResponse","speechStartDetected","SpeechDetected","speechStartEventArgs","RecognitionEventArgs","json","length","speechStopDetected","onServiceRecognized","speechStopEventArgs","speechEndDetected","turnEndRequestId","CompleteTurn","sessionStopEventArgs","onServiceTurnEndResponse","isContinuousRecognition","isSpeechEnded","sessionStopped","e","serviceEvents","onEvent","ServiceEvent","ret","catch","reason","Events","instance","BackgroundEvent","_this6","_this7","reject","sendSpeechServiceConfig","serialize","sendAgentConfig","_this8","addKeywordContextData","sendSpeechContext","sendAgentContext","sendWaveHeader","agentConfig","getProperty","Conversation_DialogType","DialogServiceConfig","DialogTypes","CustomCommands","config","get","botInfo","commandsCulture","SpeechServiceConnection_RecoLanguage","set","SendingAgentContextMessageEvent","agentConfigJson","toJsonString","guid","speechActivityTemplate","Conversation_Speech_Activity_Template","agentContext","channelData","agentContextJson","serviceResult","resultReason","EnumTranslation","implTranslateRecognitionResult","DisplayText","responseMessage","responsePayload","responseRequestId","activityPayload","ActivityPayloadResponse","conversationId","updateAgentConfig","pullAudioOutputStream","processActivityPayload","AudioOutputFormatImpl","fromSpeechSynthesisOutputFormatString","SpeechServiceConnection_SynthOutputFormat","activity","ActivityReceivedEventArgs","activityReceived","turnStatusReceived","TurnStatusReceivedEventArgs","keywordPropertyValue","keywordOffsetPropertyValue","keywordDurationPropertyValue","keywords","split","keywordOffsets","keywordDurations","keywordDefinitionArray","i","definition","text","Number","push","speechContext","setSection","clientDetectedKeywords","onReject","action","type"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/DialogServiceAdapter.js"],"sourcesContent":["\"use strict\";\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.DialogServiceAdapter = void 0;\nconst Exports_js_1 = require(\"../common.browser/Exports.js\");\nconst DialogEvents_js_1 = require(\"../common/DialogEvents.js\");\nconst Exports_js_2 = require(\"../common/Exports.js\");\nconst AudioOutputFormat_js_1 = require(\"../sdk/Audio/AudioOutputFormat.js\");\nconst Exports_js_3 = require(\"../sdk/Exports.js\");\nconst DialogServiceTurnStateManager_js_1 = require(\"./DialogServiceTurnStateManager.js\");\nconst Exports_js_4 = require(\"./Exports.js\");\nconst ActivityResponsePayload_js_1 = require(\"./ServiceMessages/ActivityResponsePayload.js\");\nconst SpeechConnectionMessage_Internal_js_1 = require(\"./SpeechConnectionMessage.Internal.js\");\nclass DialogServiceAdapter extends Exports_js_4.ServiceRecognizerBase {\n constructor(authentication, connectionFactory, audioSource, recognizerConfig, dialogServiceConnector) {\n super(authentication, connectionFactory, audioSource, recognizerConfig, dialogServiceConnector);\n this.privEvents = new Exports_js_2.EventSource();\n this.privDialogServiceConnector = dialogServiceConnector;\n this.receiveMessageOverride = () => this.receiveDialogMessageOverride();\n this.privTurnStateManager = new DialogServiceTurnStateManager_js_1.DialogServiceTurnStateManager();\n this.recognizeOverride =\n (recoMode, successCallback, errorCallback) => this.listenOnce(recoMode, successCallback, errorCallback);\n this.postConnectImplOverride = (connection) => this.dialogConnectImpl(connection);\n this.configConnectionOverride = (connection) => this.configConnection(connection);\n this.disconnectOverride = () => this.privDisconnect();\n this.privDialogAudioSource = audioSource;\n this.agentConfigSent = false;\n this.privLastResult = null;\n this.connectionEvents.attach((connectionEvent) => {\n if (connectionEvent.name === \"ConnectionClosedEvent\") {\n this.terminateMessageLoop = true;\n }\n });\n }\n async sendMessage(message) {\n const interactionGuid = Exports_js_2.createGuid();\n const requestId = Exports_js_2.createNoDashGuid();\n const agentMessage = {\n context: {\n interactionId: interactionGuid\n },\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n messagePayload: JSON.parse(message),\n version: 0.5\n };\n const agentMessageJson = JSON.stringify(agentMessage);\n const connection = await this.fetchConnection();\n await connection.send(new SpeechConnectionMessage_Internal_js_1.SpeechConnectionMessage(Exports_js_2.MessageType.Text, \"agent\", requestId, \"application/json\", agentMessageJson));\n }\n async privDisconnect() {\n await this.cancelRecognition(this.privRequestSession.sessionId, this.privRequestSession.requestId, Exports_js_3.CancellationReason.Error, Exports_js_3.CancellationErrorCode.NoError, \"Disconnecting\");\n this.terminateMessageLoop = true;\n this.agentConfigSent = false;\n return;\n }\n processTypeSpecificMessages(connectionMessage) {\n const resultProps = new Exports_js_3.PropertyCollection();\n if (connectionMessage.messageType === Exports_js_2.MessageType.Text) {\n resultProps.setProperty(Exports_js_3.PropertyId.SpeechServiceResponse_JsonResult, connectionMessage.textBody);\n }\n let result;\n let processed;\n switch (connectionMessage.path.toLowerCase()) {\n case \"speech.phrase\":\n const speechPhrase = Exports_js_4.SimpleSpeechPhrase.fromJSON(connectionMessage.textBody);\n this.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset + speechPhrase.Offset + speechPhrase.Duration);\n if (speechPhrase.RecognitionStatus !== Exports_js_4.RecognitionStatus.TooManyRequests && speechPhrase.RecognitionStatus !== Exports_js_4.RecognitionStatus.Error) {\n const args = this.fireEventForResult(speechPhrase, resultProps);\n this.privLastResult = args.result;\n if (!!this.privDialogServiceConnector.recognized) {\n try {\n this.privDialogServiceConnector.recognized(this.privDialogServiceConnector, args);\n /* eslint-disable no-empty */\n }\n catch (error) {\n // Not going to let errors in the event handler\n // trip things up.\n }\n }\n }\n processed = true;\n break;\n case \"speech.hypothesis\":\n const hypothesis = Exports_js_4.SpeechHypothesis.fromJSON(connectionMessage.textBody);\n const offset = hypothesis.Offset + this.privRequestSession.currentTurnAudioOffset;\n result = new Exports_js_3.SpeechRecognitionResult(this.privRequestSession.requestId, Exports_js_3.ResultReason.RecognizingSpeech, hypothesis.Text, hypothesis.Duration, offset, hypothesis.Language, hypothesis.LanguageDetectionConfidence, undefined, undefined, connectionMessage.textBody, resultProps);\n this.privRequestSession.onHypothesis(offset);\n const ev = new Exports_js_3.SpeechRecognitionEventArgs(result, hypothesis.Duration, this.privRequestSession.sessionId);\n if (!!this.privDialogServiceConnector.recognizing) {\n try {\n this.privDialogServiceConnector.recognizing(this.privDialogServiceConnector, ev);\n /* eslint-disable no-empty */\n }\n catch (error) {\n // Not going to let errors in the event handler\n // trip things up.\n }\n }\n processed = true;\n break;\n case \"speech.keyword\":\n const keyword = Exports_js_4.SpeechKeyword.fromJSON(connectionMessage.textBody);\n result = new Exports_js_3.SpeechRecognitionResult(this.privRequestSession.requestId, keyword.Status === \"Accepted\" ? Exports_js_3.ResultReason.RecognizedKeyword : Exports_js_3.ResultReason.NoMatch, keyword.Text, keyword.Duration, keyword.Offset, undefined, undefined, undefined, undefined, connectionMessage.textBody, resultProps);\n if (keyword.Status !== \"Accepted\") {\n this.privLastResult = result;\n }\n const event = new Exports_js_3.SpeechRecognitionEventArgs(result, result.duration, result.resultId);\n if (!!this.privDialogServiceConnector.recognized) {\n try {\n this.privDialogServiceConnector.recognized(this.privDialogServiceConnector, event);\n /* eslint-disable no-empty */\n }\n catch (error) {\n // Not going to let errors in the event handler\n // trip things up.\n }\n }\n processed = true;\n break;\n case \"audio\":\n {\n const audioRequestId = connectionMessage.requestId.toUpperCase();\n const turn = this.privTurnStateManager.GetTurn(audioRequestId);\n try {\n // Empty binary message signals end of stream.\n if (!connectionMessage.binaryBody) {\n turn.endAudioStream();\n }\n else {\n turn.audioStream.write(connectionMessage.binaryBody);\n }\n }\n catch (error) {\n // Not going to let errors in the event handler\n // trip things up.\n }\n }\n processed = true;\n break;\n case \"response\":\n {\n this.handleResponseMessage(connectionMessage);\n }\n processed = true;\n break;\n default:\n break;\n }\n const defferal = new Exports_js_2.Deferred();\n defferal.resolve(processed);\n return defferal.promise;\n }\n // Cancels recognition.\n async cancelRecognition(sessionId, requestId, cancellationReason, errorCode, error) {\n this.terminateMessageLoop = true;\n if (!!this.privRequestSession.isRecognizing) {\n await this.privRequestSession.onStopRecognizing();\n }\n if (!!this.privDialogServiceConnector.canceled) {\n const properties = new Exports_js_3.PropertyCollection();\n properties.setProperty(Exports_js_4.CancellationErrorCodePropertyName, Exports_js_3.CancellationErrorCode[errorCode]);\n const cancelEvent = new Exports_js_3.SpeechRecognitionCanceledEventArgs(cancellationReason, error, errorCode, undefined, sessionId);\n try {\n this.privDialogServiceConnector.canceled(this.privDialogServiceConnector, cancelEvent);\n /* eslint-disable no-empty */\n }\n catch { }\n if (!!this.privSuccessCallback) {\n const result = new Exports_js_3.SpeechRecognitionResult(undefined, // ResultId\n Exports_js_3.ResultReason.Canceled, undefined, // Text\n undefined, // Duration\n undefined, // Offset\n undefined, // Language\n undefined, // Language Detection Confidence\n undefined, // Speaker Id\n error, undefined, // Json\n properties);\n try {\n this.privSuccessCallback(result);\n this.privSuccessCallback = undefined;\n /* eslint-disable no-empty */\n }\n catch { }\n }\n }\n }\n async listenOnce(recoMode, successCallback, errorCallback) {\n this.privRecognizerConfig.recognitionMode = recoMode;\n this.privSuccessCallback = successCallback;\n this.privErrorCallback = errorCallback;\n this.privRequestSession.startNewRecognition();\n this.privRequestSession.listenForServiceTelemetry(this.privDialogAudioSource.events);\n this.privRecognizerConfig.parameters.setProperty(Exports_js_3.PropertyId.Speech_SessionId, this.privRequestSession.sessionId);\n // Start the connection to the service. The promise this will create is stored and will be used by configureConnection().\n const conPromise = this.connectImpl();\n const preAudioPromise = this.sendPreAudioMessages();\n const node = await this.privDialogAudioSource.attach(this.privRequestSession.audioNodeId);\n const format = await this.privDialogAudioSource.format;\n const deviceInfo = await this.privDialogAudioSource.deviceInfo;\n const audioNode = new Exports_js_1.ReplayableAudioNode(node, format.avgBytesPerSec);\n await this.privRequestSession.onAudioSourceAttachCompleted(audioNode, false);\n this.privRecognizerConfig.SpeechServiceConfig.Context.audio = { source: deviceInfo };\n try {\n await conPromise;\n await preAudioPromise;\n }\n catch (error) {\n await this.cancelRecognition(this.privRequestSession.sessionId, this.privRequestSession.requestId, Exports_js_3.CancellationReason.Error, Exports_js_3.CancellationErrorCode.ConnectionFailure, error);\n return Promise.resolve();\n }\n const sessionStartEventArgs = new Exports_js_3.SessionEventArgs(this.privRequestSession.sessionId);\n if (!!this.privRecognizer.sessionStarted) {\n this.privRecognizer.sessionStarted(this.privRecognizer, sessionStartEventArgs);\n }\n const audioSendPromise = this.sendAudio(audioNode);\n // /* eslint-disable no-empty */\n audioSendPromise.then(() => { }, async (error) => {\n await this.cancelRecognition(this.privRequestSession.sessionId, this.privRequestSession.requestId, Exports_js_3.CancellationReason.Error, Exports_js_3.CancellationErrorCode.RuntimeError, error);\n });\n }\n // Establishes a websocket connection to the end point.\n dialogConnectImpl(connection) {\n this.privConnectionLoop = this.startMessageLoop();\n return connection;\n }\n receiveDialogMessageOverride() {\n // we won't rely on the cascading promises of the connection since we want to continually be available to receive messages\n const communicationCustodian = new Exports_js_2.Deferred();\n const loop = async () => {\n try {\n const isDisposed = this.isDisposed();\n const terminateMessageLoop = (!this.isDisposed() && this.terminateMessageLoop);\n if (isDisposed || terminateMessageLoop) {\n // We're done.\n communicationCustodian.resolve(undefined);\n return;\n }\n const connection = await this.fetchConnection();\n const message = await connection.read();\n if (!message) {\n return loop();\n }\n const connectionMessage = SpeechConnectionMessage_Internal_js_1.SpeechConnectionMessage.fromConnectionMessage(message);\n switch (connectionMessage.path.toLowerCase()) {\n case \"turn.start\":\n {\n const turnRequestId = connectionMessage.requestId.toUpperCase();\n const audioSessionReqId = this.privRequestSession.requestId.toUpperCase();\n // turn started by the service\n if (turnRequestId !== audioSessionReqId) {\n this.privTurnStateManager.StartTurn(turnRequestId);\n }\n else {\n this.privRequestSession.onServiceTurnStartResponse();\n }\n }\n break;\n case \"speech.startdetected\":\n const speechStartDetected = Exports_js_4.SpeechDetected.fromJSON(connectionMessage.textBody);\n const speechStartEventArgs = new Exports_js_3.RecognitionEventArgs(speechStartDetected.Offset, this.privRequestSession.sessionId);\n if (!!this.privRecognizer.speechStartDetected) {\n this.privRecognizer.speechStartDetected(this.privRecognizer, speechStartEventArgs);\n }\n break;\n case \"speech.enddetected\":\n let json;\n if (connectionMessage.textBody.length > 0) {\n json = connectionMessage.textBody;\n }\n else {\n // If the request was empty, the JSON returned is empty.\n json = \"{ Offset: 0 }\";\n }\n const speechStopDetected = Exports_js_4.SpeechDetected.fromJSON(json);\n this.privRequestSession.onServiceRecognized(speechStopDetected.Offset + this.privRequestSession.currentTurnAudioOffset);\n const speechStopEventArgs = new Exports_js_3.RecognitionEventArgs(speechStopDetected.Offset + this.privRequestSession.currentTurnAudioOffset, this.privRequestSession.sessionId);\n if (!!this.privRecognizer.speechEndDetected) {\n this.privRecognizer.speechEndDetected(this.privRecognizer, speechStopEventArgs);\n }\n break;\n case \"turn.end\":\n {\n const turnEndRequestId = connectionMessage.requestId.toUpperCase();\n const audioSessionReqId = this.privRequestSession.requestId.toUpperCase();\n // turn started by the service\n if (turnEndRequestId !== audioSessionReqId) {\n this.privTurnStateManager.CompleteTurn(turnEndRequestId);\n }\n else {\n // Audio session turn\n const sessionStopEventArgs = new Exports_js_3.SessionEventArgs(this.privRequestSession.sessionId);\n await this.privRequestSession.onServiceTurnEndResponse(false);\n if (!this.privRecognizerConfig.isContinuousRecognition || this.privRequestSession.isSpeechEnded || !this.privRequestSession.isRecognizing) {\n if (!!this.privRecognizer.sessionStopped) {\n this.privRecognizer.sessionStopped(this.privRecognizer, sessionStopEventArgs);\n }\n }\n // report result to promise.\n if (!!this.privSuccessCallback && this.privLastResult) {\n try {\n this.privSuccessCallback(this.privLastResult);\n this.privLastResult = null;\n }\n catch (e) {\n if (!!this.privErrorCallback) {\n this.privErrorCallback(e);\n }\n }\n // Only invoke the call back once.\n // and if it's successful don't invoke the\n // error after that.\n this.privSuccessCallback = undefined;\n this.privErrorCallback = undefined;\n }\n }\n }\n break;\n default:\n try {\n const processed = await this.processTypeSpecificMessages(connectionMessage);\n if (!processed) {\n if (!!this.serviceEvents) {\n this.serviceEvents.onEvent(new Exports_js_2.ServiceEvent(connectionMessage.path.toLowerCase(), connectionMessage.textBody));\n }\n }\n }\n catch (e) {\n //\n }\n }\n const ret = loop();\n return ret;\n }\n catch (error) {\n this.terminateMessageLoop = true;\n communicationCustodian.resolve();\n }\n };\n loop().catch((reason) => {\n Exports_js_2.Events.instance.onEvent(new Exports_js_2.BackgroundEvent(reason));\n });\n return communicationCustodian.promise;\n }\n async startMessageLoop() {\n this.terminateMessageLoop = false;\n try {\n await this.receiveDialogMessageOverride();\n }\n catch (error) {\n await this.cancelRecognition(this.privRequestSession.sessionId, this.privRequestSession.requestId, Exports_js_3.CancellationReason.Error, Exports_js_3.CancellationErrorCode.RuntimeError, error);\n }\n return Promise.resolve();\n }\n // Takes an established websocket connection to the endpoint and sends speech configuration information.\n async configConnection(connection) {\n if (this.terminateMessageLoop) {\n this.terminateMessageLoop = false;\n return Promise.reject(\"Connection to service terminated.\");\n }\n await this.sendSpeechServiceConfig(connection, this.privRequestSession, this.privRecognizerConfig.SpeechServiceConfig.serialize());\n await this.sendAgentConfig(connection);\n return connection;\n }\n async sendPreAudioMessages() {\n const connection = await this.fetchConnection();\n this.addKeywordContextData();\n await this.sendSpeechContext(connection, true);\n await this.sendAgentContext(connection);\n await this.sendWaveHeader(connection);\n }\n sendAgentConfig(connection) {\n if (this.agentConfig && !this.agentConfigSent) {\n if (this.privRecognizerConfig\n .parameters\n .getProperty(Exports_js_3.PropertyId.Conversation_DialogType) === Exports_js_3.DialogServiceConfig.DialogTypes.CustomCommands) {\n const config = this.agentConfig.get();\n config.botInfo.commandsCulture = this.privRecognizerConfig.parameters.getProperty(Exports_js_3.PropertyId.SpeechServiceConnection_RecoLanguage, \"en-us\");\n this.agentConfig.set(config);\n }\n this.onEvent(new DialogEvents_js_1.SendingAgentContextMessageEvent(this.agentConfig));\n const agentConfigJson = this.agentConfig.toJsonString();\n // guard against sending this multiple times on one connection\n this.agentConfigSent = true;\n return connection.send(new SpeechConnectionMessage_Internal_js_1.SpeechConnectionMessage(Exports_js_2.MessageType.Text, \"agent.config\", this.privRequestSession.requestId, \"application/json\", agentConfigJson));\n }\n return;\n }\n sendAgentContext(connection) {\n const guid = Exports_js_2.createGuid();\n const speechActivityTemplate = this.privDialogServiceConnector.properties.getProperty(Exports_js_3.PropertyId.Conversation_Speech_Activity_Template);\n const agentContext = {\n channelData: \"\",\n context: {\n interactionId: guid\n },\n messagePayload: typeof speechActivityTemplate === undefined ? undefined : speechActivityTemplate,\n version: 0.5\n };\n const agentContextJson = JSON.stringify(agentContext);\n return connection.send(new SpeechConnectionMessage_Internal_js_1.SpeechConnectionMessage(Exports_js_2.MessageType.Text, \"speech.agent.context\", this.privRequestSession.requestId, \"application/json\", agentContextJson));\n }\n fireEventForResult(serviceResult, properties) {\n const resultReason = Exports_js_4.EnumTranslation.implTranslateRecognitionResult(serviceResult.RecognitionStatus);\n const offset = serviceResult.Offset + this.privRequestSession.currentTurnAudioOffset;\n const result = new Exports_js_3.SpeechRecognitionResult(this.privRequestSession.requestId, resultReason, serviceResult.DisplayText, serviceResult.Duration, offset, serviceResult.Language, serviceResult.LanguageDetectionConfidence, undefined, undefined, JSON.stringify(serviceResult), properties);\n const ev = new Exports_js_3.SpeechRecognitionEventArgs(result, offset, this.privRequestSession.sessionId);\n return ev;\n }\n handleResponseMessage(responseMessage) {\n // \"response\" messages can contain either \"message\" (activity) or \"MessageStatus\" data. Fire the appropriate\n // event according to the message type that's specified.\n const responsePayload = JSON.parse(responseMessage.textBody);\n switch (responsePayload.messageType.toLowerCase()) {\n case \"message\":\n const responseRequestId = responseMessage.requestId.toUpperCase();\n const activityPayload = ActivityResponsePayload_js_1.ActivityPayloadResponse.fromJSON(responseMessage.textBody);\n const turn = this.privTurnStateManager.GetTurn(responseRequestId);\n // update the conversation Id\n if (activityPayload.conversationId) {\n const updateAgentConfig = this.agentConfig.get();\n updateAgentConfig.botInfo.conversationId = activityPayload.conversationId;\n this.agentConfig.set(updateAgentConfig);\n }\n const pullAudioOutputStream = turn.processActivityPayload(activityPayload, AudioOutputFormat_js_1.AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString(this.privDialogServiceConnector.properties.getProperty(Exports_js_3.PropertyId.SpeechServiceConnection_SynthOutputFormat, undefined)));\n const activity = new Exports_js_3.ActivityReceivedEventArgs(activityPayload.messagePayload, pullAudioOutputStream);\n if (!!this.privDialogServiceConnector.activityReceived) {\n try {\n this.privDialogServiceConnector.activityReceived(this.privDialogServiceConnector, activity);\n /* eslint-disable-next-line no-empty */\n }\n catch (error) {\n // Not going to let errors in the event handler\n // trip things up.\n }\n }\n break;\n case \"messagestatus\":\n if (!!this.privDialogServiceConnector.turnStatusReceived) {\n try {\n this.privDialogServiceConnector.turnStatusReceived(this.privDialogServiceConnector, new Exports_js_3.TurnStatusReceivedEventArgs(responseMessage.textBody));\n /* eslint-disable-next-line no-empty */\n }\n catch (error) {\n // Not going to let errors in the event handler\n // trip things up.\n }\n }\n break;\n default:\n Exports_js_2.Events.instance.onEvent(new Exports_js_2.BackgroundEvent(`Unexpected response of type ${responsePayload.messageType}. Ignoring.`));\n break;\n }\n }\n onEvent(event) {\n this.privEvents.onEvent(event);\n Exports_js_2.Events.instance.onEvent(event);\n }\n addKeywordContextData() {\n const keywordPropertyValue = this.privRecognizerConfig.parameters.getProperty(\"SPEECH-KeywordsToDetect\");\n if (keywordPropertyValue === undefined) {\n return;\n }\n const keywordOffsetPropertyValue = this.privRecognizerConfig.parameters\n .getProperty(\"SPEECH-KeywordsToDetect-Offsets\");\n const keywordDurationPropertyValue = this.privRecognizerConfig.parameters\n .getProperty(\"SPEECH-KeywordsToDetect-Durations\");\n const keywords = keywordPropertyValue.split(\";\");\n const keywordOffsets = keywordOffsetPropertyValue === undefined ? [] : keywordOffsetPropertyValue.split(\";\");\n const keywordDurations = keywordDurationPropertyValue === undefined ? [] : keywordDurationPropertyValue.split(\";\");\n const keywordDefinitionArray = [];\n for (let i = 0; i < keywords.length; i++) {\n const definition = {};\n definition.text = keywords[i];\n if (i < keywordOffsets.length) {\n definition.offset = Number(keywordOffsets[i]);\n }\n if (i < keywordDurations.length) {\n definition.duration = Number(keywordDurations[i]);\n }\n keywordDefinitionArray.push(definition);\n }\n this.speechContext.setSection(\"invocationSource\", \"VoiceActivationWithKeyword\");\n this.speechContext.setSection(\"keywordDetection\", [{\n clientDetectedKeywords: keywordDefinitionArray,\n onReject: { action: \"EndOfTurn\" },\n type: \"startTrigger\"\n }]);\n }\n}\nexports.DialogServiceAdapter = DialogServiceAdapter;\n\n"],"mappings":"AAAA,YAAY;;AACZ;AACA;AAAA,IAAAA,iBAAA,GAAAC,OAAA,qGAAAC,OAAA;AACAC,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,oBAAoB,GAAG,KAAK,CAAC;AACrC,MAAMC,YAAY,GAAGP,OAAO,CAAC,8BAA8B,CAAC;AAC5D,MAAMQ,iBAAiB,GAAGR,OAAO,CAAC,2BAA2B,CAAC;AAC9D,MAAMS,YAAY,GAAGT,OAAO,CAAC,sBAAsB,CAAC;AACpD,MAAMU,sBAAsB,GAAGV,OAAO,CAAC,mCAAmC,CAAC;AAC3E,MAAMW,YAAY,GAAGX,OAAO,CAAC,mBAAmB,CAAC;AACjD,MAAMY,kCAAkC,GAAGZ,OAAO,CAAC,oCAAoC,CAAC;AACxF,MAAMa,YAAY,GAAGb,OAAO,CAAC,cAAc,CAAC;AAC5C,MAAMc,4BAA4B,GAAGd,OAAO,CAAC,8CAA8C,CAAC;AAC5F,MAAMe,qCAAqC,GAAGf,OAAO,CAAC,uCAA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