web-speech-cognitive-services 7.1.4-master.9e026d9 → 8.0.0-main.478b2e9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web-speech-cognitive-services.d.mts +186 -0
- package/dist/web-speech-cognitive-services.d.ts +186 -0
- package/dist/web-speech-cognitive-services.development.js +25677 -0
- package/dist/web-speech-cognitive-services.development.js.map +1 -0
- package/dist/web-speech-cognitive-services.js +1267 -0
- package/dist/web-speech-cognitive-services.js.map +1 -0
- package/dist/web-speech-cognitive-services.mjs +1232 -0
- package/dist/web-speech-cognitive-services.mjs.map +1 -0
- package/dist/web-speech-cognitive-services.production.min.js +31 -0
- package/dist/web-speech-cognitive-services.production.min.js.map +1 -0
- package/package.json +54 -40
- package/CHANGELOG.md +0 -372
- package/lib/BingSpeech/SpeechToText/SpeechGrammarList.js +0 -94
- package/lib/BingSpeech/SpeechToText/SpeechGrammarList.js.map +0 -1
- package/lib/BingSpeech/SpeechToText/createSpeechRecognitionPonyfill.js +0 -483
- package/lib/BingSpeech/SpeechToText/createSpeechRecognitionPonyfill.js.map +0 -1
- package/lib/BingSpeech/SpeechToText.js +0 -14
- package/lib/BingSpeech/SpeechToText.js.map +0 -1
- package/lib/BingSpeech/TextToSpeech/AudioContextConsumer.js +0 -122
- package/lib/BingSpeech/TextToSpeech/AudioContextConsumer.js.map +0 -1
- package/lib/BingSpeech/TextToSpeech/AudioContextQueue.js +0 -104
- package/lib/BingSpeech/TextToSpeech/AudioContextQueue.js.map +0 -1
- package/lib/BingSpeech/TextToSpeech/SpeechSynthesisUtterance.js +0 -264
- package/lib/BingSpeech/TextToSpeech/SpeechSynthesisUtterance.js.map +0 -1
- package/lib/BingSpeech/TextToSpeech/SpeechSynthesisVoice.js +0 -61
- package/lib/BingSpeech/TextToSpeech/SpeechSynthesisVoice.js.map +0 -1
- package/lib/BingSpeech/TextToSpeech/buildSSML.js +0 -32
- package/lib/BingSpeech/TextToSpeech/buildSSML.js.map +0 -1
- package/lib/BingSpeech/TextToSpeech/createSpeechSynthesisPonyfill.js +0 -220
- package/lib/BingSpeech/TextToSpeech/createSpeechSynthesisPonyfill.js.map +0 -1
- package/lib/BingSpeech/TextToSpeech/fetchSpeechData.js +0 -74
- package/lib/BingSpeech/TextToSpeech/fetchSpeechData.js.map +0 -1
- package/lib/BingSpeech/TextToSpeech/fetchVoices.js +0 -335
- package/lib/BingSpeech/TextToSpeech/fetchVoices.js.map +0 -1
- package/lib/BingSpeech/TextToSpeech/isSSML.js +0 -13
- package/lib/BingSpeech/TextToSpeech/isSSML.js.map +0 -1
- package/lib/BingSpeech/TextToSpeech/subscribeEvent.js +0 -14
- package/lib/BingSpeech/TextToSpeech/subscribeEvent.js.map +0 -1
- package/lib/BingSpeech/TextToSpeech.js +0 -14
- package/lib/BingSpeech/TextToSpeech.js.map +0 -1
- package/lib/BingSpeech/Util/DOMEventEmitter.js +0 -61
- package/lib/BingSpeech/Util/DOMEventEmitter.js.map +0 -1
- package/lib/BingSpeech/Util/createFetchTokenUsingSubscriptionKey.js +0 -41
- package/lib/BingSpeech/Util/createFetchTokenUsingSubscriptionKey.js.map +0 -1
- package/lib/BingSpeech/fetchAuthorizationToken.js +0 -57
- package/lib/BingSpeech/fetchAuthorizationToken.js.map +0 -1
- package/lib/BingSpeech/index.js +0 -84
- package/lib/BingSpeech/index.js.map +0 -1
- package/lib/SpeechServices/SpeechSDK.js +0 -19
- package/lib/SpeechServices/SpeechSDK.js.map +0 -1
- package/lib/SpeechServices/SpeechToText/SpeechGrammarList.js +0 -45
- package/lib/SpeechServices/SpeechToText/SpeechGrammarList.js.map +0 -1
- package/lib/SpeechServices/SpeechToText/cognitiveServiceEventResultToWebSpeechRecognitionResultList.js +0 -56
- package/lib/SpeechServices/SpeechToText/cognitiveServiceEventResultToWebSpeechRecognitionResultList.js.map +0 -1
- package/lib/SpeechServices/SpeechToText/createSpeechRecognitionPonyfill.js +0 -984
- package/lib/SpeechServices/SpeechToText/createSpeechRecognitionPonyfill.js.map +0 -1
- package/lib/SpeechServices/SpeechToText.js +0 -24
- package/lib/SpeechServices/SpeechToText.js.map +0 -1
- package/lib/SpeechServices/TextToSpeech/AudioContextConsumer.js +0 -92
- package/lib/SpeechServices/TextToSpeech/AudioContextConsumer.js.map +0 -1
- package/lib/SpeechServices/TextToSpeech/AudioContextQueue.js +0 -111
- package/lib/SpeechServices/TextToSpeech/AudioContextQueue.js.map +0 -1
- package/lib/SpeechServices/TextToSpeech/SpeechSynthesisEvent.js +0 -40
- package/lib/SpeechServices/TextToSpeech/SpeechSynthesisEvent.js.map +0 -1
- package/lib/SpeechServices/TextToSpeech/SpeechSynthesisUtterance.js +0 -283
- package/lib/SpeechServices/TextToSpeech/SpeechSynthesisUtterance.js.map +0 -1
- package/lib/SpeechServices/TextToSpeech/SpeechSynthesisVoice.js +0 -63
- package/lib/SpeechServices/TextToSpeech/SpeechSynthesisVoice.js.map +0 -1
- package/lib/SpeechServices/TextToSpeech/buildSSML.js +0 -32
- package/lib/SpeechServices/TextToSpeech/buildSSML.js.map +0 -1
- package/lib/SpeechServices/TextToSpeech/createSpeechSynthesisPonyfill.js +0 -282
- package/lib/SpeechServices/TextToSpeech/createSpeechSynthesisPonyfill.js.map +0 -1
- package/lib/SpeechServices/TextToSpeech/fetchCustomVoices.js +0 -110
- package/lib/SpeechServices/TextToSpeech/fetchCustomVoices.js.map +0 -1
- package/lib/SpeechServices/TextToSpeech/fetchSpeechData.js +0 -127
- package/lib/SpeechServices/TextToSpeech/fetchSpeechData.js.map +0 -1
- package/lib/SpeechServices/TextToSpeech/fetchVoices.js +0 -87
- package/lib/SpeechServices/TextToSpeech/fetchVoices.js.map +0 -1
- package/lib/SpeechServices/TextToSpeech/isSSML.js +0 -13
- package/lib/SpeechServices/TextToSpeech/isSSML.js.map +0 -1
- package/lib/SpeechServices/TextToSpeech/subscribeEvent.js +0 -14
- package/lib/SpeechServices/TextToSpeech/subscribeEvent.js.map +0 -1
- package/lib/SpeechServices/TextToSpeech.js +0 -14
- package/lib/SpeechServices/TextToSpeech.js.map +0 -1
- package/lib/SpeechServices/fetchAuthorizationToken.js +0 -58
- package/lib/SpeechServices/fetchAuthorizationToken.js.map +0 -1
- package/lib/SpeechServices/patchOptions.js +0 -213
- package/lib/SpeechServices/patchOptions.js.map +0 -1
- package/lib/SpeechServices/resolveFunctionOrReturnValue.js +0 -11
- package/lib/SpeechServices/resolveFunctionOrReturnValue.js.map +0 -1
- package/lib/SpeechServices.js +0 -73
- package/lib/SpeechServices.js.map +0 -1
- package/lib/Util/arrayToMap.js +0 -28
- package/lib/Util/arrayToMap.js.map +0 -1
- package/lib/Util/createPromiseQueue.js +0 -40
- package/lib/Util/createPromiseQueue.js.map +0 -1
- package/lib/index.js +0 -14
- package/lib/index.js.map +0 -1
- package/umd/web-speech-cognitive-services.development.js +0 -4740
- package/umd/web-speech-cognitive-services.production.min.js +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/uuid/dist/commonjs-browser/rng.js","../../../node_modules/uuid/dist/commonjs-browser/regex.js","../../../node_modules/uuid/dist/commonjs-browser/validate.js","../../../node_modules/uuid/dist/commonjs-browser/stringify.js","../../../node_modules/uuid/dist/commonjs-browser/v1.js","../../../node_modules/uuid/dist/commonjs-browser/parse.js","../../../node_modules/uuid/dist/commonjs-browser/v35.js","../../../node_modules/uuid/dist/commonjs-browser/md5.js","../../../node_modules/uuid/dist/commonjs-browser/v3.js","../../../node_modules/uuid/dist/commonjs-browser/native.js","../../../node_modules/uuid/dist/commonjs-browser/v4.js","../../../node_modules/uuid/dist/commonjs-browser/sha1.js","../../../node_modules/uuid/dist/commonjs-browser/v5.js","../../../node_modules/uuid/dist/commonjs-browser/nil.js","../../../node_modules/uuid/dist/commonjs-browser/version.js","../../../node_modules/uuid/dist/commonjs-browser/index.js","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/Guid.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/PlatformEvent.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/AudioSourceEvents.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/ConnectionEvents.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/Error.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/ConnectionMessage.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/ConnectionOpenResponse.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/DeferralMap.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/DialogEvents.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/EventSource.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/Events.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/IConnection.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/IErrorMessages.js","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/List.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/Promise.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/Queue.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/RawWebsocketMessage.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/RiffPcmEncoder.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/Stream.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/TranslationStatus.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/ChunkedArrayBufferStream.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/Timeout.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/OCSPEvents.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/BackgroundError.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/Exports.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/HeaderNames.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/IAuthentication.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/CognitiveSubscriptionKeyAuthentication.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/CognitiveTokenAuthentication.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/LogLevel.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/Contracts.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/src/common.browser/ConsoleLoggingListener.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Audio/src/sdk/Audio/AudioStreamFormat.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/src/common.browser/MicAudioSource.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/src/common.browser/FileAudioSource.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/src/common.browser/PCMRecorder.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/src/common.browser/WebsocketMessageAdapter.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/src/common.browser/WebsocketConnection.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/src/common.browser/ReplayableAudioNode.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Audio/src/sdk/Audio/AudioFileWriter.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Audio/src/sdk/Audio/AudioInputStream.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SpeechSynthesisOutputFormat.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Audio/src/sdk/Audio/AudioOutputFormat.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Audio/src/sdk/Audio/AudioOutputStream.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Audio/src/sdk/Audio/AudioConfig.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/CancellationReason.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Audio/src/sdk/Audio/PullAudioInputStreamCallback.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Audio/src/sdk/Audio/PushAudioOutputStreamCallback.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/KeywordRecognitionModel.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SessionEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/RecognitionEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/OutputFormat.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/IntentRecognitionEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/RecognitionResult.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SpeechRecognitionResult.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/IntentRecognitionResult.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/LanguageUnderstandingModel.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SpeechRecognitionEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/CancellationEventArgsBase.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SpeechRecognitionCanceledEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/TranslationRecognitionEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/TranslationSynthesisEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/TranslationRecognitionResult.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/TranslationSynthesisResult.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/ResultReason.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SpeechConfig.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SpeechTranslationConfig.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/PropertyCollection.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/PropertyId.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/Recognizer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SpeechRecognizer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/IntentRecognizer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/VoiceProfileType.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/ConnectionMessage.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/Connection.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/TranslationRecognizer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/Translations.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/NoMatchReason.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/NoMatchDetails.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/TranslationRecognitionCanceledEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/IntentRecognitionCanceledEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/CancellationDetailsBase.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/CancellationDetails.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/CancellationErrorCodes.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/ConnectionEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/ServiceEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/PhraseListGrammar.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/DialogServiceConfig.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/BotFrameworkConfig.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/CustomCommandsConfig.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/QueryParameterNames.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/ConnectionFactoryBase.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/DialogConnectorFactory.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/DialogServiceConnector.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/ActivityReceivedEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/ServiceMessages/src/common.speech/ServiceMessages/TurnStatusPayload.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/TurnStatusReceivedEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/ServicePropertyChannel.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/ProfanityOption.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Audio/src/sdk/Audio/BaseAudioPlayer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/ConnectionMessageEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/VoiceProfile.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/VoiceProfileEnrollmentResult.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/VoiceProfileResult.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/VoiceProfilePhraseResult.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/VoiceProfileClient.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SpeakerRecognizer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SpeakerIdentificationModel.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SpeakerVerificationModel.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/LanguageIdMode.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/AutoDetectSourceLanguageConfig.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/AutoDetectSourceLanguageResult.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SourceLanguageConfig.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SpeakerRecognitionResult.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Transcription/src/sdk/Transcription/Conversation.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Transcription/src/sdk/Transcription/ConversationCommon.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Transcription/src/sdk/Transcription/ConversationExpirationEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Transcription/src/sdk/Transcription/ConversationParticipantsChangedEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Transcription/src/sdk/Transcription/ConversationTranslationCanceledEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Transcription/src/sdk/Transcription/ConversationTranslationEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Transcription/src/sdk/Transcription/ConversationTranslationResult.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common/src/common/StringUtils.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Transcription/src/common.speech/Transcription/ConversationTranslatorConnectionFactory.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Transcription/src/sdk/Transcription/ConversationTranslator.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Transcription/src/sdk/Transcription/ConversationTranscriber.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Transcription/src/sdk/Transcription/IParticipant.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Transcription/src/sdk/Transcription/ParticipantChangedReason.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Transcription/src/sdk/Transcription/Meeting.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Transcription/src/sdk/Transcription/MeetingTranscriptionCanceledEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Transcription/src/sdk/Transcription/MeetingTranscriber.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Transcription/src/sdk/Transcription/ConversationTranscriptionResult.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Transcription/src/sdk/Transcription/Exports.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/Synthesizer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SpeechSynthesizer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SynthesisResult.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SpeechSynthesisResult.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SpeechSynthesisEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SpeechSynthesisWordBoundaryEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SpeechSynthesisBookmarkEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SpeechSynthesisVisemeEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SpeechSynthesisBoundaryType.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/SynthesisVoicesResult.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/VoiceInfo.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Audio/src/sdk/Audio/SpeakerAudioDestination.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/ConversationTranscriptionCanceledEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/MeetingTranscriptionCanceledEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/PronunciationAssessmentGradingSystem.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/PronunciationAssessmentGranularity.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/PronunciationAssessmentConfig.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/PronunciationAssessmentResult.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/AvatarConfig.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/AvatarEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/SpeechSynthesisConnectionFactory.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/AvatarSynthesizer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/AvatarVideoFormat.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/AvatarWebRTCConnectionResult.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/Diagnostics.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/src/sdk/Exports.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/src/common.browser/ProxyInfo.ts","../../../node_modules/bent/src/core.js","../../../node_modules/bent/src/browser.js","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/src/common.browser/RestMessageAdapter.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/src/common.browser/RestConfigBase.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/src/common.browser/Exports.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/IntentConnectionFactory.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/SpeakerRecognitionConnectionFactory.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/RecognitionEvents.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/SpeechConnectionMessage.Internal.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/ServiceRecognizerBase.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/ConversationServiceRecognizer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/RecognizerConfig.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/WebsocketMessageFormatter.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/SpeechConnectionFactory.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/ConversationTranscriberConnectionFactory.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/TranscriberConnectionFactory.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/TranslationConnectionFactory.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/EnumTranslation.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/ServiceMessages/src/common.speech/ServiceMessages/Enums.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/ServiceMessages/src/common.speech/ServiceMessages/TranslationSynthesisEnd.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/ServiceMessages/src/common.speech/ServiceMessages/TranslationHypothesis.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/ServiceMessages/src/common.speech/ServiceMessages/TranslationPhrase.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/TranslationServiceRecognizer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/ServiceMessages/src/common.speech/ServiceMessages/SpeechDetected.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/ServiceMessages/src/common.speech/ServiceMessages/SpeechHypothesis.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/ServiceMessages/src/common.speech/ServiceMessages/SpeechKeyword.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/SpeechServiceRecognizer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/ConversationTranscriptionServiceRecognizer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/TranscriptionServiceRecognizer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/ServiceMessages/src/common.speech/ServiceMessages/DetailedSpeechPhrase.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/ServiceMessages/src/common.speech/ServiceMessages/SimpleSpeechPhrase.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/AddedLmIntent.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/IntentServiceRecognizer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/ServiceMessages/src/common.speech/ServiceMessages/IntentResponse.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/ServiceTelemetryListener.Internal.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/RequestSession.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/SpeechContext.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/DynamicGrammarBuilder.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/ServiceMessages/src/common.speech/ServiceMessages/ActivityResponsePayload.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/DialogServiceTurnState.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/DialogServiceTurnStateManager.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/DialogServiceAdapter.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/AgentConfig.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Transcription/src/common.speech/Transcription/ConversationConnectionConfig.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Transcription/src/common.speech/Transcription/ConversationManager.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Transcription/src/common.speech/Transcription/ConversationConnectionMessage.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Transcription/src/common.speech/Transcription/ConversationWebsocketMessageFormatter.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Transcription/src/common.speech/Transcription/ConversationConnectionFactory.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Transcription/src/common.speech/Transcription/ConversationRequestSession.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Transcription/src/common.speech/Transcription/ConversationTranslatorEventArgs.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Transcription/src/common.speech/Transcription/ConversationTranslatorInterfaces.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Transcription/ServiceMessages/src/common.speech/Transcription/ServiceMessages/CommandResponsePayload.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Transcription/ServiceMessages/src/common.speech/Transcription/ServiceMessages/ParticipantResponsePayload.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Transcription/ServiceMessages/src/common.speech/Transcription/ServiceMessages/TranslationResponsePayload.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Transcription/ServiceMessages/src/common.speech/Transcription/ServiceMessages/Exports.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Transcription/src/common.speech/Transcription/ConversationServiceAdapter.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Transcription/src/common.speech/Transcription/ConversationTranslatorRecognizer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Transcription/src/common.speech/Transcription/TranscriberRecognizer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/Transcription/src/common.speech/Transcription/Exports.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/ServiceMessages/src/common.speech/ServiceMessages/SynthesisAudioMetadata.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/SynthesisEvents.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/SynthesisTurn.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/SynthesisAdapterBase.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/AvatarSynthesisAdapter.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/SpeechSynthesisAdapter.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/SynthesisRestAdapter.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/SynthesizerConfig.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/SynthesisContext.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/SpeakerRecognitionConfig.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/SpeakerServiceRecognizer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/VoiceServiceRecognizer.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/SpeechServiceConfig.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/src/common.speech/Exports.ts","../../../node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/microsoft.cognitiveservices.speech.sdk.ts","../node_modules/on-error-resume-next/lib/index.js","../../../node_modules/event-as-promise/src/external/p-defer.js","../../../node_modules/event-as-promise/src/index.js","../../../node_modules/src/lib/misc.ts","../../../node_modules/src/lib/error-handler.ts","../../../node_modules/src/lib/global.ts","../../../node_modules/src/lib/warning-handler.ts","../../../node_modules/src/lib/warnings.ts","../../../node_modules/src/lib/event.ts","../../../node_modules/src/lib/dom-exception.ts","../../../node_modules/src/lib/event-wrapper.ts","../../../node_modules/src/lib/listener.ts","../../../node_modules/src/lib/listener-list.ts","../../../node_modules/src/lib/listener-list-map.ts","../../../node_modules/src/lib/event-target.ts","../../../node_modules/src/lib/event-attribute-handler.ts","../../../node_modules/src/lib/legacy.ts","../src/Util/arrayToMap.js","../src/SpeechServices/SpeechSDK.js","../src/SpeechServices/SpeechToText/cognitiveServiceEventResultToWebSpeechRecognitionResultList.js","../../../node_modules/p-defer/index.js","../src/Util/createPromiseQueue.js","../src/SpeechServices/resolveFunctionOrReturnValue.ts","../src/SpeechServices/patchOptions.js","../src/SpeechServices/SpeechToText/SpeechGrammarList.js","../src/SpeechServices/SpeechToText/createSpeechRecognitionPonyfill.js","../src/SpeechServices/SpeechToText.js","../src/SpeechServices/TextToSpeech/createSpeechSynthesisPonyfill.js","../../../node_modules/memoize-one/dist/memoize-one.esm.js","../src/SpeechServices/TextToSpeech/AudioContextConsumer.js","../src/SpeechServices/TextToSpeech/AudioContextQueue.js","../src/SpeechServices/TextToSpeech/SpeechSynthesisVoice.js","../src/SpeechServices/TextToSpeech/fetchCustomVoices.js","../src/SpeechServices/TextToSpeech/fetchVoices.js","../src/SpeechServices/TextToSpeech/SpeechSynthesisEvent.js","../src/SpeechServices/TextToSpeech/SpeechSynthesisUtterance.js","../../../node_modules/src/index.ts","../src/SpeechServices/TextToSpeech/buildSSML.js","../src/SpeechServices/TextToSpeech/isSSML.js","../src/SpeechServices/TextToSpeech/fetchSpeechData.js","../src/SpeechServices/TextToSpeech/subscribeEvent.js","../src/SpeechServices/TextToSpeech.js","../src/SpeechServices.js","../src/index.umd.js"],"sourcesContent":["\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = rng;\n// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nlet getRandomValues;\nconst rnds8 = new Uint8Array(16);\n\nfunction rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);\n\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n\n return getRandomValues(rnds8);\n}","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\nvar _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;\nexports.default = _default;","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _regex = _interopRequireDefault(require(\"./regex.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && _regex.default.test(uuid);\n}\n\nvar _default = validate;\nexports.default = _default;","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\nexports.unsafeStringify = unsafeStringify;\n\nvar _validate = _interopRequireDefault(require(\"./validate.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nfunction unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!(0, _validate.default)(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nvar _default = stringify;\nexports.default = _default;","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _rng = _interopRequireDefault(require(\"./rng.js\"));\n\nvar _stringify = require(\"./stringify.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n// **`v1()` - Generate time-based UUID**\n//\n// Inspired by https://github.com/LiosK/UUID.js\n// and http://docs.python.org/library/uuid.html\nlet _nodeId;\n\nlet _clockseq; // Previous uuid creation time\n\n\nlet _lastMSecs = 0;\nlet _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details\n\nfunction v1(options, buf, offset) {\n let i = buf && offset || 0;\n const b = buf || new Array(16);\n options = options || {};\n let node = options.node || _nodeId;\n let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not\n // specified. We do this lazily to minimize issues related to insufficient\n // system entropy. See #189\n\n if (node == null || clockseq == null) {\n const seedBytes = options.random || (options.rng || _rng.default)();\n\n if (node == null) {\n // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)\n node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];\n }\n\n if (clockseq == null) {\n // Per 4.2.2, randomize (14 bit) clockseq\n clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;\n }\n } // UUID timestamps are 100 nano-second units since the Gregorian epoch,\n // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so\n // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'\n // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.\n\n\n let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock\n // cycle to simulate higher resolution clock\n\n let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)\n\n const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression\n\n if (dt < 0 && options.clockseq === undefined) {\n clockseq = clockseq + 1 & 0x3fff;\n } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new\n // time interval\n\n\n if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {\n nsecs = 0;\n } // Per 4.2.1.2 Throw error if too many uuids are requested\n\n\n if (nsecs >= 10000) {\n throw new Error(\"uuid.v1(): Can't create more than 10M uuids/sec\");\n }\n\n _lastMSecs = msecs;\n _lastNSecs = nsecs;\n _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch\n\n msecs += 12219292800000; // `time_low`\n\n const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;\n b[i++] = tl >>> 24 & 0xff;\n b[i++] = tl >>> 16 & 0xff;\n b[i++] = tl >>> 8 & 0xff;\n b[i++] = tl & 0xff; // `time_mid`\n\n const tmh = msecs / 0x100000000 * 10000 & 0xfffffff;\n b[i++] = tmh >>> 8 & 0xff;\n b[i++] = tmh & 0xff; // `time_high_and_version`\n\n b[i++] = tmh >>> 24 & 0xf | 0x10; // include version\n\n b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)\n\n b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`\n\n b[i++] = clockseq & 0xff; // `node`\n\n for (let n = 0; n < 6; ++n) {\n b[i + n] = node[n];\n }\n\n return buf || (0, _stringify.unsafeStringify)(b);\n}\n\nvar _default = v1;\nexports.default = _default;","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _validate = _interopRequireDefault(require(\"./validate.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction parse(uuid) {\n if (!(0, _validate.default)(uuid)) {\n throw TypeError('Invalid UUID');\n }\n\n let v;\n const arr = new Uint8Array(16); // Parse ########-....-....-....-............\n\n arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;\n arr[1] = v >>> 16 & 0xff;\n arr[2] = v >>> 8 & 0xff;\n arr[3] = v & 0xff; // Parse ........-####-....-....-............\n\n arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;\n arr[5] = v & 0xff; // Parse ........-....-####-....-............\n\n arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;\n arr[7] = v & 0xff; // Parse ........-....-....-####-............\n\n arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;\n arr[9] = v & 0xff; // Parse ........-....-....-....-############\n // (Use \"/\" to avoid 32-bit truncation when bit-shifting high-order bytes)\n\n arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;\n arr[11] = v / 0x100000000 & 0xff;\n arr[12] = v >>> 24 & 0xff;\n arr[13] = v >>> 16 & 0xff;\n arr[14] = v >>> 8 & 0xff;\n arr[15] = v & 0xff;\n return arr;\n}\n\nvar _default = parse;\nexports.default = _default;","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.URL = exports.DNS = void 0;\nexports.default = v35;\n\nvar _stringify = require(\"./stringify.js\");\n\nvar _parse = _interopRequireDefault(require(\"./parse.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction stringToBytes(str) {\n str = unescape(encodeURIComponent(str)); // UTF8 escape\n\n const bytes = [];\n\n for (let i = 0; i < str.length; ++i) {\n bytes.push(str.charCodeAt(i));\n }\n\n return bytes;\n}\n\nconst DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';\nexports.DNS = DNS;\nconst URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';\nexports.URL = URL;\n\nfunction v35(name, version, hashfunc) {\n function generateUUID(value, namespace, buf, offset) {\n var _namespace;\n\n if (typeof value === 'string') {\n value = stringToBytes(value);\n }\n\n if (typeof namespace === 'string') {\n namespace = (0, _parse.default)(namespace);\n }\n\n if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {\n throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');\n } // Compute hash of namespace and value, Per 4.3\n // Future: Use spread syntax when supported on all platforms, e.g. `bytes =\n // hashfunc([...namespace, ... value])`\n\n\n let bytes = new Uint8Array(16 + value.length);\n bytes.set(namespace);\n bytes.set(value, namespace.length);\n bytes = hashfunc(bytes);\n bytes[6] = bytes[6] & 0x0f | version;\n bytes[8] = bytes[8] & 0x3f | 0x80;\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = bytes[i];\n }\n\n return buf;\n }\n\n return (0, _stringify.unsafeStringify)(bytes);\n } // Function#name is not settable on some platforms (#270)\n\n\n try {\n generateUUID.name = name; // eslint-disable-next-line no-empty\n } catch (err) {} // For CommonJS default export support\n\n\n generateUUID.DNS = DNS;\n generateUUID.URL = URL;\n return generateUUID;\n}","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\n/*\n * Browser-compatible JavaScript MD5\n *\n * Modification of JavaScript MD5\n * https://github.com/blueimp/JavaScript-MD5\n *\n * Copyright 2011, Sebastian Tschan\n * https://blueimp.net\n *\n * Licensed under the MIT license:\n * https://opensource.org/licenses/MIT\n *\n * Based on\n * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message\n * Digest Algorithm, as defined in RFC 1321.\n * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009\n * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet\n * Distributed under the BSD License\n * See http://pajhome.org.uk/crypt/md5 for more info.\n */\nfunction md5(bytes) {\n if (typeof bytes === 'string') {\n const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape\n\n bytes = new Uint8Array(msg.length);\n\n for (let i = 0; i < msg.length; ++i) {\n bytes[i] = msg.charCodeAt(i);\n }\n }\n\n return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));\n}\n/*\n * Convert an array of little-endian words to an array of bytes\n */\n\n\nfunction md5ToHexEncodedArray(input) {\n const output = [];\n const length32 = input.length * 32;\n const hexTab = '0123456789abcdef';\n\n for (let i = 0; i < length32; i += 8) {\n const x = input[i >> 5] >>> i % 32 & 0xff;\n const hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);\n output.push(hex);\n }\n\n return output;\n}\n/**\n * Calculate output length with padding and bit length\n */\n\n\nfunction getOutputLength(inputLength8) {\n return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;\n}\n/*\n * Calculate the MD5 of an array of little-endian words, and a bit length.\n */\n\n\nfunction wordsToMd5(x, len) {\n /* append padding */\n x[len >> 5] |= 0x80 << len % 32;\n x[getOutputLength(len) - 1] = len;\n let a = 1732584193;\n let b = -271733879;\n let c = -1732584194;\n let d = 271733878;\n\n for (let i = 0; i < x.length; i += 16) {\n const olda = a;\n const oldb = b;\n const oldc = c;\n const oldd = d;\n a = md5ff(a, b, c, d, x[i], 7, -680876936);\n d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);\n c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);\n b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);\n a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);\n d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);\n c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);\n b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);\n a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);\n d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);\n c = md5ff(c, d, a, b, x[i + 10], 17, -42063);\n b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);\n a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);\n d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);\n c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);\n b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);\n a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);\n d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);\n c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);\n b = md5gg(b, c, d, a, x[i], 20, -373897302);\n a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);\n d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);\n c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);\n b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);\n a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);\n d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);\n c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);\n b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);\n a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);\n d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);\n c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);\n b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);\n a = md5hh(a, b, c, d, x[i + 5], 4, -378558);\n d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);\n c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);\n b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);\n a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);\n d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);\n c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);\n b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);\n a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);\n d = md5hh(d, a, b, c, x[i], 11, -358537222);\n c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);\n b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);\n a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);\n d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);\n c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);\n b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);\n a = md5ii(a, b, c, d, x[i], 6, -198630844);\n d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);\n c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);\n b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);\n a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);\n d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);\n c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);\n b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);\n a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);\n d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);\n c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);\n b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);\n a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);\n d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);\n c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);\n b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);\n a = safeAdd(a, olda);\n b = safeAdd(b, oldb);\n c = safeAdd(c, oldc);\n d = safeAdd(d, oldd);\n }\n\n return [a, b, c, d];\n}\n/*\n * Convert an array bytes to an array of little-endian words\n * Characters >255 have their high-byte silently ignored.\n */\n\n\nfunction bytesToWords(input) {\n if (input.length === 0) {\n return [];\n }\n\n const length8 = input.length * 8;\n const output = new Uint32Array(getOutputLength(length8));\n\n for (let i = 0; i < length8; i += 8) {\n output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;\n }\n\n return output;\n}\n/*\n * Add integers, wrapping at 2^32. This uses 16-bit operations internally\n * to work around bugs in some JS interpreters.\n */\n\n\nfunction safeAdd(x, y) {\n const lsw = (x & 0xffff) + (y & 0xffff);\n const msw = (x >> 16) + (y >> 16) + (lsw >> 16);\n return msw << 16 | lsw & 0xffff;\n}\n/*\n * Bitwise rotate a 32-bit number to the left.\n */\n\n\nfunction bitRotateLeft(num, cnt) {\n return num << cnt | num >>> 32 - cnt;\n}\n/*\n * These functions implement the four basic operations the algorithm uses.\n */\n\n\nfunction md5cmn(q, a, b, x, s, t) {\n return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);\n}\n\nfunction md5ff(a, b, c, d, x, s, t) {\n return md5cmn(b & c | ~b & d, a, b, x, s, t);\n}\n\nfunction md5gg(a, b, c, d, x, s, t) {\n return md5cmn(b & d | c & ~d, a, b, x, s, t);\n}\n\nfunction md5hh(a, b, c, d, x, s, t) {\n return md5cmn(b ^ c ^ d, a, b, x, s, t);\n}\n\nfunction md5ii(a, b, c, d, x, s, t) {\n return md5cmn(c ^ (b | ~d), a, b, x, s, t);\n}\n\nvar _default = md5;\nexports.default = _default;","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _v = _interopRequireDefault(require(\"./v35.js\"));\n\nvar _md = _interopRequireDefault(require(\"./md5.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nconst v3 = (0, _v.default)('v3', 0x30, _md.default);\nvar _default = v3;\nexports.default = _default;","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\nconst randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nvar _default = {\n randomUUID\n};\nexports.default = _default;","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _native = _interopRequireDefault(require(\"./native.js\"));\n\nvar _rng = _interopRequireDefault(require(\"./rng.js\"));\n\nvar _stringify = require(\"./stringify.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction v4(options, buf, offset) {\n if (_native.default.randomUUID && !buf && !options) {\n return _native.default.randomUUID();\n }\n\n options = options || {};\n\n const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return (0, _stringify.unsafeStringify)(rnds);\n}\n\nvar _default = v4;\nexports.default = _default;","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\n// Adapted from Chris Veness' SHA1 code at\n// http://www.movable-type.co.uk/scripts/sha1.html\nfunction f(s, x, y, z) {\n switch (s) {\n case 0:\n return x & y ^ ~x & z;\n\n case 1:\n return x ^ y ^ z;\n\n case 2:\n return x & y ^ x & z ^ y & z;\n\n case 3:\n return x ^ y ^ z;\n }\n}\n\nfunction ROTL(x, n) {\n return x << n | x >>> 32 - n;\n}\n\nfunction sha1(bytes) {\n const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];\n const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];\n\n if (typeof bytes === 'string') {\n const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape\n\n bytes = [];\n\n for (let i = 0; i < msg.length; ++i) {\n bytes.push(msg.charCodeAt(i));\n }\n } else if (!Array.isArray(bytes)) {\n // Convert Array-like to Array\n bytes = Array.prototype.slice.call(bytes);\n }\n\n bytes.push(0x80);\n const l = bytes.length / 4 + 2;\n const N = Math.ceil(l / 16);\n const M = new Array(N);\n\n for (let i = 0; i < N; ++i) {\n const arr = new Uint32Array(16);\n\n for (let j = 0; j < 16; ++j) {\n arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];\n }\n\n M[i] = arr;\n }\n\n M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);\n M[N - 1][14] = Math.floor(M[N - 1][14]);\n M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;\n\n for (let i = 0; i < N; ++i) {\n const W = new Uint32Array(80);\n\n for (let t = 0; t < 16; ++t) {\n W[t] = M[i][t];\n }\n\n for (let t = 16; t < 80; ++t) {\n W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);\n }\n\n let a = H[0];\n let b = H[1];\n let c = H[2];\n let d = H[3];\n let e = H[4];\n\n for (let t = 0; t < 80; ++t) {\n const s = Math.floor(t / 20);\n const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;\n e = d;\n d = c;\n c = ROTL(b, 30) >>> 0;\n b = a;\n a = T;\n }\n\n H[0] = H[0] + a >>> 0;\n H[1] = H[1] + b >>> 0;\n H[2] = H[2] + c >>> 0;\n H[3] = H[3] + d >>> 0;\n H[4] = H[4] + e >>> 0;\n }\n\n return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];\n}\n\nvar _default = sha1;\nexports.default = _default;","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _v = _interopRequireDefault(require(\"./v35.js\"));\n\nvar _sha = _interopRequireDefault(require(\"./sha1.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nconst v5 = (0, _v.default)('v5', 0x50, _sha.default);\nvar _default = v5;\nexports.default = _default;","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\nvar _default = '00000000-0000-0000-0000-000000000000';\nexports.default = _default;","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _validate = _interopRequireDefault(require(\"./validate.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction version(uuid) {\n if (!(0, _validate.default)(uuid)) {\n throw TypeError('Invalid UUID');\n }\n\n return parseInt(uuid.slice(14, 15), 16);\n}\n\nvar _default = version;\nexports.default = _default;","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"NIL\", {\n enumerable: true,\n get: function get() {\n return _nil.default;\n }\n});\nObject.defineProperty(exports, \"parse\", {\n enumerable: true,\n get: function get() {\n return _parse.default;\n }\n});\nObject.defineProperty(exports, \"stringify\", {\n enumerable: true,\n get: function get() {\n return _stringify.default;\n }\n});\nObject.defineProperty(exports, \"v1\", {\n enumerable: true,\n get: function get() {\n return _v.default;\n }\n});\nObject.defineProperty(exports, \"v3\", {\n enumerable: true,\n get: function get() {\n return _v2.default;\n }\n});\nObject.defineProperty(exports, \"v4\", {\n enumerable: true,\n get: function get() {\n return _v3.default;\n }\n});\nObject.defineProperty(exports, \"v5\", {\n enumerable: true,\n get: function get() {\n return _v4.default;\n }\n});\nObject.defineProperty(exports, \"validate\", {\n enumerable: true,\n get: function get() {\n return _validate.default;\n }\n});\nObject.defineProperty(exports, \"version\", {\n enumerable: true,\n get: function get() {\n return _version.default;\n }\n});\n\nvar _v = _interopRequireDefault(require(\"./v1.js\"));\n\nvar _v2 = _interopRequireDefault(require(\"./v3.js\"));\n\nvar _v3 = _interopRequireDefault(require(\"./v4.js\"));\n\nvar _v4 = _interopRequireDefault(require(\"./v5.js\"));\n\nvar _nil = _interopRequireDefault(require(\"./nil.js\"));\n\nvar _version = _interopRequireDefault(require(\"./version.js\"));\n\nvar _validate = _interopRequireDefault(require(\"./validate.js\"));\n\nvar _stringify = _interopRequireDefault(require(\"./stringify.js\"));\n\nvar _parse = _interopRequireDefault(require(\"./parse.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { v4 as uuid } from \"uuid\";\r\n\r\nconst createGuid: () => string = (): string => uuid();\r\n\r\nconst createNoDashGuid: () => string = (): string => createGuid().replace(new RegExp(\"-\", \"g\"), \"\").toUpperCase();\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 { createNoDashGuid } from \"./Guid.js\";\r\nimport { IStringDictionary } from \"./IDictionary.js\";\r\n\r\nexport enum EventType {\r\n Debug,\r\n Info,\r\n Warning,\r\n Error,\r\n None,\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<string>;\r\n\r\n public 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<string> {\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\n/* eslint-disable max-classes-per-file */\r\n\r\nimport { EventType, PlatformEvent } from \"./PlatformEvent.js\";\r\n\r\nexport class AudioSourceEvent extends PlatformEvent {\r\n private privAudioSourceId: string;\r\n\r\n public 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\nexport class AudioSourceInitializingEvent extends AudioSourceEvent {\r\n public constructor(audioSourceId: string) {\r\n super(\"AudioSourceInitializingEvent\", audioSourceId);\r\n }\r\n}\r\n\r\nexport class AudioSourceReadyEvent extends AudioSourceEvent {\r\n public constructor(audioSourceId: string) {\r\n super(\"AudioSourceReadyEvent\", audioSourceId);\r\n }\r\n}\r\n\r\nexport class AudioSourceOffEvent extends AudioSourceEvent {\r\n public constructor(audioSourceId: string) {\r\n super(\"AudioSourceOffEvent\", audioSourceId);\r\n }\r\n}\r\n\r\nexport class AudioSourceErrorEvent extends AudioSourceEvent {\r\n private privError: string;\r\n\r\n public 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\nexport class AudioStreamNodeEvent extends AudioSourceEvent {\r\n private privAudioNodeId: string;\r\n\r\n public 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\nexport class AudioStreamNodeAttachingEvent extends AudioStreamNodeEvent {\r\n public constructor(audioSourceId: string, audioNodeId: string) {\r\n super(\"AudioStreamNodeAttachingEvent\", audioSourceId, audioNodeId);\r\n }\r\n}\r\n\r\nexport class AudioStreamNodeAttachedEvent extends AudioStreamNodeEvent {\r\n public constructor(audioSourceId: string, audioNodeId: string) {\r\n super(\"AudioStreamNodeAttachedEvent\", audioSourceId, audioNodeId);\r\n }\r\n}\r\n\r\nexport class AudioStreamNodeDetachedEvent extends AudioStreamNodeEvent {\r\n public constructor(audioSourceId: string, audioNodeId: string) {\r\n super(\"AudioStreamNodeDetachedEvent\", audioSourceId, audioNodeId);\r\n }\r\n}\r\n\r\nexport class AudioStreamNodeErrorEvent extends AudioStreamNodeEvent {\r\n private privError: string;\r\n\r\n public 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\n/* eslint-disable max-classes-per-file */\r\n\r\nimport { ConnectionMessage } from \"./ConnectionMessage.js\";\r\nimport { IStringDictionary } from \"./IDictionary.js\";\r\nimport { EventType, PlatformEvent } from \"./PlatformEvent.js\";\r\n\r\nexport class ServiceEvent extends PlatformEvent {\r\n private privJsonResult: string;\r\n\r\n public 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\nexport class ConnectionEvent extends PlatformEvent {\r\n private privConnectionId: string;\r\n\r\n public 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\nexport class ConnectionStartEvent extends ConnectionEvent {\r\n private privUri: string;\r\n private privHeaders: IStringDictionary<string>;\r\n\r\n public constructor(connectionId: string, uri: string, headers?: IStringDictionary<string>) {\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<string> {\r\n return this.privHeaders;\r\n }\r\n}\r\n\r\nexport class ConnectionEstablishedEvent extends ConnectionEvent {\r\n public constructor(connectionId: string) {\r\n super(\"ConnectionEstablishedEvent\", connectionId);\r\n }\r\n}\r\n\r\nexport class ConnectionClosedEvent extends ConnectionEvent {\r\n private privReason: string;\r\n private privStatusCode: number;\r\n\r\n public constructor(connectionId: string, statusCode: number, reason: string) {\r\n super(\"ConnectionClosedEvent\", connectionId, EventType.Debug);\r\n this.privReason = reason;\r\n this.privStatusCode = statusCode;\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\nexport class ConnectionErrorEvent extends ConnectionEvent {\r\n private readonly privMessage: string;\r\n private readonly privType: string;\r\n\r\n public 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\nexport class ConnectionEstablishErrorEvent extends ConnectionEvent {\r\n private privStatusCode: number;\r\n private privReason: string;\r\n\r\n public 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\nexport class ConnectionMessageReceivedEvent extends ConnectionEvent {\r\n private privNetworkReceivedTime: string;\r\n private privMessage: ConnectionMessage;\r\n\r\n public 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\nexport class ConnectionMessageSentEvent extends ConnectionEvent {\r\n private privNetworkSentTime: string;\r\n private privMessage: ConnectionMessage;\r\n\r\n public 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\n/* eslint-disable max-classes-per-file */\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\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\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","/* eslint-disable @typescript-eslint/no-unsafe-return */\r\n// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { InvalidOperationError } from \"./Error.js\";\r\nimport { createNoDashGuid } from \"./Guid.js\";\r\nimport { IStringDictionary } from \"./IDictionary.js\";\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<string>;\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<string>,\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 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\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<string> {\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\nexport class ConnectionOpenResponse {\r\n private privStatusCode: number;\r\n private privReason: string;\r\n\r\n public 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 { Deferred } from \"./Promise.js\";\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 DefferalMap\r\n */\r\n\r\nexport class DeferralMap {\r\n private privMap: { [id: string]: Deferred<any> } = {};\r\n\r\n public add<T>(id: string, deferral: Deferred<T>): void {\r\n this.privMap[id] = deferral;\r\n }\r\n\r\n public getId(id: string): Deferred<any> {\r\n return this.privMap[id];\r\n }\r\n\r\n public complete<T>(id: string, result: T): void {\r\n try {\r\n this.privMap[id].resolve(result);\r\n } catch (error) {\r\n this.privMap[id].reject(error as string);\r\n } finally {\r\n this.privMap[id] = undefined;\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/* eslint-disable max-classes-per-file */\r\n\r\nimport { AgentConfig } from \"../common.speech/Exports.js\";\r\nimport { EventType, PlatformEvent } from \"./PlatformEvent.js\";\r\n\r\nexport class DialogEvent extends PlatformEvent {\r\n\r\n public constructor(eventName: string, eventType: EventType = EventType.Info) {\r\n super(eventName, eventType);\r\n }\r\n}\r\n\r\nexport class SendingAgentContextMessageEvent extends DialogEvent {\r\n private privAgentConfig: AgentConfig;\r\n\r\n public constructor(agentConfig: AgentConfig) {\r\n super(\"SendingAgentContextMessageEvent\");\r\n this.privAgentConfig = agentConfig;\r\n }\r\n\r\n public get agentConfig(): AgentConfig {\r\n return this.privAgentConfig;\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.js\";\r\nimport { createNoDashGuid } from \"./Guid.js\";\r\nimport { IDetachable } from \"./IDetachable.js\";\r\nimport { IStringDictionary } from \"./IDictionary.js\";\r\nimport { IEventListener } from \"./IEventListener.js\";\r\nimport { IEventSource } from \"./IEventSource.js\";\r\nimport { PlatformEvent } from \"./PlatformEvent.js\";\r\n\r\nexport class EventSource<TEvent extends PlatformEvent> implements IEventSource<TEvent> {\r\n private privEventListeners: IStringDictionary<(event: TEvent) => void> = {};\r\n private privMetadata: IStringDictionary<string>;\r\n private privIsDisposed: boolean = false;\r\n private privConsoleListener: IDetachable = undefined;\r\n\r\n public constructor(metadata?: IStringDictionary<string>) {\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: (): Promise<void> => {\r\n delete this.privEventListeners[id];\r\n return Promise.resolve();\r\n },\r\n };\r\n }\r\n\r\n public attachListener(listener: IEventListener<TEvent>): IDetachable {\r\n return this.attach((e: TEvent): void => listener.onEvent(e));\r\n }\r\n\r\n public attachConsoleListener(listener: IEventListener<TEvent>): IDetachable {\r\n if (!!this.privConsoleListener) {\r\n void this.privConsoleListener.detach(); // Detach implementation for eventListeners is synchronous\r\n }\r\n this.privConsoleListener = this.attach((e: TEvent): void => listener.onEvent(e));\r\n return this.privConsoleListener;\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<string> {\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 { ArgumentNullError } from \"./Error.js\";\r\nimport { EventSource } from \"./EventSource.js\";\r\nimport { IEventSource } from \"./IEventSource.js\";\r\nimport { PlatformEvent } from \"./PlatformEvent.js\";\r\n\r\nexport class Events {\r\n private static privInstance: IEventSource<PlatformEvent> = new EventSource<PlatformEvent>();\r\n\r\n public static setEventSource(eventSource: IEventSource<PlatformEvent>): 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<PlatformEvent> {\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 { ConnectionEvent } from \"./ConnectionEvents.js\";\r\nimport { ConnectionMessage } from \"./ConnectionMessage.js\";\r\nimport { ConnectionOpenResponse } from \"./ConnectionOpenResponse.js\";\r\nimport { EventSource } from \"./EventSource.js\";\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 {\r\n id: string;\r\n state(): ConnectionState;\r\n open(): Promise<ConnectionOpenResponse>;\r\n send(message: ConnectionMessage): Promise<void>;\r\n read(): Promise<ConnectionMessage>;\r\n events: EventSource<ConnectionEvent>;\r\n dispose(disposing?: string): Promise<void>;\r\n}\r\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n\n//# sourceMappingURL=IErrorMessages.js.map\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ObjectDisposedError } from \"./Error.js\";\r\nimport { IDetachable } from \"./IDetachable.js\";\r\nimport { IStringDictionary } from \"./IDictionary.js\";\r\nimport { IDisposable } from \"./IDisposable.js\";\r\n\r\nexport interface IList<TItem> 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<T2>(callback: (item: TItem, index: number) => T2): List<T2>;\r\n where(callback: (item: TItem, index: number) => boolean): List<TItem>;\r\n orderBy(compareFn: (a: TItem, b: TItem) => number): List<TItem>;\r\n orderByDesc(compareFn: (a: TItem, b: TItem) => number): List<TItem>;\r\n clone(): List<TItem>;\r\n concat(list: List<TItem>): List<TItem>;\r\n concatArray(array: TItem[]): List<TItem>;\r\n}\r\n\r\nexport class List<TItem> implements IList<TItem> {\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: (): Promise<void> => {\r\n delete this.privAddSubscriptions[subscriptionId];\r\n return Promise.resolve();\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: (): Promise<void> => {\r\n delete this.privRemoveSubscriptions[subscriptionId];\r\n return Promise.resolve();\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: (): Promise<void> => {\r\n delete this.privDisposedSubscriptions[subscriptionId];\r\n return Promise.resolve();\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<TItem>();\r\n this.privList.forEach((val: TItem): void => {\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<T2>(callback: (item: TItem, index: number) => T2): List<T2> {\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<T2>(selectList);\r\n }\r\n\r\n public where(callback: (item: TItem, index: number) => boolean): List<TItem> {\r\n this.throwIfDisposed();\r\n const filteredList = new List<TItem>();\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<TItem> {\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<TItem> {\r\n this.throwIfDisposed();\r\n return this.orderBy((a: TItem, b: TItem): number => compareFn(b, a));\r\n }\r\n\r\n public clone(): List<TItem> {\r\n this.throwIfDisposed();\r\n return new List<TItem>(this.toArray());\r\n }\r\n\r\n public concat(list: List<TItem>): List<TItem> {\r\n this.throwIfDisposed();\r\n return new List<TItem>(this.privList.concat(list.toArray()));\r\n }\r\n\r\n public concatArray(array: TItem[]): List<TItem> {\r\n this.throwIfDisposed();\r\n return new List<TItem>(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\n/* eslint-disable max-classes-per-file, @typescript-eslint/typedef */\r\n\r\nexport enum PromiseState {\r\n None,\r\n Resolved,\r\n Rejected,\r\n}\r\n\r\nexport interface IDeferred<T> {\r\n readonly promise: Promise<T>;\r\n\r\n resolve(result: T): IDeferred<T>;\r\n\r\n reject(error: string): IDeferred<T>;\r\n}\r\n\r\nexport class PromiseResult<T> {\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<T>) {\r\n promiseResultEventSource.on((result: T): void => {\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): void => {\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\nexport class PromiseResultEventSource<T> {\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\nexport class Deferred<T> implements IDeferred<T> {\r\n private privPromise: Promise<T>;\r\n private privResolve: (value?: T | PromiseLike<T>) => void;\r\n private privReject: (reason?: any) => void;\r\n\r\n public constructor() {\r\n // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\r\n this.privPromise = new Promise<T>((resolve: (value: T) => void, reject: (reason: any) => void) => {\r\n this.privResolve = resolve;\r\n this.privReject = reject;\r\n });\r\n }\r\n\r\n public get promise(): Promise<T> {\r\n return this.privPromise;\r\n }\r\n\r\n public resolve = (result: T | Promise<T>): Deferred<T> => {\r\n this.privResolve(result);\r\n return this;\r\n };\r\n\r\n public reject = (error: string): Deferred<T> => {\r\n this.privReject(error);\r\n return this;\r\n };\r\n}\r\n\r\nexport class Sink<T> {\r\n private privState: PromiseState = PromiseState.None;\r\n private privPromiseResult: PromiseResult<T> = null;\r\n private privPromiseResultEvents: PromiseResultEventSource<T> = null;\r\n\r\n private privSuccessHandlers: ((result: T) => void)[] = [];\r\n private privErrorHandlers: ((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<T> {\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 // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n successCallback = (): void => { };\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 as string}'`, 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 as string}. 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\r\n// eslint-disable-next-line prefer-arrow/prefer-arrow-functions\r\nexport function marshalPromiseToCallbacks<T>(\r\n promise: Promise<T>,\r\n cb?: (value: T) => void,\r\n err?: (error: string) => void): void {\r\n promise.then((val: T): void => {\r\n try {\r\n if (!!cb) {\r\n cb(val);\r\n }\r\n } catch (error) {\r\n if (!!err) {\r\n try {\r\n if (error instanceof Error) {\r\n const typedError: Error = error ;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error as string);\r\n }\r\n // eslint-disable-next-line no-empty\r\n } catch (error) { }\r\n }\r\n }\r\n }, (error: any): void => {\r\n if (!!err) {\r\n try {\r\n if (error instanceof Error) {\r\n const typedError: Error = error;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error as string);\r\n }\r\n // eslint-disable-next-line no-empty\r\n } catch (error) { }\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 { InvalidOperationError, ObjectDisposedError } from \"./Error.js\";\r\nimport { IDetachable } from \"./IDetachable.js\";\r\nimport { IDisposable } from \"./IDisposable.js\";\r\nimport { List } from \"./List.js\";\r\nimport {\r\n Deferred,\r\n} from \"./Promise.js\";\r\nexport interface IQueue<TItem> extends IDisposable {\r\n enqueue(item: TItem): void;\r\n enqueueFromPromise(promise: Promise<TItem>): void;\r\n dequeue(): Promise<TItem>;\r\n peek(): Promise<TItem>;\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<TItem> implements IQueue<TItem> {\r\n private privPromiseStore: List<Promise<TItem>> = new List<Promise<TItem>>();\r\n private privList: List<TItem>;\r\n private privDetachables: IDetachable[];\r\n private privSubscribers: List<{ type: SubscriberType; deferral: Deferred<TItem> }>;\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<TItem>) {\r\n this.privList = list ? list : new List<TItem>();\r\n this.privDetachables = [];\r\n this.privSubscribers = new List<{ type: SubscriberType; deferral: Deferred<TItem> }>();\r\n this.privDetachables.push(this.privList.onAdded((): void => this.drain()));\r\n }\r\n\r\n public enqueue(item: TItem): void {\r\n this.throwIfDispose();\r\n this.enqueueFromPromise(new Promise<TItem>((resolve: (value: TItem) => void): void => resolve(item)));\r\n }\r\n\r\n public enqueueFromPromise(promise: Promise<TItem>): void {\r\n this.throwIfDispose();\r\n promise.then((val: TItem): void => {\r\n this.privList.add(val);\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n }, (): void => { });\r\n }\r\n\r\n public dequeue(): Promise<TItem> {\r\n this.throwIfDispose();\r\n const deferredSubscriber = new Deferred<TItem>();\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<TItem> {\r\n this.throwIfDispose();\r\n const deferredSubscriber = new Deferred<TItem>();\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 async drainAndDispose(pendingItemProcessor: (pendingItemInQueue: TItem) => void, reason?: string): Promise<void> {\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 await detachable.detach();\r\n }\r\n\r\n if (this.privPromiseStore.length() > 0 && pendingItemProcessor) {\r\n const promiseArray: Promise<TItem>[] = [];\r\n\r\n this.privPromiseStore.toArray().forEach((wrapper: Promise<TItem>): void => {\r\n promiseArray.push(wrapper);\r\n });\r\n return Promise.all(promiseArray).finally((): void => {\r\n this.privSubscribers = null;\r\n this.privList.forEach((item: TItem): void => {\r\n pendingItemProcessor(item);\r\n });\r\n this.privList = null;\r\n return;\r\n }).then<void>();\r\n } else {\r\n this.privSubscribers = null;\r\n this.privList = null;\r\n }\r\n }\r\n }\r\n\r\n public async dispose(reason?: string): Promise<void> {\r\n await 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","/* eslint-disable @typescript-eslint/no-unsafe-assignment */\r\n// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { MessageType } from \"./ConnectionMessage.js\";\r\nimport { ArgumentNullError, InvalidOperationError } from \"./Error.js\";\r\nimport { createNoDashGuid } from \"./Guid.js\";\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 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\r\n if (messageType === MessageType.Binary && Object.getPrototypeOf(payload).constructor.name !== \"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 // eslint-disable-next-line @typescript-eslint/no-unsafe-return\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 as ArrayBuffer;\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(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 (!srcFrame) {\r\n return null;\r\n }\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.js\";\r\nimport { createNoDashGuid } from \"./Guid.js\";\r\nimport { Queue } from \"./Queue.js\";\r\n\r\nexport interface IStreamChunk<TBuffer> {\r\n isEnd: boolean;\r\n buffer: TBuffer;\r\n timeReceived: number;\r\n}\r\n\r\nexport class Stream<TBuffer> {\r\n private privId: string;\r\n private privIsWriteEnded: boolean = false;\r\n private privIsReadEnded: boolean = false;\r\n private privReaderQueue: Queue<IStreamChunk<TBuffer>>;\r\n\r\n public constructor(streamId?: string) {\r\n this.privId = streamId ? streamId : createNoDashGuid();\r\n this.privReaderQueue = new Queue<IStreamChunk<TBuffer>>();\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<TBuffer>): 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<IStreamChunk<TBuffer>> {\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 .then(async (streamChunk: IStreamChunk<TBuffer>): Promise<IStreamChunk<TBuffer>> => {\r\n if (streamChunk === undefined || streamChunk.isEnd) {\r\n await this.privReaderQueue.dispose(\"End of stream reached\");\r\n }\r\n\r\n return streamChunk;\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<IStreamChunk<TBuffer>>();\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.js\";\r\n\r\nexport class ChunkedArrayBufferStream extends Stream<ArrayBuffer> {\r\n private privTargetChunkSize: number;\r\n private privNextBufferToWrite: ArrayBuffer;\r\n private privNextBufferStartTime: number;\r\n private privNextBufferReadyBytes: number;\r\n\r\n public 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<ArrayBuffer>): 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: number): void => Timeout.timers().clearTimeout(timerId);\r\n\r\n public static setTimeout: IWorkerTimers[\"setTimeout\"] = (func: () => any, delay: number): number => Timeout.timers().setTimeout(func, delay);\r\n\r\n public static load(): any {\r\n // Prefilling the Maps with a function indexed by zero is necessary to be compliant with the specification.\r\n const scheduledTimeoutFunctions: Map<number, number | Func> = new Map([[0, (): void => { }]]); // eslint-disable-line @typescript-eslint/no-empty-function\r\n const unhandledRequests: Map<number, number> = new Map();\r\n\r\n // eslint-disable-next-line\r\n const workerScript = `!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})}})}]);`;\r\n const workerUrl = \"data:text/javascript;base64,\" + btoa(workerScript);\r\n const worker = new Worker(workerUrl);\r\n\r\n worker.addEventListener(\"message\", ({ data }: IWorkerEvent): void => {\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): void => {\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): 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(): () => IWorkerTimers {\r\n return (): IWorkerTimers => {\r\n if (Timeout.workerTimers !== null) {\r\n return Timeout.workerTimers;\r\n }\r\n\r\n Timeout.workerTimers = Timeout.load() as IWorkerTimers;\r\n\r\n return Timeout.workerTimers;\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\n/* eslint-disable max-classes-per-file */\r\n\r\nimport { EventType, PlatformEvent } from \"./PlatformEvent.js\";\r\n\r\nexport class OCSPEvent extends PlatformEvent {\r\n private privSignature: string;\r\n\r\n public 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\nexport class OCSPMemoryCacheHitEvent extends OCSPEvent {\r\n public constructor(signature: string) {\r\n super(\"OCSPMemoryCacheHitEvent\", EventType.Debug, signature);\r\n }\r\n}\r\n\r\nexport class OCSPCacheMissEvent extends OCSPEvent {\r\n public constructor(signature: string) {\r\n super(\"OCSPCacheMissEvent\", EventType.Debug, signature);\r\n }\r\n}\r\n\r\nexport class OCSPDiskCacheHitEvent extends OCSPEvent {\r\n public constructor(signature: string) {\r\n super(\"OCSPDiskCacheHitEvent\", EventType.Debug, signature);\r\n }\r\n}\r\n\r\nexport class OCSPCacheUpdateNeededEvent extends OCSPEvent {\r\n public constructor(signature: string) {\r\n super(\"OCSPCacheUpdateNeededEvent\", EventType.Debug, signature);\r\n }\r\n}\r\n\r\nexport class OCSPMemoryCacheStoreEvent extends OCSPEvent {\r\n public constructor(signature: string) {\r\n super(\"OCSPMemoryCacheStoreEvent\", EventType.Debug, signature);\r\n }\r\n}\r\n\r\nexport class OCSPDiskCacheStoreEvent extends OCSPEvent {\r\n public constructor(signature: string) {\r\n super(\"OCSPDiskCacheStoreEvent\", EventType.Debug, signature);\r\n }\r\n}\r\n\r\nexport class OCSPCacheUpdateCompleteEvent extends OCSPEvent {\r\n public constructor(signature: string) {\r\n super(\"OCSPCacheUpdateCompleteEvent\", EventType.Debug, signature);\r\n }\r\n}\r\n\r\nexport class OCSPStapleReceivedEvent extends OCSPEvent {\r\n public constructor() {\r\n super(\"OCSPStapleReceivedEvent\", EventType.Debug, \"\");\r\n }\r\n}\r\n\r\nexport class OCSPWSUpgradeStartedEvent extends OCSPEvent {\r\n public constructor(serialNumber: string) {\r\n super(\"OCSPWSUpgradeStartedEvent\", EventType.Debug, serialNumber);\r\n }\r\n}\r\n\r\nexport class OCSPCacheEntryExpiredEvent extends OCSPEvent {\r\n private privExpireTime: number;\r\n\r\n public constructor(serialNumber: string, expireTime: number) {\r\n super(\"OCSPCacheEntryExpiredEvent\", EventType.Debug, serialNumber);\r\n this.privExpireTime = expireTime;\r\n }\r\n}\r\n\r\nexport class OCSPCacheEntryNeedsRefreshEvent extends OCSPEvent {\r\n private privExpireTime: number;\r\n private privStartTime: number;\r\n\r\n public 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\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 public 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\nexport class OCSPVerificationFailedEvent extends OCSPEvent {\r\n private privError: string;\r\n\r\n public constructor(serialNumber: string, error: string) {\r\n super(\"OCSPVerificationFailedEvent\", EventType.Debug, serialNumber);\r\n this.privError = error;\r\n }\r\n}\r\n\r\nexport class OCSPCacheFetchErrorEvent extends OCSPEvent {\r\n private privError: string;\r\n\r\n public constructor(serialNumber: string, error: string) {\r\n super(\"OCSPCacheFetchErrorEvent\", EventType.Debug, serialNumber);\r\n this.privError = error;\r\n }\r\n}\r\n\r\nexport class OCSPResponseRetrievedEvent extends OCSPEvent {\r\n public constructor(serialNumber: string) {\r\n super(\"OCSPResponseRetrievedEvent\", EventType.Debug, serialNumber);\r\n }\r\n}\r\n\r\nexport class OCSPCacheUpdateErrorEvent extends OCSPEvent {\r\n private privError: string;\r\n\r\n public constructor(serialNumber: string, error: string) {\r\n super(\"OCSPCacheUpdateErrorEvent\", EventType.Debug, serialNumber);\r\n this.privError = error;\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 EventType,\r\n PlatformEvent\r\n} from \"./Exports.js\";\r\n\r\nexport class BackgroundEvent extends PlatformEvent {\r\n private privError: string;\r\n\r\n public constructor(error: string) {\r\n super(\"BackgroundEvent\", 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","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nexport * from \"./AudioSourceEvents.js\";\r\nexport * from \"./ConnectionEvents.js\";\r\nexport * from \"./ConnectionMessage.js\";\r\nexport * from \"./ConnectionOpenResponse.js\";\r\nexport * from \"./DeferralMap.js\";\r\nexport * from \"./DialogEvents.js\";\r\nexport * from \"./Error.js\";\r\nexport * from \"./Events.js\";\r\nexport * from \"./EventSource.js\";\r\nexport * from \"./Guid.js\";\r\nexport * from \"./IAudioSource.js\";\r\nexport * from \"./IConnection.js\";\r\nexport * from \"./IDetachable.js\";\r\nexport * from \"./IDictionary.js\";\r\nexport * from \"./IDisposable.js\";\r\nexport * from \"./IEventListener.js\";\r\nexport * from \"./IEventSource.js\";\r\nexport * from \"./IErrorMessages.js\";\r\nexport * from \"./ITimer.js\";\r\nexport * from \"./IWebsocketMessageFormatter.js\";\r\nexport * from \"./List.js\";\r\nexport * from \"./PlatformEvent.js\";\r\nexport * from \"./Promise.js\";\r\nexport * from \"./Queue.js\";\r\nexport * from \"./RawWebsocketMessage.js\";\r\nexport * from \"./RiffPcmEncoder.js\";\r\nexport * from \"./Stream.js\";\r\nexport { TranslationStatus } from \"../common.speech/TranslationStatus.js\";\r\nexport * from \"./ChunkedArrayBufferStream.js\";\r\nexport * from \"./IAudioDestination.js\";\r\nexport * from \"./Timeout.js\";\r\nexport * from \"./OCSPEvents.js\";\r\nexport * from \"./BackgroundError.js\";\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nexport class HeaderNames {\r\n public static AuthKey: string = \"Ocp-Apim-Subscription-Key\";\r\n public static Authorization: string = \"Authorization\";\r\n public static SpIDAuthKey: string = \"Apim-Subscription-Id\";\r\n public static ConnectionId: string = \"X-ConnectionId\";\r\n public static ContentType: string = \"Content-Type\";\r\n public static CustomCommandsAppId: string = \"X-CommandsAppId\";\r\n public static Path: string = \"Path\";\r\n public static RequestId: string = \"X-RequestId\";\r\n public static RequestStreamId: string = \"X-StreamId\";\r\n public static RequestTimestamp: string = \"X-Timestamp\";\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nexport interface IAuthentication {\r\n fetch(authFetchEventId: string): Promise<AuthInfo>;\r\n fetchOnExpiry(authFetchEventId: string): Promise<AuthInfo>;\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 {\r\n ArgumentNullError,\r\n} from \"../common/Exports.js\";\r\nimport { HeaderNames } from \"./HeaderNames.js\";\r\nimport {\r\n AuthInfo,\r\n IAuthentication\r\n} from \"./IAuthentication.js\";\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 public constructor(subscriptionKey: string) {\r\n if (!subscriptionKey) {\r\n throw new ArgumentNullError(\"subscriptionKey\");\r\n }\r\n\r\n this.privAuthInfo = new AuthInfo(HeaderNames.AuthKey, 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 // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public fetch(authFetchEventId: string): Promise<AuthInfo> {\r\n return Promise.resolve(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 // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public fetchOnExpiry(authFetchEventId: string): Promise<AuthInfo> {\r\n return Promise.resolve(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 { ArgumentNullError } from \"../common/Exports.js\";\r\nimport { AuthInfo, IAuthentication } from \"./IAuthentication.js\";\r\nimport { HeaderNames } from \"./HeaderNames.js\";\r\n\r\nexport class CognitiveTokenAuthentication implements IAuthentication {\r\n private static privTokenPrefix: string = \"Bearer \";\r\n private privFetchCallback: (authFetchEventId: string) => Promise<string>;\r\n private privFetchOnExpiryCallback: (authFetchEventId: string) => Promise<string>;\r\n\r\n public constructor(fetchCallback: (authFetchEventId: string) => Promise<string>, fetchOnExpiryCallback: (authFetchEventId: string) => Promise<string>) {\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<AuthInfo> {\r\n return this.privFetchCallback(authFetchEventId).then((token: string): AuthInfo => new AuthInfo(HeaderNames.Authorization, token === undefined ? undefined : CognitiveTokenAuthentication.privTokenPrefix + token));\r\n }\r\n\r\n public fetchOnExpiry(authFetchEventId: string): Promise<AuthInfo> {\r\n return this.privFetchOnExpiryCallback(authFetchEventId).then((token: string): AuthInfo => new AuthInfo(HeaderNames.Authorization, token === undefined ? undefined : CognitiveTokenAuthentication.privTokenPrefix + 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 { EventType } from \"../common/Exports.js\";\r\n\r\n/**\r\n * Define event severity types for setting logging output.\r\n * @class LogLevel\r\n */\r\n\r\nexport { EventType as LogLevel };\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 throwIfNullOrTooLong(param: string, name: string, maxLength: number): void {\r\n Contracts.throwIfNullOrUndefined(param, name);\r\n\r\n if ((\"\" + param).length > maxLength) {\r\n throw new Error(\"throwIfNullOrTooLong:\" + name + \" (more than \" + maxLength.toString() + \" characters)\");\r\n }\r\n }\r\n\r\n public static throwIfNullOrTooShort(param: string, name: string, minLength: number): void {\r\n Contracts.throwIfNullOrUndefined(param, name);\r\n\r\n if ((\"\" + param).length < minLength) {\r\n throw new Error(\"throwIfNullOrTooShort:\" + name + \" (less than \" + minLength.toString() + \" characters)\");\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: string, 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","/* eslint-disable @typescript-eslint/no-unsafe-assignment */\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 { LogLevel } from \"../sdk/LogLevel.js\";\r\nimport { IEventListener, PlatformEvent } from \"../common/Exports.js\";\r\nimport { Contracts } from \"../sdk/Contracts.js\";\r\n\r\nexport class ConsoleLoggingListener implements IEventListener<PlatformEvent> {\r\n private privLogLevelFilter: LogLevel;\r\n private privLogPath: fs.PathLike = undefined;\r\n private privEnableConsoleOutput: boolean = true;\r\n\r\n public logCallback: (s: string) => void;\r\n\r\n public constructor(logLevelFilter: LogLevel = LogLevel.None) { // Console output disabled by default\r\n this.privLogLevelFilter = logLevelFilter;\r\n }\r\n\r\n public set logPath(path: fs.PathLike) {\r\n Contracts.throwIfNullOrUndefined(fs.openSync, \"\\nFile System access not available\");\r\n this.privLogPath = path;\r\n }\r\n\r\n public set enableConsoleOutput(enableOutput: boolean) {\r\n this.privEnableConsoleOutput = enableOutput;\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 if (!!this.logCallback) {\r\n this.logCallback(log);\r\n }\r\n if (!!this.privLogPath) {\r\n fs.writeFileSync(this.privLogPath, log + \"\\n\", { flag: \"a+\" });\r\n }\r\n\r\n if (this.privEnableConsoleOutput) {\r\n switch (event.eventType) {\r\n case LogLevel.Debug:\r\n // eslint-disable-next-line no-console\r\n console.debug(log);\r\n break;\r\n case LogLevel.Info:\r\n // eslint-disable-next-line no-console\r\n console.info(log);\r\n break;\r\n case LogLevel.Warning:\r\n // eslint-disable-next-line no-console\r\n console.warn(log);\r\n break;\r\n case LogLevel.Error:\r\n // eslint-disable-next-line no-console\r\n console.error(log);\r\n break;\r\n default:\r\n // eslint-disable-next-line no-console\r\n console.log(log);\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n private toString(event: PlatformEvent): string {\r\n const logFragments = [\r\n `${event.eventTime}`,\r\n `${event.name}`,\r\n ];\r\n\r\n const e: any = event as any;\r\n for (const prop in e) {\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 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\r\n const value = e[prop];\r\n let valueToLog = \"<NULL>\";\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\n// eslint-disable-next-line max-classes-per-file\r\nexport enum AudioFormatTag {\r\n PCM = 1,\r\n MuLaw,\r\n Siren,\r\n MP3,\r\n SILKSkype,\r\n OGG_OPUS,\r\n WEBM_OPUS,\r\n ALaw,\r\n FLAC,\r\n OPUS,\r\n}\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 format characteristics.\r\n * @member AudioStreamFormat.getWaveFormat\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 * @param {AudioFormatTag} format - Audio format (PCM, alaw or mulaw).\r\n * @returns {AudioStreamFormat} The audio stream format being created.\r\n */\r\n public static getWaveFormat(samplesPerSecond: number, bitsPerSample: number, channels: number, format: AudioFormatTag): AudioStreamFormat {\r\n return new AudioStreamFormatImpl(samplesPerSecond, bitsPerSample, channels, format);\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\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 * @param {AudioFormatTag} format - Audio format (PCM, alaw or mulaw).\r\n */\r\n public constructor(samplesPerSec: number = 16000, bitsPerSample: number = 16, channels: number = 1, format: AudioFormatTag = AudioFormatTag.PCM) {\r\n super();\r\n\r\n let isWavFormat: boolean = true;\r\n /* 1 for PCM; 6 for alaw; 7 for mulaw */\r\n switch (format) {\r\n case AudioFormatTag.PCM:\r\n this.formatTag = 1;\r\n break;\r\n case AudioFormatTag.ALaw:\r\n this.formatTag = 6;\r\n break;\r\n case AudioFormatTag.MuLaw:\r\n this.formatTag = 7;\r\n break;\r\n default:\r\n isWavFormat = false;\r\n }\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 if (isWavFormat) {\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 /* audio format */\r\n view.setUint16(20, this.formatTag, 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 /**\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 * Creates an audio context appropriate to current browser\r\n * @member AudioStreamFormatImpl.getAudioContext\r\n * @function\r\n * @public\r\n * @returns {AudioContext} An audio context instance\r\n */\r\n /* eslint-disable */\r\n public static getAudioContext(sampleRate?: number): AudioContext {\r\n // Workaround for Speech SDK bug in Safari.\r\n const AudioContext = (window as any).AudioContext // our preferred impl\r\n || (window as any).webkitAudioContext // fallback, mostly when on Safari\r\n || false; // could not find.\r\n\r\n // https://developer.mozilla.org/en-US/docs/Web/API/AudioContext\r\n if (!!AudioContext) {\r\n if (sampleRate !== undefined && navigator.mediaDevices.getSupportedConstraints().sampleRate) {\r\n return new AudioContext({ sampleRate });\r\n } else {\r\n return new AudioContext();\r\n }\r\n } else {\r\n throw new Error(\"Browser does not support Web Audio API (AudioContext is not available).\");\r\n }\r\n }\r\n /* eslint-enable */\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 {\r\n return;\r\n }\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 connectivity,\r\n ISpeechConfigAudioDevice,\r\n type\r\n} from \"../common.speech/Exports.js\";\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 Stream,\r\n} from \"../common/Exports.js\";\r\nimport { IStreamChunk } from \"../common/Stream.js\";\r\nimport {\r\n AudioStreamFormat,\r\n AudioStreamFormatImpl,\r\n} from \"../sdk/Audio/AudioStreamFormat.js\";\r\nimport { IRecorder } from \"./IRecorder.js\";\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 | undefined, errorCallback: NavigatorUserMediaErrorCallback) => void;\r\n mozGetUserMedia: (constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback | undefined, 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<Stream<ArrayBuffer>> = {};\r\n\r\n private privId: string;\r\n\r\n private privEvents: EventSource<AudioSourceEvent>;\r\n\r\n private privInitializeDeferral: Deferred<void>;\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 private privIsClosing: boolean;\r\n\r\n public constructor(\r\n private readonly privRecorder: IRecorder,\r\n private readonly deviceId?: string,\r\n audioSourceId?: string,\r\n mediaStream?: MediaStream\r\n ) {\r\n\r\n this.privOutputChunkSize = MicAudioSource.AUDIOFORMAT.avgBytesPerSec / 10;\r\n this.privId = audioSourceId ? audioSourceId : createNoDashGuid();\r\n this.privEvents = new EventSource<AudioSourceEvent>();\r\n this.privMediaStream = mediaStream || null;\r\n this.privIsClosing = false;\r\n }\r\n\r\n public get format(): Promise<AudioStreamFormatImpl> {\r\n return Promise.resolve(MicAudioSource.AUDIOFORMAT);\r\n }\r\n\r\n public turnOn(): Promise<void> {\r\n if (this.privInitializeDeferral) {\r\n return this.privInitializeDeferral.promise;\r\n }\r\n\r\n this.privInitializeDeferral = new Deferred<void>();\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;\r\n this.privInitializeDeferral.reject(typedError.name + \": \" + typedError.message);\r\n } else {\r\n this.privInitializeDeferral.reject(error as string);\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 // eslint-disable-next-line\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 = (): void => {\r\n this.onEvent(new AudioSourceInitializingEvent(this.privId)); // no stream id\r\n if (this.privMediaStream && this.privMediaStream.active) {\r\n this.onEvent(new AudioSourceReadyEvent(this.privId));\r\n this.privInitializeDeferral.resolve();\r\n } else {\r\n getUserMedia(\r\n { audio: this.deviceId ? { deviceId: this.deviceId } : true, video: false },\r\n (mediaStream: MediaStream): void => {\r\n this.privMediaStream = mediaStream;\r\n this.onEvent(new AudioSourceReadyEvent(this.privId));\r\n this.privInitializeDeferral.resolve();\r\n }, (error: any): void => {\r\n const errorMsg = `Error occurred during microphone initialization: ${error as string}`;\r\n this.privInitializeDeferral.reject(errorMsg);\r\n this.onEvent(new AudioSourceErrorEvent(this.privId, errorMsg));\r\n });\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()\r\n .then(next)\r\n .catch((reason: any): void => {\r\n this.privInitializeDeferral.reject(`Failed to initialize audio context: ${reason as string}`);\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<IAudioStreamNode> {\r\n this.onEvent(new AudioStreamNodeAttachingEvent(this.privId, audioNodeId));\r\n\r\n return this.listen(audioNodeId).then<IAudioStreamNode>(\r\n (stream: Stream<ArrayBuffer>): IAudioStreamNode => {\r\n this.onEvent(new AudioStreamNodeAttachedEvent(this.privId, audioNodeId));\r\n return {\r\n detach: async (): Promise<void> => {\r\n stream.readEnded();\r\n delete this.privStreams[audioNodeId];\r\n this.onEvent(new AudioStreamNodeDetachedEvent(this.privId, audioNodeId));\r\n return this.turnOff();\r\n },\r\n id: (): string => audioNodeId,\r\n read: (): Promise<IStreamChunk<ArrayBuffer>> => stream.read(),\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 async turnOff(): Promise<void> {\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 if (this.privInitializeDeferral) {\r\n // Correctly handle when browser forces mic off before turnOn() completes\r\n // eslint-disable-next-line @typescript-eslint/await-thenable\r\n await this.privInitializeDeferral;\r\n this.privInitializeDeferral = null;\r\n }\r\n\r\n await this.destroyAudioContext();\r\n\r\n return;\r\n }\r\n\r\n public get events(): EventSource<AudioSourceEvent> {\r\n return this.privEvents;\r\n }\r\n\r\n public get deviceInfo(): Promise<ISpeechConfigAudioDevice> {\r\n return this.getMicrophoneLabel().then((label: string): ISpeechConfigAudioDevice => (\r\n {\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<string> {\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 Promise.resolve(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 Promise.resolve(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 Promise.resolve(this.privMicrophoneLabel);\r\n }\r\n\r\n const deferred: Deferred<string> = new Deferred<string>();\r\n\r\n // Enumerate the media devices.\r\n navigator.mediaDevices.enumerateDevices().then((devices: MediaDeviceInfo[]): void => {\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<string> => deferred.resolve(this.privMicrophoneLabel));\r\n\r\n return deferred.promise;\r\n }\r\n\r\n private async listen(audioNodeId: string): Promise<Stream<ArrayBuffer>> {\r\n await this.turnOn();\r\n const stream = new ChunkedArrayBufferStream(this.privOutputChunkSize, audioNodeId);\r\n this.privStreams[audioNodeId] = stream;\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 as string));\r\n throw error;\r\n }\r\n const result: Stream<ArrayBuffer> = stream;\r\n return result;\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 this.privContext = AudioStreamFormatImpl.getAudioContext(MicAudioSource.AUDIOFORMAT.samplesPerSec);\r\n }\r\n\r\n private async destroyAudioContext(): Promise<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 if (!this.privIsClosing) {\r\n // The audio context close may take enough time that the close is called twice\r\n this.privIsClosing = true;\r\n await this.privContext.close();\r\n this.privContext = null;\r\n this.privIsClosing = false;\r\n }\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 await 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\nimport {\r\n connectivity,\r\n ISpeechConfigAudioDevice,\r\n type,\r\n} from \"../common.speech/Exports.js\";\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 IStreamChunk,\r\n IStringDictionary,\r\n Stream,\r\n} from \"../common/Exports.js\";\r\nimport { AudioStreamFormat, AudioStreamFormatImpl } from \"../sdk/Audio/AudioStreamFormat.js\";\r\n\r\nexport class FileAudioSource implements IAudioSource {\r\n\r\n private privAudioFormatPromise: Promise<AudioStreamFormatImpl>;\r\n\r\n private privStreams: IStringDictionary<Stream<ArrayBuffer>> = {};\r\n\r\n private privId: string;\r\n\r\n private privEvents: EventSource<AudioSourceEvent>;\r\n\r\n private privSource: Blob | Buffer;\r\n\r\n private privFilename: string;\r\n\r\n private privHeaderEnd: number = 44;\r\n\r\n public constructor(file: File | Buffer, filename?: string, audioSourceId?: string) {\r\n this.privId = audioSourceId ? audioSourceId : createNoDashGuid();\r\n this.privEvents = new EventSource<AudioSourceEvent>();\r\n this.privSource = file;\r\n if (typeof window !== \"undefined\" && typeof Blob !== \"undefined\" && this.privSource instanceof Blob) {\r\n this.privFilename = (file as File).name;\r\n } else {\r\n this.privFilename = filename || \"unknown.wav\";\r\n }\r\n\r\n // Read the header.\r\n this.privAudioFormatPromise = this.readHeader();\r\n }\r\n\r\n public get format(): Promise<AudioStreamFormatImpl> {\r\n return this.privAudioFormatPromise;\r\n }\r\n\r\n public turnOn(): Promise<void> {\r\n if (this.privFilename.lastIndexOf(\".wav\") !== this.privFilename.length - 4) {\r\n const errorMsg = this.privFilename + \" is not supported. Only WAVE files are allowed at the moment.\";\r\n this.onEvent(new AudioSourceErrorEvent(errorMsg, \"\"));\r\n return Promise.reject(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;\r\n }\r\n\r\n public id(): string {\r\n return this.privId;\r\n }\r\n\r\n public async attach(audioNodeId: string): Promise<IAudioStreamNode> {\r\n this.onEvent(new AudioStreamNodeAttachingEvent(this.privId, audioNodeId));\r\n\r\n const stream: Stream<ArrayBuffer> = await this.upload(audioNodeId);\r\n\r\n this.onEvent(new AudioStreamNodeAttachedEvent(this.privId, audioNodeId));\r\n return Promise.resolve({\r\n detach: async (): Promise<void> => {\r\n stream.readEnded();\r\n delete this.privStreams[audioNodeId];\r\n this.onEvent(new AudioStreamNodeDetachedEvent(this.privId, audioNodeId));\r\n await this.turnOff();\r\n },\r\n id: (): string => audioNodeId,\r\n read: (): Promise<IStreamChunk<ArrayBuffer>> => stream.read(),\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<void> {\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 Promise.resolve();\r\n }\r\n\r\n public get events(): EventSource<AudioSourceEvent> {\r\n return this.privEvents;\r\n }\r\n\r\n public get deviceInfo(): Promise<ISpeechConfigAudioDevice> {\r\n return this.privAudioFormatPromise.then<ISpeechConfigAudioDevice>((result: AudioStreamFormatImpl): Promise<{\r\n bitspersample: number;\r\n channelcount: number;\r\n connectivity: connectivity.Unknown;\r\n manufacturer: string;\r\n model: string;\r\n samplerate: number;\r\n type: type.File;\r\n }> => ( Promise.resolve({\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<AudioStreamFormatImpl> {\r\n // Read the wave header.\r\n const maxHeaderSize: number = 4296;\r\n const header: Blob | Buffer = this.privSource.slice(0, maxHeaderSize);\r\n\r\n const headerResult: Deferred<AudioStreamFormatImpl> = new Deferred<AudioStreamFormatImpl>();\r\n\r\n const processHeader = (header: ArrayBuffer): void => {\r\n const view: DataView = new DataView(header);\r\n\r\n const getWord = (index: number): string => String.fromCharCode(view.getUint8(index), view.getUint8(index + 1), view.getUint8(index + 2), view.getUint8(index + 3));\r\n\r\n // RIFF 4 bytes.\r\n if (\"RIFF\" !== getWord(0)) {\r\n headerResult.reject(\"Invalid WAV header in file, RIFF was not found\");\r\n return;\r\n }\r\n\r\n // length, 4 bytes\r\n // RIFF Type & fmt 8 bytes\r\n if (\"WAVE\" !== getWord(8) || \"fmt \" !== getWord(12)) {\r\n headerResult.reject(\"Invalid WAV header in file, WAVEfmt was not found\");\r\n return;\r\n }\r\n\r\n const formatSize: number = view.getInt32(16, true);\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 // Confirm if header is 44 bytes long.\r\n let pos: number = 36 + Math.max(formatSize - 16, 0);\r\n for (; getWord(pos) !== \"data\"; pos += 2) {\r\n if (pos > maxHeaderSize - 8) {\r\n headerResult.reject(\"Invalid WAV header in file, data block was not found\");\r\n return;\r\n }\r\n }\r\n this.privHeaderEnd = pos + 8;\r\n headerResult.resolve(AudioStreamFormat.getWaveFormatPCM(sampleRate, bitsPerSample, channelCount) as AudioStreamFormatImpl);\r\n };\r\n\r\n if (typeof window !== \"undefined\" && typeof Blob !== \"undefined\" && header instanceof Blob) {\r\n const reader: FileReader = new FileReader();\r\n\r\n reader.onload = (event: Event): void => {\r\n const header: ArrayBuffer = (event.target as FileReader).result as ArrayBuffer;\r\n processHeader(header);\r\n };\r\n\r\n reader.readAsArrayBuffer(header);\r\n } else {\r\n const h: Buffer = header as Buffer;\r\n processHeader(h.buffer.slice(h.byteOffset, h.byteOffset + h.byteLength));\r\n }\r\n return headerResult.promise;\r\n }\r\n\r\n private async upload(audioNodeId: string): Promise<Stream<ArrayBuffer>> {\r\n const onerror = (error: string): void => {\r\n const errorMsg = `Error occurred while processing '${this.privFilename}'. ${error}`;\r\n this.onEvent(new AudioStreamNodeErrorEvent(this.privId, audioNodeId, errorMsg));\r\n throw new Error(errorMsg);\r\n };\r\n\r\n try {\r\n await this.turnOn();\r\n\r\n const format: AudioStreamFormatImpl = await this.privAudioFormatPromise;\r\n const stream = new ChunkedArrayBufferStream(format.avgBytesPerSec / 10, audioNodeId);\r\n\r\n this.privStreams[audioNodeId] = stream;\r\n const chunk: Blob | Buffer = this.privSource.slice(this.privHeaderEnd);\r\n\r\n const processFile = (buff: ArrayBuffer): 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: buff,\r\n isEnd: false,\r\n timeReceived: Date.now(),\r\n });\r\n stream.close();\r\n };\r\n\r\n if (typeof window !== \"undefined\" && typeof Blob !== \"undefined\" && chunk instanceof Blob) {\r\n const reader: FileReader = new FileReader();\r\n reader.onerror = (ev: ProgressEvent<FileReader>): void => onerror(ev.toString());\r\n\r\n reader.onload = (event: Event): void => {\r\n const fileBuffer: ArrayBuffer = (event.target as FileReader).result as ArrayBuffer;\r\n processFile(fileBuffer);\r\n };\r\n\r\n reader.readAsArrayBuffer(chunk);\r\n } else {\r\n const c: Buffer = chunk as Buffer;\r\n processFile(c.buffer.slice(c.byteOffset, c.byteOffset + c.byteLength));\r\n }\r\n\r\n return stream;\r\n } catch (e) {\r\n onerror(e as string);\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 private privStopInputOnRelease: boolean;\r\n\r\n public constructor(stopInputOnRelease: boolean) {\r\n this.privStopInputOnRelease = stopInputOnRelease;\r\n }\r\n\r\n public record(context: AudioContext, mediaStream: MediaStream, outputStream: Stream<ArrayBuffer>): void {\r\n const desiredSampleRate = 16000;\r\n\r\n const waveStreamEncoder = new RiffPcmEncoder(context.sampleRate, desiredSampleRate);\r\n\r\n const micInput = context.createMediaStreamSource(mediaStream);\r\n\r\n const attachScriptProcessor = (): void => {\r\n // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\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 scriptNode.onaudioprocess = (event: AudioProcessingEvent): void => {\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 }\r\n }\r\n };\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 // 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 const skipAudioWorklet = !!this.privSpeechProcessorScript && this.privSpeechProcessorScript.toLowerCase() === \"ignore\";\r\n\r\n if (!!context.audioWorklet && !skipAudioWorklet) {\r\n if (!this.privSpeechProcessorScript) {\r\n const workletScript = `class SP extends AudioWorkletProcessor {\r\n constructor(options) {\r\n super(options);\r\n }\r\n process(inputs, outputs) {\r\n const input = inputs[0];\r\n const output = [];\r\n for (let channel = 0; channel < input.length; channel += 1) {\r\n output[channel] = input[channel];\r\n }\r\n this.port.postMessage(output[0]);\r\n return true;\r\n }\r\n }\r\n registerProcessor('speech-processor', SP);`;\r\n const blob = new Blob([workletScript], { type: \"application/javascript; charset=utf-8\" });\r\n this.privSpeechProcessorScript = URL.createObjectURL(blob);\r\n }\r\n\r\n context.audioWorklet\r\n .addModule(this.privSpeechProcessorScript)\r\n .then((): void => {\r\n const workletNode = new AudioWorkletNode(context, \"speech-processor\");\r\n workletNode.port.onmessage = (ev: MessageEvent): void => {\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 }\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((): void => {\r\n attachScriptProcessor();\r\n });\r\n } else {\r\n try {\r\n attachScriptProcessor();\r\n } catch (err) {\r\n throw new Error(`Unable to start audio worklet node for PCMRecorder: ${err as string}`);\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 if (this.privStopInputOnRelease) {\r\n this.privMediaResources.stream.getTracks().forEach((track: MediaStreamTrack): void => track.stop());\r\n }\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\n// Node.JS specific web socket / browser support.\r\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\r\nimport * as http from \"http\";\r\nimport * as net from \"net\";\r\nimport * as tls from \"tls\";\r\nimport Agent from \"agent-base\";\r\nimport HttpsProxyAgent from \"https-proxy-agent\";\r\n\r\nimport ws from \"ws\";\r\nimport { HeaderNames } from \"../common.speech/HeaderNames.js\";\r\nimport {\r\n ArgumentNullError,\r\n BackgroundEvent,\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 Queue,\r\n RawWebsocketMessage,\r\n} from \"../common/Exports.js\";\r\nimport { ProxyInfo } from \"./ProxyInfo.js\";\r\n\r\ninterface ISendItem {\r\n Message: ConnectionMessage;\r\n RawWebsocketMessage: RawWebsocketMessage;\r\n sendStatusDeferral: Deferred<void>;\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<ISendItem>;\r\n private privReceivingMessageQueue: Queue<ConnectionMessage>;\r\n private privConnectionEstablishDeferral: Deferred<ConnectionOpenResponse>;\r\n private privCertificateValidatedDeferral: Deferred<void>;\r\n private privDisconnectDeferral: Deferred<void>;\r\n private privConnectionEvents: EventSource<ConnectionEvent>;\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 private privEnableCompression: boolean;\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 enableCompression: boolean) {\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<ConnectionEvent>();\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 this.privEnableCompression = enableCompression;\r\n\r\n // Add the connection ID to the headers\r\n this.privHeaders[HeaderNames.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<ConnectionOpenResponse> {\r\n if (this.privConnectionState === ConnectionState.Disconnected) {\r\n return Promise.reject<ConnectionOpenResponse>(`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<ConnectionOpenResponse>();\r\n this.privCertificateValidatedDeferral = new Deferred<void>();\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();\r\n\r\n this.privWebsocketClient = new WebSocket(this.privUri);\r\n } else {\r\n const options: ws.ClientOptions = { headers: this.privHeaders, perMessageDeflate: this.privEnableCompression };\r\n // The ocsp library will handle validation for us and fail the connection if needed.\r\n this.privCertificateValidatedDeferral.resolve();\r\n\r\n options.agent = this.getAgent();\r\n // Workaround for https://github.com/microsoft/cognitive-services-speech-sdk-js/issues/465\r\n // Which is root caused by https://github.com/TooTallNate/node-agent-base/issues/61\r\n const uri = new URL(this.privUri);\r\n let protocol: string = uri.protocol;\r\n\r\n if (protocol?.toLocaleLowerCase() === \"wss:\") {\r\n protocol = \"https:\";\r\n } else if (protocol?.toLocaleLowerCase() === \"ws:\") {\r\n protocol = \"http:\";\r\n }\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\r\n (options.agent as any).protocol = protocol;\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<ConnectionMessage>();\r\n this.privDisconnectDeferral = new Deferred<void>();\r\n this.privSendMessageQueue = new Queue<ISendItem>();\r\n this.processSendQueue().catch((reason: string): void => {\r\n Events.instance.onEvent(new BackgroundEvent(reason));\r\n });\r\n } catch (error) {\r\n this.privConnectionEstablishDeferral.resolve(new ConnectionOpenResponse(500, error as string));\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 = (): void => {\r\n this.privCertificateValidatedDeferral.promise.then((): 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 }): void => {\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 }): void => {\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.privWebsocketClient = null;\r\n this.onEvent(new ConnectionClosedEvent(this.privConnectionId, e.code, e.reason));\r\n }\r\n\r\n this.onClose(e.code, e.reason).catch((reason: string): void => {\r\n Events.instance.onEvent(new BackgroundEvent(reason));\r\n });\r\n };\r\n\r\n this.privWebsocketClient.onmessage = (e: { data: ws.Data; type: string; target: WebSocket | ws }): void => {\r\n const networkReceivedTime = new Date().toISOString();\r\n if (this.privConnectionState === ConnectionState.Connected) {\r\n const deferred = new Deferred<ConnectionMessage>();\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 .then((connectionMessage: ConnectionMessage): void => {\r\n this.onEvent(new ConnectionMessageReceivedEvent(this.privConnectionId, networkReceivedTime, connectionMessage));\r\n deferred.resolve(connectionMessage);\r\n }, (error: string): void => {\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 .then((connectionMessage: ConnectionMessage): void => {\r\n this.onEvent(new ConnectionMessageReceivedEvent(this.privConnectionId, networkReceivedTime, connectionMessage));\r\n deferred.resolve(connectionMessage);\r\n }, (error: string): void => {\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<void> {\r\n if (this.privConnectionState !== ConnectionState.Connected) {\r\n return Promise.reject(`Cannot send on connection that is in ${ConnectionState[this.privConnectionState]} state`);\r\n }\r\n\r\n const messageSendStatusDeferral = new Deferred<void>();\r\n const messageSendDeferral = new Deferred<ISendItem>();\r\n\r\n this.privSendMessageQueue.enqueueFromPromise(messageSendDeferral.promise);\r\n\r\n this.privMessageFormatter\r\n .fromConnectionMessage(message)\r\n .then((rawMessage: RawWebsocketMessage): void => {\r\n messageSendDeferral.resolve({\r\n Message: message,\r\n RawWebsocketMessage: rawMessage,\r\n sendStatusDeferral: messageSendStatusDeferral,\r\n });\r\n }, (error: string): void => {\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<ConnectionMessage> {\r\n if (this.privConnectionState !== ConnectionState.Connected) {\r\n return Promise.reject<ConnectionMessage>(`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<void> {\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 return Promise.resolve();\r\n }\r\n\r\n return this.privDisconnectDeferral.promise;\r\n }\r\n\r\n public get events(): EventSource<ConnectionEvent> {\r\n return this.privConnectionEvents;\r\n }\r\n\r\n private sendRawMessage(sendItem: ISendItem): Promise<void> {\r\n try {\r\n // indicates we are draining the queue and it came with no message;\r\n if (!sendItem) {\r\n return Promise.resolve();\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 // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\r\n this.privWebsocketClient.send(sendItem.RawWebsocketMessage.payload);\r\n } else {\r\n return Promise.reject(\"websocket send error: Websocket not ready \" + this.privConnectionId + \" \" + sendItem.Message.id + \" \" + new Error().stack);\r\n }\r\n return Promise.resolve();\r\n\r\n } catch (e) {\r\n return Promise.reject(`websocket send error: ${e as string}`);\r\n }\r\n }\r\n\r\n private async onClose(code: number, reason: string): Promise<void> {\r\n const closeReason = `Connection closed. ${code}: ${reason}`;\r\n this.privConnectionState = ConnectionState.Disconnected;\r\n this.privDisconnectDeferral.resolve();\r\n await this.privReceivingMessageQueue.drainAndDispose((): void => {\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 await this.privSendMessageQueue.drainAndDispose((pendingSendItem: ISendItem): void => {\r\n pendingSendItem.sendStatusDeferral.reject(closeReason);\r\n }, closeReason);\r\n }\r\n\r\n private async processSendQueue(): Promise<void> {\r\n while (true) {\r\n const itemToSend: Promise<ISendItem> = this.privSendMessageQueue.dequeue();\r\n const sendItem: ISendItem = await itemToSend;\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 try {\r\n await this.sendRawMessage(sendItem);\r\n sendItem.sendStatusDeferral.resolve();\r\n } catch (sendError) {\r\n sendItem.sendStatusDeferral.reject(sendError as string);\r\n }\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 // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n private getAgent(): http.Agent {\r\n // eslint-disable-next-line @typescript-eslint/unbound-method\r\n const agent: { proxyInfo: ProxyInfo } = new Agent.Agent(this.createConnection) as unknown as { proxyInfo: ProxyInfo } ;\r\n\r\n if (this.proxyInfo !== undefined &&\r\n this.proxyInfo.HostName !== undefined &&\r\n this.proxyInfo.Port > 0) {\r\n agent.proxyInfo = this.proxyInfo;\r\n }\r\n\r\n return agent as unknown as http.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 createConnection(request: Agent.ClientRequest, options: Agent.RequestOptions): Promise<net.Socket> {\r\n let socketPromise: Promise<net.Socket>;\r\n\r\n options = {\r\n ...options,\r\n ...{\r\n requestOCSP: true,\r\n servername: options.host\r\n }\r\n };\r\n\r\n if (!!this.proxyInfo) {\r\n const httpProxyAgent: HttpsProxyAgent = WebsocketMessageAdapter.GetProxyAgent(this.proxyInfo);\r\n const baseAgent: Agent.Agent = httpProxyAgent as unknown as Agent.Agent;\r\n\r\n socketPromise = new Promise<net.Socket>((resolve: (value: net.Socket) => void, reject: (error: string | Error) => void): void => {\r\n baseAgent.callback(request, options, (error: Error, socket: net.Socket): void => {\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 if (!!options.secureEndpoint) {\r\n socketPromise = Promise.resolve(tls.connect(options));\r\n } else {\r\n socketPromise = Promise.resolve(net.connect(options));\r\n }\r\n }\r\n\r\n return socketPromise;\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","// 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} from \"../common/Exports.js\";\r\nimport { ProxyInfo } from \"./ProxyInfo.js\";\r\nimport { WebsocketMessageAdapter } from \"./WebsocketMessageAdapter.js\";\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<string>,\r\n headers: IStringDictionary<string>,\r\n messageFormatter: IWebsocketMessageFormatter,\r\n proxyInfo: ProxyInfo,\r\n enableCompression: boolean = false,\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\r\n const key = encodeURIComponent(paramName);\r\n queryParams += key;\r\n\r\n let val = queryParameters[paramName];\r\n if (val) {\r\n val = encodeURIComponent(val);\r\n queryParams += `=${val}`;\r\n }\r\n\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 enableCompression);\r\n }\r\n\r\n public async dispose(): Promise<void> {\r\n this.privIsDisposed = true;\r\n\r\n if (this.privConnectionMessageAdapter) {\r\n await 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 get uri(): string {\r\n return this.privUri;\r\n }\r\n\r\n public state(): ConnectionState {\r\n return this.privConnectionMessageAdapter.state;\r\n }\r\n\r\n public open(): Promise<ConnectionOpenResponse> {\r\n return this.privConnectionMessageAdapter.open();\r\n }\r\n\r\n public send(message: ConnectionMessage): Promise<void> {\r\n return this.privConnectionMessageAdapter.send(message);\r\n }\r\n\r\n public read(): Promise<ConnectionMessage> {\r\n return this.privConnectionMessageAdapter.read();\r\n }\r\n\r\n public get events(): EventSource<ConnectionEvent> {\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\n// eslint-disable-next-line max-classes-per-file\r\nimport {\r\n IAudioStreamNode,\r\n IStreamChunk,\r\n} from \"../common/Exports.js\";\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<IStreamChunk<ArrayBuffer>> {\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 if (i < this.privBuffers.length) {\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 Promise.resolve<IStreamChunk<ArrayBuffer>>({\r\n buffer: retVal,\r\n isEnd: false,\r\n timeReceived: this.privBuffers[i].chunk.timeReceived,\r\n });\r\n }\r\n }\r\n\r\n return this.privAudioNode.read()\r\n .then((result: IStreamChunk<ArrayBuffer>): IStreamChunk<ArrayBuffer> => {\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(): Promise<void> {\r\n this.privBuffers = undefined;\r\n return this.privAudioNode.detach();\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 || this.privBuffers.length === 0) {\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\nclass BufferEntry {\r\n public chunk: IStreamChunk<ArrayBuffer>;\r\n public serial: number;\r\n public byteOffset: number;\r\n\r\n public constructor(chunk: IStreamChunk<ArrayBuffer>, 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 * as fs from \"fs\";\r\nimport { IAudioDestination } from \"../../common/Exports.js\";\r\nimport { Contracts } from \"../Contracts.js\";\r\nimport { AudioStreamFormat } from \"../Exports.js\";\r\nimport { AudioOutputFormatImpl } from \"./AudioOutputFormat.js\";\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 Contracts.throwIfNullOrUndefined(fs.openSync, \"\\nFile System access not available, please use Push or PullAudioOutputStream\");\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\", (): void => {\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","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/* eslint-disable max-classes-per-file */\r\n\r\nimport {\r\n connectivity,\r\n ISpeechConfigAudioDevice,\r\n type,\r\n} from \"../../common.speech/Exports.js\";\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 Events,\r\n EventSource,\r\n IAudioSource,\r\n IAudioStreamNode,\r\n IStreamChunk,\r\n Stream,\r\n} from \"../../common/Exports.js\";\r\nimport { createNoDashGuid } from \"../../common/Guid.js\";\r\nimport { AudioStreamFormat, PullAudioInputStreamCallback } from \"../Exports.js\";\r\nimport { AudioStreamFormatImpl } from \"./AudioStreamFormat.js\";\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 return;\r\n }\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\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\nexport class PushAudioInputStreamImpl extends PushAudioInputStream implements IAudioSource {\r\n\r\n private privFormat: AudioStreamFormatImpl;\r\n private privId: string;\r\n private privEvents: EventSource<AudioSourceEvent>;\r\n private privStream: Stream<ArrayBuffer>;\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<AudioSourceEvent>();\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<AudioStreamFormatImpl> {\r\n return Promise.resolve(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 turnOn(): Promise<void> {\r\n this.onEvent(new AudioSourceInitializingEvent(this.privId)); // no stream id\r\n this.onEvent(new AudioSourceReadyEvent(this.privId));\r\n return;\r\n }\r\n\r\n public async attach(audioNodeId: string): Promise<IAudioStreamNode> {\r\n this.onEvent(new AudioStreamNodeAttachingEvent(this.privId, audioNodeId));\r\n\r\n await this.turnOn();\r\n const stream = this.privStream;\r\n this.onEvent(new AudioStreamNodeAttachedEvent(this.privId, audioNodeId));\r\n return {\r\n detach: async (): Promise<void> => {\r\n this.onEvent(new AudioStreamNodeDetachedEvent(this.privId, audioNodeId));\r\n return this.turnOff();\r\n },\r\n id: (): string => audioNodeId,\r\n read: (): Promise<IStreamChunk<ArrayBuffer>> => stream.read(),\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<void> {\r\n return;\r\n }\r\n\r\n public get events(): EventSource<AudioSourceEvent> {\r\n return this.privEvents;\r\n }\r\n\r\n public get deviceInfo(): Promise<ISpeechConfigAudioDevice> {\r\n return Promise.resolve({\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\nexport abstract class PullAudioInputStream extends AudioInputStream {\r\n /**\r\n * Creates and initializes and instance.\r\n * @constructor\r\n */\r\n protected constructor() {\r\n super();\r\n}\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\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<AudioSourceEvent>;\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<AudioSourceEvent>();\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<AudioStreamFormatImpl> {\r\n return Promise.resolve(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 turnOn(): Promise<void> {\r\n this.onEvent(new AudioSourceInitializingEvent(this.privId)); // no stream id\r\n this.onEvent(new AudioSourceReadyEvent(this.privId));\r\n return;\r\n }\r\n\r\n public async attach(audioNodeId: string): Promise<IAudioStreamNode> {\r\n this.onEvent(new AudioStreamNodeAttachingEvent(this.privId, audioNodeId));\r\n\r\n await this.turnOn();\r\n this.onEvent(new AudioStreamNodeAttachedEvent(this.privId, audioNodeId));\r\n return {\r\n detach: (): Promise<void> => {\r\n this.privCallback.close();\r\n this.onEvent(new AudioStreamNodeDetachedEvent(this.privId, audioNodeId));\r\n return this.turnOff();\r\n },\r\n id: (): string => audioNodeId,\r\n read: (): Promise<IStreamChunk<ArrayBuffer>> => {\r\n let totalBytes: number = 0;\r\n let transmitBuff: ArrayBuffer;\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 // 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 // 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 totalBytes += pulledBytes;\r\n }\r\n return Promise.resolve<IStreamChunk<ArrayBuffer>>({\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 public detach(audioNodeId: string): void {\r\n this.onEvent(new AudioStreamNodeDetachedEvent(this.privId, audioNodeId));\r\n }\r\n\r\n public turnOff(): Promise<void> {\r\n return;\r\n }\r\n\r\n public get events(): EventSource<AudioSourceEvent> {\r\n return this.privEvents;\r\n }\r\n\r\n public get deviceInfo(): Promise<ISpeechConfigAudioDevice> {\r\n return Promise.resolve({\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","// 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 * Updated in version 1.17.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 * @note Unsupported by the service. Do not use this value.\r\n * @member SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren\r\n */\r\n Riff16Khz16KbpsMonoSiren,\r\n\r\n /**\r\n * audio-16khz-16kbps-mono-siren\r\n * @note Unsupported by the service. Do not use this value.\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 /**\r\n * raw-48khz-16bit-mono-pcm\r\n * @member SpeechSynthesisOutputFormat.Raw48Khz16BitMonoPcm\r\n */\r\n Raw48Khz16BitMonoPcm,\r\n\r\n /**\r\n * riff-48khz-16bit-mono-pcm\r\n * @member SpeechSynthesisOutputFormat.Riff48Khz16BitMonoPcm\r\n */\r\n\r\n Riff48Khz16BitMonoPcm,\r\n /**\r\n * audio-48khz-96kbitrate-mono-mp3\r\n * @member SpeechSynthesisOutputFormat.Audio48Khz96KBitRateMonoMp3\r\n */\r\n Audio48Khz96KBitRateMonoMp3,\r\n\r\n /**\r\n * audio-48khz-192kbitrate-mono-mp3\r\n * @member SpeechSynthesisOutputFormat.Audio48Khz192KBitRateMonoMp3\r\n */\r\n Audio48Khz192KBitRateMonoMp3,\r\n\r\n /**\r\n * ogg-48khz-16bit-mono-opus\r\n * Added in version 1.16.0\r\n * @member SpeechSynthesisOutputFormat.Ogg48Khz16BitMonoOpus\r\n */\r\n Ogg48Khz16BitMonoOpus,\r\n\r\n /**\r\n * webm-16khz-16bit-mono-opus\r\n * Added in version 1.16.0\r\n * @member SpeechSynthesisOutputFormat.Webm16Khz16BitMonoOpus\r\n */\r\n Webm16Khz16BitMonoOpus,\r\n\r\n /**\r\n * webm-24khz-16bit-mono-opus\r\n * Added in version 1.16.0\r\n * @member SpeechSynthesisOutputFormat.Webm24Khz16BitMonoOpus\r\n */\r\n Webm24Khz16BitMonoOpus,\r\n\r\n /**\r\n * raw-24khz-16bit-mono-truesilk\r\n * Added in version 1.17.0\r\n * @member SpeechSynthesisOutputFormat.Raw24Khz16BitMonoTrueSilk\r\n */\r\n Raw24Khz16BitMonoTrueSilk,\r\n\r\n /**\r\n * raw-8khz-8bit-mono-alaw\r\n * Added in version 1.17.0\r\n * @member SpeechSynthesisOutputFormat.Raw8Khz8BitMonoALaw\r\n */\r\n Raw8Khz8BitMonoALaw,\r\n\r\n /**\r\n * riff-8khz-8bit-mono-alaw\r\n * Added in version 1.17.0\r\n * @member SpeechSynthesisOutputFormat.Riff8Khz8BitMonoALaw\r\n */\r\n Riff8Khz8BitMonoALaw,\r\n\r\n /**\r\n * webm-24khz-16bit-24kbps-mono-opus\r\n * Audio compressed by OPUS codec in a webm container, with bitrate of 24kbps, optimized for IoT scenario.\r\n * Added in version 1.19.0\r\n * @member SpeechSynthesisOutputFormat.Webm24Khz16Bit24KbpsMonoOpus\r\n */\r\n Webm24Khz16Bit24KbpsMonoOpus,\r\n\r\n /**\r\n * audio-16khz-16bit-32kbps-mono-opus\r\n * Audio compressed by OPUS codec without container, with bitrate of 32kbps.\r\n * Added in version 1.20.0\r\n * @member SpeechSynthesisOutputFormat.Audio16Khz16Bit32KbpsMonoOpus\r\n */\r\n Audio16Khz16Bit32KbpsMonoOpus,\r\n\r\n /**\r\n * audio-24khz-16bit-48kbps-mono-opus\r\n * Audio compressed by OPUS codec without container, with bitrate of 48kbps.\r\n * Added in version 1.20.0\r\n * @member SpeechSynthesisOutputFormat.Audio24Khz16Bit48KbpsMonoOpus\r\n */\r\n Audio24Khz16Bit48KbpsMonoOpus,\r\n\r\n /**\r\n * audio-24khz-16bit-24kbps-mono-opus\r\n * Audio compressed by OPUS codec without container, with bitrate of 24kbps.\r\n * Added in version 1.20.0\r\n * @member SpeechSynthesisOutputFormat.Audio24Khz16Bit24KbpsMonoOpus\r\n */\r\n Audio24Khz16Bit24KbpsMonoOpus,\r\n\r\n /**\r\n * raw-22050hz-16bit-mono-pcm\r\n * Raw PCM audio at 22050Hz sampling rate and 16-bit depth.\r\n * Added in version 1.22.0\r\n * @member SpeechSynthesisOutputFormat.Raw22050Hz16BitMonoPcm\r\n */\r\n Raw22050Hz16BitMonoPcm,\r\n\r\n /**\r\n * riff-22050hz-16bit-mono-pcm\r\n * PCM audio at 22050Hz sampling rate and 16-bit depth, with RIFF header.\r\n * Added in version 1.22.0\r\n * @member SpeechSynthesisOutputFormat.Riff22050Hz16BitMonoPcm\r\n */\r\n Riff22050Hz16BitMonoPcm,\r\n\r\n /**\r\n * raw-44100hz-16bit-mono-pcm\r\n * Raw PCM audio at 44100Hz sampling rate and 16-bit depth.\r\n * Added in version 1.22.0\r\n * @member SpeechSynthesisOutputFormat.Raw44100Hz16BitMonoPcm\r\n */\r\n Raw44100Hz16BitMonoPcm,\r\n\r\n /**\r\n * riff-44100hz-16bit-mono-pcm\r\n * PCM audio at 44100Hz sampling rate and 16-bit depth, with RIFF header.\r\n * Added in version 1.22.0\r\n * @member SpeechSynthesisOutputFormat.Riff44100Hz16BitMonoPcm\r\n */\r\n Riff44100Hz16BitMonoPcm\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.js\";\r\nimport { SpeechSynthesisOutputFormat } from \"../SpeechSynthesisOutputFormat.js\";\r\nimport { AudioFormatTag, AudioStreamFormatImpl } from \"./AudioStreamFormat.js\";\r\n\r\n/**\r\n * @private\r\n * @class AudioOutputFormatImpl\r\n * Updated in version 1.17.0\r\n */\r\n// eslint-disable-next-line max-classes-per-file\r\nexport class AudioOutputFormatImpl extends AudioStreamFormatImpl {\r\n public static SpeechSynthesisOutputFormatToString: INumberDictionary<string> = {\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 [SpeechSynthesisOutputFormat.Raw48Khz16BitMonoPcm]: \"raw-48khz-16bit-mono-pcm\",\r\n [SpeechSynthesisOutputFormat.Riff48Khz16BitMonoPcm]: \"riff-48khz-16bit-mono-pcm\",\r\n [SpeechSynthesisOutputFormat.Audio48Khz96KBitRateMonoMp3]: \"audio-48khz-96kbitrate-mono-mp3\",\r\n [SpeechSynthesisOutputFormat.Audio48Khz192KBitRateMonoMp3]: \"audio-48khz-192kbitrate-mono-mp3\",\r\n [SpeechSynthesisOutputFormat.Ogg48Khz16BitMonoOpus]: \"ogg-48khz-16bit-mono-opus\",\r\n [SpeechSynthesisOutputFormat.Webm16Khz16BitMonoOpus]: \"webm-16khz-16bit-mono-opus\",\r\n [SpeechSynthesisOutputFormat.Webm24Khz16BitMonoOpus]: \"webm-24khz-16bit-mono-opus\",\r\n [SpeechSynthesisOutputFormat.Webm24Khz16Bit24KbpsMonoOpus]: \"webm-24khz-16bit-24kbps-mono-opus\",\r\n [SpeechSynthesisOutputFormat.Raw24Khz16BitMonoTrueSilk]: \"raw-24khz-16bit-mono-truesilk\",\r\n [SpeechSynthesisOutputFormat.Raw8Khz8BitMonoALaw]: \"raw-8khz-8bit-mono-alaw\",\r\n [SpeechSynthesisOutputFormat.Riff8Khz8BitMonoALaw]: \"riff-8khz-8bit-mono-alaw\",\r\n [SpeechSynthesisOutputFormat.Audio16Khz16Bit32KbpsMonoOpus]: \"audio-16khz-16bit-32kbps-mono-opus\",\r\n [SpeechSynthesisOutputFormat.Audio24Khz16Bit48KbpsMonoOpus]: \"audio-24khz-16bit-48kbps-mono-opus\",\r\n [SpeechSynthesisOutputFormat.Audio24Khz16Bit24KbpsMonoOpus]: \"audio-24khz-16bit-24kbps-mono-opus\",\r\n [SpeechSynthesisOutputFormat.Raw22050Hz16BitMonoPcm]: \"raw-22050hz-16bit-mono-pcm\",\r\n [SpeechSynthesisOutputFormat.Riff22050Hz16BitMonoPcm]: \"riff-22050hz-16bit-mono-pcm\",\r\n [SpeechSynthesisOutputFormat.Raw44100Hz16BitMonoPcm]: \"raw-44100hz-16bit-mono-pcm\",\r\n [SpeechSynthesisOutputFormat.Riff44100Hz16BitMonoPcm]: \"riff-44100hz-16bit-mono-pcm\",\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} channels - Number of channels.\r\n * @param {number} samplesPerSec - Samples per second.\r\n * @param {number} avgBytesPerSec - Average bytes per second.\r\n * @param {number} blockAlign - Block alignment.\r\n * @param {number} bitsPerSample - Bits per sample.\r\n * @param {string} audioFormatString - Audio format string\r\n * @param {string} requestAudioFormatString - Audio format string sent to service.\r\n * @param {boolean} hasHeader - If the format has header or not.\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, formatTag);\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.MuLaw,\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 24000,\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 24000,\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 24000,\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.OGG_OPUS,\r\n 1,\r\n 16000,\r\n 8192,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"ogg-24khz-16bit-mono-opus\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.OGG_OPUS,\r\n 1,\r\n 24000,\r\n 8192,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"raw-48khz-16bit-mono-pcm\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.PCM,\r\n 1,\r\n 48000,\r\n 96000,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n \"raw-48khz-16bit-mono-pcm\",\r\n false);\r\n case \"riff-48khz-16bit-mono-pcm\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.PCM,\r\n 1,\r\n 48000,\r\n 96000,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n \"raw-48khz-16bit-mono-pcm\",\r\n true);\r\n case \"audio-48khz-96kbitrate-mono-mp3\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.MP3,\r\n 1,\r\n 48000,\r\n 96 << 7,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"audio-48khz-192kbitrate-mono-mp3\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.MP3,\r\n 1,\r\n 48000,\r\n 192 << 7,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"ogg-48khz-16bit-mono-opus\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.OGG_OPUS,\r\n 1,\r\n 48000,\r\n 12000,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"webm-16khz-16bit-mono-opus\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.WEBM_OPUS,\r\n 1,\r\n 16000,\r\n 4000,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"webm-24khz-16bit-mono-opus\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.WEBM_OPUS,\r\n 1,\r\n 24000,\r\n 6000,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"webm-24khz-16bit-24kbps-mono-opus\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.WEBM_OPUS,\r\n 1,\r\n 24000,\r\n 3000,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"audio-16khz-16bit-32kbps-mono-opus\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.OPUS,\r\n 1,\r\n 16000,\r\n 4000,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"audio-24khz-16bit-48kbps-mono-opus\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.OPUS,\r\n 1,\r\n 24000,\r\n 6000,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"audio-24khz-16bit-24kbps-mono-opus\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.OPUS,\r\n 1,\r\n 24000,\r\n 3000,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"audio-24khz-16bit-mono-flac\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.FLAC,\r\n 1,\r\n 24000,\r\n 24000,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"audio-48khz-16bit-mono-flac\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.FLAC,\r\n 1,\r\n 48000,\r\n 30000,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"raw-24khz-16bit-mono-truesilk\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.SILKSkype,\r\n 1,\r\n 24000,\r\n 48000,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"raw-8khz-8bit-mono-alaw\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.ALaw,\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-8khz-8bit-mono-alaw\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.ALaw,\r\n 1,\r\n 8000,\r\n 8000,\r\n 1,\r\n 8,\r\n speechSynthesisOutputFormatString,\r\n \"raw-8khz-8bit-mono-alaw\",\r\n true);\r\n case \"raw-22050hz-16bit-mono-pcm\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.PCM,\r\n 1,\r\n 22050,\r\n 44100,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"riff-22050hz-16bit-mono-pcm\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.PCM,\r\n 1,\r\n 22050,\r\n 44100,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n \"raw-22050hz-16bit-mono-pcm\",\r\n true);\r\n case \"raw-44100hz-16bit-mono-pcm\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.PCM,\r\n 1,\r\n 44100,\r\n 88200,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n speechSynthesisOutputFormatString,\r\n false);\r\n case \"riff-44100hz-16bit-mono-pcm\":\r\n return new AudioOutputFormatImpl(\r\n AudioFormatTag.PCM,\r\n 1,\r\n 44100,\r\n 88200,\r\n 2,\r\n 16,\r\n speechSynthesisOutputFormatString,\r\n \"raw-44100hz-16bit-mono-pcm\",\r\n true);\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(4, audioLength + this.privHeader.byteLength - 8, true);\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 * Adds audio header\r\n * @param audio the raw audio without header\r\n * @returns the audio with header if applicable\r\n */\r\n\r\n public addHeader(audio: ArrayBuffer): ArrayBuffer {\r\n if (!this.hasHeader) {\r\n return audio;\r\n }\r\n this.updateHeader(audio.byteLength);\r\n const tmp = new Uint8Array(audio.byteLength + this.header.byteLength);\r\n tmp.set(new Uint8Array(this.header), 0);\r\n tmp.set(new Uint8Array(audio), this.header.byteLength);\r\n return tmp.buffer;\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/* eslint-disable max-classes-per-file */\r\n\r\nimport {\r\n createNoDashGuid,\r\n IAudioDestination,\r\n IStreamChunk,\r\n Stream,\r\n} from \"../../common/Exports.js\";\r\nimport { Contracts } from \"../Contracts.js\";\r\nimport {\r\n AudioStreamFormat,\r\n PushAudioOutputStreamCallback\r\n} from \"../Exports.js\";\r\nimport { AudioOutputFormatImpl } from \"./AudioOutputFormat.js\";\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 return;\r\n }\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\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<number>} Audio buffer length has been read.\r\n */\r\n public abstract read(dataBuffer: ArrayBuffer): Promise<number>;\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\nexport class PullAudioOutputStreamImpl extends PullAudioOutputStream implements IAudioDestination {\r\n private privFormat: AudioOutputFormatImpl;\r\n private privId: string;\r\n private privStream: Stream<ArrayBuffer>;\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<ArrayBuffer>();\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<number>} - Audio buffer length has been read.\r\n */\r\n public async read(dataBuffer: ArrayBuffer): Promise<number> {\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 Promise.resolve(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 // Until we have the minimum number of bytes to send in a transmission, keep asking for more.\r\n while (totalBytes < dataBuffer.byteLength && !this.privStream.isReadEnded) {\r\n const chunk: IStreamChunk<ArrayBuffer> = await this.privStream.read();\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 } else {\r\n this.privStream.readEnded();\r\n }\r\n }\r\n return totalBytes;\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\nexport abstract class PushAudioOutputStream extends AudioOutputStream {\r\n /**\r\n * Creates and initializes and instance.\r\n * @constructor\r\n */\r\n protected constructor() {\r\n super();\r\n }\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\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 // eslint-disable-next-line @typescript-eslint/no-empty-function\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\n/* eslint-disable max-classes-per-file */\r\n\r\nimport { PathLike } from \"fs\";\r\nimport {\r\n FileAudioSource,\r\n MicAudioSource,\r\n PcmRecorder,\r\n} from \"../../common.browser/Exports.js\";\r\nimport { ISpeechConfigAudioDevice } from \"../../common.speech/Exports.js\";\r\nimport {\r\n AudioSourceEvent,\r\n EventSource,\r\n IAudioDestination,\r\n IAudioSource,\r\n IAudioStreamNode\r\n} from \"../../common/Exports.js\";\r\nimport { Contracts } from \"../Contracts.js\";\r\nimport {\r\n AudioInputStream,\r\n AudioOutputStream,\r\n AudioStreamFormat,\r\n IPlayer,\r\n PullAudioInputStreamCallback,\r\n PullAudioOutputStream,\r\n PushAudioOutputStream,\r\n PushAudioOutputStreamCallback,\r\n SpeakerAudioDestination\r\n} from \"../Exports.js\";\r\nimport { AudioFileWriter } from \"./AudioFileWriter.js\";\r\nimport { PullAudioInputStreamImpl, PushAudioInputStreamImpl } from \"./AudioInputStream.js\";\r\nimport { PullAudioOutputStreamImpl, PushAudioOutputStreamImpl } from \"./AudioOutputStream.js\";\r\nimport { AudioStreamFormatImpl } from \"./AudioStreamFormat.js\";\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(true);\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(true);\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 | Buffer, name: string = \"unnamedBuffer.wav\"): AudioConfig {\r\n return new AudioConfigImpl(new FileAudioSource(file, name));\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 | MediaStream} 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\r\n | MediaStream): AudioConfig {\r\n if (audioStream instanceof PullAudioInputStreamCallback) {\r\n return new AudioConfigImpl(new PullAudioInputStreamImpl(audioStream));\r\n }\r\n\r\n if (audioStream instanceof AudioInputStream) {\r\n return new AudioConfigImpl(audioStream as PushAudioInputStreamImpl);\r\n }\r\n if (typeof MediaStream !== \"undefined\" && audioStream instanceof MediaStream) {\r\n const pcmRecorder = new PcmRecorder(false);\r\n return new AudioConfigImpl(new MicAudioSource(pcmRecorder, null, null, audioStream));\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);\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));\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\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<AudioStreamFormatImpl> {\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(cb?: () => void, err?: (error: string) => void): void {\r\n this.privSource.turnOff().then((): void => {\r\n if (!!cb) {\r\n cb();\r\n }\r\n }, (error: string): void => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\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.turnOn\r\n * @function\r\n * @public\r\n * @returns {Promise<void>} A promise.\r\n */\r\n public turnOn(): Promise<void> {\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<IAudioStreamNode>} A promise.\r\n */\r\n public attach(audioNodeId: string): Promise<IAudioStreamNode> {\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<void>} A promise.\r\n */\r\n public turnOff(): Promise<void> {\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<AudioSourceEvent>} An event source for audio events.\r\n */\r\n public get events(): EventSource<AudioSourceEvent> {\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<ISpeechConfigAudioDevice> {\r\n return this.privSource.deviceInfo;\r\n }\r\n}\r\n\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(): void {\r\n throw new Error(\"This AudioConfig instance does not support setting properties.\");\r\n }\r\n\r\n public getProperty(): 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 * 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.js\";\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 return;\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.js\";\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.js\";\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.js\";\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 public 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 increments.\r\n * @member RecognitionResult.prototype.duration\r\n * @function\r\n * @public\r\n * @returns {number} Duration of recognized speech in 100 nano second increments.\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 increments.\r\n * @member RecognitionResult.prototype.offset\r\n * @function\r\n * @public\r\n * @returns {number} Offset of recognized speech in 100 nano second increments.\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.js\";\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 private readonly privSpeakerId: string;\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} speakerId - speaker id for conversation transcription, 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, speakerId?: string, errorDetails?: string,\r\n json?: string, properties?: PropertyCollection) {\r\n super(resultId, reason, text, duration, offset, language, languageDetectionConfidence, errorDetails, json, properties);\r\n this.privSpeakerId = speakerId;\r\n }\r\n\r\n /**\r\n * speaker id from conversation transcription/id scenarios\r\n * @member SpeechRecognitionResult.prototype.speakerId\r\n * @function\r\n * @public\r\n * @returns {string} id of speaker in given result\r\n */\r\n public get speakerId(): string {\r\n return this.privSpeakerId;\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 { PropertyCollection, ResultReason, SpeechRecognitionResult } from \"./Exports.js\";\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 public 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, undefined, 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\n// eslint-disable-next-line max-classes-per-file\r\nimport { Contracts } from \"./Contracts.js\";\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 return;\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://<region>.api.cognitive.microsoft.com/luis/v2.0/apps/<Guid>?subscription-key=<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 <a href=\"https://aka.ms/csspeech/region\">region page</a>).\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\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\n/* eslint-disable max-classes-per-file */\r\nimport { RecognitionEventArgs, SpeechRecognitionResult, ConversationTranscriptionResult } from \"./Exports.js\";\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\r\n/**\r\n * Defines contents of conversation transcribed/transcribing event.\r\n * @class ConversationTranscriptionEventArgs\r\n */\r\nexport class ConversationTranscriptionEventArgs extends RecognitionEventArgs {\r\n private privResult: ConversationTranscriptionResult;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {ConversationTranscriptionResult} result - The conversation transcription result.\r\n * @param {number} offset - The offset.\r\n * @param {string} sessionId - The session id.\r\n */\r\n public constructor(result: ConversationTranscriptionResult, 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 transcription result.\r\n * @member ConversationTranscription1EventArgs.prototype.result\r\n * @function\r\n * @public\r\n * @returns {ConversationTranscriptionResult} the recognition result.\r\n */\r\n public get result(): ConversationTranscriptionResult {\r\n return this.privResult;\r\n }\r\n}\r\n\r\n/**\r\n * Defines contents of meeting transcribed/transcribing event.\r\n * @class MeetingTranscriptionEventArgs\r\n */\r\nexport class MeetingTranscriptionEventArgs extends SpeechRecognitionEventArgs {\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 CancellationEventArgs,\r\n CancellationReason,\r\n RecognitionEventArgs\r\n} from \"./Exports.js\";\r\n\r\n/**\r\n * Defines content of a CancellationEvent.\r\n * @class CancellationEventArgsBase\r\n */\r\nexport class CancellationEventArgsBase extends RecognitionEventArgs implements CancellationEventArgs {\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 CancellationEventArgsBase.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 operation.\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 operation, provides details of the occurred error.\r\n * @member CancellationEventArgsBase.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 CancellationEventArgsBase,\r\n} from \"./CancellationEventArgsBase.js\";\r\n\r\nexport class SpeechRecognitionCanceledEventArgs extends CancellationEventArgsBase {\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.js\";\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.js\";\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.js\";\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} 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(translations: Translations, resultId?: string, reason?: ResultReason,\r\n text?: string, 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, undefined, errorDetails, json, properties);\r\n\r\n this.privTranslations = translations;\r\n }\r\n\r\n public static fromSpeechRecognitionResult(result: SpeechRecognitionResult): TranslationRecognitionResult {\r\n return new TranslationRecognitionResult(undefined, result.resultId, result.reason, result.text, result.duration, result.offset, result.language, result.languageDetectionConfidence, result.errorDetails, result.json, result.properties);\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.js\";\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 public 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 speech result contains a finalized acceptance of a provided keyword.\r\n * Speech recognition will continue unless otherwise configured.\r\n * @member ResultReason.RecognizedKeyword\r\n */\r\n RecognizedKeyword,\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 /**\r\n * Indicates synthesis voices list has been successfully retrieved.\r\n * @member ResultReason.VoicesListRetrieved\r\n */\r\n VoicesListRetrieved,\r\n\r\n /**\r\n * Indicates the transcription result contains hypothesis text and its translation(s) for\r\n * other participants in the conversation.\r\n * @member ResultReason.TranslatingParticipantSpeech\r\n */\r\n TranslatingParticipantSpeech,\r\n\r\n /**\r\n * Indicates the transcription result contains final text and corresponding translation(s)\r\n * for other participants in the conversation. Speech Recognition and Translation are now\r\n * complete for this phrase.\r\n * @member ResultReason.TranslatedParticipantSpeech\r\n */\r\n TranslatedParticipantSpeech,\r\n\r\n /**\r\n * <summary>\r\n * Indicates the transcription result contains the instant message and corresponding\r\n * translation(s).\r\n * @member ResultReason.TranslatedInstantMessage\r\n */\r\n TranslatedInstantMessage,\r\n\r\n /**\r\n * Indicates the transcription result contains the instant message for other participants\r\n * in the conversation and corresponding translation(s).\r\n * @member ResultReason.TranslatedParticipantInstantMessage\r\n */\r\n TranslatedParticipantInstantMessage,\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n/* eslint-disable max-classes-per-file */\r\n\r\nimport {\r\n ForceDictationPropertyName,\r\n OutputFormatPropertyName,\r\n ServicePropertiesPropertyName\r\n} from \"../common.speech/Exports.js\";\r\nimport {IStringDictionary} from \"../common/Exports.js\";\r\nimport {Contracts} from \"./Contracts.js\";\r\nimport {\r\n OutputFormat,\r\n ProfanityOption,\r\n PropertyCollection,\r\n PropertyId,\r\n ServicePropertyChannel,\r\n SpeechSynthesisOutputFormat,\r\n} from \"./Exports.js\";\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 return;\r\n }\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 <a href=\"https://aka.ms/csspeech/region\">region page</a>).\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 <a href=\"https://aka.ms/csspeech/region\">region page</a>).\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 username 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 | PropertyId} 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 | PropertyId, 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 // eslint-disable-next-line @typescript-eslint/no-empty-function\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 * Sets a property value that will be passed to service using the specified channel.\r\n * Added in version 1.7.0.\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 */\r\n public abstract setServiceProperty(name: string, value: string, channel: ServicePropertyChannel): void;\r\n\r\n /**\r\n * Sets profanity option.\r\n * Added in version 1.7.0.\r\n * @member SpeechConfig.prototype.setProfanity\r\n * @function\r\n * @public\r\n * @param {profanity} Profanity option to set.\r\n */\r\n public abstract setProfanity(profanity: ProfanityOption): void;\r\n\r\n /**\r\n * Enable audio logging in service.\r\n * Audio and content logs are stored either in Microsoft-owned storage, or in your own storage account linked\r\n * to your Cognitive Services subscription (Bring Your Own Storage (BYOS) enabled Speech resource).\r\n * The logs will be removed after 30 days.\r\n * Added in version 1.7.0.\r\n * @member SpeechConfig.prototype.enableAudioLogging\r\n * @function\r\n * @public\r\n */\r\n public abstract enableAudioLogging(): void;\r\n\r\n /**\r\n * Includes word-level timestamps.\r\n * Added in version 1.7.0.\r\n * @member SpeechConfig.prototype.requestWordLevelTimestamps\r\n * @function\r\n * @public\r\n */\r\n public abstract requestWordLevelTimestamps(): void;\r\n\r\n /**\r\n * Enable dictation. Only supported in speech continuous recognition.\r\n * Added in version 1.7.0.\r\n * @member SpeechConfig.prototype.enableDictation\r\n * @function\r\n * @public\r\n */\r\n public abstract enableDictation(): void;\r\n\r\n /**\r\n * Gets the language of the speech synthesizer.\r\n * Added in version 1.11.0.\r\n * @member SpeechConfig.prototype.speechSynthesisLanguage\r\n * @function\r\n * @public\r\n * @returns {string} Returns the speech synthesis language.\r\n */\r\n public abstract get speechSynthesisLanguage(): string;\r\n\r\n /**\r\n * Sets the language of the speech synthesizer.\r\n * Added in version 1.11.0.\r\n * @member SpeechConfig.prototype.speechSynthesisLanguage\r\n * @function\r\n * @public\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 * Added in version 1.11.0.\r\n * @member SpeechConfig.prototype.speechSynthesisVoiceName\r\n * @function\r\n * @public\r\n * @returns {string} Returns the speech synthesis voice.\r\n */\r\n public abstract get speechSynthesisVoiceName(): string;\r\n\r\n /**\r\n * Sets the voice of the speech synthesizer. (see <a href=\"https://aka.ms/speech/tts-languages\">available voices</a>).\r\n * Added in version 1.11.0.\r\n * @member SpeechConfig.prototype.speechSynthesisVoiceName\r\n * @function\r\n * @public\r\n */\r\n public abstract set speechSynthesisVoiceName(voice: string);\r\n\r\n /**\r\n * Gets the speech synthesis output format.\r\n * Added in version 1.11.0.\r\n * @member SpeechConfig.prototype.speechSynthesisOutputFormat\r\n * @function\r\n * @public\r\n * @returns {SpeechSynthesisOutputFormat} Returns the speech synthesis output format\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 * The default format is Audio16Khz64KBitRateMonoMp3 for browser and Riff16Khz16BitMonoPcm for Node.JS.\r\n * Added in version 1.11.0.\r\n * @member SpeechConfig.prototype.speechSynthesisOutputFormat\r\n * @function\r\n * @public\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\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[this.privProperties.getProperty(OutputFormatPropertyName, undefined) as keyof typeof OutputFormat];\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 as string);\r\n this.setProperty(PropertyId[PropertyId.SpeechServiceConnection_ProxyPort], proxyPort as string);\r\n this.setProperty(PropertyId[PropertyId.SpeechServiceConnection_ProxyUserName], proxyUserName as string);\r\n this.setProperty(PropertyId[PropertyId.SpeechServiceConnection_ProxyPassword], proxyPassword as string);\r\n }\r\n\r\n public setServiceProperty(name: string, value: string): void {\r\n const currentProperties: IStringDictionary<string> = JSON.parse(this.privProperties.getProperty(ServicePropertiesPropertyName, \"{}\")) as IStringDictionary<string>;\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[this.privProperties.getProperty(PropertyId.SpeechServiceConnection_SynthOutputFormat, undefined) as keyof typeof SpeechSynthesisOutputFormat];\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\n/* eslint-disable max-classes-per-file */\r\nimport {\r\n ForceDictationPropertyName,\r\n OutputFormatPropertyName,\r\n ServicePropertiesPropertyName\r\n} from \"../common.speech/Exports.js\";\r\nimport { IStringDictionary } from \"../common/Exports.js\";\r\nimport { Contracts } from \"./Contracts.js\";\r\nimport {\r\n OutputFormat,\r\n ProfanityOption,\r\n PropertyCollection,\r\n PropertyId,\r\n SpeechConfig,\r\n SpeechSynthesisOutputFormat,\r\n} from \"./Exports.js\";\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 <a href=\"https://aka.ms/csspeech/region\">region page</a>).\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 <a href=\"https://aka.ms/csspeech/region\">region page</a>).\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 | PropertyId} 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 | PropertyId, 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\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 * 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 * Gets the speech recognition language.\r\n * @member SpeechTranslationConfigImpl.prototype.speechRecognitionLanguage\r\n * @function\r\n * @public\r\n * @return {string} The speechRecognitionLanguage.\r\n */\r\n public get speechRecognitionLanguage(): string {\r\n return this.privSpeechProperties.getProperty(PropertyId[PropertyId.SpeechServiceConnection_RecoLanguage]);\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 // eslint-disable-next-line\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 if (!languages.includes(value)) {\r\n languages.push(value);\r\n this.privSpeechProperties.setProperty(PropertyId.SpeechServiceConnection_TranslationToLanguages, languages.join(\",\"));\r\n }\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 as string);\r\n this.setProperty(PropertyId[PropertyId.SpeechServiceConnection_ProxyPort], proxyPort as string);\r\n this.setProperty(PropertyId[PropertyId.SpeechServiceConnection_ProxyUserName], proxyUserName as string);\r\n this.setProperty(PropertyId[PropertyId.SpeechServiceConnection_ProxyPassword], proxyPassword as string);\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 | PropertyId} name - The name of the property to set.\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): void {\r\n const currentProperties: IStringDictionary<string> = JSON.parse(this.privSpeechProperties.getProperty(ServicePropertiesPropertyName, \"{}\")) as IStringDictionary<string>;\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 // eslint-disable-next-line\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.js\";\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.\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 | number | boolean} 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 | number | boolean): 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 if (def === undefined) {\r\n return undefined;\r\n }\r\n\r\n return String(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} destinationCollection - The collection to merge into.\r\n */\r\n public mergeTo(destinationCollection: PropertyCollection): void {\r\n this.privKeys.forEach((key: string | PropertyId): void => {\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 /**\r\n * Get the keys in Property Collection.\r\n * @member PropertyCollection.prototype.keys\r\n * @function\r\n * @public\r\n * @returns {string []} Keys in the collection.\r\n */\r\n public get keys(): string[] {\r\n return this.privKeys;\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\r\n * 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 <a href=\"https://aka.ms/csspeech/voicenames\">here</a>.\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 <see cref=\"SpeechConfig.SetProxy(string,int,string,string)\"/>.\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 <see cref=\"SpeechConfig.SetProxy(string,int,string,string)\"/>.\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 <see cref=\"SpeechConfig.SetProxy(string,int,string,string)\"/>.\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 <see cref=\"SpeechConfig.SetProxy(string,int,string,string)\"/>.\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 duration of detected silence, measured in milliseconds, after which speech-to-text will determine a spoken\r\n * phrase has ended and generate a final Recognized result. Configuring this timeout may be helpful in situations\r\n * where spoken input is significantly faster or slower than usual and default segmentation behavior consistently\r\n * yields results that are too long or too short. Segmentation timeout values that are inappropriately high or low\r\n * can negatively affect speech-to-text accuracy; this property should be carefully configured and the resulting\r\n * behavior should be thoroughly validated as intended.\r\n *\r\n * For more information about timeout configuration that includes discussion of default behaviors, please visit\r\n * https://aka.ms/csspeech/timeouts.\r\n *\r\n * Added in version 1.21.0.\r\n */\r\n Speech_SegmentationSilenceTimeoutMs,\r\n\r\n /**\r\n * A boolean value specifying whether audio logging is enabled in the service or not.\r\n * Audio and content logs are stored either in Microsoft-owned storage, or in your own storage account linked\r\n * to your Cognitive Services subscription (Bring Your Own Storage (BYOS) enabled Speech resource).\r\n * The logs will be removed after 30 days.\r\n * Added in version 1.7.0\r\n */\r\n SpeechServiceConnection_EnableAudioLogging,\r\n\r\n /**\r\n * The speech service connection language identifier mode.\r\n * Can be \"AtStart\" (the default), or \"Continuous\". See Language\r\n * Identification document https://aka.ms/speech/lid?pivots=programming-language-javascript\r\n * for more details.\r\n * Added in 1.25.0\r\n **/\r\n SpeechServiceConnection_LanguageIdMode,\r\n\r\n /**\r\n * A string value representing the desired endpoint version to target for Speech Recognition.\r\n * Added in version 1.21.0\r\n */\r\n SpeechServiceConnection_RecognitionEndpointVersion,\r\n\r\n /**\r\n /**\r\n * A string value the current speaker recognition scenario/mode (TextIndependentIdentification, etc.).\r\n * Added in version 1.23.0\r\n */\r\n SpeechServiceConnection_SpeakerIdMode,\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 * A boolean value specifying whether to request WordBoundary events.\r\n * @member PropertyId.SpeechServiceResponse_RequestWordBoundary\r\n * Added in version 1.21.0.\r\n */\r\n SpeechServiceResponse_RequestWordBoundary,\r\n\r\n /**\r\n * A boolean value specifying whether to request punctuation boundary in WordBoundary Events. Default is true.\r\n * @member PropertyId.SpeechServiceResponse_RequestPunctuationBoundary\r\n * Added in version 1.21.0.\r\n */\r\n SpeechServiceResponse_RequestPunctuationBoundary,\r\n\r\n /**\r\n * A boolean value specifying whether to request sentence boundary in WordBoundary Events. Default is false.\r\n * @member PropertyId.SpeechServiceResponse_RequestSentenceBoundary\r\n * Added in version 1.21.0.\r\n */\r\n SpeechServiceResponse_RequestSentenceBoundary,\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 * Enables or disables the receipt of turn status messages as obtained on the turnStatusReceived event.\r\n * @member PropertyId.Conversation_Request_Bot_Status_Messages\r\n * Added in version 1.15.0.\r\n */\r\n Conversation_Request_Bot_Status_Messages,\r\n\r\n /**\r\n * Specifies the connection ID to be provided in the Agent configuration message, e.g. a Direct Line token for\r\n * channel authentication.\r\n * Added in version 1.15.1.\r\n */\r\n Conversation_Agent_Connection_Id,\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 /**\r\n * The reference text of the audio for pronunciation evaluation.\r\n * For this and the following pronunciation assessment parameters, see\r\n * https://docs.microsoft.com/azure/cognitive-services/speech-service/rest-speech-to-text#pronunciation-assessment-parameters for details.\r\n * Under normal circumstances, you shouldn't have to use this property directly.\r\n * Added in version 1.15.0\r\n */\r\n PronunciationAssessment_ReferenceText,\r\n\r\n /**\r\n * The point system for pronunciation score calibration (FivePoint or HundredMark).\r\n * Under normal circumstances, you shouldn't have to use this property directly.\r\n * Added in version 1.15.0\r\n */\r\n PronunciationAssessment_GradingSystem,\r\n\r\n /**\r\n * The pronunciation evaluation granularity (Phoneme, Word, or FullText).\r\n * Under normal circumstances, you shouldn't have to use this property directly.\r\n * Added in version 1.15.0\r\n */\r\n PronunciationAssessment_Granularity,\r\n\r\n /**\r\n * Defines if enable miscue calculation.\r\n * With this enabled, the pronounced words will be compared to the reference text,\r\n * and will be marked with omission/insertion based on the comparison. The default setting is False.\r\n * Under normal circumstances, you shouldn't have to use this property directly.\r\n * Added in version 1.15.0\r\n */\r\n PronunciationAssessment_EnableMiscue,\r\n\r\n /**\r\n * The json string of pronunciation assessment parameters\r\n * Under normal circumstances, you shouldn't have to use this property directly.\r\n * Added in version 1.15.0\r\n */\r\n PronunciationAssessment_Json,\r\n\r\n /**\r\n * Pronunciation assessment parameters.\r\n * This property is intended to be read-only. The SDK is using it internally.\r\n * Added in version 1.15.0\r\n */\r\n PronunciationAssessment_Params,\r\n\r\n /**\r\n * Version of Speaker Recognition API to use.\r\n * Added in version 1.18.0\r\n */\r\n SpeakerRecognition_Api_Version,\r\n\r\n /**\r\n * Specifies whether to allow load of data URL for web worker\r\n * Allowed values are \"off\" and \"on\". Default is \"on\".\r\n * Added in version 1.32.0\r\n */\r\n WebWorkerLoadType,\r\n\r\n /**\r\n * Talking avatar service WebRTC session description protocol.\r\n * This property is intended to be read-only. The SDK is using it internally.\r\n * Added in version 1.33.0\r\n */\r\n TalkingAvatarService_WebRTC_SDP,\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.js\";\r\nimport {\r\n Deferred,\r\n marshalPromiseToCallbacks\r\n} from \"../common/Exports.js\";\r\nimport {\r\n Contracts\r\n} from \"./Contracts.js\";\r\nimport {\r\n AudioConfig,\r\n PropertyCollection,\r\n PropertyId,\r\n RecognitionEventArgs,\r\n SessionEventArgs,\r\n SpeechRecognitionResult,\r\n} from \"./Exports.js\";\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 * @param {PropertyCollection} properties - A set of properties to set on the recognizer\r\n * @param {IConnectionFactory} connectionFactory - The factory class used to create a custom IConnection for 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(cb?: () => void, errorCb?: (error: string) => void): void {\r\n Contracts.throwIfDisposed(this.privDisposed);\r\n marshalPromiseToCallbacks(this.dispose(true), cb, errorCb);\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 async dispose(disposing: boolean): Promise<void> {\r\n if (this.privDisposed) {\r\n return;\r\n }\r\n\r\n this.privDisposed = true;\r\n\r\n if (disposing) {\r\n if (this.privReco) {\r\n await this.privReco.audioSource.turnOff();\r\n await this.privReco.dispose();\r\n }\r\n }\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 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 this.privReco = this.createServiceRecognizer(\r\n Recognizer.getAuthFromProperties(this.privProperties),\r\n this.privConnectionFactory,\r\n this.audioConfig,\r\n recognizerConfig);\r\n }\r\n\r\n protected async recognizeOnceAsyncImpl(recognitionMode: RecognitionMode): Promise<SpeechRecognitionResult> {\r\n Contracts.throwIfDisposed(this.privDisposed);\r\n const ret: Deferred<SpeechRecognitionResult> = new Deferred<SpeechRecognitionResult>();\r\n\r\n await this.implRecognizerStop();\r\n await this.privReco.recognize(recognitionMode, ret.resolve, ret.reject);\r\n const result: SpeechRecognitionResult = await ret.promise;\r\n await this.implRecognizerStop();\r\n\r\n return result;\r\n\r\n }\r\n\r\n protected async startContinuousRecognitionAsyncImpl(recognitionMode: RecognitionMode): Promise<void> {\r\n Contracts.throwIfDisposed(this.privDisposed);\r\n\r\n await this.implRecognizerStop();\r\n await this.privReco.recognize(recognitionMode, undefined, undefined);\r\n }\r\n\r\n protected async stopContinuousRecognitionAsyncImpl(): Promise<void> {\r\n Contracts.throwIfDisposed(this.privDisposed);\r\n await this.implRecognizerStop();\r\n }\r\n\r\n protected async implRecognizerStop(): Promise<void> {\r\n if (this.privReco) {\r\n await this.privReco.stopRecognizing();\r\n }\r\n return;\r\n }\r\n\r\n protected static getAuthFromProperties(properties: PropertyCollection): IAuthentication {\r\n const subscriptionKey = properties.getProperty(PropertyId.SpeechServiceConnection_Key, undefined);\r\n const authentication = (subscriptionKey && subscriptionKey !== \"\") ?\r\n new CognitiveSubscriptionKeyAuthentication(subscriptionKey) :\r\n new CognitiveTokenAuthentication(\r\n (): Promise<string> => {\r\n const authorizationToken = properties.getProperty(PropertyId.SpeechServiceAuthorization_Token, undefined);\r\n return Promise.resolve(authorizationToken);\r\n },\r\n (): Promise<string> => {\r\n const authorizationToken = properties.getProperty(PropertyId.SpeechServiceAuthorization_Token, undefined);\r\n return Promise.resolve(authorizationToken);\r\n });\r\n\r\n return authentication;\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 SpeechConnectionFactory,\r\n SpeechServiceConfig,\r\n SpeechServiceRecognizer,\r\n} from \"../common.speech/Exports.js\";\r\nimport { marshalPromiseToCallbacks } from \"../common/Exports.js\";\r\nimport { AudioConfigImpl } from \"./Audio/AudioConfig.js\";\r\nimport { Contracts } from \"./Contracts.js\";\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.js\";\r\nimport { SpeechConfig, SpeechConfigImpl } from \"./SpeechConfig.js\";\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 privDisposedRecognizer: 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.privDisposedRecognizer = 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.privDisposedRecognizer);\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.privDisposedRecognizer);\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.privDisposedRecognizer);\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 marshalPromiseToCallbacks(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 marshalPromiseToCallbacks(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 marshalPromiseToCallbacks(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): 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(cb?: () => void, errorCb?: (error: string) => void): void {\r\n Contracts.throwIfDisposed(this.privDisposedRecognizer);\r\n marshalPromiseToCallbacks(this.dispose(true), cb, errorCb);\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 async dispose(disposing: boolean): Promise<void> {\r\n if (this.privDisposedRecognizer) {\r\n return;\r\n }\r\n\r\n if (disposing) {\r\n this.privDisposedRecognizer = true;\r\n await this.implRecognizerStop();\r\n }\r\n\r\n await super.dispose(disposing);\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 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 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.js\";\r\nimport { marshalPromiseToCallbacks } from \"../common/Exports.js\";\r\nimport { AudioConfigImpl } from \"./Audio/AudioConfig.js\";\r\nimport { Contracts } from \"./Contracts.js\";\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.js\";\r\nimport { LanguageUnderstandingModelImpl } from \"./LanguageUnderstandingModel.js\";\r\nimport { SpeechConfigImpl } from \"./SpeechConfig.js\";\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 marshalPromiseToCallbacks(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 || 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 marshalPromiseToCallbacks(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 marshalPromiseToCallbacks(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 try {\r\n cb();\r\n } catch (e) {\r\n if (!!err) {\r\n err(e as string);\r\n }\r\n }\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(cb?: () => void, errorCb?: (error: string) => void): void {\r\n Contracts.throwIfDisposed(this.privDisposedIntentRecognizer);\r\n\r\n marshalPromiseToCallbacks(this.dispose(true), cb, errorCb);\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(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 async dispose(disposing: boolean): Promise<void> {\r\n if (this.privDisposedIntentRecognizer) {\r\n return;\r\n }\r\n\r\n if (disposing) {\r\n this.privDisposedIntentRecognizer = true;\r\n await 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","//\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\n// eslint-disable-next-line max-classes-per-file\r\nimport { HeaderNames } from \"../common.speech/HeaderNames.js\";\r\nimport {\r\n ConnectionMessage as IntConnectionMessage,\r\n MessageType\r\n} from \"../common/Exports.js\";\r\nimport {\r\n PropertyCollection\r\n} from \"./PropertyCollection.js\";\r\nimport { PropertyId } from \"./PropertyId.js\";\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 <see cref=\"ConnectionMessage\"/>.\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\nexport class ConnectionMessageImpl {\r\n\r\n private privConnectionMessage: IntConnectionMessage;\r\n private privProperties: PropertyCollection;\r\n\r\n public constructor(message: IntConnectionMessage) {\r\n this.privConnectionMessage = message;\r\n this.privProperties = new PropertyCollection();\r\n if (!!this.privConnectionMessage.headers[HeaderNames.ConnectionId]) {\r\n this.privProperties.setProperty(PropertyId.Speech_SessionId, this.privConnectionMessage.headers[HeaderNames.ConnectionId]);\r\n }\r\n\r\n Object.keys(this.privConnectionMessage.headers).forEach((header: 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): boolean => 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 <see cref=\"ConnectionMessage\"/>.\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","//\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.js\";\r\nimport {\r\n ConnectionEvent,\r\n ConnectionMessageReceivedEvent,\r\n ConnectionMessageSentEvent,\r\n IDetachable,\r\n marshalPromiseToCallbacks,\r\n ServiceEvent,\r\n} from \"../common/Exports.js\";\r\nimport {\r\n ConnectionMessageImpl\r\n} from \"./ConnectionMessage.js\";\r\nimport { Contracts } from \"./Contracts.js\";\r\nimport {\r\n ConnectionEventArgs,\r\n ConnectionMessageEventArgs,\r\n ConversationTranscriber,\r\n Recognizer,\r\n ServiceEventArgs,\r\n SpeechSynthesizer,\r\n} from \"./Exports.js\";\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 | ConversationTranscriber): Connection {\r\n const recoBase = recognizer.internalData as ServiceRecognizerBase;\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(cb?: () => void, err?: (error: string) => void): void {\r\n marshalPromiseToCallbacks(this.privInternalData.connect(), cb, err);\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(cb?: () => void, err?: (error: string) => void): 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 marshalPromiseToCallbacks(this.privInternalData.disconnect(), cb, err);\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 | object): 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.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.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 marshalPromiseToCallbacks(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 /* eslint-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","// 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.js\";\r\nimport { marshalPromiseToCallbacks } from \"../common/Exports.js\";\r\nimport { AudioConfigImpl } from \"./Audio/AudioConfig.js\";\r\nimport { Connection } from \"./Connection.js\";\r\nimport { Contracts } from \"./Contracts.js\";\r\nimport {\r\n AudioConfig,\r\n AutoDetectSourceLanguageConfig,\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.js\";\r\nimport { SpeechTranslationConfig, SpeechTranslationConfigImpl } from \"./SpeechTranslationConfig.js\";\r\n\r\n/**\r\n * Translation recognizer\r\n * @class TranslationRecognizer\r\n */\r\nexport class TranslationRecognizer extends Recognizer {\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 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 * @param {IConnectionFactory} connectionFactory - An optional connection factory to use to generate the endpoint URIs, headers to set, etc...\r\n */\r\n public constructor(speechConfig: SpeechTranslationConfig, audioConfig?: AudioConfig, connectionFactory?: IConnectionFactory) {\r\n const configImpl = speechConfig as SpeechTranslationConfigImpl;\r\n Contracts.throwIfNull(configImpl, \"speechConfig\");\r\n\r\n super(audioConfig, configImpl.properties, connectionFactory || new TranslationConnectionFactory());\r\n\r\n this.privDisposedTranslationRecognizer = false;\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 /**\r\n * TranslationRecognizer constructor.\r\n * @constructor\r\n * @param {SpeechTranslationConfig} speechTranslationConfig - 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(speechTranslationConfig: SpeechTranslationConfig, autoDetectSourceLanguageConfig: AutoDetectSourceLanguageConfig, audioConfig?: AudioConfig): TranslationRecognizer {\r\n const speechTranslationConfigImpl: SpeechTranslationConfigImpl = speechTranslationConfig as SpeechTranslationConfigImpl;\r\n autoDetectSourceLanguageConfig.properties.mergeTo(speechTranslationConfigImpl.properties);\r\n return new TranslationRecognizer(speechTranslationConfig, audioConfig);\r\n }\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 * 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 * 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 * 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 suitable only\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 marshalPromiseToCallbacks(this.recognizeOnceAsyncImpl(RecognitionMode.Interactive), 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 marshalPromiseToCallbacks(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 marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(), cb, err);\r\n }\r\n\r\n /**\r\n * dynamically remove a language from list of target language\r\n * (can be used while recognition is ongoing)\r\n * @member TranslationRecognizer.prototype.removeTargetLanguage\r\n * @function\r\n * @param lang - language to be removed\r\n * @public\r\n */\r\n public removeTargetLanguage(lang: string): void {\r\n Contracts.throwIfNullOrUndefined(lang, \"language to be removed\");\r\n if (this.properties.getProperty(PropertyId.SpeechServiceConnection_TranslationToLanguages, undefined) !== undefined) {\r\n const languages: string[] = this.properties.getProperty(PropertyId.SpeechServiceConnection_TranslationToLanguages).split(\",\");\r\n const index: number = languages.indexOf(lang);\r\n if (index > -1) {\r\n languages.splice(index, 1);\r\n this.properties.setProperty(PropertyId.SpeechServiceConnection_TranslationToLanguages, languages.join(\",\"));\r\n this.updateLanguages(languages);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * dynamically add a language to list of target language\r\n * (can be used while recognition is ongoing)\r\n * @member TranslationRecognizer.prototype.addTargetLanguage\r\n * @function\r\n * @param lang - language to be added\r\n * @public\r\n */\r\n public addTargetLanguage(lang: string): void {\r\n Contracts.throwIfNullOrUndefined(lang, \"language to be added\");\r\n let languages: string[] = [];\r\n if (this.properties.getProperty(PropertyId.SpeechServiceConnection_TranslationToLanguages, undefined) !== undefined) {\r\n languages = this.properties.getProperty(PropertyId.SpeechServiceConnection_TranslationToLanguages).split(\",\");\r\n if (!languages.includes(lang)) {\r\n languages.push(lang);\r\n this.properties.setProperty(PropertyId.SpeechServiceConnection_TranslationToLanguages, languages.join(\",\"));\r\n }\r\n } else {\r\n this.properties.setProperty(PropertyId.SpeechServiceConnection_TranslationToLanguages, lang);\r\n languages = [lang];\r\n }\r\n this.updateLanguages(languages);\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(cb?: () => void, errorCb?: (error: string) => void): void {\r\n Contracts.throwIfDisposed(this.privDisposedTranslationRecognizer);\r\n marshalPromiseToCallbacks(this.dispose(true), cb, errorCb);\r\n }\r\n\r\n /**\r\n * handles ConnectionEstablishedEvent for conversation translation scenarios.\r\n * @member TranslationRecognizer.prototype.onConnection\r\n * @function\r\n * @public\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n public onConnection(): void { }\r\n\r\n protected async dispose(disposing: boolean): Promise<void> {\r\n if (this.privDisposedTranslationRecognizer) {\r\n return;\r\n }\r\n\r\n this.privDisposedTranslationRecognizer = true;\r\n\r\n if (disposing) {\r\n await this.implRecognizerStop();\r\n await super.dispose(disposing);\r\n }\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 configImpl: AudioConfigImpl = audioConfig as AudioConfigImpl;\r\n\r\n return new TranslationServiceRecognizer(authentication, connectionFactory, configImpl, recognizerConfig, this);\r\n }\r\n\r\n private updateLanguages(languages: string[]): void {\r\n const conn: Connection = Connection.fromRecognizer(this);\r\n if (!!conn) {\r\n conn.setMessageProperty(\"speech.context\", \"translationcontext\", {to: languages});\r\n conn.sendMessageAsync(\"event\", JSON.stringify({\r\n id: \"translation\",\r\n name: \"updateLanguage\",\r\n to: languages\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 { PropertyCollection } from \"./Exports.js\";\r\n\r\n/**\r\n * Represents collection of parameters and their values.\r\n * @class Translations\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 * Get the languages in the object in a String array.\r\n * @member Translations.prototype.languages\r\n * @function\r\n * @public\r\n * @returns {string[]} languages in translations object.\r\n */\r\n public get languages(): string[] {\r\n return this.privMap.keys;\r\n }\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 Translations.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 Translations.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.js\";\r\nimport { IntentRecognitionResult, NoMatchReason, SpeechRecognitionResult, TranslationRecognitionResult } from \"./Exports.js\";\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.js\";\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 { CancellationEventArgs } from \"./CancellationEventArgs.js\";\r\nimport { CancellationErrorCode, CancellationReason, IntentRecognitionEventArgs, IntentRecognitionResult } from \"./Exports.js\";\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 implements CancellationEventArgs {\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.js\";\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.js\";\r\nimport { CancellationDetailsBase } from \"./CancellationDetailsBase.js\";\r\nimport {\r\n CancellationErrorCode,\r\n CancellationReason,\r\n RecognitionResult,\r\n SpeechSynthesisResult\r\n} from \"./Exports.js\";\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[result.properties.getProperty(CancellationErrorCodePropertyName, CancellationErrorCode[CancellationErrorCode.NoError]) as keyof typeof CancellationErrorCode];\r\n }\r\n\r\n return new CancellationDetails(reason, result.errorDetails || EnumTranslation.implTranslateErrorDetails(errorCode), 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 * Indicates an quota overrun on existing key.\r\n */\r\n Forbidden,\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.js\";\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.js\";\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","// 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.js\";\r\nimport {\r\n ConversationTranscriber,\r\n MeetingTranscriber,\r\n Recognizer\r\n} from \"./Exports.js\";\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 | ConversationTranscriber | MeetingTranscriber): PhraseListGrammar {\r\n const recoBase = recognizer.internalData as ServiceRecognizerBase;\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\n/* eslint-disable max-classes-per-file */\r\nimport { Contracts } from \"./Contracts.js\";\r\nimport { PropertyCollection, PropertyId, ServicePropertyChannel, SpeechConfigImpl } from \"./Exports.js\";\r\nimport { OutputFormat } from \"./OutputFormat.js\";\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 return;\r\n }\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 | PropertyId, 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 | PropertyId, 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 * Sets the corresponding backend application identifier.\r\n * @member DialogServiceConfig.prototype.Conversation_ApplicationId\r\n * @function\r\n * @public\r\n * @param {string} value - The application identifier to set.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n public set applicationId(value: string) { }\r\n\r\n public static get DialogTypes(): { BotFramework: string; CustomCommands: string } {\r\n return {\r\n BotFramework: \"bot_framework\",\r\n CustomCommands: \"custom_commands\"\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Dialog Service configuration.\r\n * @class DialogServiceConfigImpl\r\n */\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 public get outputFormat(): OutputFormat {\r\n return this.privSpeechConfig.outputFormat;\r\n }\r\n\r\n public set outputFormat(value: OutputFormat) {\r\n this.privSpeechConfig.outputFormat = 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 void def;\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 void channel;\r\n this.privSpeechConfig.setServiceProperty(name, value);\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.js\";\r\nimport { DialogServiceConfig, DialogServiceConfigImpl } from \"./DialogServiceConfig.js\";\r\nimport { PropertyId } from \"./Exports.js\";\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 a bot framework configuration instance with the provided subscription information.\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 <a href=\"https://aka.ms/csspeech/region\">region page</a>).\r\n * @param botId Optional. Identifier for using a specific bot within an Azure resource group. Equivalent to the\r\n * resource name.\r\n * @returns {BotFrameworkConfig} A new bot framework configuration instance.\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(\r\n PropertyId.Conversation_DialogType,\r\n DialogServiceConfig.DialogTypes.BotFramework);\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 a bot framework configuration instance for the specified authorization token and region.\r\n * Note: The caller must ensure that an authorization token is valid. Before an authorization token expires, the\r\n * caller must refresh it by setting the authorizationToken property on the corresponding\r\n * DialogServiceConnector instance created with this config. The contents of configuration objects are copied\r\n * when connectors are created, so setting authorizationToken on a DialogServiceConnector will not update the\r\n * original configuration's authorization token. Create a new configuration instance or set the\r\n * SpeechServiceAuthorization_Token property to update an existing instance if it will be used to create\r\n * further DialogServiceConnectors.\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 <a href=\"https://aka.ms/csspeech/region\">region page</a>).\r\n * @param botId Optional. Identifier for using a specific bot within an Azure resource group. Equivalent to the\r\n * resource name.\r\n * @returns {BotFrameworkConfig} A new bot framework configuration instance.\r\n */\r\n public static fromAuthorizationToken(\r\n authorizationToken: string, region: string, botId?: string\r\n ): 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(\r\n PropertyId.Conversation_DialogType,\r\n DialogServiceConfig.DialogTypes.BotFramework);\r\n botFrameworkConfig.setProperty(PropertyId.SpeechServiceAuthorization_Token, authorizationToken);\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 a BotFrameworkConfig.\r\n * This method is intended only for users who use a non-default service host. The standard resource path will be\r\n * assumed. 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) and then set the AuthorizationToken\r\n * property on the created BotFrameworkConfig instance.\r\n * Note: Added in version 1.15.0.\r\n * @member BotFrameworkConfig.fromHost\r\n * @function\r\n * @public\r\n * @param {URL | string} host - If a URL is provided, the fully-qualified host with protocol (e.g.\r\n * wss://your.host.com:1234) will be used. If a string is provided, it will be embedded in\r\n * wss://{host}.convai.speech.azure.us.\r\n * @param {string} subscriptionKey - The subscription key. If a subscription key is not specified, an authorization\r\n * token must be set.\r\n * @param botId Optional. Identifier for using a specific bot within an Azure resource group. Equivalent to the\r\n * resource name.\r\n * @returns {BotFrameworkConfig} A new bot framework configuration instance.\r\n */\r\n public static fromHost(\r\n host: URL | string,\r\n subscriptionKey?: string,\r\n botId?: string): BotFrameworkConfig {\r\n\r\n void botId;\r\n Contracts.throwIfNullOrUndefined(host, \"host\");\r\n const resolvedHost: URL = host instanceof URL ? host : new URL(`wss://${host}.convai.speech.azure.us`);\r\n Contracts.throwIfNullOrUndefined(resolvedHost, \"resolvedHost\");\r\n\r\n const botFrameworkConfig: BotFrameworkConfig = new DialogServiceConfigImpl();\r\n botFrameworkConfig.setProperty(\r\n PropertyId.Conversation_DialogType,\r\n DialogServiceConfig.DialogTypes.BotFramework);\r\n botFrameworkConfig.setProperty(PropertyId.SpeechServiceConnection_Host, resolvedHost.toString());\r\n\r\n if (undefined !== subscriptionKey) {\r\n botFrameworkConfig.setProperty(PropertyId.SpeechServiceConnection_Key, subscriptionKey);\r\n }\r\n\r\n return botFrameworkConfig;\r\n }\r\n\r\n /**\r\n * Creates an instance of a BotFrameworkConfig.\r\n * This method is intended only for users who use a non-standard service endpoint or parameters.\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 * 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 BotFrameworkConfig instance to\r\n * use the authorization token.\r\n * Note: Added in version 1.15.0.\r\n * @member BotFrameworkConfig.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\r\n * token must be set.\r\n * @returns {BotFrameworkConfig} - A new bot framework configuration instance using the provided endpoint.\r\n */\r\n public static fromEndpoint(endpoint: URL, subscriptionKey?: string): BotFrameworkConfig {\r\n Contracts.throwIfNull(endpoint, \"endpoint\");\r\n\r\n const botFrameworkConfig: BotFrameworkConfig = new DialogServiceConfigImpl();\r\n botFrameworkConfig.setProperty(\r\n PropertyId.Conversation_DialogType,\r\n DialogServiceConfig.DialogTypes.BotFramework);\r\n botFrameworkConfig.setProperty(PropertyId.SpeechServiceConnection_Endpoint, endpoint.toString());\r\n\r\n if (undefined !== subscriptionKey) {\r\n botFrameworkConfig.setProperty(PropertyId.SpeechServiceConnection_Key, subscriptionKey);\r\n }\r\n\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.js\";\r\nimport { DialogServiceConfig, DialogServiceConfigImpl } from \"./DialogServiceConfig.js\";\r\nimport { PropertyId } from \"./Exports.js\";\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 <a href=\"https://aka.ms/csspeech/region\">region page</a>).\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, DialogServiceConfig.DialogTypes.CustomCommands);\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 <a href=\"https://aka.ms/csspeech/region\">region page</a>).\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, DialogServiceConfig.DialogTypes.CustomCommands);\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\nexport class QueryParameterNames {\r\n public static BotId: string = \"botid\";\r\n public static CustomSpeechDeploymentId: string = \"cid\";\r\n public static CustomVoiceDeploymentId: string = \"deploymentId\";\r\n public static EnableAudioLogging: string = \"storeAudio\";\r\n public static EnableLanguageId: string = \"lidEnabled\";\r\n public static EnableWordLevelTimestamps: string = \"wordLevelTimestamps\";\r\n public static EndSilenceTimeoutMs: string = \"endSilenceTimeoutMs\";\r\n public static SegmentationSilenceTimeoutMs: string = \"segmentationSilenceTimeoutMs\";\r\n public static Format: string = \"format\";\r\n public static InitialSilenceTimeoutMs: string = \"initialSilenceTimeoutMs\";\r\n public static Language: string = \"language\";\r\n public static Profanity: string = \"profanity\";\r\n public static RequestBotStatusMessages: string = \"enableBotMessageStatus\";\r\n public static StableIntermediateThreshold: string = \"stableIntermediateThreshold\";\r\n public static StableTranslation: string = \"stableTranslation\";\r\n public static TestHooks: string = \"testhooks\";\r\n public static Postprocessing: string = \"postprocessing\";\r\n public static CtsMeetingId: string = \"meetingId\";\r\n public static CtsDeviceId: string = \"deviceId\";\r\n public static CtsIsParticipant: string = \"isParticipant\";\r\n public static EnableAvatar: string = \"enableTalkingAvatar\";\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.js\";\r\nimport { IConnection, IStringDictionary } from \"../common/Exports.js\";\r\nimport { PropertyId } from \"../sdk/Exports.js\";\r\nimport { AuthInfo, IConnectionFactory, RecognizerConfig } from \"./Exports.js\";\r\nimport { QueryParameterNames } from \"./QueryParameterNames.js\";\r\n\r\nexport abstract class ConnectionFactoryBase implements IConnectionFactory {\r\n\r\n public static getHostSuffix(region: string): string {\r\n if (!!region) {\r\n if (region.toLowerCase().startsWith(\"china\")) {\r\n return \".azure.cn\";\r\n }\r\n if (region.toLowerCase().startsWith(\"usgov\")) {\r\n return \".azure.us\";\r\n }\r\n }\r\n return \".microsoft.com\";\r\n }\r\n\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<string>,\r\n endpoint: string): void {\r\n\r\n const propertyIdToParameterMap: Map<number, string> = new Map([\r\n [PropertyId.Speech_SegmentationSilenceTimeoutMs, QueryParameterNames.SegmentationSilenceTimeoutMs],\r\n [PropertyId.SpeechServiceConnection_EnableAudioLogging, QueryParameterNames.EnableAudioLogging],\r\n [PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs, QueryParameterNames.EndSilenceTimeoutMs],\r\n [PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs, QueryParameterNames.InitialSilenceTimeoutMs],\r\n [PropertyId.SpeechServiceResponse_PostProcessingOption, QueryParameterNames.Postprocessing],\r\n [PropertyId.SpeechServiceResponse_ProfanityOption, QueryParameterNames.Profanity],\r\n [PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps, QueryParameterNames.EnableWordLevelTimestamps],\r\n [PropertyId.SpeechServiceResponse_StablePartialResultThreshold, QueryParameterNames.StableIntermediateThreshold],\r\n ]);\r\n\r\n propertyIdToParameterMap.forEach((parameterName: string, propertyId: PropertyId): void => {\r\n this.setUrlParameter(propertyId, parameterName, config, queryParams, endpoint);\r\n });\r\n\r\n\r\n const serviceProperties: IStringDictionary<string> = JSON.parse(config.parameters.getProperty(ServicePropertiesPropertyName, \"{}\")) as IStringDictionary<string>;\r\n\r\n Object.keys(serviceProperties).forEach((value: string): void => {\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<string>,\r\n endpoint: string): void {\r\n\r\n const value: string = config.parameters.getProperty(propId, undefined);\r\n\r\n // FIXME: The .search() check will incorrectly match parameter name anywhere in the string\r\n // including e.g. the path portion, or even as a substring of other query parameters\r\n if (value && (!endpoint || endpoint.search(parameterName) === -1)) {\r\n queryParams[parameterName] = value.toLocaleLowerCase();\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/* eslint-disable max-classes-per-file */\r\nimport {\r\n ProxyInfo,\r\n WebsocketConnection,\r\n} from \"../common.browser/Exports.js\";\r\nimport { OutputFormatPropertyName } from \"../common.speech/Exports.js\";\r\nimport { IConnection, IStringDictionary } from \"../common/Exports.js\";\r\nimport { DialogServiceConfig, OutputFormat, PropertyId } from \"../sdk/Exports.js\";\r\nimport { ConnectionFactoryBase } from \"./ConnectionFactoryBase.js\";\r\nimport { AuthInfo, RecognizerConfig, WebsocketMessageFormatter } from \"./Exports.js\";\r\nimport { HeaderNames } from \"./HeaderNames.js\";\r\nimport { QueryParameterNames } from \"./QueryParameterNames.js\";\r\n\r\nexport class DialogConnectionFactory extends ConnectionFactoryBase {\r\n\r\n private static readonly ApiKey: string = \"api\";\r\n private static readonly BaseUrl: string = \"convai.speech\";\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 const language: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage, \"en-US\");\r\n const requestTurnStatus: string = config.parameters.getProperty(PropertyId.Conversation_Request_Bot_Status_Messages, \"true\");\r\n\r\n const queryParams: IStringDictionary<string> = {};\r\n queryParams[HeaderNames.ConnectionId] = connectionId;\r\n queryParams[QueryParameterNames.Format] = config.parameters.getProperty(OutputFormatPropertyName, OutputFormat[OutputFormat.Simple]).toLowerCase();\r\n queryParams[QueryParameterNames.Language] = language;\r\n queryParams[QueryParameterNames.RequestBotStatusMessages] = requestTurnStatus;\r\n if (applicationId) {\r\n queryParams[QueryParameterNames.BotId] = applicationId;\r\n if (dialogType === DialogServiceConfig.DialogTypes.CustomCommands) {\r\n queryParams[HeaderNames.CustomCommandsAppId] = applicationId;\r\n }\r\n }\r\n\r\n const resourceInfix: string =\r\n dialogType === DialogServiceConfig.DialogTypes.CustomCommands ? \"commands/\"\r\n : \"\";\r\n const version: string =\r\n dialogType === DialogServiceConfig.DialogTypes.CustomCommands ? \"v1\"\r\n : dialogType === DialogServiceConfig.DialogTypes.BotFramework ? \"v3\"\r\n : \"v0\";\r\n\r\n const headers: IStringDictionary<string> = {};\r\n\r\n if (authInfo.token != null && authInfo.token !== \"\") {\r\n headers[authInfo.headerName] = authInfo.token;\r\n }\r\n\r\n // The URL used for connection is chosen in a priority order of specification:\r\n // 1. If a custom endpoint is provided, that URL is used verbatim.\r\n // 2. If a custom host is provided (e.g. \"wss://my.custom.endpoint.com:1123\"), a URL is constructed from it.\r\n // 3. If no custom connection details are provided, a URL is constructed from default values.\r\n let endpoint: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint, \"\");\r\n if (!endpoint) {\r\n const hostSuffix: string = ConnectionFactoryBase.getHostSuffix(region);\r\n const host: string = config.parameters.getProperty(\r\n PropertyId.SpeechServiceConnection_Host,\r\n `wss://${region}.${DialogConnectionFactory.BaseUrl}${hostSuffix}`);\r\n const standardizedHost: string = host.endsWith(\"/\") ? host : host + \"/\";\r\n endpoint = `${standardizedHost}${resourceInfix}${DialogConnectionFactory.ApiKey}/${version}`;\r\n }\r\n\r\n this.setCommonUrlParams(config, queryParams, endpoint);\r\n\r\n const enableCompression: boolean = config.parameters.getProperty(\"SPEECH-EnableWebsocketCompression\", \"false\") === \"true\";\r\n return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, 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 { DialogConnectionFactory } from \"../common.speech/DialogConnectorFactory.js\";\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.js\";\r\nimport {\r\n Deferred,\r\n marshalPromiseToCallbacks\r\n} from \"../common/Exports.js\";\r\nimport { ActivityReceivedEventArgs } from \"./ActivityReceivedEventArgs.js\";\r\nimport { AudioConfigImpl } from \"./Audio/AudioConfig.js\";\r\nimport { Contracts } from \"./Contracts.js\";\r\nimport { DialogServiceConfig, DialogServiceConfigImpl } from \"./DialogServiceConfig.js\";\r\nimport {\r\n AudioConfig,\r\n PropertyCollection,\r\n Recognizer,\r\n SpeechRecognitionCanceledEventArgs,\r\n SpeechRecognitionEventArgs,\r\n SpeechRecognitionResult\r\n} from \"./Exports.js\";\r\nimport { PropertyId } from \"./PropertyId.js\";\r\nimport { TurnStatusReceivedEventArgs } from \"./TurnStatusReceivedEventArgs.js\";\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 * The event turnStatusReceived signals that a turn status message has been received. These messages are\r\n * associated with both an interaction and a conversation. They are used to notify the client in the event\r\n * of an interaction failure with the dialog backend, e.g. in the event of a network issue, timeout, crash,\r\n * or other problem.\r\n * @member DialogServiceConnector.prototype.turnStatusReceived\r\n * @function\r\n * @public\r\n */\r\n public turnStatusReceived: (sender: DialogServiceConnector, event: TurnStatusReceivedEventArgs) => 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(cb?: () => void, err?: (error: string) => void): void {\r\n marshalPromiseToCallbacks(this.privReco.connect(), cb, err);\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(cb?: () => void, err?: (error: string) => void): void {\r\n marshalPromiseToCallbacks(this.privReco.disconnect(), cb, err);\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 Contracts.throwIfDisposed(this.privIsDisposed);\r\n const callbackHolder = async (): Promise<SpeechRecognitionResult> => {\r\n await this.privReco.connect();\r\n await this.implRecognizerStop();\r\n this.isTurnComplete = false;\r\n\r\n const ret: Deferred<SpeechRecognitionResult> = new Deferred<SpeechRecognitionResult>();\r\n await this.privReco.recognize(RecognitionMode.Conversation, ret.resolve, ret.reject);\r\n\r\n const e: SpeechRecognitionResult = await ret.promise;\r\n await this.implRecognizerStop();\r\n\r\n return e;\r\n };\r\n\r\n const retPromise: Promise<SpeechRecognitionResult> = callbackHolder();\r\n\r\n retPromise.catch((): void => {\r\n // Destroy the recognizer.\r\n // We've done all we can here.\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n this.dispose(true).catch((): void => { });\r\n });\r\n\r\n marshalPromiseToCallbacks(retPromise.finally((): void => {\r\n this.isTurnComplete = true;\r\n }), cb, err);\r\n }\r\n }\r\n\r\n public sendActivityAsync(activity: string, cb?: () => void, errCb?: (error: string) => void): void {\r\n marshalPromiseToCallbacks((this.privReco as DialogServiceAdapter).sendMessage(activity), cb, errCb);\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(cb?: () => void, err?: (error: string) => void): void {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n\r\n marshalPromiseToCallbacks(this.dispose(true), cb, err);\r\n }\r\n\r\n protected async dispose(disposing: boolean): Promise<void> {\r\n if (this.privIsDisposed) {\r\n return;\r\n }\r\n\r\n if (disposing) {\r\n this.privIsDisposed = true;\r\n await this.implRecognizerStop();\r\n await 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_Agent_Connection_Id),\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: 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\n/* eslint-disable max-classes-per-file */\r\nimport { PullAudioOutputStream } from \"./Audio/AudioOutputStream.js\";\r\n\r\ninterface IActivity {\r\n conversation?: any;\r\n id?: string;\r\n replyToId?: string;\r\n type?: string;\r\n text?: string;\r\n speak?: any;\r\n}\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: IActivity;\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 as IActivity;\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. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nexport interface ITurnStatusResponsePayload {\r\n interactionId: string;\r\n conversationId: string;\r\n statusCode: any;\r\n}\r\n\r\nexport class TurnStatusResponsePayload implements ITurnStatusResponsePayload {\r\n private privMessageStatusResponse: ITurnStatusResponsePayload;\r\n\r\n private constructor(json: string) {\r\n this.privMessageStatusResponse = JSON.parse(json) as ITurnStatusResponsePayload;\r\n }\r\n\r\n public static fromJSON(json: string): TurnStatusResponsePayload {\r\n return new TurnStatusResponsePayload(json);\r\n }\r\n\r\n public get interactionId(): string {\r\n return this.privMessageStatusResponse.interactionId;\r\n }\r\n\r\n public get conversationId(): string {\r\n return this.privMessageStatusResponse.conversationId;\r\n }\r\n\r\n public get statusCode(): any {\r\n // Payloads may contain a limited set of textual representations or a numeric status\r\n // code. The textual values are here converted into numeric ones.\r\n switch (this.privMessageStatusResponse.statusCode) {\r\n case \"Success\":\r\n return 200;\r\n case \"Failed\":\r\n return 400;\r\n case \"TimedOut\":\r\n return 429;\r\n default:\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\r\n return this.privMessageStatusResponse.statusCode;\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 ITurnStatusResponsePayload,\r\n TurnStatusResponsePayload\r\n } from \"../common.speech/ServiceMessages/TurnStatusPayload.js\";\r\n\r\n/**\r\n * Defines contents of received message/events.\r\n * @class TurnStatusReceivedEventArgs\r\n */\r\nexport class TurnStatusReceivedEventArgs {\r\n private privTurnStatus: ITurnStatusResponsePayload;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {string} turnStatus - The JSON-encoded turn status message.\r\n */\r\n public constructor(turnStatus: string) {\r\n this.privTurnStatus = TurnStatusResponsePayload.fromJSON(turnStatus);\r\n }\r\n\r\n /**\r\n * Gets the interaction identifier associated with this turn status event.\r\n * @member TurnStatusReceivedEventArgs.prototype.interactionId\r\n * @function\r\n * @public\r\n * @returns {any} the received interaction id.\r\n */\r\n public get interactionId(): any {\r\n return this.privTurnStatus.interactionId;\r\n }\r\n\r\n /**\r\n * Gets the conversation identifier associated with this turn status event.\r\n * @member TurnStatusReceivedEventArgs.prototype.conversationId\r\n * @function\r\n * @public\r\n * @returns {any} the received conversation id.\r\n */\r\n public get conversationId(): any {\r\n return this.privTurnStatus.conversationId;\r\n }\r\n\r\n /**\r\n * Gets the received turn status code.\r\n * @member TurnStatusReceivedEventArgs.prototype.statusCode\r\n * @function\r\n * @public\r\n * @returns {number} the received turn status.\r\n */\r\n public get statusCode(): number {\r\n return this.privTurnStatus.statusCode; // eslint-disable-line @typescript-eslint/no-unsafe-return\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.js\";\r\nimport { AudioStreamFormat } from \"../Exports.js\";\r\nimport { AudioStreamFormatImpl } from \"./AudioStreamFormat.js\";\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 * @param {AudioStreamFormat} audioFormat audio stream format recognized by the player.\r\n */\r\n public constructor(audioFormat?: AudioStreamFormat) {\r\n if (audioFormat === undefined) {\r\n audioFormat = AudioStreamFormat.getDefaultInputFormat();\r\n }\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, cb?: () => void, err?: (error: string) => void): void {\r\n try {\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 if (!!cb) {\r\n cb();\r\n }\r\n } catch (e) {\r\n if (!!err) {\r\n err(e as string);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * stops audio and clears the buffers\r\n */\r\n public stopAudio(cb?: () => void, err?: (error: string) => void): void {\r\n if (this.audioContext !== null) {\r\n this.samples = new Float32Array();\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\r\n clearInterval(this.autoUpdateBufferTimer);\r\n this.audioContext.close().then((): void => {\r\n if (!!cb) {\r\n cb();\r\n }\r\n }, (error: string): void => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\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((): void => {\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 = AudioStreamFormatImpl.getAudioContext();\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 private async playAudio(audioData: ArrayBuffer): Promise<void> {\r\n if (this.audioContext === null) {\r\n this.createAudioContext();\r\n }\r\n const source: AudioBufferSourceNode = this.audioContext.createBufferSource();\r\n const destination: AudioDestinationNode = this.audioContext.destination;\r\n await this.audioContext.decodeAudioData(audioData, (newBuffer: AudioBuffer): void => {\r\n source.buffer = newBuffer;\r\n source.connect(destination);\r\n source.start(0);\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\r\n} from \"./Exports.js\";\r\n\r\nexport class ConnectionMessageEventArgs {\r\n\r\n private privConnectionMessage: ConnectionMessage;\r\n\r\n public constructor(message: ConnectionMessage) {\r\n this.privConnectionMessage = message;\r\n }\r\n\r\n /**\r\n * Gets the <see cref=\"ConnectionMessage\"/> associated with this <see cref=\"ConnectionMessageEventArgs\"/>.\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.js\";\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 public 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\n/* eslint-disable max-classes-per-file */\r\nimport { CancellationErrorCodePropertyName } from \"../common.speech/Exports.js\";\r\nimport {\r\n CancellationDetailsBase,\r\n CancellationErrorCode,\r\n CancellationReason,\r\n PropertyCollection,\r\n ResultReason\r\n} from \"./Exports.js\";\r\n\r\nexport interface EnrollmentResultDetails {\r\n profileId: string;\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\nexport interface EnrollmentResultJSON {\r\n profileId: string;\r\n enrollmentsCount: number;\r\n enrollmentsLength: string;\r\n enrollmentsSpeechLength: string;\r\n remainingEnrollmentsCount: number;\r\n remainingEnrollmentsSpeechLength: string;\r\n audioLength: string;\r\n audioSpeechLength: string;\r\n enrollmentStatus: string;\r\n remainingEnrollments?: number;\r\n identificationProfileId?: string;\r\n verificationProfileId?: 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: EnrollmentResultDetails;\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 if (!!json) {\r\n this.privDetails = JSON.parse(json) as EnrollmentResultDetails;\r\n if (this.privDetails.enrollmentStatus.toLowerCase() === \"enrolling\") {\r\n this.privReason = ResultReason.EnrollingVoiceProfile;\r\n }\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 enrollmentResultDetails(): EnrollmentResultDetails {\r\n return this.privDetails;\r\n }\r\n\r\n public get errorDetails(): string {\r\n return this.privErrorDetails;\r\n }\r\n\r\n public static FromIdentificationProfileList(json: { value: EnrollmentResultJSON[] }): VoiceProfileEnrollmentResult[] {\r\n const results: VoiceProfileEnrollmentResult[] = [];\r\n for (const item of json.value) {\r\n const reason: ResultReason = item.enrollmentStatus.toLowerCase() === \"enrolling\" ?\r\n ResultReason.EnrollingVoiceProfile : item.enrollmentStatus.toLowerCase() === \"enrolled\" ?\r\n ResultReason.EnrolledVoiceProfile : ResultReason.Canceled;\r\n const result = new VoiceProfileEnrollmentResult(reason, null, null);\r\n result.privDetails = this.getIdentificationDetails(item) as EnrollmentResultDetails;\r\n results.push(result);\r\n }\r\n return results;\r\n }\r\n\r\n public static FromVerificationProfileList(json: { value: EnrollmentResultJSON[] }): VoiceProfileEnrollmentResult[] {\r\n const results: VoiceProfileEnrollmentResult[] = [];\r\n for (const item of json.value) {\r\n const reason: ResultReason = item.enrollmentStatus.toLowerCase() === \"enrolling\" ?\r\n ResultReason.EnrollingVoiceProfile : item.enrollmentStatus.toLowerCase() === \"enrolled\" ?\r\n ResultReason.EnrolledVoiceProfile : ResultReason.Canceled;\r\n const result = new VoiceProfileEnrollmentResult(reason, null, null);\r\n result.privDetails = this.getVerificationDetails(item) as EnrollmentResultDetails;\r\n results.push(result);\r\n }\r\n return results;\r\n }\r\n\r\n private static getIdentificationDetails(json: EnrollmentResultJSON): unknown {\r\n return {\r\n audioLength: json.audioLength ? parseFloat(json.audioLength) : 0,\r\n audioSpeechLength: json.audioSpeechLength ? parseFloat(json.audioSpeechLength) : 0,\r\n enrollmentStatus: json.enrollmentStatus,\r\n enrollmentsCount: json.enrollmentsCount || 0,\r\n enrollmentsLength: json.enrollmentsLength ? parseFloat(json.enrollmentsLength) : 0,\r\n enrollmentsSpeechLength: json.enrollmentsSpeechLength ? parseFloat(json.enrollmentsSpeechLength) : 0,\r\n profileId: json.profileId || json.identificationProfileId,\r\n remainingEnrollmentsSpeechLength: json.remainingEnrollmentsSpeechLength ? parseFloat(json.remainingEnrollmentsSpeechLength) : 0\r\n };\r\n }\r\n\r\n private static getVerificationDetails(json: EnrollmentResultJSON): unknown {\r\n return {\r\n audioLength: json.audioLength ? parseFloat(json.audioLength) : 0,\r\n audioSpeechLength: json.audioSpeechLength ? parseFloat(json.audioSpeechLength) : 0,\r\n enrollmentStatus: json.enrollmentStatus,\r\n enrollmentsCount: json.enrollmentsCount,\r\n enrollmentsLength: json.enrollmentsLength ? parseFloat(json.enrollmentsLength) : 0,\r\n enrollmentsSpeechLength: json.enrollmentsSpeechLength ? parseFloat(json.enrollmentsSpeechLength) : 0,\r\n profileId: json.profileId || json.verificationProfileId,\r\n remainingEnrollmentsCount: json.remainingEnrollments || json.remainingEnrollmentsCount,\r\n remainingEnrollmentsSpeechLength: json.remainingEnrollmentsSpeechLength ? parseFloat(json.remainingEnrollmentsSpeechLength) : 0\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * @class VoiceProfileEnrollmentCancellationDetails\r\n */\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])]; //eslint-disable-line\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\n/* eslint-disable max-classes-per-file */\r\nimport { CancellationErrorCodePropertyName } from \"../common.speech/Exports.js\";\r\nimport { Contracts } from \"./Contracts.js\";\r\nimport {\r\n CancellationDetailsBase,\r\n CancellationErrorCode,\r\n CancellationReason,\r\n PropertyCollection,\r\n ResultReason\r\n} from \"./Exports.js\";\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\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])]; //eslint-disable-line\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 { Contracts } from \"./Contracts.js\";\r\nimport {\r\n ResultReason,\r\n VoiceProfileResult\r\n} from \"./Exports.js\";\r\n\r\n/**\r\n * Output format\r\n * @class VoiceProfilePhraseResult\r\n */\r\nexport class VoiceProfilePhraseResult extends VoiceProfileResult {\r\n private privPhrases: string[] = [];\r\n private privType: string;\r\n\r\n public constructor(reason: ResultReason, statusText: string, type: string, phraseArray: string[]) {\r\n super(reason, statusText);\r\n Contracts.throwIfNullOrUndefined(phraseArray, \"phrase array\");\r\n this.privType = type;\r\n if (!!phraseArray && !!phraseArray[0]) {\r\n this.privPhrases = phraseArray;\r\n }\r\n }\r\n\r\n public get phrases(): string[] {\r\n return this.privPhrases;\r\n }\r\n\r\n public get type(): string {\r\n return this.privType;\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.js\";\r\nimport {\r\n IAuthentication,\r\n IConnectionFactory,\r\n RecognizerConfig,\r\n ServiceRecognizerBase,\r\n SpeechServiceConfig,\r\n VoiceProfileConnectionFactory,\r\n VoiceServiceRecognizer\r\n} from \"../common.speech/Exports.js\";\r\nimport { AudioConfig, AudioConfigImpl } from \"./Audio/AudioConfig.js\";\r\nimport { Contracts } from \"./Contracts.js\";\r\nimport {\r\n AudioInputStream,\r\n PropertyCollection,\r\n PropertyId,\r\n Recognizer,\r\n ResultReason,\r\n VoiceProfile,\r\n VoiceProfileEnrollmentResult,\r\n VoiceProfilePhraseResult,\r\n VoiceProfileResult,\r\n VoiceProfileType\r\n} from \"./Exports.js\";\r\nimport { SpeechConfig, SpeechConfigImpl } from \"./SpeechConfig.js\";\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 extends Recognizer {\r\n protected privProperties: PropertyCollection;\r\n private privVoiceAdapter: VoiceServiceRecognizer;\r\n private privDisposedVoiceAdapter: boolean;\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 Contracts.throwIfNullOrUndefined(speechConfig, \"speechConfig\");\r\n const speechConfigImpl: SpeechConfigImpl = speechConfig as SpeechConfigImpl;\r\n Contracts.throwIfNull(speechConfigImpl, \"speechConfig\");\r\n\r\n super(AudioConfig.fromStreamInput(AudioInputStream.createPushStream()), speechConfigImpl.properties, new VoiceProfileConnectionFactory());\r\n\r\n this.privProperties = speechConfigImpl.properties.clone();\r\n this.privVoiceAdapter = this.privReco as VoiceServiceRecognizer;\r\n this.privDisposedVoiceAdapter = false;\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 * 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 * Create a speaker recognition voice profile\r\n * @member VoiceProfileClient.prototype.createProfileAsync\r\n * @function\r\n * @public\r\n * @async\r\n * @param {VoiceProfileType} profileType Type of Voice Profile to be created\r\n * @param {string} lang Language string (locale) for Voice Profile\r\n * @return {Promise<VoiceProfile>} - Promise of a VoiceProfile.\r\n */\r\n public async createProfileAsync(profileType: VoiceProfileType, lang: string): Promise<VoiceProfile> {\r\n const profileIds: string[] = await this.privVoiceAdapter.createProfile(profileType, lang);\r\n return new VoiceProfile(profileIds[0], profileType);\r\n }\r\n\r\n /**\r\n * Get current information of a voice profile\r\n * @member VoiceProfileClient.prototype.retrieveEnrollmentResultAsync\r\n * @function\r\n * @public\r\n * @async\r\n * @param {VoiceProfile} profile Voice Profile to retrieve info for\r\n * @return {Promise<VoiceProfileEnrollmentResult>} - Promise of a VoiceProfileEnrollmentResult.\r\n */\r\n public async retrieveEnrollmentResultAsync(profile: VoiceProfile): Promise<VoiceProfileEnrollmentResult> {\r\n return this.privVoiceAdapter.retrieveEnrollmentResult(profile);\r\n }\r\n\r\n /**\r\n * Get all voice profiles on account with given voice profile type\r\n * @member VoiceProfileClient.prototype.getAllProfilesAsync\r\n * @function\r\n * @public\r\n * @async\r\n * @param {VoiceProfileType} profileType profile type (identification/verification) for which to list profiles\r\n * @return {Promise<VoiceProfileEnrollmentResult[]>} - Promise of an array of VoiceProfileEnrollmentResults.\r\n */\r\n public async getAllProfilesAsync(profileType: VoiceProfileType): Promise<VoiceProfileEnrollmentResult[]> {\r\n return this.privVoiceAdapter.getAllProfiles(profileType);\r\n /*\r\n const result: { json: { value: EnrollmentResultJSON[] } } = await this.privAdapter.getProfiles(profileType);\r\n if (profileType === VoiceProfileType.TextIndependentIdentification) {\r\n return VoiceProfileEnrollmentResult.FromIdentificationProfileList(result.json);\r\n }\r\n return VoiceProfileEnrollmentResult.FromVerificationProfileList(result.json);\r\n */\r\n }\r\n\r\n /**\r\n * Get valid authorization phrases for voice profile enrollment\r\n * @member VoiceProfileClient.prototype.getActivationPhrasesAsync\r\n * @function\r\n * @public\r\n * @async\r\n * @param {VoiceProfileType} profileType Profile Type to get activation phrases for\r\n * @param {string} lang Language string (locale) for Voice Profile\r\n */\r\n public async getActivationPhrasesAsync(profileType: VoiceProfileType, lang: string): Promise<VoiceProfilePhraseResult> {\r\n return this.privVoiceAdapter.getActivationPhrases(profileType, lang);\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 * @async\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 * @return {Promise<VoiceProfileEnrollmentResult>} - Promise of a VoiceProfileEnrollmentResult.\r\n */\r\n public async enrollProfileAsync(profile: VoiceProfile, audioConfig: AudioConfig): Promise<VoiceProfileEnrollmentResult> {\r\n const configImpl: AudioConfigImpl = audioConfig as AudioConfigImpl;\r\n Contracts.throwIfNullOrUndefined(configImpl, \"audioConfig\");\r\n this.audioConfig = audioConfig;\r\n this.privVoiceAdapter.SpeakerAudioSource = configImpl;\r\n\r\n return this.privVoiceAdapter.enrollProfile(profile);\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 * @async\r\n * @param {VoiceProfile} profile Voice Profile to be deleted\r\n * @return {Promise<VoiceProfileResult>} - Promise of a VoiceProfileResult.\r\n */\r\n public async deleteProfileAsync(profile: VoiceProfile): Promise<VoiceProfileResult> {\r\n return this.privVoiceAdapter.deleteProfile(profile);\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 * @async\r\n * @param {VoiceProfile} profile Voice Profile to be reset\r\n * @return {Promise<VoiceProfileResult>} - Promise of a VoiceProfileResult.\r\n */\r\n public async resetProfileAsync(profile: VoiceProfile): Promise<VoiceProfileResult> {\r\n return this.privVoiceAdapter.resetProfile(profile);\r\n }\r\n\r\n /**\r\n * Clean up object and close underlying connection\r\n * @member VoiceProfileClient.prototype.close\r\n * @function\r\n * @async\r\n * @public\r\n */\r\n public async close(): Promise<void> {\r\n await this.dispose(true);\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 VoiceServiceRecognizer(authentication, connectionFactory, audioImpl, recognizerConfig, this);\r\n }\r\n\r\n protected async dispose(disposing: boolean): Promise<void> {\r\n if (this.privDisposedVoiceAdapter) {\r\n return;\r\n }\r\n\r\n this.privDisposedVoiceAdapter = true;\r\n\r\n if (disposing) {\r\n await 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 private getResult(result: IRestResponse, successReason: ResultReason): VoiceProfileResult {\r\n const response: VoiceProfileResult =\r\n new VoiceProfileResult(\r\n result.ok ? successReason : ResultReason.Canceled,\r\n result.statusText\r\n );\r\n return (response);\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 SpeakerRecognitionConnectionFactory,\r\n SpeakerServiceRecognizer,\r\n SpeechServiceConfig\r\n} from \"../common.speech/Exports.js\";\r\nimport { SpeakerRecognitionModel } from \"./SpeakerRecognitionModel.js\";\r\nimport { AudioConfig, AudioConfigImpl } from \"./Audio/AudioConfig.js\";\r\nimport { Contracts } from \"./Contracts.js\";\r\nimport {\r\n PropertyCollection,\r\n PropertyId,\r\n Recognizer,\r\n SpeakerIdentificationModel,\r\n SpeakerRecognitionResult,\r\n SpeakerVerificationModel,\r\n} from \"./Exports.js\";\r\nimport { SpeechConfig, SpeechConfigImpl } from \"./SpeechConfig.js\";\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 extends Recognizer {\r\n protected privProperties: PropertyCollection;\r\n private privDisposedSpeakerRecognizer: boolean;\r\n private privAudioConfigImpl: AudioConfigImpl;\r\n /**\r\n * Initializes an instance of the SpeakerRecognizer.\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 SpeakerRecognitionConnectionFactory());\r\n this.privAudioConfigImpl = audioConfig as AudioConfigImpl;\r\n Contracts.throwIfNull(this.privAudioConfigImpl, \"audioConfig\");\r\n\r\n this.privDisposedSpeakerRecognizer = false;\r\n this.privProperties = configImpl.properties;\r\n }\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 * Get recognition result for model using given audio\r\n * @member SpeakerRecognizer.prototype.recognizeOnceAsync\r\n * @function\r\n * @public\r\n * @async\r\n * @param {SpeakerIdentificationModel | SpeakerVerificationModel} 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 async recognizeOnceAsync(model: SpeakerIdentificationModel | SpeakerVerificationModel): Promise<SpeakerRecognitionResult> {\r\n Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer);\r\n\r\n return this.recognizeSpeakerOnceAsyncImpl(model);\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 * @async\r\n */\r\n public async close(): Promise<void> {\r\n Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer);\r\n await this.dispose(true);\r\n }\r\n\r\n protected async recognizeSpeakerOnceAsyncImpl(model: SpeakerRecognitionModel): Promise<SpeakerRecognitionResult> {\r\n Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer);\r\n\r\n await this.implRecognizerStop();\r\n const result: SpeakerRecognitionResult = await this.privReco.recognizeSpeaker(model);\r\n await this.implRecognizerStop();\r\n\r\n return result;\r\n }\r\n\r\n protected async implRecognizerStop(): Promise<void> {\r\n if (this.privReco) {\r\n await this.privReco.stopRecognizing();\r\n }\r\n return;\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(authentication: IAuthentication, connectionFactory: IConnectionFactory, audioConfig: AudioConfig, recognizerConfig: RecognizerConfig): ServiceRecognizerBase {\r\n const audioImpl: AudioConfigImpl = audioConfig as AudioConfigImpl;\r\n return new SpeakerServiceRecognizer(authentication, connectionFactory, audioImpl, recognizerConfig, this);\r\n }\r\n\r\n protected async dispose(disposing: boolean): Promise<void> {\r\n if (this.privDisposedSpeakerRecognizer) {\r\n return;\r\n }\r\n\r\n if (disposing) {\r\n this.privDisposedSpeakerRecognizer = true;\r\n await super.dispose(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 { Contracts } from \"./Contracts.js\";\r\nimport { SpeakerRecognitionModel } from \"./SpeakerRecognitionModel.js\";\r\nimport {\r\n VoiceProfile,\r\n VoiceProfileType,\r\n} from \"./Exports.js\";\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 implements SpeakerRecognitionModel {\r\n private privVoiceProfiles: VoiceProfile[] = [];\r\n private privProfileIds: string[] = [];\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 for (const profile of profiles) {\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 this.privProfileIds.push(profile.profileId);\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.privProfileIds.join(\",\");\r\n }\r\n\r\n public get profileIds(): string[] {\r\n return this.privProfileIds;\r\n }\r\n\r\n public get scenario(): string {\r\n return \"TextIndependentIdentification\";\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.js\";\r\nimport { SpeakerRecognitionModel } from \"./SpeakerRecognitionModel.js\";\r\nimport {\r\n VoiceProfile,\r\n VoiceProfileType,\r\n} from \"./Exports.js\";\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 implements SpeakerRecognitionModel {\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 public get profileIds(): string[] {\r\n return [ this.voiceProfile.profileId ];\r\n }\r\n\r\n public get scenario(): string {\r\n if (this.voiceProfile.profileType === VoiceProfileType.TextDependentVerification) {\r\n return \"TextDependentVerification\";\r\n } else {\r\n return \"TextIndependentVerification\";\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 * Language Identification mode\r\n * @class LanguageIdMode\r\n */\r\nexport enum LanguageIdMode {\r\n\r\n /**\r\n * Detect language at audio start\r\n * @member LanguageIdMode.AtStart\r\n */\r\n AtStart,\r\n\r\n /**\r\n * Continuously detect language\r\n * @member LanguageIdMode.Continuous\r\n */\r\n Continuous,\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.js\";\r\nimport {Contracts} from \"./Contracts.js\";\r\nimport {\r\n PropertyCollection,\r\n PropertyId,\r\n SourceLanguageConfig,\r\n} from \"./Exports.js\";\r\nimport { LanguageIdMode } from \"./LanguageIdMode.js\";\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 private privLanguageIdMode: LanguageIdMode;\r\n\r\n private constructor() {\r\n this.privProperties = new PropertyCollection();\r\n this.privProperties.setProperty(PropertyId.SpeechServiceConnection_LanguageIdMode, \"AtStart\");\r\n this.privLanguageIdMode = LanguageIdMode.AtStart;\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): void => {\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 an 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 * @member AutoDetectSourceLanguageConfig.prototype.mode\r\n * @function\r\n * @public\r\n * @param {LanguageIdMode} mode LID mode desired.\r\n * @summary Sets LID operation to desired mode\r\n */\r\n public set mode(mode: LanguageIdMode) {\r\n if (mode === LanguageIdMode.Continuous) {\r\n this.privProperties.setProperty(PropertyId.SpeechServiceConnection_RecognitionEndpointVersion, \"2\");\r\n this.privProperties.setProperty(PropertyId.SpeechServiceConnection_LanguageIdMode, \"Continuous\");\r\n } else { // LanguageIdMode.AtStart\r\n this.privProperties.setProperty(PropertyId.SpeechServiceConnection_RecognitionEndpointVersion, \"1\");\r\n this.privProperties.setProperty(PropertyId.SpeechServiceConnection_LanguageIdMode, \"AtStart\");\r\n }\r\n this.privLanguageIdMode = mode;\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.js\";\r\nimport {\r\n SpeechRecognitionResult,\r\n ConversationTranscriptionResult\r\n} from \"./Exports.js\";\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 /**\r\n * Creates an instance of AutoDetectSourceLanguageResult object from a ConversationTranscriptionResult instance.\r\n * @member AutoDetectSourceLanguageResult.fromConversationTranscriptionResult\r\n * @function\r\n * @public\r\n * @param {ConversationTranscriptionResult} result - The transcription result.\r\n * @returns {AutoDetectSourceLanguageResult} AutoDetectSourceLanguageResult object being created.\r\n */\r\n public static fromConversationTranscriptionResult(result: ConversationTranscriptionResult): 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.js\";\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\n/* eslint-disable max-classes-per-file */\r\nimport { CancellationErrorCodePropertyName, SpeakerResponse } from \"../common.speech/Exports.js\";\r\nimport {\r\n CancellationDetailsBase,\r\n CancellationErrorCode,\r\n CancellationReason,\r\n PropertyCollection,\r\n PropertyId,\r\n ResultReason,\r\n} from \"./Exports.js\";\r\n\r\nexport enum SpeakerRecognitionResultType {\r\n Verify,\r\n Identify\r\n}\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(response: SpeakerResponse, resultReason: ResultReason = ResultReason.RecognizedSpeaker, cancellationErrorCode: CancellationErrorCode = CancellationErrorCode.NoError, errorDetails: string = \"\") {\r\n this.privProperties = new PropertyCollection();\r\n const resultType = response.scenario === \"TextIndependentIdentification\" ? SpeakerRecognitionResultType.Identify : SpeakerRecognitionResultType.Verify;\r\n this.privReason = resultReason;\r\n if (this.privReason !== ResultReason.Canceled) {\r\n if (resultType === SpeakerRecognitionResultType.Identify) {\r\n this.privProfileId = response.identificationResult.identifiedProfile.profileId;\r\n this.privScore = response.identificationResult.identifiedProfile.score;\r\n this.privReason = ResultReason.RecognizedSpeakers;\r\n } else {\r\n this.privScore = response.verificationResult.score;\r\n if (response.verificationResult.recognitionResult.toLowerCase() !== \"accept\") {\r\n this.privReason = ResultReason.NoMatch;\r\n }\r\n if (response.verificationResult.profileId !== undefined && response.verificationResult.profileId !== \"\") {\r\n this.privProfileId = response.verificationResult.profileId;\r\n }\r\n }\r\n } else {\r\n this.privErrorDetails = errorDetails;\r\n this.privProperties.setProperty(CancellationErrorCodePropertyName, CancellationErrorCode[cancellationErrorCode]);\r\n }\r\n this.privProperties.setProperty(PropertyId.SpeechServiceResponse_JsonResult, JSON.stringify(response));\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\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[result.properties.getProperty(CancellationErrorCodePropertyName, CancellationErrorCode[CancellationErrorCode.NoError]) as keyof typeof CancellationErrorCode];\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\n/* eslint-disable max-classes-per-file */\r\n\r\nimport {\r\n ConversationConnectionConfig,\r\n ConversationManager,\r\n ConversationReceivedTranslationEventArgs,\r\n ConversationRecognizer,\r\n ConversationRecognizerFactory,\r\n ConversationTranslatorCommandTypes,\r\n ConversationTranslatorMessageTypes,\r\n IAuthentication,\r\n IInternalConversation,\r\n IInternalParticipant,\r\n InternalParticipants,\r\n MuteAllEventArgs,\r\n ParticipantAttributeEventArgs,\r\n ParticipantEventArgs,\r\n ParticipantsListEventArgs,\r\n TranscriberRecognizer\r\n} from \"../../common.speech/Exports.js\";\r\nimport {\r\n IDisposable,\r\n IErrorMessages,\r\n marshalPromiseToCallbacks\r\n} from \"../../common/Exports.js\";\r\nimport { Contracts } from \"../Contracts.js\";\r\nimport {\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.js\";\r\nimport { SpeechTranslationConfigImpl } from \"../SpeechTranslationConfig.js\";\r\nimport { Callback, ConversationInfo, ConversationProperties, IConversation } from \"./IConversation.js\";\r\nimport { IParticipant, IUser, TranscriptionParticipant } from \"./IParticipant.js\";\r\n\r\nexport abstract class Conversation implements IConversation {\r\n\r\n protected constructor() {\r\n return;\r\n }\r\n\r\n public abstract get authorizationToken(): string;\r\n\r\n public abstract get config(): SpeechTranslationConfig;\r\n\r\n public abstract get conversationId(): string;\r\n public abstract get conversationInfo(): ConversationInfo;\r\n public abstract get properties(): PropertyCollection;\r\n public abstract get speechRecognitionLanguage(): string;\r\n public abstract get participants(): Participant[];\r\n public abstract set authorizationToken(value: string);\r\n public abstract get isConnected(): boolean;\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, arg2?: string | Callback, arg3?: Callback, arg4?: 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 let conversationImpl: ConversationImpl;\r\n let cb: Callback;\r\n let err: Callback;\r\n if (typeof arg2 === \"string\") {\r\n conversationImpl = new ConversationImpl(speechConfig, arg2);\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n marshalPromiseToCallbacks((async (): Promise<void> => {})(), arg3, arg4);\r\n } else {\r\n conversationImpl = new ConversationImpl(speechConfig);\r\n cb = arg2;\r\n err = arg3;\r\n conversationImpl.createConversationAsync(\r\n ((): void => {\r\n if (!!cb) {\r\n cb();\r\n }\r\n }),\r\n (error: any): void => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n }\r\n return conversationImpl;\r\n\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 /** Add Participant to Conversation. */\r\n public abstract addParticipantAsync(participant: IParticipant, 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\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;\r\n private privRoom: IInternalConversation;\r\n private privManager: ConversationManager;\r\n private privConversationRecognizer: ConversationRecognizer;\r\n private privIsConnected: boolean;\r\n private privParticipants: InternalParticipants;\r\n private privIsReady: boolean;\r\n private privConversationTranslator: ConversationTranslator;\r\n private privTranscriberRecognizer: TranscriberRecognizer;\r\n private privErrors: IErrorMessages = ConversationConnectionConfig.restErrors;\r\n private privConversationId: string;\r\n private readonly privTextMessageMaxLength: number;\r\n\r\n /**\r\n * Create a conversation impl\r\n * @param speechConfig\r\n * @param {string} id - optional conversationId\r\n */\r\n public constructor(speechConfig: SpeechTranslationConfig, id?: string) {\r\n super();\r\n this.privIsConnected = false;\r\n this.privIsDisposed = false;\r\n this.privConversationId = \"\";\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 if (!id) {\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 // 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) {\r\n hostNickname = \"Host\";\r\n }\r\n Contracts.throwIfNullOrTooLong(hostNickname, \"nickname\", 50);\r\n Contracts.throwIfNullOrTooShort(hostNickname, \"nickname\", 2);\r\n speechConfig.setProperty(PropertyId[PropertyId.ConversationTranslator_Name], hostNickname);\r\n\r\n } else {\r\n this.privConversationId = id;\r\n }\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 // 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(): ConversationRecognizer {\r\n return this.privConversationRecognizer; // this.privConnection;\r\n }\r\n\r\n // get the config\r\n public get config(): SpeechTranslationConfig {\r\n return this.privConfig;\r\n }\r\n\r\n // get the conversation Id\r\n public get conversationId(): string {\r\n return this.privRoom ? this.privRoom.roomId : this.privConversationId;\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 public get transcriberRecognizer(): TranscriberRecognizer {\r\n return this.privTranscriberRecognizer;\r\n }\r\n\r\n public get conversationInfo(): ConversationInfo {\r\n const convId: string = this.conversationId;\r\n const p: TranscriptionParticipant[] = this.participants.map((part: Participant): TranscriptionParticipant => (\r\n {\r\n id: part.id,\r\n preferredLanguage: part.preferredLanguage,\r\n voice: part.voice\r\n }\r\n ));\r\n const props: ConversationProperties = {};\r\n for (const key of ConversationConnectionConfig.transcriptionEventKeys) {\r\n const val: string = this.properties.getProperty(key, \"\");\r\n if (val !== \"\") {\r\n props[key] = val;\r\n }\r\n }\r\n const info: ConversationInfo = { id: convId, participants: p, conversationProperties: props };\r\n return info;\r\n }\r\n\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 // get / set the speech auth token\r\n // eslint-disable-next-line @typescript-eslint/member-ordering\r\n public get authorizationToken(): string {\r\n return this.privToken;\r\n }\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 public set conversationTranslator(conversationTranslator: ConversationTranslator) {\r\n this.privConversationTranslator = conversationTranslator;\r\n }\r\n\r\n public onToken(token: IAuthentication): void {\r\n this.privConversationTranslator.onToken(token);\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): void => {\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): void => {\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 = ConversationRecognizerFactory.fromConfig(this, this.privConfig);\r\n\r\n // Because ConversationTranslator manually sets up and manages the connection, Conversation\r\n // has to forward serviceRecognizer connection events that usually get passed automatically\r\n this.privConversationRecognizer.connected = this.onConnected;\r\n this.privConversationRecognizer.disconnected = this.onDisconnected;\r\n this.privConversationRecognizer.canceled = this.onCanceled;\r\n\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\r\n this.privConversationRecognizer.connect(this.privRoom.token,\r\n ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 { IParticipant } participant - participant to add\r\n * @param cb\r\n * @param err\r\n */\r\n public addParticipantAsync(participant: IParticipant, cb?: Callback, err?: Callback): void {\r\n Contracts.throwIfNullOrUndefined(participant, \"Participant\");\r\n marshalPromiseToCallbacks(this.addParticipantImplAsync(participant), cb, err);\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): void => {\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): void => {\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 marshalPromiseToCallbacks(this.deleteConversationImplAsync(), cb, err);\r\n }\r\n\r\n public async deleteConversationImplAsync(): Promise<void> {\r\n Contracts.throwIfNullOrUndefined(this.privProperties, this.privErrors.permissionDeniedConnect);\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.token, this.privErrors.permissionDeniedConnect);\r\n await this.privManager.leave(this.privProperties, this.privRoom.token);\r\n\r\n this.dispose();\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 marshalPromiseToCallbacks(this.endConversationImplAsync(), cb, err);\r\n }\r\n\r\n public endConversationImplAsync(): Promise<void> {\r\n return this.close(true);\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 if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getLockCommand(true),\r\n ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 * 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 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 if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(true),\r\n ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 * 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 if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getMuteCommand(userId, true), ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 * 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 if (!!this.privTranscriberRecognizer && userId.hasOwnProperty(\"id\")) {\r\n // Assume this is a transcription participant\r\n marshalPromiseToCallbacks(this.removeParticipantImplAsync(userId as IParticipant), cb, err);\r\n } else {\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 = \"\";\r\n if (typeof userId === \"string\") {\r\n participantId = userId;\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): boolean => p.id === participantId);\r\n if (index === -1) {\r\n this.handleError(new Error(this.privErrors.invalidParticipantRequest), err);\r\n }\r\n if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getEjectCommand(participantId), ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\r\n this.handleError(error, err);\r\n }));\r\n }\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 if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getLockCommand(false), ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 * 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 if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(false), ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 * 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 if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getMuteCommand(userId, false), ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 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 if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getMessageCommand(message), ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 * Set translated to languages\r\n * @param {string[]} languages - languages to translate to\r\n * @param cb\r\n * @param err\r\n */\r\n public setTranslatedLanguagesAsync(languages: 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.throwIfArrayEmptyOrWhitespace(languages, this.privErrors.invalidArgs.replace(\"{arg}\", \"languages\"));\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 if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getSetTranslateToLanguagesCommand(languages),\r\n ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 * Change nickname\r\n * @param {string} nickname - new nickname for the room\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 if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getChangeNicknameCommand(nickname),\r\n ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 public isDisposed(): boolean {\r\n return this.privIsDisposed;\r\n }\r\n\r\n public dispose(): void {\r\n if (this.isDisposed) {\r\n return;\r\n }\r\n this.privIsDisposed = true;\r\n if (!!this.config) {\r\n this.config.close();\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.privIsConnected = false;\r\n this.privIsReady = false;\r\n this.privParticipants = undefined;\r\n }\r\n\r\n public async connectTranscriberRecognizer(recognizer: TranscriberRecognizer): Promise<void> {\r\n if (!!this.privTranscriberRecognizer) {\r\n await this.privTranscriberRecognizer.close();\r\n }\r\n await recognizer.enforceAudioGating();\r\n this.privTranscriberRecognizer = recognizer;\r\n this.privTranscriberRecognizer.conversation = this;\r\n }\r\n\r\n public getKeepAlive(): string {\r\n const nickname: string = (!!this.me) ? this.me.displayName : \"default_nickname\";\r\n return JSON.stringify({\r\n id: \"0\",\r\n nickname,\r\n participantId: this.privRoom.participantId,\r\n roomId: this.privRoom.roomId,\r\n type: ConversationTranslatorMessageTypes.keepAlive\r\n });\r\n }\r\n\r\n /** websocket callbacks */\r\n /* eslint-disable @typescript-eslint/typedef */\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 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 } finally {\r\n void this.close(false);\r\n }\r\n };\r\n\r\n private onCanceled = (r: ConversationRecognizer, e: ConversationTranslationCanceledEventArgs): void => {\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: ConversationRecognizer, e: ParticipantAttributeEventArgs): void => {\r\n try {\r\n const updatedParticipant: IInternalParticipant = 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 as string;\r\n break;\r\n case ConversationTranslatorCommandTypes.setUseTTS:\r\n updatedParticipant.isUsingTts = e.value as boolean;\r\n break;\r\n case ConversationTranslatorCommandTypes.setProfanityFiltering:\r\n updatedParticipant.profanity = e.value as boolean;\r\n break;\r\n case ConversationTranslatorCommandTypes.setMute:\r\n updatedParticipant.isMuted = e.value as boolean;\r\n break;\r\n case ConversationTranslatorCommandTypes.setTranslateToLanguages:\r\n updatedParticipant.translateToLanguages = e.value as string[];\r\n break;\r\n }\r\n this.privParticipants.addOrUpdateParticipant(updatedParticipant);\r\n\r\n if (!!this.privConversationTranslator) {\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 = (): void => {\r\n // TODO\r\n };\r\n\r\n private onMuteAllCommandReceived = (r: ConversationRecognizer, e: MuteAllEventArgs): void => {\r\n try {\r\n this.privParticipants.participants.forEach((p: IInternalParticipant): boolean => p.isMuted = (p.isHost ? false : e.isMuted));\r\n if (!!this.privConversationTranslator) {\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: ConversationRecognizer, 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) {\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: ConversationRecognizer, 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) {\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: ConversationRecognizer, e: ConversationReceivedTranslationEventArgs): void => {\r\n try {\r\n switch (e.command) {\r\n case ConversationTranslatorMessageTypes.final:\r\n if (!!this.privConversationTranslator) {\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) {\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) {\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: ConversationRecognizer, 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) {\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: ConversationRecognizer, e: ConversationExpirationEventArgs): void => {\r\n try {\r\n if (!!this.privConversationTranslator) {\r\n this.privConversationTranslator.conversationExpiration(this.privConversationTranslator, e);\r\n }\r\n } catch (e) {\r\n //\r\n }\r\n };\r\n /* eslint-enable @typescript-eslint/typedef */\r\n\r\n private addParticipantImplAsync(participant: IParticipant): Promise<void> {\r\n const newParticipant: IInternalParticipant = this.privParticipants.addOrUpdateParticipant(participant);\r\n if (newParticipant !== undefined) {\r\n if (!!this.privTranscriberRecognizer) {\r\n const conversationInfo = this.conversationInfo;\r\n conversationInfo.participants = [participant];\r\n return this.privTranscriberRecognizer.pushConversationEvent(conversationInfo, \"join\");\r\n }\r\n }\r\n }\r\n\r\n private removeParticipantImplAsync(participant: IParticipant): Promise<void> {\r\n this.privParticipants.deleteParticipant(participant.id);\r\n const conversationInfo = this.conversationInfo;\r\n conversationInfo.participants = [participant];\r\n return this.privTranscriberRecognizer.pushConversationEvent(conversationInfo, \"leave\");\r\n }\r\n\r\n private async close(dispose: boolean): Promise<void> {\r\n try {\r\n this.privIsConnected = false;\r\n await this.privConversationRecognizer?.close();\r\n this.privConversationRecognizer = undefined;\r\n if (!!this.privConversationTranslator) {\r\n this.privConversationTranslator.dispose();\r\n }\r\n } catch (e) {\r\n // ignore error\r\n throw e;\r\n }\r\n if (dispose) {\r\n this.dispose();\r\n }\r\n }\r\n\r\n /** Helpers */\r\n private handleCallback(cb: () => void, err: (message: string) => void): void {\r\n if (!!cb) {\r\n try {\r\n cb();\r\n } catch (e) {\r\n if (!!err) {\r\n err(e as string);\r\n }\r\n }\r\n cb = undefined;\r\n }\r\n }\r\n\r\n private handleError(error: any, err: (message: string) => void): void {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error;\r\n err(typedError.name + \": \" + typedError.message);\r\n\r\n } else {\r\n err(error as string);\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): Participant => ( this.toParticipant(p) ) );\r\n if (!includeHost) {\r\n return participants.filter((p: Participant): boolean => 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, p.voice);\r\n }\r\n\r\n private getMuteAllCommand(isMuted: boolean): string {\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"conversationId\");\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, \"participantId\");\r\n\r\n return JSON.stringify({\r\n command: ConversationTranslatorCommandTypes.setMuteAll,\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\r\n private getMuteCommand(participantId: string, isMuted: boolean): string {\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"conversationId\");\r\n Contracts.throwIfNullOrWhitespace(participantId, \"participantId\");\r\n\r\n return JSON.stringify({\r\n command: ConversationTranslatorCommandTypes.setMute,\r\n // eslint-disable-next-line object-shorthand\r\n participantId: participantId,\r\n roomid: this.privRoom.roomId,\r\n type: ConversationTranslatorMessageTypes.participantCommand,\r\n value: isMuted\r\n });\r\n }\r\n\r\n private getLockCommand(isLocked: boolean): string {\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"conversationId\");\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, \"participantId\");\r\n\r\n return JSON.stringify({\r\n command: ConversationTranslatorCommandTypes.setLockState,\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\r\n private getEjectCommand(participantId: string): string {\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"conversationId\");\r\n Contracts.throwIfNullOrWhitespace(participantId, \"participantId\");\r\n\r\n return JSON.stringify({\r\n command: ConversationTranslatorCommandTypes.ejectParticipant,\r\n // eslint-disable-next-line object-shorthand\r\n participantId: participantId,\r\n roomid: this.privRoom.roomId,\r\n type: ConversationTranslatorMessageTypes.participantCommand,\r\n });\r\n }\r\n\r\n private getSetTranslateToLanguagesCommand(languages: string[]): string {\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"conversationId\");\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, \"participantId\");\r\n\r\n return JSON.stringify({\r\n command: ConversationTranslatorCommandTypes.setTranslateToLanguages,\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: languages\r\n });\r\n }\r\n\r\n private getChangeNicknameCommand(nickname: string): string {\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"conversationId\");\r\n Contracts.throwIfNullOrWhitespace(nickname, \"nickname\");\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, \"participantId\");\r\n\r\n return JSON.stringify({\r\n command: ConversationTranslatorCommandTypes.changeNickname,\r\n nickname,\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\r\n private getMessageCommand(message: string): string {\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 return JSON.stringify({\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\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n AudioConfig,\r\n SpeechTranslationConfig\r\n} from \"../Exports.js\";\r\nimport { Callback } from \"./IConversation.js\";\r\n\r\nexport class ConversationCommon {\r\n\r\n protected privAudioConfig: AudioConfig;\r\n protected privSpeechTranslationConfig: SpeechTranslationConfig;\r\n\r\n public constructor(audioConfig?: AudioConfig) {\r\n this.privAudioConfig = audioConfig;\r\n }\r\n\r\n protected 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 protected handleError(error: any, err: Callback): void {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = 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 { SessionEventArgs } from \"../Exports.js\";\r\n\r\nexport class ConversationExpirationEventArgs extends SessionEventArgs {\r\n private privExpirationTime: number;\r\n\r\n public 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 public 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.js\";\r\nimport { ParticipantChangedReason } from \"./Exports.js\";\r\nimport { IParticipant } from \"./IParticipant.js\";\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 { CancellationEventArgsBase } from \"../CancellationEventArgsBase.js\";\r\n\r\nexport class ConversationTranslationCanceledEventArgs extends CancellationEventArgsBase {\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.js\";\r\nimport { ConversationTranslationResult } from \"./Exports.js\";\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.js\";\r\nimport { ResultReason } from \"../ResultReason.js\";\r\nimport { TranslationRecognitionResult } from \"../TranslationRecognitionResult.js\";\r\nimport { Translations } from \"../Translations.js\";\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, undefined, undefined, 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\r\nimport { IStringDictionary } from \"./IDictionary.js\";\r\n\r\n/**\r\n * String helper functions\r\n */\r\nexport class StringUtils {\r\n\r\n /**\r\n * Formats a string by replacing the named {keys} in the string with the values contained in the replacement dictionary.\r\n * @param format The format string that contains the parts to replace surrounded by {}. For example: \"wss://{region}.cts.speech.microsoft.com\".\r\n * If your string needs to contain a { or } you can use the {{ and }} escape sequences respectively.\r\n * @param replacements The dictionary of replacements. If a replacement is not found, it is replaced with an empty string\r\n * @returns The formatted string. If you pass in a null or undefined format string, an empty string will be returned\r\n */\r\n public static formatString(format: string, replacements: IStringDictionary<string>): string {\r\n if (!format) {\r\n return \"\";\r\n }\r\n\r\n if (!replacements) {\r\n return format;\r\n }\r\n\r\n let formatted: string = \"\";\r\n let key: string = \"\";\r\n\r\n const appendToFormatted = (str: string): void => {\r\n formatted += str;\r\n };\r\n const appendToKey = (str: string): void => {\r\n key += str;\r\n };\r\n let appendFunc: (str: string) => void = appendToFormatted;\r\n\r\n for (let i = 0; i < format.length; i++) {\r\n const c: string = format[i];\r\n const next: string = i + 1 < format.length ? format[i + 1] : \"\";\r\n\r\n switch (c) {\r\n case \"{\":\r\n if (next === \"{\") {\r\n appendFunc(\"{\");\r\n i++;\r\n } else {\r\n appendFunc = appendToKey;\r\n }\r\n break;\r\n\r\n case \"}\":\r\n if (next === \"}\") {\r\n appendFunc(\"}\");\r\n i++;\r\n } else {\r\n if (replacements.hasOwnProperty(key)) {\r\n formatted += replacements[key];\r\n }\r\n\r\n appendFunc = appendToFormatted;\r\n key = \"\";\r\n }\r\n break;\r\n\r\n default:\r\n appendFunc(c);\r\n break;\r\n }\r\n }\r\n\r\n return formatted;\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 RestConfigBase,\r\n WebsocketConnection,\r\n} from \"../../common.browser/Exports.js\";\r\nimport {\r\n IConnection,\r\n IStringDictionary,\r\n} from \"../../common/Exports.js\";\r\nimport { StringUtils } from \"../../common/StringUtils.js\";\r\nimport { Contracts } from \"../../sdk/Contracts.js\";\r\nimport {\r\n PropertyId\r\n} from \"../../sdk/Exports.js\";\r\nimport {\r\n ConversationImpl\r\n} from \"../../sdk/Transcription/Conversation.js\";\r\nimport { HeaderNames } from \"../HeaderNames.js\";\r\nimport { QueryParameterNames } from \"../QueryParameterNames.js\";\r\nimport {\r\n ConnectionFactoryBase\r\n} from \"./../ConnectionFactoryBase.js\";\r\nimport {\r\n AuthInfo,\r\n RecognizerConfig,\r\n TranscriberConnectionFactory,\r\n TranslationConnectionFactory,\r\n WebsocketMessageFormatter,\r\n} from \"./../Exports.js\";\r\n\r\n/**\r\n * Connection factory for the conversation translator. Handles connecting to the regular translator endpoint,\r\n * as well as the virtual microphone array transcription endpoint\r\n */\r\nexport class ConversationTranslatorConnectionFactory extends ConnectionFactoryBase {\r\n\r\n private static readonly CTS_VIRT_MIC_PATH: string = \"/speech/recognition/dynamicaudio\";\r\n\r\n private privConvGetter: () => ConversationImpl;\r\n\r\n public constructor(convGetter: () => ConversationImpl) {\r\n super();\r\n\r\n Contracts.throwIfNullOrUndefined(convGetter, \"convGetter\");\r\n this.privConvGetter = convGetter;\r\n }\r\n\r\n public create(config: RecognizerConfig, authInfo: AuthInfo, connectionId?: string): IConnection {\r\n const isVirtMicArrayEndpoint = config.parameters.getProperty(\"ConversationTranslator_MultiChannelAudio\", \"\").toUpperCase() === \"TRUE\";\r\n\r\n const convInfo = this.privConvGetter().room;\r\n const region = convInfo.cognitiveSpeechRegion || config.parameters.getProperty(PropertyId.SpeechServiceConnection_Region, \"\");\r\n\r\n const replacementValues: IStringDictionary<string> = {\r\n hostSuffix: ConnectionFactoryBase.getHostSuffix(region),\r\n path: ConversationTranslatorConnectionFactory.CTS_VIRT_MIC_PATH,\r\n region: encodeURIComponent(region)\r\n };\r\n replacementValues[QueryParameterNames.Language] = encodeURIComponent(config.parameters.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage, \"\"));\r\n replacementValues[QueryParameterNames.CtsMeetingId] = encodeURIComponent(convInfo.roomId);\r\n replacementValues[QueryParameterNames.CtsDeviceId] = encodeURIComponent(convInfo.participantId);\r\n replacementValues[QueryParameterNames.CtsIsParticipant] = convInfo.isHost ? \"\" : (\"&\" + QueryParameterNames.CtsIsParticipant);\r\n\r\n let endpointUrl: string = \"\";\r\n const queryParams: IStringDictionary<string> = {};\r\n const headers: IStringDictionary<string> = {};\r\n\r\n if (isVirtMicArrayEndpoint) {\r\n // connecting to the conversation transcription virtual microphone array endpoint\r\n endpointUrl = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint);\r\n if (!endpointUrl) {\r\n const hostName = config.parameters.getProperty(\r\n PropertyId.SpeechServiceConnection_Host,\r\n \"transcribe.{region}.cts.speech{hostSuffix}\");\r\n\r\n endpointUrl = \"wss://\" + hostName + \"{path}\";\r\n }\r\n\r\n // because the region can change during a session, we support being passed a format string which we can then\r\n // replace with the correct information.\r\n endpointUrl = StringUtils.formatString(endpointUrl, replacementValues);\r\n\r\n const parsedUrl = new URL(endpointUrl);\r\n parsedUrl.searchParams.forEach((val: string, key: string): void => {\r\n queryParams[key] = val;\r\n });\r\n\r\n const connFactory = new TranscriberConnectionFactory();\r\n connFactory.setQueryParams(queryParams, config, endpointUrl);\r\n\r\n // Some query parameters are required for the CTS endpoint, let's explicity set them here\r\n queryParams[QueryParameterNames.CtsMeetingId] = replacementValues[QueryParameterNames.CtsMeetingId];\r\n queryParams[QueryParameterNames.CtsDeviceId] = replacementValues[QueryParameterNames.CtsDeviceId];\r\n if (!convInfo.isHost) {\r\n queryParams[QueryParameterNames.CtsIsParticipant] = \"\"; // this doesn't have a value so set to an empty string\r\n }\r\n\r\n if (!(QueryParameterNames.Format in queryParams)) {\r\n queryParams[QueryParameterNames.Format] = \"simple\";\r\n }\r\n\r\n parsedUrl.searchParams.forEach((val: string, key: string): void => {\r\n parsedUrl.searchParams.set(key, queryParams[key]);\r\n delete queryParams[key];\r\n });\r\n\r\n endpointUrl = parsedUrl.toString();\r\n\r\n } else {\r\n // connecting to regular translation endpoint\r\n const connFactory = new TranslationConnectionFactory();\r\n\r\n endpointUrl = connFactory.getEndpointUrl(config, true);\r\n endpointUrl = StringUtils.formatString(endpointUrl, replacementValues);\r\n\r\n connFactory.setQueryParams(queryParams, config, endpointUrl);\r\n }\r\n\r\n headers[HeaderNames.ConnectionId] = connectionId;\r\n headers[RestConfigBase.configParams.token] = convInfo.token;\r\n if (!!authInfo.token) {\r\n headers[authInfo.headerName] = authInfo.token;\r\n }\r\n\r\n const enableCompression = config.parameters.getProperty(\"SPEECH-EnableWebsocketCompression\", \"\").toUpperCase() === \"TRUE\";\r\n return new WebsocketConnection(endpointUrl, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, connectionId);\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\n/* eslint-disable max-classes-per-file */\r\n\r\nimport {\r\n ConversationConnectionConfig,\r\n IAuthentication,\r\n ServicePropertiesPropertyName,\r\n} from \"../../common.speech/Exports.js\";\r\nimport { ConversationTranslatorConnectionFactory } from \"../../common.speech/Transcription/ConversationTranslatorConnectionFactory.js\";\r\nimport {\r\n IDisposable,\r\n IErrorMessages,\r\n IStringDictionary,\r\n marshalPromiseToCallbacks\r\n} from \"../../common/Exports.js\";\r\nimport { Contracts } from \"../Contracts.js\";\r\nimport {\r\n AudioConfig,\r\n CancellationErrorCode,\r\n CancellationReason,\r\n ProfanityOption,\r\n PropertyCollection,\r\n PropertyId,\r\n ServicePropertyChannel,\r\n SessionEventArgs,\r\n SpeechTranslationConfig,\r\n TranslationRecognitionEventArgs,\r\n TranslationRecognizer\r\n} from \"../Exports.js\";\r\nimport { ConversationImpl } from \"./Conversation.js\";\r\nimport {\r\n ConversationCommon,\r\n ConversationExpirationEventArgs,\r\n ConversationHandler,\r\n ConversationParticipantsChangedEventArgs,\r\n ConversationTranslationCanceledEventArgs,\r\n ConversationTranslationEventArgs,\r\n IConversationTranslator,\r\n Participant\r\n} from \"./Exports.js\";\r\nimport { Callback, IConversation } from \"./IConversation.js\";\r\n\r\nexport enum SpeechState {\r\n Inactive, Connecting, Connected\r\n}\r\n\r\n// child class of TranslationRecognizer meant only for use with ConversationTranslator\r\nclass ConversationTranslationRecognizer extends TranslationRecognizer {\r\n private privTranslator: ConversationTranslator;\r\n private privSpeechState: SpeechState;\r\n\r\n public constructor(speechConfig: SpeechTranslationConfig, audioConfig: AudioConfig, translator: ConversationTranslator, convGetter: () => ConversationImpl) {\r\n\r\n super(speechConfig, audioConfig, new ConversationTranslatorConnectionFactory(convGetter));\r\n\r\n this.privSpeechState = SpeechState.Inactive;\r\n if (!!translator) {\r\n this.privTranslator = translator;\r\n this.sessionStarted = (): void => {\r\n this.privSpeechState = SpeechState.Connected;\r\n };\r\n\r\n this.sessionStopped = (): void => {\r\n this.privSpeechState = SpeechState.Inactive;\r\n };\r\n\r\n this.recognizing = (tr: TranslationRecognizer, e: TranslationRecognitionEventArgs): void => {\r\n if (!!this.privTranslator.recognizing) {\r\n this.privTranslator.recognizing(this.privTranslator, e);\r\n }\r\n };\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\r\n this.recognized = async (tr: TranslationRecognizer, e: TranslationRecognitionEventArgs): Promise<void> => {\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 await this.cancelSpeech();\r\n // TODO: format the error message contained in 'errorDetails'\r\n this.fireCancelEvent(e.result.errorDetails);\r\n } else {\r\n if (!!this.privTranslator.recognized) {\r\n this.privTranslator.recognized(this.privTranslator, e);\r\n }\r\n }\r\n return;\r\n };\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\r\n this.canceled = async (): Promise<void> => {\r\n if (this.privSpeechState !== SpeechState.Inactive) {\r\n try {\r\n await this.cancelSpeech();\r\n } catch (error) {\r\n this.privSpeechState = SpeechState.Inactive;\r\n }\r\n }\r\n };\r\n }\r\n }\r\n\r\n public get state(): SpeechState {\r\n return this.privSpeechState;\r\n }\r\n\r\n public set state(newState: SpeechState) {\r\n this.privSpeechState = newState;\r\n }\r\n\r\n public set authentication(token: IAuthentication) {\r\n this.privReco.authentication = token;\r\n }\r\n\r\n\r\n public onConnection(): void {\r\n this.privSpeechState = SpeechState.Connected;\r\n }\r\n\r\n public async onCancelSpeech(): Promise<void> {\r\n this.privSpeechState = SpeechState.Inactive;\r\n await this.cancelSpeech();\r\n }\r\n\r\n /**\r\n * Fire a cancel event\r\n * @param error\r\n */\r\n private fireCancelEvent(error: string): void {\r\n try {\r\n if (!!this.privTranslator.canceled) {\r\n const cancelEvent: ConversationTranslationCanceledEventArgs = new ConversationTranslationCanceledEventArgs(\r\n CancellationReason.Error,\r\n error,\r\n CancellationErrorCode.RuntimeError\r\n );\r\n\r\n this.privTranslator.canceled(this.privTranslator, cancelEvent);\r\n }\r\n } catch (e) {\r\n //\r\n }\r\n }\r\n\r\n private async cancelSpeech(): Promise<void> {\r\n try {\r\n this.stopContinuousRecognitionAsync();\r\n await this.privReco?.disconnect();\r\n this.privSpeechState = SpeechState.Inactive;\r\n } catch (e) {\r\n // ignore the error\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Join, leave or connect to a conversation.\r\n */\r\nexport class ConversationTranslator extends ConversationCommon implements IConversationTranslator, IDisposable {\r\n\r\n public canceled: (sender: ConversationHandler, 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: ConversationHandler, event: SessionEventArgs) => void;\r\n public sessionStopped: (sender: ConversationHandler, event: SessionEventArgs) => void;\r\n public textMessageReceived: (sender: IConversationTranslator, event: ConversationTranslationEventArgs) => void;\r\n\r\n // Callbacks for whole conversation results\r\n public transcribed: (sender: IConversationTranslator, event: ConversationTranslationEventArgs) => void;\r\n public transcribing: (sender: IConversationTranslator, event: ConversationTranslationEventArgs) => void;\r\n\r\n // Callbacks for detecting speech/translation results from self\r\n public recognized: (sender: IConversationTranslator, event: TranslationRecognitionEventArgs) => void;\r\n public recognizing: (sender: IConversationTranslator, event: TranslationRecognitionEventArgs) => void;\r\n\r\n private privSpeechRecognitionLanguage: string;\r\n private privProperties: PropertyCollection;\r\n private privIsDisposed: boolean;\r\n private privCTRecognizer: ConversationTranslationRecognizer;\r\n private privIsSpeaking: boolean;\r\n private privConversation: ConversationImpl;\r\n private privErrors: IErrorMessages = ConversationConnectionConfig.restErrors;\r\n private privPlaceholderKey: string;\r\n private privPlaceholderRegion: string;\r\n\r\n public constructor(audioConfig?: AudioConfig) {\r\n super(audioConfig);\r\n this.privIsDisposed = false;\r\n this.privIsSpeaking = false;\r\n this.privPlaceholderKey = \"abcdefghijklmnopqrstuvwxyz012345\";\r\n this.privPlaceholderRegion = \"westus\";\r\n this.privProperties = new PropertyCollection();\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 private get canSpeak(): boolean {\r\n\r\n // is there a Conversation websocket available and has the Recognizer been set up\r\n if (!this.privConversation.isConnected || !this.privCTRecognizer) {\r\n return false;\r\n }\r\n\r\n // is the user already speaking\r\n if (this.privIsSpeaking || this.privCTRecognizer.state === SpeechState.Connected || this.privCTRecognizer.state === 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 public onToken(token: IAuthentication): void {\r\n this.privCTRecognizer.authentication = token;\r\n }\r\n\r\n public setServiceProperty(name: string, value: string): void {\r\n const currentProperties: IStringDictionary<string> = JSON.parse(this.privProperties.getProperty(ServicePropertiesPropertyName, \"{}\")) as IStringDictionary<string>;\r\n\r\n currentProperties[name] = value;\r\n\r\n this.privProperties.setProperty(ServicePropertiesPropertyName, JSON.stringify(currentProperties));\r\n }\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: string | IConversation, 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 === \"\") {\r\n lang = ConversationConnectionConfig.defaultLanguageCode;\r\n }\r\n\r\n // create a placeholder 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 propertyIdsToCopy: (string | PropertyId)[] = [\r\n PropertyId.SpeechServiceConnection_Host,\r\n PropertyId.ConversationTranslator_Host,\r\n PropertyId.SpeechServiceConnection_Endpoint,\r\n PropertyId.SpeechServiceConnection_ProxyHostName,\r\n PropertyId.SpeechServiceConnection_ProxyPassword,\r\n PropertyId.SpeechServiceConnection_ProxyPort,\r\n PropertyId.SpeechServiceConnection_ProxyUserName,\r\n \"ConversationTranslator_MultiChannelAudio\",\r\n \"ConversationTranslator_Region\"\r\n ];\r\n\r\n for (const prop of propertyIdsToCopy) {\r\n const value = this.privProperties.getProperty(prop);\r\n if (value) {\r\n const key = typeof prop === \"string\" ? prop : PropertyId[prop];\r\n this.privSpeechTranslationConfig.setProperty(key, value);\r\n }\r\n }\r\n\r\n const currentProperties = JSON.parse(this.privProperties.getProperty(ServicePropertiesPropertyName, \"{}\")) as IStringDictionary<string>;\r\n for (const prop of Object.keys(currentProperties)) {\r\n this.privSpeechTranslationConfig.setServiceProperty(prop, currentProperties[prop], ServicePropertyChannel.UriQueryParameter);\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): void => {\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 this.privConversation.room.isHost = false;\r\n\r\n // connect to the ws\r\n this.privConversation.startConversationAsync(\r\n ((): void => {\r\n this.handleCallback(param2, param3);\r\n }),\r\n ((error: any): void => {\r\n this.handleError(error, param3);\r\n }));\r\n\r\n }),\r\n ((error: any): void => {\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 this.privConversation.room.isHost = true;\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 marshalPromiseToCallbacks((async (): Promise<void> => {\r\n\r\n // stop the speech websocket\r\n await this.cancelSpeech();\r\n // stop the websocket\r\n await this.privConversation.endConversationImplAsync();\r\n // https delete request\r\n await this.privConversation.deleteConversationImplAsync();\r\n this.dispose();\r\n\r\n })(), cb, err);\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 marshalPromiseToCallbacks((async (): Promise<void> => {\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.privCTRecognizer === undefined) {\r\n await this.connectTranslatorRecognizer();\r\n }\r\n Contracts.throwIfNullOrUndefined(this.privCTRecognizer, this.privErrors.permissionDeniedSend);\r\n\r\n if (!this.canSpeak) {\r\n this.handleError(new Error(this.privErrors.permissionDeniedSend), err);\r\n }\r\n\r\n await this.startContinuousRecognition();\r\n\r\n this.privIsSpeaking = true;\r\n } catch (error) {\r\n this.privIsSpeaking = false;\r\n await this.cancelSpeech();\r\n throw error;\r\n }\r\n })(), cb, err);\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 marshalPromiseToCallbacks((async (): Promise<void> => {\r\n try {\r\n if (!this.privIsSpeaking) {\r\n // stop speech\r\n await this.cancelSpeech();\r\n return;\r\n }\r\n\r\n // stop the recognition but leave the websocket open\r\n this.privIsSpeaking = false;\r\n await new Promise((resolve: () => void, reject: (error: string) => void): void => {\r\n this.privCTRecognizer.stopContinuousRecognitionAsync(resolve, reject);\r\n });\r\n\r\n } catch (error) {\r\n await this.cancelSpeech();\r\n }\r\n })(), cb, err);\r\n }\r\n\r\n public isDisposed(): boolean {\r\n return this.privIsDisposed;\r\n }\r\n\r\n public dispose(reason?: string, success?: () => void, err?: (error: string) => void): void {\r\n marshalPromiseToCallbacks((async (): Promise<void> => {\r\n if (this.isDisposed && !this.privIsSpeaking) {\r\n return;\r\n }\r\n await 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 })(), success, err);\r\n }\r\n\r\n /**\r\n * Cancel the speech websocket\r\n */\r\n private async cancelSpeech(): Promise<void> {\r\n try {\r\n this.privIsSpeaking = false;\r\n await this.privCTRecognizer?.onCancelSpeech();\r\n this.privCTRecognizer = undefined;\r\n } catch (e) {\r\n // ignore the error\r\n }\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 */\r\n private async connectTranslatorRecognizer(): Promise<void> {\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 const convGetter = (): ConversationImpl => this.privConversation;\r\n this.privCTRecognizer = new ConversationTranslationRecognizer(this.privSpeechTranslationConfig, this.privAudioConfig, this, convGetter);\r\n } catch (error) {\r\n await this.cancelSpeech();\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Handle the start speaking request\r\n */\r\n private startContinuousRecognition(): Promise<void> {\r\n return new Promise((resolve: () => void, reject: (error: string) => void): void => {\r\n this.privCTRecognizer.startContinuousRecognitionAsync(resolve, reject);\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 OutputFormatPropertyName,\r\n RecognitionMode,\r\n RecognizerConfig,\r\n ServiceRecognizerBase,\r\n // SpeechConnectionFactory,\r\n ConversationTranscriberConnectionFactory,\r\n SpeechServiceConfig,\r\n ConversationTranscriptionServiceRecognizer,\r\n} from \"../../common.speech/Exports.js\";\r\nimport { marshalPromiseToCallbacks } from \"../../common/Exports.js\";\r\nimport { AudioConfigImpl } from \"../Audio/AudioConfig.js\";\r\nimport { Contracts } from \"../Contracts.js\";\r\nimport {\r\n AudioConfig,\r\n AutoDetectSourceLanguageConfig,\r\n ConversationTranscriptionEventArgs,\r\n ConversationTranscriptionCanceledEventArgs,\r\n OutputFormat,\r\n PropertyCollection,\r\n PropertyId,\r\n Recognizer,\r\n} from \"../Exports.js\";\r\nimport { SpeechConfig, SpeechConfigImpl } from \"../SpeechConfig.js\";\r\n\r\n/**\r\n * Performs speech recognition with speaker separation from microphone, file, or other audio input streams, and gets transcribed text as result.\r\n * @class ConversationTranscriber\r\n */\r\nexport class ConversationTranscriber extends Recognizer {\r\n private privDisposedRecognizer: boolean;\r\n\r\n /**\r\n * ConversationTranscriber 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 ConversationTranscriberConnectionFactory());\r\n this.privProperties.setProperty(PropertyId.SpeechServiceConnection_RecognitionEndpointVersion, \"2\");\r\n this.privDisposedRecognizer = false;\r\n }\r\n\r\n /**\r\n * ConversationTranscriber 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): ConversationTranscriber {\r\n const speechConfigImpl: SpeechConfigImpl = speechConfig as SpeechConfigImpl;\r\n autoDetectSourceLanguageConfig.properties.mergeTo(speechConfigImpl.properties);\r\n const recognizer = new ConversationTranscriber(speechConfig, audioConfig);\r\n return recognizer;\r\n }\r\n\r\n /**\r\n * The event transcribing signals that an intermediate transcription result is received.\r\n * @member ConversationTranscriber.prototype.transcribing\r\n * @function\r\n * @public\r\n */\r\n public transcribing: (sender: Recognizer, event: ConversationTranscriptionEventArgs) => void;\r\n\r\n /**\r\n * The event transcriber signals that a final recognition result is received.\r\n * @member ConversationTranscriber.prototype.transcribed\r\n * @function\r\n * @public\r\n */\r\n public transcribed: (sender: Recognizer, event: ConversationTranscriptionEventArgs) => void;\r\n\r\n /**\r\n * The event canceled signals that an error occurred during transcription.\r\n * @member ConversationTranscriber.prototype.canceled\r\n * @function\r\n * @public\r\n */\r\n public canceled: (sender: Recognizer, event: ConversationTranscriptionCanceledEventArgs) => void;\r\n\r\n /**\r\n * Gets the endpoint id of a customized speech model that is used for transcription.\r\n * @member ConversationTranscriber.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.privDisposedRecognizer);\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 ConversationTranscriber.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 ConversationTranscriber.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 transcription.\r\n * @member ConversationTranscriber.prototype.speechRecognitionLanguage\r\n * @function\r\n * @public\r\n * @returns {string} The spoken language of transcription.\r\n */\r\n public get speechRecognitionLanguage(): string {\r\n Contracts.throwIfDisposed(this.privDisposedRecognizer);\r\n\r\n return this.properties.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage);\r\n }\r\n\r\n /**\r\n * Gets the output format of transcription.\r\n * @member ConversationTranscriber.prototype.outputFormat\r\n * @function\r\n * @public\r\n * @returns {OutputFormat} The output format of transcription.\r\n */\r\n public get outputFormat(): OutputFormat {\r\n Contracts.throwIfDisposed(this.privDisposedRecognizer);\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 conversation transcriber.\r\n * @member ConversationTranscriber.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 conversation transcription, until stopTranscribingAsync() is called.\r\n * User must subscribe to events to receive transcription results.\r\n * @member ConversationTranscriber.prototype.startTranscribingAsync\r\n * @function\r\n * @public\r\n * @param cb - Callback invoked once the transcription has started.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public startTranscribingAsync(cb?: () => void, err?: (e: string) => void): void {\r\n marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(RecognitionMode.Conversation), cb, err);\r\n }\r\n\r\n /**\r\n * Stops conversation transcription.\r\n * @member ConversationTranscriber.prototype.stopTranscribingAsync\r\n * @function\r\n * @public\r\n * @param cb - Callback invoked once the transcription has stopped.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public stopTranscribingAsync(cb?: () => void, err?: (e: string) => void): void {\r\n marshalPromiseToCallbacks(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 ConversationTranscriber.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(cb?: () => void, errorCb?: (error: string) => void): void {\r\n Contracts.throwIfDisposed(this.privDisposedRecognizer);\r\n marshalPromiseToCallbacks(this.dispose(true), cb, errorCb);\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 async dispose(disposing: boolean): Promise<void> {\r\n if (this.privDisposedRecognizer) {\r\n return;\r\n }\r\n\r\n if (disposing) {\r\n this.privDisposedRecognizer = true;\r\n await this.implRecognizerStop();\r\n }\r\n\r\n await super.dispose(disposing);\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 const configImpl: AudioConfigImpl = audioConfig as AudioConfigImpl;\r\n recognizerConfig.isSpeakerDiarizationEnabled = true;\r\n return new ConversationTranscriptionServiceRecognizer(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// Multi-device Conversation is a Preview feature.\r\n\r\n/* eslint-disable max-classes-per-file */\r\nimport { PropertyCollection } from \"../Exports.js\";\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 public 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\nexport interface VoiceSignature {\r\n Version: number;\r\n Tag: string;\r\n Data: string;\r\n}\r\n\r\nexport interface TranscriptionParticipant {\r\n /** The unique identifier for the participant. */\r\n readonly id: string;\r\n /** The participant's preferred spoken language. */\r\n readonly preferredLanguage: string;\r\n /** The participant's voice signature */\r\n readonly voice: string;\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 extends TranscriptionParticipant {\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 <see cref=\"Id\"/> property to tell them apart.\r\n */\r\n readonly displayName: 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 /** Contains properties of the participant. */\r\n readonly properties: PropertyCollection;\r\n}\r\n\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 privVoice: string;\r\n private privProperties: PropertyCollection;\r\n\r\n public constructor(id: string, avatar: string, displayName: string, isHost: boolean, isMuted: boolean, isUsingTts: boolean, preferredLanguage: string, voice?: 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.privVoice = voice;\r\n this.privProperties = new PropertyCollection();\r\n }\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 voice(): string {\r\n return this.privVoice;\r\n }\r\n\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n public static From(id: string, language: string, voice: string): IParticipant {\r\n return new Participant(id, \"\", id, false, false, false, language, voice);\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// Multi-device Conversation is a Preview feature.\r\n\r\n/* eslint-disable max-classes-per-file */\r\n\r\nimport {\r\n ConversationConnectionConfig,\r\n ConversationManager,\r\n ConversationReceivedTranslationEventArgs,\r\n ConversationRecognizer,\r\n ConversationTranslatorCommandTypes,\r\n ConversationTranslatorMessageTypes,\r\n IInternalConversation,\r\n IInternalParticipant,\r\n InternalParticipants,\r\n MuteAllEventArgs,\r\n ParticipantAttributeEventArgs,\r\n ParticipantEventArgs,\r\n ParticipantsListEventArgs,\r\n TranscriberRecognizer\r\n} from \"../../common.speech/Exports.js\";\r\nimport {\r\n IDisposable,\r\n IErrorMessages,\r\n marshalPromiseToCallbacks\r\n} from \"../../common/Exports.js\";\r\nimport { Contracts } from \"../Contracts.js\";\r\nimport {\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 PropertyCollection,\r\n PropertyId,\r\n SpeechTranslationConfig,\r\n} from \"../Exports.js\";\r\nimport { SpeechTranslationConfigImpl } from \"../SpeechTranslationConfig.js\";\r\nimport { Callback, MeetingInfo, MeetingProperties, IMeeting } from \"./IMeeting.js\";\r\nimport { IParticipant, IUser, TranscriptionParticipant } from \"./IParticipant.js\";\r\n\r\nexport abstract class Meeting implements IMeeting {\r\n\r\n protected constructor() {\r\n return;\r\n }\r\n\r\n public abstract get authorizationToken(): string;\r\n\r\n public abstract get config(): SpeechTranslationConfig;\r\n\r\n public abstract get meetingId(): string;\r\n public abstract get meetingInfo(): MeetingInfo;\r\n public abstract get properties(): PropertyCollection;\r\n public abstract get speechRecognitionLanguage(): string;\r\n public abstract get participants(): Participant[];\r\n public abstract set authorizationToken(value: string);\r\n public abstract get isConnected(): boolean;\r\n\r\n /**\r\n * Create a meeting\r\n * @param speechConfig\r\n * @param meetingId\r\n * @param cb\r\n * @param err\r\n */\r\n public static createMeetingAsync(speechConfig: SpeechTranslationConfig, meetingId: string, arg3?: Callback, arg4?: Callback): Meeting {\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 Contracts.throwIfNull(meetingId, \"meetingId\");\r\n if (meetingId.length === 0) {\r\n throw new Error(\"meetingId cannot be empty\");\r\n }\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 meetingImpl = new MeetingImpl(speechConfig, meetingId);\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n marshalPromiseToCallbacks((async (): Promise<void> => {})(), arg3, arg4);\r\n return meetingImpl;\r\n }\r\n\r\n /** Start a meeting. */\r\n public abstract startMeetingAsync(cb?: Callback, err?: Callback): void;\r\n\r\n /** Delete a meeting. After this no one will be able to join the meeting. */\r\n public abstract deleteMeetingAsync(cb?: Callback, err?: Callback): void;\r\n\r\n /** End a meeting. */\r\n public abstract endMeetingAsync(cb?: Callback, err?: Callback): void;\r\n\r\n /** Lock a meeting. This will prevent new participants from joining. */\r\n public abstract lockMeetingAsync(cb?: Callback, err?: Callback): void;\r\n\r\n /** Add Participant to Meeting. */\r\n public abstract addParticipantAsync(participant: IParticipant, cb?: Callback, err?: Callback): void;\r\n\r\n /**\r\n * Mute all other participants in the Meeting. 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 meeting 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 meeting. */\r\n public abstract unlockMeetingAsync(cb?: Callback, err?: Callback): void;\r\n\r\n /** Unmute all other participants in the meeting. */\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\nexport class MeetingImpl extends Meeting 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;\r\n private privRoom: IInternalConversation;\r\n private privManager: ConversationManager;\r\n private privConversationRecognizer: ConversationRecognizer;\r\n private privIsConnected: boolean;\r\n private privParticipants: InternalParticipants;\r\n private privIsReady: boolean;\r\n private privConversationTranslator: ConversationTranslator;\r\n private privTranscriberRecognizer: TranscriberRecognizer;\r\n private privErrors: IErrorMessages = ConversationConnectionConfig.restErrors;\r\n private privConversationId: string;\r\n private readonly privTextMessageMaxLength: number;\r\n\r\n /**\r\n * Create a Meeting impl\r\n * @param speechConfig\r\n * @param {string} id - optional conversationId\r\n */\r\n public constructor(speechConfig: SpeechTranslationConfig, id: string) {\r\n super();\r\n this.privIsConnected = false;\r\n this.privIsDisposed = false;\r\n this.privConversationId = \"\";\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 this.privConversationId = id;\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 // 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(): ConversationRecognizer {\r\n return this.privConversationRecognizer; // this.privConnection;\r\n }\r\n\r\n // get the config\r\n public get config(): SpeechTranslationConfig {\r\n return this.privConfig;\r\n }\r\n\r\n // get the meeting Id\r\n public get meetingId(): string {\r\n return this.privRoom ? this.privRoom.roomId : this.privConversationId;\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 public get transcriberRecognizer(): TranscriberRecognizer {\r\n return this.privTranscriberRecognizer;\r\n }\r\n\r\n public get meetingInfo(): MeetingInfo {\r\n const convId: string = this.meetingId;\r\n const p: TranscriptionParticipant[] = this.participants.map((part: Participant): TranscriptionParticipant => (\r\n {\r\n id: part.id,\r\n preferredLanguage: part.preferredLanguage,\r\n voice: part.voice\r\n }\r\n ));\r\n const props: MeetingProperties = {};\r\n for (const key of ConversationConnectionConfig.transcriptionEventKeys) {\r\n const val: string = this.properties.getProperty(key, \"\");\r\n if (val !== \"\") {\r\n props[key] = val;\r\n }\r\n }\r\n const info: MeetingInfo = { id: convId, participants: p, meetingProperties: props };\r\n return info;\r\n }\r\n\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 // get / set the speech auth token\r\n // eslint-disable-next-line @typescript-eslint/member-ordering\r\n public get authorizationToken(): string {\r\n return this.privToken;\r\n }\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 /**\r\n * Create a new meeting as Host\r\n * @param cb\r\n * @param err\r\n */\r\n public createMeetingAsync(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): void => {\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): void => {\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 meeting as host.\r\n * @param cb\r\n * @param err\r\n */\r\n public startMeetingAsync(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\r\n // Because ConversationTranslator manually sets up and manages the connection, Conversation\r\n // has to forward serviceRecognizer connection events that usually get passed automatically\r\n this.privConversationRecognizer.connected = this.onConnected;\r\n this.privConversationRecognizer.disconnected = this.onDisconnected;\r\n this.privConversationRecognizer.canceled = this.onCanceled;\r\n\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\r\n this.privConversationRecognizer.connect(this.privRoom.token,\r\n ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 meeting as a participant.\r\n * @param { IParticipant } participant - participant to add\r\n * @param cb\r\n * @param err\r\n */\r\n public addParticipantAsync(participant: IParticipant, cb?: Callback, err?: Callback): void {\r\n Contracts.throwIfNullOrUndefined(participant, \"Participant\");\r\n marshalPromiseToCallbacks(this.addParticipantImplAsync(participant), cb, err);\r\n }\r\n\r\n /**\r\n * Join a meeting as a participant.\r\n * @param meeting\r\n * @param nickname\r\n * @param lang\r\n * @param cb\r\n * @param err\r\n */\r\n public joinMeetingAsync(meetingId: 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(meetingId, 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, meetingId,\r\n ((room: IInternalConversation): void => {\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): void => {\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 meeting\r\n * @param cb\r\n * @param err\r\n */\r\n public deleteMeetingAsync(cb?: Callback, err?: Callback): void {\r\n marshalPromiseToCallbacks(this.deleteMeetingImplAsync(), cb, err);\r\n }\r\n\r\n public async deleteMeetingImplAsync(): Promise<void> {\r\n Contracts.throwIfNullOrUndefined(this.privProperties, this.privErrors.permissionDeniedConnect);\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.token, this.privErrors.permissionDeniedConnect);\r\n await this.privManager.leave(this.privProperties, this.privRoom.token);\r\n\r\n this.dispose();\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 endMeetingAsync(cb?: Callback, err?: Callback): void {\r\n marshalPromiseToCallbacks(this.endMeetingImplAsync(), cb, err);\r\n }\r\n\r\n public endMeetingImplAsync(): Promise<void> {\r\n return this.close(true);\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 lockMeetingAsync(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 if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getLockCommand(true),\r\n ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 * Issues a request to mute the meeting\r\n * @param cb\r\n * @param err\r\n */\r\n public muteAllParticipantsAsync(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.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 if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(true),\r\n ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 * Issues a request to mute a participant in the meeting\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 if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getMuteCommand(userId, true), ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 * 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 if (!!this.privTranscriberRecognizer && userId.hasOwnProperty(\"id\")) {\r\n // Assume this is a transcription participant\r\n marshalPromiseToCallbacks(this.removeParticipantImplAsync(userId as IParticipant), cb, err);\r\n } else {\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 = \"\";\r\n if (typeof userId === \"string\") {\r\n participantId = userId;\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): boolean => p.id === participantId);\r\n if (index === -1) {\r\n this.handleError(new Error(this.privErrors.invalidParticipantRequest), err);\r\n }\r\n if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getEjectCommand(participantId), ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\r\n this.handleError(error, err);\r\n }));\r\n }\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 meeting\r\n * @param cb\r\n * @param err\r\n */\r\n public unlockMeetingAsync(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 if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getLockCommand(false), ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 * Issues a request to unmute all participants in the meeting\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 if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getMuteAllCommand(false), ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 * Issues a request to unmute a participant in the meeting\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 if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getMuteCommand(userId, false), ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 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 if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getMessageCommand(message), ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 * Set translated to languages\r\n * @param {string[]} languages - languages to translate to\r\n * @param cb\r\n * @param err\r\n */\r\n public setTranslatedLanguagesAsync(languages: 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.throwIfArrayEmptyOrWhitespace(languages, this.privErrors.invalidArgs.replace(\"{arg}\", \"languages\"));\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 if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getSetTranslateToLanguagesCommand(languages),\r\n ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 * Change nickname\r\n * @param {string} nickname - new nickname for the room\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 if (!!this.privConversationRecognizer) {\r\n this.privConversationRecognizer.sendRequest(this.getChangeNicknameCommand(nickname),\r\n ((): void => {\r\n this.handleCallback(cb, err);\r\n }),\r\n ((error: any): void => {\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 public isDisposed(): boolean {\r\n return this.privIsDisposed;\r\n }\r\n\r\n public dispose(): void {\r\n if (this.isDisposed) {\r\n return;\r\n }\r\n this.privIsDisposed = true;\r\n if (!!this.config) {\r\n this.config.close();\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.privIsConnected = false;\r\n this.privIsReady = false;\r\n this.privParticipants = undefined;\r\n }\r\n\r\n public async connectTranscriberRecognizer(recognizer: TranscriberRecognizer): Promise<void> {\r\n if (!!this.privTranscriberRecognizer) {\r\n await this.privTranscriberRecognizer.close();\r\n }\r\n await recognizer.enforceAudioGating();\r\n this.privTranscriberRecognizer = recognizer;\r\n this.privTranscriberRecognizer.meeting = this;\r\n }\r\n\r\n public getKeepAlive(): string {\r\n const nickname: string = (!!this.me) ? this.me.displayName : \"default_nickname\";\r\n return JSON.stringify({\r\n id: \"0\",\r\n nickname,\r\n participantId: this.privRoom.participantId,\r\n roomId: this.privRoom.roomId,\r\n type: ConversationTranslatorMessageTypes.keepAlive\r\n });\r\n }\r\n\r\n /** websocket callbacks */\r\n /* eslint-disable @typescript-eslint/typedef */\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 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 } finally {\r\n void this.close(false);\r\n }\r\n };\r\n\r\n private onCanceled = (r: ConversationRecognizer, e: ConversationTranslationCanceledEventArgs): void => {\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: ConversationRecognizer, e: ParticipantAttributeEventArgs): void => {\r\n try {\r\n const updatedParticipant: IInternalParticipant = 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 as string;\r\n break;\r\n case ConversationTranslatorCommandTypes.setUseTTS:\r\n updatedParticipant.isUsingTts = e.value as boolean;\r\n break;\r\n case ConversationTranslatorCommandTypes.setProfanityFiltering:\r\n updatedParticipant.profanity = e.value as boolean;\r\n break;\r\n case ConversationTranslatorCommandTypes.setMute:\r\n updatedParticipant.isMuted = e.value as boolean;\r\n break;\r\n case ConversationTranslatorCommandTypes.setTranslateToLanguages:\r\n updatedParticipant.translateToLanguages = e.value as string[];\r\n break;\r\n }\r\n this.privParticipants.addOrUpdateParticipant(updatedParticipant);\r\n\r\n if (!!this.privConversationTranslator) {\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 = (): void => {\r\n // TODO\r\n };\r\n\r\n private onMuteAllCommandReceived = (r: ConversationRecognizer, e: MuteAllEventArgs): void => {\r\n try {\r\n this.privParticipants.participants.forEach((p: IInternalParticipant): boolean => p.isMuted = (p.isHost ? false : e.isMuted));\r\n if (!!this.privConversationTranslator) {\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: ConversationRecognizer, 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) {\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: ConversationRecognizer, 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) {\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: ConversationRecognizer, e: ConversationReceivedTranslationEventArgs): void => {\r\n try {\r\n switch (e.command) {\r\n case ConversationTranslatorMessageTypes.final:\r\n if (!!this.privConversationTranslator) {\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) {\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) {\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: ConversationRecognizer, 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) {\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: ConversationRecognizer, e: ConversationExpirationEventArgs): void => {\r\n try {\r\n if (!!this.privConversationTranslator) {\r\n this.privConversationTranslator.conversationExpiration(this.privConversationTranslator, e);\r\n }\r\n } catch (e) {\r\n //\r\n }\r\n };\r\n /* eslint-enable @typescript-eslint/typedef */\r\n\r\n private addParticipantImplAsync(participant: IParticipant): Promise<void> {\r\n const newParticipant: IInternalParticipant = this.privParticipants.addOrUpdateParticipant(participant);\r\n if (newParticipant !== undefined) {\r\n if (!!this.privTranscriberRecognizer) {\r\n const meetingInfo = this.meetingInfo;\r\n meetingInfo.participants = [participant];\r\n return this.privTranscriberRecognizer.pushMeetingEvent(meetingInfo, \"join\");\r\n }\r\n }\r\n }\r\n\r\n private removeParticipantImplAsync(participant: IParticipant): Promise<void> {\r\n this.privParticipants.deleteParticipant(participant.id);\r\n const meetingInfo = this.meetingInfo;\r\n meetingInfo.participants = [participant];\r\n return this.privTranscriberRecognizer.pushMeetingEvent(meetingInfo, \"leave\");\r\n }\r\n\r\n private async close(dispose: boolean): Promise<void> {\r\n try {\r\n this.privIsConnected = false;\r\n await this.privConversationRecognizer?.close();\r\n this.privConversationRecognizer = undefined;\r\n if (!!this.privConversationTranslator) {\r\n this.privConversationTranslator.dispose();\r\n }\r\n } catch (e) {\r\n // ignore error\r\n throw e;\r\n }\r\n if (dispose) {\r\n this.dispose();\r\n }\r\n }\r\n\r\n /** Helpers */\r\n private handleCallback(cb: () => void, err: (message: string) => void): void {\r\n if (!!cb) {\r\n try {\r\n cb();\r\n } catch (e) {\r\n if (!!err) {\r\n err(e as string);\r\n }\r\n }\r\n cb = undefined;\r\n }\r\n }\r\n\r\n private handleError(error: any, err: (message: string) => void): void {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error;\r\n err(typedError.name + \": \" + typedError.message);\r\n\r\n } else {\r\n err(error as string);\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): Participant => ( this.toParticipant(p) ) );\r\n if (!includeHost) {\r\n return participants.filter((p: Participant): boolean => 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, p.voice);\r\n }\r\n\r\n private getMuteAllCommand(isMuted: boolean): string {\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"meetingd\");\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, \"participantId\");\r\n\r\n return JSON.stringify({\r\n command: ConversationTranslatorCommandTypes.setMuteAll,\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\r\n private getMuteCommand(participantId: string, isMuted: boolean): string {\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"conversationId\");\r\n Contracts.throwIfNullOrWhitespace(participantId, \"participantId\");\r\n\r\n return JSON.stringify({\r\n command: ConversationTranslatorCommandTypes.setMute,\r\n // eslint-disable-next-line object-shorthand\r\n participantId: participantId,\r\n roomid: this.privRoom.roomId,\r\n type: ConversationTranslatorMessageTypes.participantCommand,\r\n value: isMuted\r\n });\r\n }\r\n\r\n private getLockCommand(isLocked: boolean): string {\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"meetingId\");\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, \"participantId\");\r\n\r\n return JSON.stringify({\r\n command: ConversationTranslatorCommandTypes.setLockState,\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\r\n private getEjectCommand(participantId: string): string {\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"meetingId\");\r\n Contracts.throwIfNullOrWhitespace(participantId, \"participantId\");\r\n\r\n return JSON.stringify({\r\n command: ConversationTranslatorCommandTypes.ejectParticipant,\r\n // eslint-disable-next-line object-shorthand\r\n participantId: participantId,\r\n roomid: this.privRoom.roomId,\r\n type: ConversationTranslatorMessageTypes.participantCommand,\r\n });\r\n }\r\n\r\n private getSetTranslateToLanguagesCommand(languages: string[]): string {\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"meetingId\");\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, \"participantId\");\r\n\r\n return JSON.stringify({\r\n command: ConversationTranslatorCommandTypes.setTranslateToLanguages,\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: languages\r\n });\r\n }\r\n\r\n private getChangeNicknameCommand(nickname: string): string {\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"meetingId\");\r\n Contracts.throwIfNullOrWhitespace(nickname, \"nickname\");\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, \"participantId\");\r\n\r\n return JSON.stringify({\r\n command: ConversationTranslatorCommandTypes.changeNickname,\r\n nickname,\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\r\n private getMessageCommand(message: string): string {\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.roomId, \"meetingId\");\r\n Contracts.throwIfNullOrWhitespace(this.privRoom.participantId, \"participantId\");\r\n Contracts.throwIfNullOrWhitespace(message, \"message\");\r\n\r\n return JSON.stringify({\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\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 { CancellationEventArgsBase } from \"../CancellationEventArgsBase.js\";\r\n\r\nexport class MeetingTranscriptionCanceledEventArgs extends CancellationEventArgsBase {\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { TranscriberRecognizer } from \"../../common.speech/Exports.js\";\r\nimport { marshalPromiseToCallbacks } from \"../../common/Exports.js\";\r\nimport { Contracts } from \"../Contracts.js\";\r\nimport {\r\n AudioConfig,\r\n CancellationEventArgs,\r\n Connection,\r\n MeetingTranscriptionEventArgs,\r\n PropertyCollection,\r\n PropertyId,\r\n SessionEventArgs\r\n} from \"../Exports.js\";\r\nimport {\r\n MeetingHandler,\r\n MeetingImpl,\r\n MeetingTranscriptionHandler\r\n} from \"./Exports.js\";\r\nimport { Callback, IMeeting } from \"./IMeeting.js\";\r\n\r\nexport class MeetingTranscriber implements MeetingTranscriptionHandler {\r\n\r\n /**\r\n * The event canceled signals that an error occurred during the meeting.\r\n * @member MeetingTranscriber.prototype.MeetingCanceled\r\n * @function\r\n * @public\r\n */\r\n public MeetingCanceled: (sender: MeetingHandler, event: CancellationEventArgs) => void;\r\n\r\n /**\r\n * The event canceled signals that an error occurred during transcription.\r\n * @member MeetingTranscriber.prototype.canceled\r\n * @function\r\n * @public\r\n */\r\n public canceled: (sender: MeetingHandler, event: CancellationEventArgs) => void;\r\n\r\n /**\r\n * The event recognized signals that a final meeting transcription result is received.\r\n * @member MeetingTranscriber.prototype.transcribed\r\n * @function\r\n * @public\r\n */\r\n public transcribed: (sender: MeetingTranscriptionHandler, event: MeetingTranscriptionEventArgs) => void;\r\n\r\n /**\r\n * The event recognizing signals that an intermediate meeting transcription result is received.\r\n * @member MeetingTranscriber.prototype.transcribing\r\n * @function\r\n * @public\r\n */\r\n public transcribing: (sender: MeetingTranscriptionHandler, event: MeetingTranscriptionEventArgs) => void;\r\n\r\n /**\r\n * Defines event handler for session started events.\r\n * @member MeetingTranscriber.prototype.sessionStarted\r\n * @function\r\n * @public\r\n */\r\n public sessionStarted: (sender: MeetingHandler, event: SessionEventArgs) => void;\r\n\r\n /**\r\n * Defines event handler for session stopped events.\r\n * @member MeetingTranscriber.prototype.sessionStopped\r\n * @function\r\n * @public\r\n */\r\n public sessionStopped: (sender: MeetingHandler, event: SessionEventArgs) => void;\r\n\r\n /**\r\n * Defines event handler for meeting started events.\r\n * @member MeetingTranscriber.prototype.MeetingStarted\r\n * @function\r\n * @public\r\n */\r\n public MeetingStarted: (sender: MeetingHandler, event: SessionEventArgs) => void;\r\n\r\n /**\r\n * Defines event handler for meeting stopped events.\r\n * @member MeetingTranscriber.prototype.MeetingStopped\r\n * @function\r\n * @public\r\n */\r\n public meetingStopped: (sender: MeetingHandler, event: SessionEventArgs) => void;\r\n\r\n protected privAudioConfig: AudioConfig;\r\n private privDisposedRecognizer: boolean;\r\n private privRecognizer: TranscriberRecognizer;\r\n private privProperties: PropertyCollection;\r\n\r\n /**\r\n * MeetingTranscriber constructor.\r\n * @constructor\r\n * @param {AudioConfig} audioConfig - An optional audio configuration associated with the recognizer\r\n */\r\n public constructor(audioConfig?: AudioConfig) {\r\n this.privAudioConfig = audioConfig;\r\n this.privProperties = new PropertyCollection();\r\n this.privRecognizer = undefined;\r\n this.privDisposedRecognizer = false;\r\n }\r\n\r\n /**\r\n * Gets the spoken language of recognition.\r\n * @member MeetingTranscriber.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.privDisposedRecognizer);\r\n\r\n return this.properties.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage);\r\n }\r\n\r\n /**\r\n * The collection of properties and their values defined for this MeetingTranscriber.\r\n * @member MeetingTranscriber.prototype.properties\r\n * @function\r\n * @public\r\n * @returns {PropertyCollection} The collection of properties and their values defined for this MeetingTranscriber.\r\n */\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\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.privRecognizer.internalData;\r\n }\r\n\r\n /**\r\n * @Deprecated\r\n * @Obsolete\r\n * Please use the Connection.fromRecognizer pattern to obtain a connection object\r\n */\r\n public get connection(): Connection {\r\n return Connection.fromRecognizer(this.privRecognizer);\r\n }\r\n\r\n /**\r\n * Gets the authorization token used to communicate with the service.\r\n * @member MeetingTranscriber.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 MeetingTranscriber.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 * @param {Meeting} meeting - meeting to be recognized\r\n */\r\n public joinMeetingAsync(meeting: IMeeting, cb?: Callback, err?: Callback): void {\r\n /* eslint-disable no-console */\r\n // console.log(\">> MeetingTranscriber::joinMeetingAsync\");\r\n /* eslint-enable no-console */\r\n const meetingImpl = meeting as MeetingImpl;\r\n Contracts.throwIfNullOrUndefined(MeetingImpl, \"Meeting\");\r\n\r\n // ref the meeting object\r\n // create recognizer and subscribe to recognizer events\r\n this.privRecognizer = new TranscriberRecognizer(meeting.config, this.privAudioConfig);\r\n Contracts.throwIfNullOrUndefined(this.privRecognizer, \"Recognizer\");\r\n this.privRecognizer.connectMeetingCallbacks(this);\r\n\r\n marshalPromiseToCallbacks(meetingImpl.connectTranscriberRecognizer(this.privRecognizer), cb, err);\r\n }\r\n\r\n /**\r\n * Starts meeting transcription, until stopTranscribingAsync() is called.\r\n * User must subscribe to events to receive transcription results.\r\n * @member MeetingTranscriber.prototype.startTranscribingAsync\r\n * @function\r\n * @public\r\n * @param cb - Callback invoked once the transcription has started.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public startTranscribingAsync(cb?: Callback, err?: Callback): void {\r\n this.privRecognizer.startContinuousRecognitionAsync(cb, err);\r\n }\r\n\r\n /**\r\n * Starts meeting transcription, until stopTranscribingAsync() is called.\r\n * User must subscribe to events to receive transcription results.\r\n * @member MeetingTranscriber.prototype.stopTranscribingAsync\r\n * @function\r\n * @public\r\n * @param cb - Callback invoked once the transcription has started.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public stopTranscribingAsync(cb?: Callback, err?: Callback): void {\r\n this.privRecognizer.stopContinuousRecognitionAsync(cb, err);\r\n }\r\n\r\n /**\r\n * Leave the current meeting. After this is called, you will no longer receive any events.\r\n */\r\n public leaveMeetingAsync(cb?: Callback, err?: Callback): void {\r\n this.privRecognizer.disconnectCallbacks();\r\n // eslint-disable-next-line\r\n marshalPromiseToCallbacks((async (): Promise<void> => { return; })(), cb, err);\r\n }\r\n\r\n /**\r\n * closes all external resources held by an instance of this class.\r\n * @member MeetingTranscriber.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(cb?: () => void, errorCb?: (error: string) => void): void {\r\n Contracts.throwIfDisposed(this.privDisposedRecognizer);\r\n marshalPromiseToCallbacks(this.dispose(true), cb, errorCb);\r\n }\r\n\r\n /**\r\n * Disposes any resources held by the object.\r\n * @member MeetingTranscriber.prototype.dispose\r\n * @function\r\n * @public\r\n * @param {boolean} disposing - true if disposing the object.\r\n */\r\n protected async dispose(disposing: boolean): Promise<void> {\r\n if (this.privDisposedRecognizer) {\r\n return;\r\n }\r\n if (!!this.privRecognizer) {\r\n await this.privRecognizer.close();\r\n this.privRecognizer = undefined;\r\n }\r\n if (disposing) {\r\n this.privDisposedRecognizer = true;\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 { PropertyCollection, RecognitionResult, ResultReason } from \"../Exports.js\";\r\n\r\n/**\r\n * Defines result of conversation transcription.\r\n * @class ConversationTranscriptionResult\r\n */\r\nexport class ConversationTranscriptionResult extends RecognitionResult {\r\n private readonly privSpeakerId: string;\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} speakerId - speaker id for conversation transcription.\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, speakerId?: string, errorDetails?: string,\r\n json?: string, properties?: PropertyCollection) {\r\n super(resultId, reason, text, duration, offset, language, languageDetectionConfidence, errorDetails, json, properties);\r\n this.privSpeakerId = speakerId;\r\n }\r\n\r\n /**\r\n * speaker id\r\n * @member ConversationTranscriptionResult.prototype.speakerId\r\n * @function\r\n * @public\r\n * @returns {string} id of speaker in given result\r\n */\r\n public get speakerId(): string {\r\n return this.privSpeakerId;\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\nexport { Conversation, ConversationImpl } from \"./Conversation.js\";\r\nexport { ConversationInfo } from \"./IConversation.js\";\r\nexport { ConversationCommon } from \"./ConversationCommon.js\";\r\nexport { ConversationExpirationEventArgs } from \"./ConversationExpirationEventArgs.js\";\r\nexport { ConversationParticipantsChangedEventArgs } from \"./ConversationParticipantsChangedEventArgs.js\";\r\nexport { ConversationTranslationCanceledEventArgs } from \"./ConversationTranslationCanceledEventArgs.js\";\r\nexport { ConversationTranslationEventArgs } from \"./ConversationTranslationEventArgs.js\";\r\nexport { ConversationTranslationResult } from \"./ConversationTranslationResult.js\";\r\nexport { ConversationTranslator } from \"./ConversationTranslator.js\";\r\nexport { ConversationTranscriber } from \"./ConversationTranscriber.js\";\r\nexport { IParticipant, Participant, User, VoiceSignature } from \"./IParticipant.js\";\r\nexport { ParticipantChangedReason } from \"./ParticipantChangedReason.js\";\r\nexport { ConversationHandler, ConversationTranscriptionHandler, IConversationTranslator } from \"./ConversationHandler.js\";\r\nexport { Meeting, MeetingImpl } from \"./Meeting.js\";\r\nexport { MeetingInfo } from \"./IMeeting.js\";\r\nexport { MeetingTranscriptionCanceledEventArgs } from \"./MeetingTranscriptionCanceledEventArgs.js\";\r\nexport { MeetingTranscriber } from \"./MeetingTranscriber.js\";\r\nexport { MeetingHandler, MeetingTranscriptionHandler } from \"./MeetingHandler.js\";\r\nexport { ConversationTranscriptionResult } from \"./ConversationTranscriptionResult.js\";\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/* eslint-disable max-classes-per-file */\r\n\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 SynthesisAdapterBase,\r\n SynthesisRestAdapter,\r\n SynthesizerConfig } from \"../common.speech/Exports.js\";\r\nimport { IAudioDestination, IStringDictionary, Queue } from \"../common/Exports.js\";\r\nimport { Contracts } from \"./Contracts.js\";\r\nimport { PropertyCollection, PropertyId, SpeechConfig, SpeechConfigImpl, SpeechSynthesisResult } from \"./Exports.js\";\r\n\r\nexport abstract class Synthesizer {\r\n protected privAdapter: SynthesisAdapterBase;\r\n protected privRestAdapter: SynthesisRestAdapter;\r\n protected privProperties: PropertyCollection;\r\n protected privConnectionFactory: ISynthesisConnectionFactory;\r\n protected privDisposed: boolean;\r\n protected privSynthesizing: boolean;\r\n protected synthesisRequestQueue: Queue<SynthesisRequest>;\r\n\r\n /**\r\n * Gets the authorization token used to communicate with the service.\r\n * @member Synthesizer.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 Synthesizer.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 Synthesizer.\r\n * @member Synthesizer.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 Synthesizer.prototype.autoDetectSourceLanguage\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 /**\r\n * Creates and initializes an instance of a Recognizer\r\n * @constructor\r\n * @param {SpeechConfig} speechConfig - The speech config to initialize the synthesizer.\r\n */\r\n protected 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.privDisposed = false;\r\n this.privSynthesizing = false;\r\n this.synthesisRequestQueue = new Queue<SynthesisRequest>();\r\n }\r\n\r\n public buildSsml(text: string): string {\r\n const languageToDefaultVoice: IStringDictionary<string> = {\r\n [\"af-ZA\"]: \"af-ZA-AdriNeural\",\r\n [\"am-ET\"]: \"am-ET-AmehaNeural\",\r\n [\"ar-AE\"]: \"ar-AE-FatimaNeural\",\r\n [\"ar-BH\"]: \"ar-BH-AliNeural\",\r\n [\"ar-DZ\"]: \"ar-DZ-AminaNeural\",\r\n [\"ar-EG\"]: \"ar-EG-SalmaNeural\",\r\n [\"ar-IQ\"]: \"ar-IQ-BasselNeural\",\r\n [\"ar-JO\"]: \"ar-JO-SanaNeural\",\r\n [\"ar-KW\"]: \"ar-KW-FahedNeural\",\r\n [\"ar-LY\"]: \"ar-LY-ImanNeural\",\r\n [\"ar-MA\"]: \"ar-MA-JamalNeural\",\r\n [\"ar-QA\"]: \"ar-QA-AmalNeural\",\r\n [\"ar-SA\"]: \"ar-SA-HamedNeural\",\r\n [\"ar-SY\"]: \"ar-SY-AmanyNeural\",\r\n [\"ar-TN\"]: \"ar-TN-HediNeural\",\r\n [\"ar-YE\"]: \"ar-YE-MaryamNeural\",\r\n [\"bg-BG\"]: \"bg-BG-BorislavNeural\",\r\n [\"bn-BD\"]: \"bn-BD-NabanitaNeural\",\r\n [\"bn-IN\"]: \"bn-IN-BashkarNeural\",\r\n [\"ca-ES\"]: \"ca-ES-JoanaNeural\",\r\n [\"cs-CZ\"]: \"cs-CZ-AntoninNeural\",\r\n [\"cy-GB\"]: \"cy-GB-AledNeural\",\r\n [\"da-DK\"]: \"da-DK-ChristelNeural\",\r\n [\"de-AT\"]: \"de-AT-IngridNeural\",\r\n [\"de-CH\"]: \"de-CH-JanNeural\",\r\n [\"de-DE\"]: \"de-DE-KatjaNeural\",\r\n [\"el-GR\"]: \"el-GR-AthinaNeural\",\r\n [\"en-AU\"]: \"en-AU-NatashaNeural\",\r\n [\"en-CA\"]: \"en-CA-ClaraNeural\",\r\n [\"en-GB\"]: \"en-GB-LibbyNeural\",\r\n [\"en-HK\"]: \"en-HK-SamNeural\",\r\n [\"en-IE\"]: \"en-IE-ConnorNeural\",\r\n [\"en-IN\"]: \"en-IN-NeerjaNeural\",\r\n [\"en-KE\"]: \"en-KE-AsiliaNeural\",\r\n [\"en-NG\"]: \"en-NG-AbeoNeural\",\r\n [\"en-NZ\"]: \"en-NZ-MitchellNeural\",\r\n [\"en-PH\"]: \"en-PH-JamesNeural\",\r\n [\"en-SG\"]: \"en-SG-LunaNeural\",\r\n [\"en-TZ\"]: \"en-TZ-ElimuNeural\",\r\n [\"en-US\"]: \"en-US-JennyNeural\",\r\n [\"en-ZA\"]: \"en-ZA-LeahNeural\",\r\n [\"es-AR\"]: \"es-AR-ElenaNeural\",\r\n [\"es-BO\"]: \"es-BO-MarceloNeural\",\r\n [\"es-CL\"]: \"es-CL-CatalinaNeural\",\r\n [\"es-CO\"]: \"es-CO-GonzaloNeural\",\r\n [\"es-CR\"]: \"es-CR-JuanNeural\",\r\n [\"es-CU\"]: \"es-CU-BelkysNeural\",\r\n [\"es-DO\"]: \"es-DO-EmilioNeural\",\r\n [\"es-EC\"]: \"es-EC-AndreaNeural\",\r\n [\"es-ES\"]: \"es-ES-AlvaroNeural\",\r\n [\"es-GQ\"]: \"es-GQ-JavierNeural\",\r\n [\"es-GT\"]: \"es-GT-AndresNeural\",\r\n [\"es-HN\"]: \"es-HN-CarlosNeural\",\r\n [\"es-MX\"]: \"es-MX-DaliaNeural\",\r\n [\"es-NI\"]: \"es-NI-FedericoNeural\",\r\n [\"es-PA\"]: \"es-PA-MargaritaNeural\",\r\n [\"es-PE\"]: \"es-PE-AlexNeural\",\r\n [\"es-PR\"]: \"es-PR-KarinaNeural\",\r\n [\"es-PY\"]: \"es-PY-MarioNeural\",\r\n [\"es-SV\"]: \"es-SV-LorenaNeural\",\r\n [\"es-US\"]: \"es-US-AlonsoNeural\",\r\n [\"es-UY\"]: \"es-UY-MateoNeural\",\r\n [\"es-VE\"]: \"es-VE-PaolaNeural\",\r\n [\"et-EE\"]: \"et-EE-AnuNeural\",\r\n [\"fa-IR\"]: \"fa-IR-DilaraNeural\",\r\n [\"fi-FI\"]: \"fi-FI-SelmaNeural\",\r\n [\"fil-PH\"]: \"fil-PH-AngeloNeural\",\r\n [\"fr-BE\"]: \"fr-BE-CharlineNeural\",\r\n [\"fr-CA\"]: \"fr-CA-SylvieNeural\",\r\n [\"fr-CH\"]: \"fr-CH-ArianeNeural\",\r\n [\"fr-FR\"]: \"fr-FR-DeniseNeural\",\r\n [\"ga-IE\"]: \"ga-IE-ColmNeural\",\r\n [\"gl-ES\"]: \"gl-ES-RoiNeural\",\r\n [\"gu-IN\"]: \"gu-IN-DhwaniNeural\",\r\n [\"he-IL\"]: \"he-IL-AvriNeural\",\r\n [\"hi-IN\"]: \"hi-IN-MadhurNeural\",\r\n [\"hr-HR\"]: \"hr-HR-GabrijelaNeural\",\r\n [\"hu-HU\"]: \"hu-HU-NoemiNeural\",\r\n [\"id-ID\"]: \"id-ID-ArdiNeural\",\r\n [\"is-IS\"]: \"is-IS-GudrunNeural\",\r\n [\"it-IT\"]: \"it-IT-IsabellaNeural\",\r\n [\"ja-JP\"]: \"ja-JP-NanamiNeural\",\r\n [\"jv-ID\"]: \"jv-ID-DimasNeural\",\r\n [\"kk-KZ\"]: \"kk-KZ-AigulNeural\",\r\n [\"km-KH\"]: \"km-KH-PisethNeural\",\r\n [\"kn-IN\"]: \"kn-IN-GaganNeural\",\r\n [\"ko-KR\"]: \"ko-KR-SunHiNeural\",\r\n [\"lo-LA\"]: \"lo-LA-ChanthavongNeural\",\r\n [\"lt-LT\"]: \"lt-LT-LeonasNeural\",\r\n [\"lv-LV\"]: \"lv-LV-EveritaNeural\",\r\n [\"mk-MK\"]: \"mk-MK-AleksandarNeural\",\r\n [\"ml-IN\"]: \"ml-IN-MidhunNeural\",\r\n [\"mr-IN\"]: \"mr-IN-AarohiNeural\",\r\n [\"ms-MY\"]: \"ms-MY-OsmanNeural\",\r\n [\"mt-MT\"]: \"mt-MT-GraceNeural\",\r\n [\"my-MM\"]: \"my-MM-NilarNeural\",\r\n [\"nb-NO\"]: \"nb-NO-PernilleNeural\",\r\n [\"nl-BE\"]: \"nl-BE-ArnaudNeural\",\r\n [\"nl-NL\"]: \"nl-NL-ColetteNeural\",\r\n [\"pl-PL\"]: \"pl-PL-AgnieszkaNeural\",\r\n [\"ps-AF\"]: \"ps-AF-GulNawazNeural\",\r\n [\"pt-BR\"]: \"pt-BR-FranciscaNeural\",\r\n [\"pt-PT\"]: \"pt-PT-DuarteNeural\",\r\n [\"ro-RO\"]: \"ro-RO-AlinaNeural\",\r\n [\"ru-RU\"]: \"ru-RU-SvetlanaNeural\",\r\n [\"si-LK\"]: \"si-LK-SameeraNeural\",\r\n [\"sk-SK\"]: \"sk-SK-LukasNeural\",\r\n [\"sl-SI\"]: \"sl-SI-PetraNeural\",\r\n [\"so-SO\"]: \"so-SO-MuuseNeural\",\r\n [\"sr-RS\"]: \"sr-RS-NicholasNeural\",\r\n [\"su-ID\"]: \"su-ID-JajangNeural\",\r\n [\"sv-SE\"]: \"sv-SE-SofieNeural\",\r\n [\"sw-KE\"]: \"sw-KE-RafikiNeural\",\r\n [\"sw-TZ\"]: \"sw-TZ-DaudiNeural\",\r\n [\"ta-IN\"]: \"ta-IN-PallaviNeural\",\r\n [\"ta-LK\"]: \"ta-LK-KumarNeural\",\r\n [\"ta-SG\"]: \"ta-SG-AnbuNeural\",\r\n [\"te-IN\"]: \"te-IN-MohanNeural\",\r\n [\"th-TH\"]: \"th-TH-PremwadeeNeural\",\r\n [\"tr-TR\"]: \"tr-TR-AhmetNeural\",\r\n [\"uk-UA\"]: \"uk-UA-OstapNeural\",\r\n [\"ur-IN\"]: \"ur-IN-GulNeural\",\r\n [\"ur-PK\"]: \"ur-PK-AsadNeural\",\r\n [\"uz-UZ\"]: \"uz-UZ-MadinaNeural\",\r\n [\"vi-VN\"]: \"vi-VN-HoaiMyNeural\",\r\n [\"zh-CN\"]: \"zh-CN-XiaoxiaoNeural\",\r\n [\"zh-HK\"]: \"zh-HK-HiuMaanNeural\",\r\n [\"zh-TW\"]: \"zh-TW-HsiaoChenNeural\",\r\n [\"zu-ZA\"]: \"zu-ZA-ThandoNeural\",\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 = Synthesizer.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 = `<voice name='${voice}'>${ssml}</voice>`;\r\n }\r\n ssml = `<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xmlns:mstts='http://www.w3.org/2001/mstts' xmlns:emo='http://www.w3.org/2009/10/emotionml' xml:lang='${language}'>${ssml}</speak>`;\r\n return ssml;\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 Synthesizer.prototype.dispose\r\n * @function\r\n * @public\r\n * @param {boolean} disposing - Flag to request disposal.\r\n */\r\n protected async dispose(disposing: boolean): Promise<void> {\r\n if (this.privDisposed) {\r\n return;\r\n }\r\n\r\n if (disposing) {\r\n if (this.privAdapter) {\r\n await this.privAdapter.dispose();\r\n }\r\n }\r\n\r\n this.privDisposed = true;\r\n }\r\n\r\n protected async adapterSpeak(): Promise<void> {\r\n if (!this.privDisposed && !this.privSynthesizing) {\r\n this.privSynthesizing = true;\r\n const request: SynthesisRequest = await this.synthesisRequestQueue.dequeue();\r\n return this.privAdapter.Speak(request.text, request.isSSML, request.requestId, request.cb, request.err, request.dataStream);\r\n }\r\n }\r\n\r\n //\r\n // ################################################################################################################\r\n // IMPLEMENTATION.\r\n // Move to independent class\r\n // ################################################################################################################\r\n //\r\n\r\n // Creates the synthesis adapter\r\n protected abstract createSynthesisAdapter(\r\n authentication: IAuthentication,\r\n connectionFactory: ISynthesisConnectionFactory,\r\n synthesizerConfig: SynthesizerConfig): SynthesisAdapterBase;\r\n\r\n // Creates the REST synthesis adapter\r\n protected abstract createRestSynthesisAdapter(\r\n authentication: IAuthentication,\r\n synthesizerConfig: SynthesizerConfig): SynthesisRestAdapter;\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 // Does the generic synthesizer setup that is common across all synthesizer types.\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: 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 (): Promise<string> => {\r\n const authorizationToken = this.privProperties.getProperty(PropertyId.SpeechServiceAuthorization_Token, undefined);\r\n return Promise.resolve(authorizationToken);\r\n },\r\n (): Promise<string> => {\r\n const authorizationToken = this.privProperties.getProperty(PropertyId.SpeechServiceAuthorization_Token, undefined);\r\n return Promise.resolve(authorizationToken);\r\n });\r\n\r\n this.privAdapter = this.createSynthesisAdapter(\r\n authentication,\r\n this.privConnectionFactory,\r\n synthesizerConfig);\r\n\r\n this.privRestAdapter = this.createRestSynthesisAdapter(\r\n authentication,\r\n synthesizerConfig);\r\n }\r\n\r\n protected 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 .replace(/'/g, \"'\");\r\n }\r\n}\r\n\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 public 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\n/* eslint-disable @typescript-eslint/no-empty-function */\r\n\r\nimport { PathLike } from \"fs\";\r\nimport { IRestResponse } from \"../common.browser/RestMessageAdapter.js\";\r\nimport {\r\n IAuthentication,\r\n ISynthesisConnectionFactory,\r\n SpeechSynthesisConnectionFactory,\r\n SynthesisAdapterBase,\r\n SpeechSynthesisAdapter,\r\n SynthesisRestAdapter,\r\n SynthesizerConfig,\r\n} from \"../common.speech/Exports.js\";\r\nimport {\r\n createNoDashGuid,\r\n marshalPromiseToCallbacks,\r\n} from \"../common/Exports.js\";\r\nimport { AudioOutputConfigImpl } from \"./Audio/AudioConfig.js\";\r\nimport { AudioFileWriter } from \"./Audio/AudioFileWriter.js\";\r\nimport { AudioOutputFormatImpl } from \"./Audio/AudioOutputFormat.js\";\r\nimport {\r\n PullAudioOutputStreamImpl,\r\n PushAudioOutputStreamImpl\r\n} from \"./Audio/AudioOutputStream.js\";\r\nimport { Contracts } from \"./Contracts.js\";\r\nimport {\r\n AudioConfig,\r\n AudioOutputStream,\r\n AutoDetectSourceLanguageConfig,\r\n PropertyId,\r\n PullAudioOutputStream,\r\n PushAudioOutputStreamCallback,\r\n SpeechConfig,\r\n SpeechSynthesisBookmarkEventArgs,\r\n SpeechSynthesisEventArgs,\r\n SpeechSynthesisOutputFormat,\r\n SpeechSynthesisResult,\r\n SpeechSynthesisVisemeEventArgs,\r\n SpeechSynthesisWordBoundaryEventArgs,\r\n SynthesisVoicesResult,\r\n Synthesizer\r\n} from \"./Exports.js\";\r\nimport { SpeechConfigImpl } from \"./SpeechConfig.js\";\r\nimport { SynthesisRequest } from \"./Synthesizer.js\";\r\n\r\n/**\r\n * Defines the class SpeechSynthesizer for text to speech.\r\n * Updated in version 1.16.0\r\n * @class SpeechSynthesizer\r\n */\r\nexport class SpeechSynthesizer extends Synthesizer {\r\n protected audioConfig: AudioConfig;\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 * Defines event handler for bookmark reached events\r\n * Added in version 1.16.0\r\n * @member SpeechSynthesizer.prototype.bookmarkReached\r\n * @function\r\n * @public\r\n */\r\n public bookmarkReached: (sender: SpeechSynthesizer, event: SpeechSynthesisBookmarkEventArgs) => void;\r\n\r\n /**\r\n * Defines event handler for viseme received event\r\n * Added in version 1.16.0\r\n * @member SpeechSynthesizer.prototype.visemeReceived\r\n * @function\r\n * @public\r\n */\r\n public visemeReceived: (sender: SpeechSynthesizer, event: SpeechSynthesisVisemeEventArgs) => void;\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 super(speechConfig);\r\n\r\n if (audioConfig !== null) {\r\n if (audioConfig === undefined) {\r\n this.audioConfig = (typeof window === \"undefined\") ? undefined : AudioConfig.fromDefaultSpeakerOutput();\r\n } else {\r\n this.audioConfig = audioConfig;\r\n }\r\n }\r\n\r\n this.privConnectionFactory = new SpeechSynthesisConnectionFactory();\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 /**\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 * Get list of synthesis voices available.\r\n * The task returns the synthesis voice result.\r\n * @member SpeechSynthesizer.prototype.getVoicesAsync\r\n * @function\r\n * @async\r\n * @public\r\n * @param locale - Locale of voices in BCP-47 format; if left empty, get all available voices.\r\n * @return {Promise<SynthesisVoicesResult>} - Promise of a SynthesisVoicesResult.\r\n */\r\n public async getVoicesAsync(locale: string = \"\"): Promise<SynthesisVoicesResult> {\r\n return this.getVoices(locale);\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(cb?: () => void, err?: (error: string) => void): void {\r\n Contracts.throwIfDisposed(this.privDisposed);\r\n\r\n marshalPromiseToCallbacks(this.dispose(true), cb, err);\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 // ################################################################################################################\r\n // IMPLEMENTATION.\r\n // ################################################################################################################\r\n //\r\n\r\n // Creates the synthesis adapter\r\n protected createSynthesisAdapter(\r\n authentication: IAuthentication,\r\n connectionFactory: ISynthesisConnectionFactory,\r\n synthesizerConfig: SynthesizerConfig): SynthesisAdapterBase {\r\n return new SpeechSynthesisAdapter(authentication, connectionFactory,\r\n synthesizerConfig, this, this.audioConfig as AudioOutputConfigImpl);\r\n }\r\n\r\n protected createRestSynthesisAdapter(\r\n authentication: IAuthentication,\r\n synthesizerConfig: SynthesizerConfig): SynthesisRestAdapter {\r\n return new SynthesisRestAdapter(synthesizerConfig, authentication);\r\n }\r\n\r\n protected implCommonSynthesizeSetup(): void {\r\n super.implCommonSynthesizeSetup();\r\n\r\n this.privAdapter.audioOutputFormat = AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(\r\n SpeechSynthesisOutputFormat[this.properties.getProperty(PropertyId.SpeechServiceConnection_SynthOutputFormat, undefined) as keyof typeof SpeechSynthesisOutputFormat]\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 as string);\r\n }\r\n }\r\n }\r\n cb = undefined;\r\n /* eslint-disable no-empty */\r\n this.adapterSpeak().catch((): void => { });\r\n\r\n }, (e: string): void => {\r\n if (!!err) {\r\n err(e);\r\n }\r\n }, audioDestination));\r\n\r\n /* eslint-disable no-empty-function */\r\n this.adapterSpeak().catch((): void => { });\r\n\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error as string);\r\n }\r\n }\r\n\r\n // Destroy the synthesizer.\r\n /* eslint-disable no-empty */\r\n this.dispose(true).catch((): void => { });\r\n }\r\n }\r\n\r\n protected async getVoices(locale: string): Promise<SynthesisVoicesResult> {\r\n const requestId = createNoDashGuid();\r\n const response: IRestResponse = await this.privRestAdapter.getVoicesList(requestId);\r\n if (response.ok && Array.isArray(response.json)) {\r\n let json = response.json;\r\n if (!!locale && locale.length > 0) {\r\n json = json.filter((item: { Locale: string }): boolean => !!item.Locale && item.Locale.toLowerCase() === locale.toLowerCase() );\r\n }\r\n return new SynthesisVoicesResult(requestId, json, undefined);\r\n } else {\r\n return new SynthesisVoicesResult(requestId, undefined, `Error: ${response.status}: ${response.statusText}`);\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 { PropertyCollection, ResultReason } from \"./Exports.js\";\r\n\r\n/**\r\n * Base class for synthesis results\r\n * @class SynthesisResult\r\n * Added in version 1.20.0\r\n */\r\nexport class SynthesisResult {\r\n private privResultId: string;\r\n private privReason: ResultReason;\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 {string} errorDetails - Error details, if provided.\r\n * @param {PropertyCollection} properties - Additional properties, if provided.\r\n */\r\n public constructor(resultId?: string, reason?: ResultReason, errorDetails?: string, properties?: PropertyCollection) {\r\n this.privResultId = resultId;\r\n this.privReason = reason;\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 SynthesisResult.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 SynthesisResult.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 * In case of an unsuccessful synthesis, provides details of the occurred error.\r\n * @member SynthesisResult.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 SynthesisResult.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 {\r\n PropertyCollection,\r\n ResultReason,\r\n SynthesisResult\r\n} from \"./Exports.js\";\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 extends SynthesisResult {\r\n private readonly privAudioData: ArrayBuffer;\r\n private readonly privAudioDuration: number;\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 {ArrayBuffer} audioData - The synthesized audio binary.\r\n * @param {string} errorDetails - Error details, if provided.\r\n * @param {PropertyCollection} properties - Additional properties, if provided.\r\n * @param {number} audioDuration - The audio duration.\r\n */\r\n public constructor(resultId?: string, reason?: ResultReason, audioData?: ArrayBuffer,\r\n errorDetails?: string, properties?: PropertyCollection, audioDuration?: number) {\r\n super(resultId, reason, errorDetails, properties);\r\n this.privAudioData = audioData;\r\n this.privAudioDuration = audioDuration;\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 * The time duration of synthesized audio, in ticks (100 nanoseconds).\r\n * @member SpeechSynthesisResult.prototype.audioDuration\r\n * @function\r\n * @public\r\n * @returns {number} The time duration of synthesized audio.\r\n */\r\n public get audioDuration(): number {\r\n return this.privAudioDuration;\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.js\";\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\nimport { SpeechSynthesisBoundaryType } from \"./SpeechSynthesisBoundaryType.js\";\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 readonly privAudioOffset: number;\r\n private readonly privDuration: number;\r\n private readonly privText: string;\r\n private readonly privWordLength: number;\r\n private readonly privTextOffset: number;\r\n private readonly privBoundaryType: SpeechSynthesisBoundaryType;\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 {number} duration - The audio duration.\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 * @param {SpeechSynthesisBoundaryType} boundaryType - The boundary type\r\n */\r\n public constructor(audioOffset: number, duration: number, text: string, wordLength: number,\r\n textOffset: number, boundaryType: SpeechSynthesisBoundaryType) {\r\n this.privAudioOffset = audioOffset;\r\n this.privDuration = duration;\r\n this.privText = text;\r\n this.privWordLength = wordLength;\r\n this.privTextOffset = textOffset;\r\n this.privBoundaryType = boundaryType;\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.privAudioOffset;\r\n }\r\n\r\n /**\r\n * Specifies the duration, in ticks (100 nanoseconds).\r\n * @member SpeechSynthesisWordBoundaryEventArgs.prototype.duration\r\n * @function\r\n * @public\r\n * @returns {number} Duration in 100 nanosecond increments.\r\n */\r\n public get duration(): number {\r\n return this.privDuration;\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 /**\r\n * Specifies the boundary type.\r\n * @member SpeechSynthesisWordBoundaryEventArgs.prototype.boundaryType\r\n * @function\r\n * @public\r\n * @returns {SpeechSynthesisBoundaryType} the boundary type.\r\n */\r\n public get boundaryType(): SpeechSynthesisBoundaryType {\r\n return this.privBoundaryType;\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 bookmark event.\r\n * @class SpeechSynthesisBookmarkEventArgs\r\n * Added in version 1.16.0\r\n */\r\nexport class SpeechSynthesisBookmarkEventArgs {\r\n private privAudioOffset: number;\r\n private privText: string;\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 bookmark text.\r\n */\r\n public constructor(audioOffset: number, text: string) {\r\n this.privAudioOffset = audioOffset;\r\n this.privText = text;\r\n }\r\n\r\n /**\r\n * Specifies the audio offset.\r\n * @member SpeechSynthesisBookmarkEventArgs.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.privAudioOffset;\r\n }\r\n\r\n /**\r\n * Specifies the bookmark.\r\n * @member SpeechSynthesisBookmarkEventArgs.prototype.text\r\n * @function\r\n * @public\r\n * @returns {string} the bookmark text.\r\n */\r\n public get text(): string {\r\n return this.privText;\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 viseme event.\r\n * @class SpeechSynthesisVisemeEventArgs\r\n * Added in version 1.16.0\r\n */\r\nexport class SpeechSynthesisVisemeEventArgs {\r\n private privAudioOffset: number;\r\n private privVisemeId: number;\r\n private privAnimation: string;\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 {number} visemeId - The viseme ID.\r\n * @param {string} animation - The animation, could be in svg or other format.\r\n */\r\n public constructor(audioOffset: number, visemeId: number, animation: string) {\r\n this.privAudioOffset = audioOffset;\r\n this.privVisemeId = visemeId;\r\n this.privAnimation = animation;\r\n }\r\n\r\n /**\r\n * Specifies the audio offset.\r\n * @member SpeechSynthesisVisemeEventArgs.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.privAudioOffset;\r\n }\r\n\r\n /**\r\n * Specifies the viseme ID.\r\n * @member SpeechSynthesisVisemeEventArgs.prototype.visemeId\r\n * @function\r\n * @public\r\n * @returns {number} the viseme ID.\r\n */\r\n public get visemeId(): number {\r\n return this.privVisemeId;\r\n }\r\n\r\n /**\r\n * Specifies the animation.\r\n * @member SpeechSynthesisVisemeEventArgs.prototype.animation\r\n * @function\r\n * @public\r\n * @returns {string} the animation, could be in svg or other format.\r\n */\r\n public get animation(): string {\r\n return this.privAnimation;\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 boundary type of speech synthesis boundary event.\r\n * @class SpeechSynthesisBoundaryType\r\n * Added in version 1.21.0\r\n */\r\nexport enum SpeechSynthesisBoundaryType {\r\n /**\r\n * Indicates the boundary text is a word.\r\n * @member SpeechSynthesisBoundaryType.Word\r\n */\r\n Word = \"WordBoundary\",\r\n\r\n /**\r\n * Indicates the boundary text is a punctuation.\r\n * @member SpeechSynthesisBoundaryType.Punctuation\r\n */\r\n Punctuation = \"PunctuationBoundary\",\r\n\r\n /**\r\n * Indicates the boundary text is a sentence.\r\n * @member SpeechSynthesisBoundaryType.Sentence\r\n */\r\n Sentence = \"SentenceBoundary\"\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n IVoiceJson,\r\n PropertyCollection,\r\n ResultReason,\r\n SynthesisResult,\r\n VoiceInfo,\r\n} from \"./Exports.js\";\r\n\r\n/**\r\n * Defines result of speech synthesis.\r\n * @class SynthesisVoicesResult\r\n * Added in version 1.20.0\r\n */\r\nexport class SynthesisVoicesResult extends SynthesisResult {\r\n private privVoices: VoiceInfo[];\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param requestId - result id for request.\r\n * @param json - json payload from endpoint.\r\n */\r\n public constructor(requestId: string, json: any, errorDetails: string ) {\r\n if (Array.isArray(json)) {\r\n super(requestId, ResultReason.VoicesListRetrieved, undefined, new PropertyCollection());\r\n this.privVoices = [];\r\n for (const item of json) {\r\n this.privVoices.push(new VoiceInfo(item as IVoiceJson));\r\n }\r\n } else {\r\n super(requestId, ResultReason.Canceled, errorDetails ? errorDetails : \"Error information unavailable\", new PropertyCollection());\r\n }\r\n }\r\n\r\n /**\r\n * The list of voices\r\n * @member SynthesisVoicesResult.prototype.voices\r\n * @function\r\n * @public\r\n * @returns {VoiceInfo[]} List of synthesized voices.\r\n */\r\n public get voices(): VoiceInfo[] {\r\n return this.privVoices;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { IVoiceJson } from \"./IVoiceJson\";\r\n\r\n/**\r\n * Defines the gender of synthesis voices.\r\n * Added in version 1.20.0.\r\n */\r\nexport enum SynthesisVoiceGender {\r\n\r\n /** Gender unknown */\r\n Unknown,\r\n\r\n /** Female voice */\r\n Female,\r\n\r\n /** Male voice */\r\n Male,\r\n\r\n /** Neutral voice */\r\n Neutral\r\n}\r\n\r\nexport enum SynthesisVoiceType {\r\n OnlineNeural = 1,\r\n OnlineStandard = 2,\r\n OfflineNeural = 3,\r\n OfflineStandard = 4,\r\n}\r\n\r\nconst GENDER_LOOKUP: Record<string, SynthesisVoiceGender> = {\r\n [SynthesisVoiceGender[SynthesisVoiceGender.Neutral]]: SynthesisVoiceGender.Neutral,\r\n [SynthesisVoiceGender[SynthesisVoiceGender.Male]]: SynthesisVoiceGender.Male,\r\n [SynthesisVoiceGender[SynthesisVoiceGender.Female]]: SynthesisVoiceGender.Female,\r\n};\r\n\r\n/**\r\n * Information about Speech Synthesis voice\r\n * Added in version 1.20.0.\r\n * @class VoiceInfo\r\n */\r\nexport class VoiceInfo {\r\n private privName: IVoiceJson[\"Name\"];\r\n private privLocale: IVoiceJson[\"Locale\"];\r\n private privShortName: IVoiceJson[\"ShortName\"];\r\n private privDisplayName: IVoiceJson[\"DisplayName\"];\r\n private privLocalName: IVoiceJson[\"LocalName\"];\r\n private privLocaleName: IVoiceJson[\"LocaleName\"];\r\n private privGender: SynthesisVoiceGender;\r\n private privVoiceType: SynthesisVoiceType;\r\n private privStyleList: IVoiceJson[\"StyleList\"] = [];\r\n private privSampleRateHertz: IVoiceJson[\"SampleRateHertz\"];\r\n private privStatus: IVoiceJson[\"Status\"];\r\n private privExtendedPropertyMap: IVoiceJson[\"ExtendedPropertyMap\"];\r\n private privWordsPerMinute: IVoiceJson[\"WordsPerMinute\"];\r\n private privSecondaryLocaleList: IVoiceJson[\"SecondaryLocaleList\"];\r\n private privRolePlayList: IVoiceJson[\"RolePlayList\"];\r\n\r\n public constructor(json: IVoiceJson) {\r\n if (!!json) {\r\n this.privName = json.Name;\r\n this.privLocale = json.Locale;\r\n this.privShortName = json.ShortName;\r\n this.privLocaleName = json.LocaleName;\r\n this.privDisplayName = json.DisplayName;\r\n this.privLocalName = json.LocalName;\r\n this.privVoiceType = json.VoiceType.endsWith(\"Standard\") ? SynthesisVoiceType.OnlineStandard : SynthesisVoiceType.OnlineNeural;\r\n this.privGender = GENDER_LOOKUP[json.Gender] || SynthesisVoiceGender.Unknown;\r\n\r\n if (!!json.StyleList && Array.isArray(json.StyleList)) {\r\n for (const style of json.StyleList) {\r\n this.privStyleList.push(style);\r\n }\r\n }\r\n\r\n this.privSampleRateHertz = json.SampleRateHertz;\r\n this.privStatus = json.Status;\r\n\r\n if (json.ExtendedPropertyMap) {\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\r\n this.privExtendedPropertyMap = json.ExtendedPropertyMap;\r\n }\r\n\r\n this.privWordsPerMinute = json.WordsPerMinute;\r\n\r\n if (Array.isArray(json.SecondaryLocaleList)) {\r\n this.privSecondaryLocaleList = [...json.SecondaryLocaleList];\r\n }\r\n\r\n if (Array.isArray(json.RolePlayList)) {\r\n this.privRolePlayList = [...json.RolePlayList];\r\n }\r\n }\r\n }\r\n\r\n public get name(): IVoiceJson[\"Name\"] {\r\n return this.privName;\r\n }\r\n\r\n public get locale(): IVoiceJson[\"Locale\"] {\r\n return this.privLocale;\r\n }\r\n\r\n public get shortName(): IVoiceJson[\"ShortName\"] {\r\n return this.privShortName;\r\n }\r\n\r\n public get displayName(): IVoiceJson[\"DisplayName\"] {\r\n return this.privDisplayName;\r\n }\r\n\r\n public get localName(): IVoiceJson[\"LocalName\"] {\r\n return this.privLocalName;\r\n }\r\n\r\n public get localeName(): IVoiceJson[\"LocaleName\"] {\r\n return this.privLocaleName;\r\n }\r\n\r\n public get gender(): SynthesisVoiceGender {\r\n return this.privGender;\r\n }\r\n\r\n public get voiceType(): SynthesisVoiceType {\r\n return this.privVoiceType;\r\n }\r\n\r\n public get styleList(): IVoiceJson[\"StyleList\"] {\r\n return this.privStyleList;\r\n }\r\n\r\n public get sampleRateHertz(): IVoiceJson[\"SampleRateHertz\"] {\r\n return this.privSampleRateHertz;\r\n }\r\n\r\n public get status(): IVoiceJson[\"Status\"] {\r\n return this.privStatus;\r\n }\r\n\r\n public get extendedPropertyMap(): IVoiceJson[\"ExtendedPropertyMap\"] {\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\r\n return this.privExtendedPropertyMap;\r\n }\r\n\r\n public get wordsPerMinute(): IVoiceJson[\"WordsPerMinute\"] {\r\n return this.privWordsPerMinute;\r\n }\r\n\r\n public get secondaryLocaleList(): IVoiceJson[\"SecondaryLocaleList\"] {\r\n return this.privSecondaryLocaleList;\r\n }\r\n\r\n public get rolePlayList(): IVoiceJson[\"RolePlayList\"] {\r\n return this.privRolePlayList;\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 BackgroundEvent,\r\n createNoDashGuid,\r\n Events,\r\n IAudioDestination,\r\n INumberDictionary\r\n} from \"../../common/Exports.js\";\r\nimport { AudioStreamFormat, IPlayer } from \"../Exports.js\";\r\nimport { AudioOutputFormatImpl } from \"./AudioOutputFormat.js\";\r\nimport { PullAudioOutputStreamImpl } from \"./AudioOutputStream.js\";\r\nimport { AudioFormatTag } from \"./AudioStreamFormat.js\";\r\n\r\nconst MediaDurationPlaceholderSeconds = 60 * 30;\r\n\r\nconst AudioFormatToMimeType: INumberDictionary<string> = {\r\n [AudioFormatTag.PCM]: \"audio/wav\",\r\n [AudioFormatTag.MuLaw]: \"audio/x-wav\",\r\n [AudioFormatTag.MP3]: \"audio/mpeg\",\r\n [AudioFormatTag.OGG_OPUS]: \"audio/ogg\",\r\n [AudioFormatTag.WEBM_OPUS]: \"audio/webm; codecs=opus\",\r\n [AudioFormatTag.ALaw]: \"audio/x-wav\",\r\n [AudioFormatTag.FLAC]: \"audio/flac\",\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 <a href=\"https://www.w3.org/TR/media-source/\">Media Source Extensions</a> 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.17.0\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, cb?: () => void, err?: (error: string) => void): void {\r\n if (this.privAudioBuffer !== undefined) {\r\n this.privAudioBuffer.push(buffer);\r\n this.updateSourceBuffer().then((): void => {\r\n if (!!cb) {\r\n cb();\r\n }\r\n }, (error: string): void => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\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(cb?: () => void, err?: (error: string) => void): void {\r\n this.privIsClosed = true;\r\n if (this.privSourceBuffer !== undefined) {\r\n this.handleSourceBufferUpdateEnd().then((): void => {\r\n if (!!cb) {\r\n cb();\r\n }\r\n }, (error: string): void => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n } else if (this.privAudioOutputStream !== undefined && typeof window !== \"undefined\") {\r\n if ((this.privFormat.formatTag === AudioFormatTag.PCM || this.privFormat.formatTag === AudioFormatTag.MuLaw\r\n || this.privFormat.formatTag === AudioFormatTag.ALaw) && this.privFormat.hasHeader === false) {\r\n // eslint-disable-next-line no-console\r\n console.warn(\"Play back is not supported for raw PCM, mulaw or alaw format without header.\");\r\n if (!!this.onAudioEnd) {\r\n this.onAudioEnd(this);\r\n }\r\n } else {\r\n let receivedAudio = new ArrayBuffer(this.privBytesReceived);\r\n this.privAudioOutputStream.read(receivedAudio).then((): void => {\r\n receivedAudio = this.privFormat.addHeader(receivedAudio);\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().then((): void => {\r\n if (!!cb) {\r\n cb();\r\n }\r\n }, (error: string): void => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n }, (error: string): void => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n }\r\n } else {\r\n // unsupported format, call onAudioEnd directly.\r\n if (!!this.onAudioEnd) {\r\n this.onAudioEnd(this);\r\n }\r\n }\r\n }\r\n\r\n public set format(format: AudioStreamFormat) {\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\r\n if (typeof (AudioContext) !== \"undefined\" || (typeof (window) !== \"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 // eslint-disable-next-line no-console\r\n console.warn(\r\n `Unknown mimeType for format ${AudioFormatTag[this.privFormat.formatTag]}; playback is not supported.`);\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 = (): 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 = (): void => {\r\n this.updateSourceBuffer().catch((reason: string): void => {\r\n Events.instance.onEvent(new BackgroundEvent(reason));\r\n });\r\n };\r\n this.privSourceBuffer.onupdateend = (): void => {\r\n this.handleSourceBufferUpdateEnd().catch((reason: string): void => {\r\n Events.instance.onEvent(new BackgroundEvent(reason));\r\n });\r\n };\r\n this.privSourceBuffer.onupdatestart = (): void => {\r\n this.privAppendingToBuffer = false;\r\n };\r\n };\r\n this.updateSourceBuffer().catch((reason: string): void => {\r\n Events.instance.onEvent(new BackgroundEvent(reason));\r\n });\r\n\r\n } else {\r\n // eslint-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 volume(): number {\r\n return this.privAudio?.volume ?? -1;\r\n }\r\n\r\n public set volume(volume: number) {\r\n if (!!this.privAudio) {\r\n this.privAudio.volume = volume;\r\n }\r\n }\r\n\r\n public mute(): void {\r\n if (!!this.privAudio) {\r\n this.privAudio.muted = true;\r\n }\r\n }\r\n\r\n public unmute(): void {\r\n if (!!this.privAudio) {\r\n this.privAudio.muted = false;\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(cb?: () => void, err?: (error: string) => void): void {\r\n if (this.privIsPaused && this.privAudio !== undefined) {\r\n this.privAudio.play().then((): void => {\r\n if (!!cb) {\r\n cb();\r\n }\r\n }, (error: string): void => {\r\n if (!!err) {\r\n err(error);\r\n }\r\n });\r\n this.privIsPaused = false;\r\n }\r\n }\r\n\r\n public onAudioStart: (sender: IPlayer) => void;\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 async updateSourceBuffer(): Promise<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 // eslint-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 await this.notifyPlayback();\r\n } else if (this.canEndStream()) {\r\n await this.handleSourceBufferUpdateEnd();\r\n }\r\n }\r\n\r\n private async handleSourceBufferUpdateEnd(): Promise<void> {\r\n if (this.canEndStream() && this.sourceBufferAvailable()) {\r\n this.privMediaSource.endOfStream();\r\n await this.notifyPlayback();\r\n }\r\n }\r\n\r\n private async notifyPlayback(): Promise<void> {\r\n if (!this.privPlaybackStarted && this.privAudio !== undefined) {\r\n this.privPlaybackStarted = true;\r\n if (!!this.onAudioStart) {\r\n this.onAudioStart(this);\r\n }\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 await this.privAudio.play();\r\n }\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 {\r\n CancellationEventArgsBase,\r\n} from \"./CancellationEventArgsBase.js\";\r\n\r\n/**\r\n * Defines content of a RecognitionErrorEvent.\r\n * @class ConversationTranscriptionCanceledEventArgs\r\n */\r\nexport class ConversationTranscriptionCanceledEventArgs extends CancellationEventArgsBase {\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n CancellationEventArgsBase,\r\n} from \"./CancellationEventArgsBase.js\";\r\n\r\n/**\r\n * Defines content of a MeetingTranscriptionCanceledEvent.\r\n * @class MeetingTranscriptionCanceledEventArgs\r\n */\r\nexport class MeetingTranscriptionCanceledEventArgs extends CancellationEventArgsBase {\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 point system for pronunciation score calibration; default value is FivePoint.\r\n * Added in version 1.15.0\r\n * @class PronunciationAssessmentGradingSystem\r\n */\r\nexport enum PronunciationAssessmentGradingSystem {\r\n /**\r\n * Five point calibration\r\n * @member PronunciationAssessmentGradingSystem.FivePoint\r\n */\r\n FivePoint = 1,\r\n\r\n /**\r\n * Hundred mark\r\n * @member PronunciationAssessmentGradingSystem.HundredMark\r\n */\r\n HundredMark,\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 pronunciation evaluation granularity; default value is Phoneme.\r\n * Added in version 1.15.0\r\n * @class PronunciationAssessmentGranularity\r\n */\r\nexport enum PronunciationAssessmentGranularity {\r\n /**\r\n * Shows the score on the full text, word and phoneme level\r\n * @member PronunciationAssessmentGranularity.Phoneme\r\n */\r\n Phoneme = 1,\r\n\r\n /**\r\n * Shows the score on the full text and word level\r\n * @member PronunciationAssessmentGranularity.Word\r\n */\r\n Word,\r\n\r\n /**\r\n * Shows the score on the full text level only\r\n * @member PronunciationAssessmentGranularity.FullText\r\n */\r\n FullText,\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ServiceRecognizerBase } from \"../common.speech/ServiceRecognizerBase.js\";\r\nimport { Contracts } from \"./Contracts.js\";\r\nimport {\r\n PronunciationAssessmentGradingSystem,\r\n PronunciationAssessmentGranularity,\r\n PropertyCollection,\r\n PropertyId,\r\n Recognizer\r\n} from \"./Exports.js\";\r\n\r\ninterface PronunciationAssessmentJSON {\r\n referenceText: string;\r\n gradingSystem: string;\r\n granularity: string;\r\n phonemeAlphabet: string;\r\n nbestPhonemeCount: number;\r\n dimension: string;\r\n enableMiscue: boolean;\r\n enableProsodyAssessment: boolean;\r\n}\r\n\r\n/**\r\n * Pronunciation assessment configuration.\r\n * @class PronunciationAssessmentConfig\r\n * Added in version 1.15.0.\r\n */\r\nexport class PronunciationAssessmentConfig {\r\n private privProperties: PropertyCollection;\r\n private privPhonemeAlphabet: string;\r\n private privNBestPhonemeCount: number;\r\n private privEnableProsodyAssessment: boolean;\r\n private privContentAssessmentTopic: string;\r\n\r\n /**\r\n * PronunciationAssessmentConfig constructor.\r\n * @constructor\r\n * @param {string} referenceText\r\n * @param gradingSystem\r\n * @param granularity\r\n * @param enableMiscue\r\n */\r\n public constructor(referenceText: string,\r\n gradingSystem: PronunciationAssessmentGradingSystem = PronunciationAssessmentGradingSystem.FivePoint,\r\n granularity: PronunciationAssessmentGranularity = PronunciationAssessmentGranularity.Phoneme,\r\n enableMiscue: boolean = false) {\r\n Contracts.throwIfNullOrUndefined(referenceText, \"referenceText\");\r\n this.privProperties = new PropertyCollection();\r\n this.privProperties.setProperty(PropertyId.PronunciationAssessment_ReferenceText, referenceText);\r\n this.privProperties.setProperty(PropertyId.PronunciationAssessment_GradingSystem, PronunciationAssessmentGradingSystem[gradingSystem]);\r\n this.privProperties.setProperty(PropertyId.PronunciationAssessment_Granularity, PronunciationAssessmentGranularity[granularity]);\r\n this.privProperties.setProperty(PropertyId.PronunciationAssessment_EnableMiscue, String(enableMiscue));\r\n }\r\n\r\n /**\r\n * @member PronunciationAssessmentConfig.fromJSON\r\n * @function\r\n * @public\r\n * @param {string} json The json string containing the pronunciation assessment parameters.\r\n * @return {PronunciationAssessmentConfig} Instance of PronunciationAssessmentConfig\r\n * @summary Creates an instance of the PronunciationAssessmentConfig from json.\r\n * This method is designed to support the pronunciation assessment parameters still in preview.\r\n * Under normal circumstances, use the constructor instead.\r\n */\r\n public static fromJSON(json: string): PronunciationAssessmentConfig {\r\n Contracts.throwIfNullOrUndefined(json, \"json\");\r\n const config = new PronunciationAssessmentConfig(\"\");\r\n config.privProperties = new PropertyCollection();\r\n config.properties.setProperty(PropertyId.PronunciationAssessment_Json, json);\r\n return config;\r\n }\r\n\r\n public toJSON(): string {\r\n this.updateJson();\r\n return this.privProperties.getProperty(PropertyId.PronunciationAssessment_Params);\r\n }\r\n\r\n public applyTo(recognizer: Recognizer): void {\r\n this.updateJson();\r\n const recoBase = recognizer.internalData as ServiceRecognizerBase;\r\n recoBase.expectContentAssessmentResponse = !!this.privContentAssessmentTopic;\r\n recoBase.speechContext.setPronunciationAssessmentParams(\r\n this.properties.getProperty(PropertyId.PronunciationAssessment_Params),\r\n this.privContentAssessmentTopic,\r\n recoBase.isSpeakerDiarizationEnabled);\r\n }\r\n\r\n /**\r\n * Gets the reference text.\r\n * @member PronunciationAssessmentConfig.prototype.referenceText\r\n * @function\r\n * @public\r\n * @returns {string} Reference text.\r\n */\r\n public get referenceText(): string {\r\n return this.properties.getProperty(PropertyId.PronunciationAssessment_ReferenceText);\r\n }\r\n\r\n /**\r\n * Gets/Sets the reference text.\r\n * @member PronunciationAssessmentConfig.prototype.referenceText\r\n * @function\r\n * @public\r\n * @param {string} referenceText - Reference text.\r\n */\r\n public set referenceText(referenceText: string) {\r\n Contracts.throwIfNullOrWhitespace(referenceText, \"referenceText\");\r\n this.properties.setProperty(PropertyId.PronunciationAssessment_ReferenceText, referenceText);\r\n }\r\n\r\n /**\r\n * Sets the phoneme alphabet.\r\n * The valid values are \"SAPI\" (default) and \"IPA\".\r\n * Added in version 1.20.0\r\n * @member PronunciationAssessmentConfig.prototype.phonemeAlphabet\r\n * @function\r\n * @public\r\n * @param {string} phonemeAlphabet - Phoneme alphabet.\r\n */\r\n public set phonemeAlphabet(phonemeAlphabet: string) {\r\n Contracts.throwIfNullOrWhitespace(phonemeAlphabet, \"phonemeAlphabet\");\r\n this.privPhonemeAlphabet = phonemeAlphabet;\r\n }\r\n\r\n /**\r\n * Sets the boolean enableMiscue property.\r\n * Added in version 1.26.0\r\n * @member PronunciationAssessmentConfig.prototype.enableMiscue\r\n * @function\r\n * @public\r\n * @param {boolean} enableMiscue - enable miscue.\r\n */\r\n public set enableMiscue(enableMiscue: boolean) {\r\n const enableMiscueString = enableMiscue ? \"true\" : \"false\";\r\n this.properties.setProperty(PropertyId.PronunciationAssessment_EnableMiscue, enableMiscueString);\r\n }\r\n\r\n /**\r\n * Gets the boolean enableMiscue property.\r\n * Added in version 1.26.0\r\n * @member PronunciationAssessmentConfig.prototype.enableMiscue\r\n * @function\r\n * @public\r\n * @return {boolean} enableMiscue - enable miscue.\r\n */\r\n public get enableMiscue(): boolean {\r\n const enableMiscueString = this.properties.getProperty(PropertyId.PronunciationAssessment_EnableMiscue, \"false\");\r\n return (enableMiscueString.toLowerCase() === \"true\");\r\n }\r\n\r\n /**\r\n * Sets the nbest phoneme count\r\n * Added in version 1.20.0\r\n * @member PronunciationAssessmentConfig.prototype.nbestPhonemeCount\r\n * @function\r\n * @public\r\n * @param {number} nbestPhonemeCount - NBest phoneme count.\r\n */\r\n public set nbestPhonemeCount(nbestPhonemeCount: number) {\r\n this.privNBestPhonemeCount = nbestPhonemeCount;\r\n }\r\n\r\n /**\r\n * Enables the prosody assessment.\r\n * Added in version 1.34.0\r\n * @member PronunciationAssessmentConfig.prototype.enableProsodyAssessment\r\n * @function\r\n * @public\r\n * @param {boolean} enableProsodyAssessment - enable prosody assessment.\r\n */\r\n public set enableProsodyAssessment(enableProsodyAssessment: boolean) {\r\n this.privEnableProsodyAssessment = enableProsodyAssessment;\r\n }\r\n\r\n /**\r\n * Enables content assessment and sets the topic.\r\n * Added in version 1.34.0\r\n * @member PronunciationAssessmentConfig.prototype.enableContentAssessmentWithTopic\r\n * @function\r\n * @public\r\n * @param {string} topic - Topic for content assessment.\r\n */\r\n public enableContentAssessmentWithTopic(topic: string): void {\r\n this.privContentAssessmentTopic = topic;\r\n }\r\n\r\n /**\r\n * @member PronunciationAssessmentConfig.prototype.properties\r\n * @function\r\n * @public\r\n * @return {PropertyCollection} Properties of the config.\r\n * @summary Gets a pronunciation assessment config properties\r\n */\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n private updateJson(): void {\r\n const jsonString = this.privProperties.getProperty(PropertyId.PronunciationAssessment_Json, \"{}\");\r\n const paramsJson: PronunciationAssessmentJSON = JSON.parse(jsonString) as PronunciationAssessmentJSON;\r\n\r\n const referenceText = this.privProperties.getProperty(PropertyId.PronunciationAssessment_ReferenceText);\r\n if (referenceText) {\r\n paramsJson.referenceText = referenceText;\r\n }\r\n\r\n const gradingSystem = this.privProperties.getProperty(PropertyId.PronunciationAssessment_GradingSystem);\r\n if (gradingSystem) {\r\n paramsJson.gradingSystem = gradingSystem;\r\n }\r\n\r\n const granularity = this.privProperties.getProperty(PropertyId.PronunciationAssessment_Granularity);\r\n if (granularity) {\r\n paramsJson.granularity = granularity;\r\n }\r\n\r\n if (this.privPhonemeAlphabet) {\r\n paramsJson.phonemeAlphabet = this.privPhonemeAlphabet;\r\n }\r\n\r\n if (this.privNBestPhonemeCount) {\r\n paramsJson.nbestPhonemeCount = this.privNBestPhonemeCount;\r\n }\r\n\r\n paramsJson.enableProsodyAssessment = this.privEnableProsodyAssessment;\r\n\r\n // always set dimension to Comprehensive\r\n paramsJson.dimension = \"Comprehensive\";\r\n\r\n const enableMiscueString = this.privProperties.getProperty(PropertyId.PronunciationAssessment_EnableMiscue);\r\n if (enableMiscueString) {\r\n paramsJson.enableMiscue = this.enableMiscue;\r\n }\r\n\r\n this.privProperties.setProperty(PropertyId.PronunciationAssessment_Params, JSON.stringify(paramsJson));\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/* eslint-disable max-classes-per-file */\r\n\r\nimport {Contracts} from \"./Contracts.js\";\r\nimport {\r\n PropertyId,\r\n RecognitionResult\r\n} from \"./Exports.js\";\r\n\r\ninterface AssessmentResult {\r\n NBest: DetailResult[];\r\n}\r\n\r\ninterface DetailResult {\r\n Words: WordResult[];\r\n PronunciationAssessment: {\r\n AccuracyScore: number;\r\n CompletenessScore: number;\r\n FluencyScore: number;\r\n PronScore: number;\r\n ProsodyScore: number;\r\n };\r\n ContentAssessment: {\r\n GrammarScore: number;\r\n VocabularyScore: number;\r\n TopicScore: number;\r\n };\r\n}\r\n\r\ninterface WordResult {\r\n Word: string;\r\n Phonemes: {\r\n Phoneme?: string;\r\n PronunciationAssessment?: {\r\n NBestPhonemes: { Phoneme: string }[];\r\n };\r\n }[];\r\n PronunciationAssessment?: {\r\n AccuracyScore: number;\r\n ErrorType: string;\r\n };\r\n Syllables: { Syllable: string }[];\r\n}\r\n\r\nexport class ContentAssessmentResult {\r\n private privPronJson: DetailResult;\r\n\r\n /**\r\n * @Internal\r\n * Do not use externally.\r\n */\r\n public constructor(detailResult: DetailResult) {\r\n this.privPronJson = detailResult;\r\n }\r\n\r\n /**\r\n * Correctness in using grammar and variety of sentence patterns.\r\n * Grammatical errors are jointly evaluated by lexical accuracy,\r\n * grammatical accuracy and diversity of sentence structures.\r\n * @member ContentAssessmentResult.prototype.grammarScore\r\n * @function\r\n * @public\r\n * @returns {number} Grammar score.\r\n */\r\n public get grammarScore(): number {\r\n return this.privPronJson.ContentAssessment.GrammarScore;\r\n }\r\n\r\n /**\r\n * Proficiency in lexical usage. It evaluates the speaker's effective usage\r\n * of words and their appropriateness within the given context to express\r\n * ideas accurately, as well as level of lexical complexity.\r\n * @member ContentAssessmentResult.prototype.vocabularyScore\r\n * @function\r\n * @public\r\n * @returns {number} Vocabulary score.\r\n */\r\n public get vocabularyScore(): number {\r\n return this.privPronJson.ContentAssessment.VocabularyScore;\r\n }\r\n\r\n /**\r\n * Level of understanding and engagement with the topic, which provides\r\n * insights into the speaker’s ability to express their thoughts and ideas\r\n * effectively and the ability to engage with the topic.\r\n * @member ContentAssessmentResult.prototype.topicScore\r\n * @function\r\n * @public\r\n * @returns {number} Topic score.\r\n */\r\n public get topicScore(): number {\r\n return this.privPronJson.ContentAssessment.TopicScore;\r\n }\r\n}\r\n\r\n/**\r\n * Pronunciation assessment results.\r\n * @class PronunciationAssessmentResult\r\n * Added in version 1.15.0.\r\n */\r\nexport class PronunciationAssessmentResult {\r\n private privPronJson: DetailResult;\r\n\r\n private constructor(jsonString: string) {\r\n const j = JSON.parse(jsonString) as AssessmentResult;\r\n Contracts.throwIfNullOrUndefined(j.NBest[0], \"NBest\");\r\n this.privPronJson = j.NBest[0];\r\n }\r\n\r\n /**\r\n * @member PronunciationAssessmentResult.fromResult\r\n * @function\r\n * @public\r\n * @param {RecognitionResult} result The recognition result.\r\n * @return {PronunciationAssessmentConfig} Instance of PronunciationAssessmentConfig\r\n * @summary Creates an instance of the PronunciationAssessmentResult from recognition result.\r\n */\r\n public static fromResult(result: RecognitionResult): PronunciationAssessmentResult {\r\n Contracts.throwIfNullOrUndefined(result, \"result\");\r\n const json: string = result.properties.getProperty(PropertyId.SpeechServiceResponse_JsonResult);\r\n Contracts.throwIfNullOrUndefined(json, \"json\");\r\n return new PronunciationAssessmentResult(json);\r\n }\r\n\r\n /**\r\n * Gets the detail result of pronunciation assessment.\r\n * @member PronunciationAssessmentConfig.prototype.detailResult\r\n * @function\r\n * @public\r\n * @returns {DetailResult} detail result.\r\n */\r\n public get detailResult(): DetailResult {\r\n return this.privPronJson;\r\n }\r\n\r\n /**\r\n * The score indicating the pronunciation accuracy of the given speech, which indicates\r\n * how closely the phonemes match a native speaker's pronunciation.\r\n * @member PronunciationAssessmentResult.prototype.accuracyScore\r\n * @function\r\n * @public\r\n * @returns {number} Accuracy score.\r\n */\r\n public get accuracyScore(): number {\r\n return this.detailResult.PronunciationAssessment?.AccuracyScore;\r\n }\r\n\r\n /**\r\n * The overall score indicating the pronunciation quality of the given speech.\r\n * This is calculated from AccuracyScore, FluencyScore and CompletenessScore with weight.\r\n * @member PronunciationAssessmentResult.prototype.pronunciationScore\r\n * @function\r\n * @public\r\n * @returns {number} Pronunciation score.\r\n */\r\n public get pronunciationScore(): number {\r\n return this.detailResult.PronunciationAssessment?.PronScore;\r\n }\r\n\r\n /**\r\n * The score indicating the completeness of the given speech by calculating the ratio of pronounced words towards entire input.\r\n * @member PronunciationAssessmentResult.prototype.completenessScore\r\n * @function\r\n * @public\r\n * @returns {number} Completeness score.\r\n */\r\n public get completenessScore(): number {\r\n return this.detailResult.PronunciationAssessment?.CompletenessScore;\r\n }\r\n\r\n /**\r\n * The score indicating the fluency of the given speech.\r\n * @member PronunciationAssessmentResult.prototype.fluencyScore\r\n * @function\r\n * @public\r\n * @returns {number} Fluency score.\r\n */\r\n public get fluencyScore(): number {\r\n return this.detailResult.PronunciationAssessment?.FluencyScore;\r\n }\r\n\r\n /**\r\n * The prosody score, which indicates how nature of the given speech, including stress, intonation, speaking speed and rhythm.\r\n * @member PronunciationAssessmentResult.prototype.prosodyScore\r\n * @function\r\n * @public\r\n * @returns {number} Prosody score.\r\n */\r\n public get prosodyScore(): number {\r\n return this.detailResult.PronunciationAssessment?.ProsodyScore;\r\n }\r\n\r\n /**\r\n * The concent assessment result.\r\n * Only available when content assessment is enabled.\r\n * @member PronunciationAssessmentResult.prototype.contentAssessmentResult\r\n * @function\r\n * @public\r\n * @returns {ContentAssessmentResult} Content assessment result.\r\n */\r\n public get contentAssessmentResult(): ContentAssessmentResult {\r\n if (this.detailResult.ContentAssessment === undefined) {\r\n return undefined;\r\n }\r\n return new ContentAssessmentResult(this.detailResult);\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.js\";\r\nimport { AvatarVideoFormat } from \"./Exports.js\";\r\n\r\n/**\r\n * Defines the talking avatar configuration.\r\n * @class AvatarConfig\r\n * Added in version 1.33.0\r\n *\r\n * @experimental This feature is experimental and might change or have limited support.\r\n */\r\nexport class AvatarConfig {\r\n private privCustomized: boolean = false;\r\n private privBackgroundColor: string;\r\n\r\n /**\r\n * Defines the avatar character.\r\n */\r\n public character: string;\r\n /**\r\n * Defines the avatar style.\r\n */\r\n public style: string;\r\n /**\r\n * Defines the talking avatar output video format.\r\n */\r\n public videoFormat: AvatarVideoFormat;\r\n\r\n /**\r\n * Indicates if the talking avatar is customized.\r\n */\r\n public get customized(): boolean {\r\n return this.privCustomized;\r\n }\r\n\r\n /**\r\n * Sets if the talking avatar is customized.\r\n */\r\n public set customized(value: boolean) {\r\n this.privCustomized = value;\r\n }\r\n\r\n /**\r\n * Sets the background color.\r\n */\r\n public get backgroundColor(): string {\r\n return this.privBackgroundColor;\r\n }\r\n\r\n /**\r\n * Gets the background color.\r\n */\r\n public set backgroundColor(value: string) {\r\n this.privBackgroundColor = value;\r\n }\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {string} character - The avatar character.\r\n * @param {string} style - The avatar style.\r\n * @param {AvatarVideoFormat} videoFormat - The talking avatar output video format.\r\n */\r\n public constructor(character: string, style: string, videoFormat: AvatarVideoFormat) {\r\n Contracts.throwIfNullOrWhitespace(character, \"character\");\r\n this.character = character;\r\n this.style = style;\r\n if (videoFormat === undefined) {\r\n videoFormat = new AvatarVideoFormat();\r\n }\r\n this.videoFormat = videoFormat;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nexport enum AvatarEventTypes {\r\n SwitchedToSpeaking = \"SwitchedToSpeaking\",\r\n SwitchedToIdle = \"SwitchedToIdle\",\r\n SessionClosed = \"SessionClosed\",\r\n}\r\n\r\n/**\r\n * Defines content for talking avatar events.\r\n * @class AvatarEventArgs\r\n * Added in version 1.33.0\r\n *\r\n * @experimental This feature is experimental and might change or have limited support.\r\n */\r\nexport class AvatarEventArgs {\r\n private privType: AvatarEventTypes;\r\n private privOffset: number;\r\n private privDescription: string;\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} description - The description of the event.\r\n */\r\n public constructor(audioOffset: number, description: string) {\r\n this.privOffset = audioOffset;\r\n this.privDescription = description;\r\n }\r\n\r\n /**\r\n * The type of the event.\r\n * @public\r\n * @returns {AvatarEventTypes} The type of the event.\r\n */\r\n public get type(): AvatarEventTypes {\r\n return this.privType;\r\n }\r\n\r\n /**\r\n * The time offset associated with this event.\r\n * @public\r\n * @returns {number} The time offset associated with this event.\r\n */\r\n public get offset(): number {\r\n return this.privOffset;\r\n }\r\n\r\n /**\r\n * The description of the event.\r\n * @public\r\n * @returns {string} The description of the event.\r\n */\r\n public get description(): string {\r\n return this.privDescription;\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.js\";\r\nimport {\r\n IConnection,\r\n IStringDictionary\r\n} from \"../common/Exports.js\";\r\nimport { PropertyId } from \"../sdk/Exports.js\";\r\nimport { ConnectionFactoryBase } from \"./ConnectionFactoryBase.js\";\r\nimport {\r\n AuthInfo,\r\n SynthesizerConfig,\r\n WebsocketMessageFormatter\r\n} from \"./Exports.js\";\r\nimport { HeaderNames } from \"./HeaderNames.js\";\r\nimport { ISynthesisConnectionFactory } from \"./ISynthesisConnectionFactory.js\";\r\nimport {\r\n QueryParameterNames\r\n} from \"./QueryParameterNames.js\";\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: string = ConnectionFactoryBase.getHostSuffix(region);\r\n const endpointId = config.parameters.getProperty(PropertyId.SpeechServiceConnection_EndpointId, undefined);\r\n const hostPrefix = (endpointId === undefined) ? \"tts\" : \"voice\";\r\n const host: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, \"wss://\" + region + \".\" + hostPrefix + \".speech\" + hostSuffix);\r\n\r\n const queryParams: IStringDictionary<string> = {};\r\n const headers: IStringDictionary<string> = {};\r\n\r\n if (authInfo.token !== undefined && authInfo.token !== \"\") {\r\n headers[authInfo.headerName] = authInfo.token;\r\n }\r\n headers[HeaderNames.ConnectionId] = connectionId;\r\n if (endpointId !== undefined && endpointId !== \"\") {\r\n if (!endpoint || endpoint.search(QueryParameterNames.CustomVoiceDeploymentId) === -1) {\r\n queryParams[QueryParameterNames.CustomVoiceDeploymentId] = endpointId;\r\n }\r\n }\r\n\r\n if (config.avatarEnabled) {\r\n if (!endpoint || endpoint.search(QueryParameterNames.EnableAvatar) === -1) {\r\n queryParams[QueryParameterNames.EnableAvatar] = \"true\";\r\n }\r\n }\r\n\r\n if (!endpoint) {\r\n endpoint = host + this.synthesisUri;\r\n }\r\n\r\n config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, endpoint);\r\n\r\n const enableCompression: boolean = config.parameters.getProperty(\"SPEECH-EnableWebsocketCompression\", \"false\") === \"true\";\r\n return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromParameters(config.parameters), enableCompression, 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 { SpeechSynthesisConnectionFactory } from \"../common.speech/SpeechSynthesisConnectionFactory.js\";\r\nimport { SynthesisRestAdapter } from \"../common.speech/SynthesisRestAdapter.js\";\r\nimport { SynthesizerConfig } from \"../common.speech/SynthesizerConfig.js\";\r\nimport {\r\n AvatarSynthesisAdapter,\r\n IAuthentication,\r\n ISynthesisConnectionFactory,\r\n SpeechServiceConfig,\r\n SynthesisAdapterBase\r\n} from \"../common.speech/Exports.js\";\r\nimport { createNoDashGuid, Deferred, Events, EventType, PlatformEvent } from \"../common/Exports.js\";\r\nimport { AudioOutputFormatImpl } from \"./Audio/AudioOutputFormat.js\";\r\nimport {\r\n AvatarConfig,\r\n AvatarEventArgs,\r\n PropertyCollection,\r\n PropertyId,\r\n ResultReason,\r\n SpeechConfig,\r\n SpeechSynthesisOutputFormat,\r\n SpeechSynthesisResult,\r\n SynthesisResult,\r\n Synthesizer\r\n} from \"./Exports.js\";\r\nimport { Contracts } from \"./Contracts.js\";\r\nimport { SynthesisRequest } from \"./Synthesizer.js\";\r\n\r\n/**\r\n * Defines the avatar synthesizer.\r\n * @class AvatarSynthesizer\r\n * Added in version 1.33.0\r\n *\r\n * @experimental This feature is experimental and might change or have limited support.\r\n */\r\nexport class AvatarSynthesizer extends Synthesizer {\r\n protected privProperties: PropertyCollection;\r\n private privAvatarConfig: AvatarConfig;\r\n private privIceServers: RTCIceServer[];\r\n /**\r\n * Defines event handler for avatar events.\r\n * @member AvatarSynthesizer.prototype.avatarEventReceived\r\n * @function\r\n * @public\r\n */\r\n public avatarEventReceived: (sender: AvatarSynthesizer, event: AvatarEventArgs) => void;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {SpeechConfig} speechConfig - The speech config.\r\n * @param {AvatarConfig} avatarConfig - The talking avatar config.\r\n */\r\n public constructor(speechConfig: SpeechConfig, avatarConfig: AvatarConfig) {\r\n super(speechConfig);\r\n\r\n Contracts.throwIfNullOrUndefined(avatarConfig, \"avatarConfig\");\r\n\r\n this.privConnectionFactory = new SpeechSynthesisConnectionFactory();\r\n this.privAvatarConfig = avatarConfig;\r\n this.implCommonSynthesizeSetup();\r\n }\r\n\r\n protected implCommonSynthesizeSetup(): void {\r\n super.implCommonSynthesizeSetup();\r\n\r\n // The service checks the audio format setting while it ignores it in avatar synthesis.\r\n this.privAdapter.audioOutputFormat = AudioOutputFormatImpl.fromSpeechSynthesisOutputFormat(\r\n SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm\r\n );\r\n }\r\n\r\n /**\r\n * Starts the talking avatar session and establishes the WebRTC connection.\r\n * @member AvatarSynthesizer.prototype.startAvatarAsync\r\n * @function\r\n * @public\r\n * @param {AvatarWebRTCConnectionInfo} peerConnection - The peer connection.\r\n * @returns {Promise<SynthesisResult>} The promise of the connection result.\r\n */\r\n public async startAvatarAsync(peerConnection: RTCPeerConnection): Promise<SynthesisResult> {\r\n Contracts.throwIfNullOrUndefined(peerConnection, \"peerConnection\");\r\n this.privIceServers = peerConnection.getConfiguration().iceServers;\r\n Contracts.throwIfNullOrUndefined(this.privIceServers, \"Ice servers must be set.\");\r\n const iceGatheringDone = new Deferred<void>();\r\n // https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/icegatheringstatechange_event\r\n peerConnection.onicegatheringstatechange = (): void => {\r\n Events.instance.onEvent(new PlatformEvent(\"peer connection: ice gathering state: \" + peerConnection.iceGatheringState, EventType.Debug));\r\n if (peerConnection.iceGatheringState === \"complete\") {\r\n Events.instance.onEvent(new PlatformEvent(\"peer connection: ice gathering complete.\", EventType.Info));\r\n iceGatheringDone.resolve();\r\n }\r\n };\r\n peerConnection.onicecandidate = (event: RTCPeerConnectionIceEvent): void => {\r\n if (event.candidate) {\r\n Events.instance.onEvent(new PlatformEvent(\"peer connection: ice candidate: \" + event.candidate.candidate, EventType.Debug));\r\n } else {\r\n Events.instance.onEvent(new PlatformEvent(\"peer connection: ice candidate: complete\", EventType.Debug));\r\n iceGatheringDone.resolve();\r\n }\r\n };\r\n // Set a timeout for ice gathering, currently 2 seconds.\r\n setTimeout((): void => {\r\n if (peerConnection.iceGatheringState !== \"complete\") {\r\n Events.instance.onEvent(new PlatformEvent(\"peer connection: ice gathering timeout.\", EventType.Warning));\r\n iceGatheringDone.resolve();\r\n }\r\n }, 2000);\r\n const sdp: RTCSessionDescriptionInit = await peerConnection.createOffer();\r\n await peerConnection.setLocalDescription(sdp);\r\n await iceGatheringDone.promise;\r\n Events.instance.onEvent(new PlatformEvent(\"peer connection: got local SDP.\", EventType.Info));\r\n this.privProperties.setProperty(PropertyId.TalkingAvatarService_WebRTC_SDP, JSON.stringify(peerConnection.localDescription));\r\n\r\n const result: SpeechSynthesisResult = await this.speak(\"\", false);\r\n if (result.reason !== ResultReason.SynthesizingAudioCompleted) {\r\n return new SynthesisResult(\r\n result.resultId,\r\n result.reason,\r\n result.errorDetails,\r\n result.properties,\r\n );\r\n }\r\n const sdpAnswerString: string = atob(result.properties.getProperty(PropertyId.TalkingAvatarService_WebRTC_SDP));\r\n const sdpAnswer: RTCSessionDescription = new RTCSessionDescription(\r\n JSON.parse(sdpAnswerString) as RTCSessionDescriptionInit,\r\n );\r\n await peerConnection.setRemoteDescription(sdpAnswer);\r\n return new SynthesisResult(\r\n result.resultId,\r\n result.reason,\r\n undefined,\r\n result.properties,\r\n );\r\n }\r\n\r\n /**\r\n * Speaks plain text asynchronously. The rendered audio and video will be sent via the WebRTC connection.\r\n * @member AvatarSynthesizer.prototype.speakTextAsync\r\n * @function\r\n * @public\r\n * @param {string} text - The plain text to speak.\r\n * @returns {Promise<SynthesisResult>} The promise of the synthesis result.\r\n */\r\n public async speakTextAsync(text: string): Promise<SynthesisResult> {\r\n const r = await this.speak(text, false);\r\n return new SynthesisResult(\r\n r.resultId,\r\n r.reason,\r\n r.errorDetails,\r\n r.properties,\r\n );\r\n }\r\n\r\n /**\r\n * Speaks SSML asynchronously. The rendered audio and video will be sent via the WebRTC connection.\r\n * @member AvatarSynthesizer.prototype.speakSsmlAsync\r\n * @function\r\n * @public\r\n * @param {string} ssml - The SSML text to speak.\r\n * @returns {Promise<SynthesisResult>} The promise of the synthesis result.\r\n */\r\n public async speakSsmlAsync(ssml: string): Promise<SynthesisResult> {\r\n const r = await this.speak(ssml, true);\r\n return new SynthesisResult(\r\n r.resultId,\r\n r.reason,\r\n r.errorDetails,\r\n r.properties,\r\n );\r\n }\r\n\r\n /**\r\n * Speaks text asynchronously. The avatar will switch to idle state.\r\n * @member AvatarSynthesizer.prototype.stopSpeakingAsync\r\n * @function\r\n * @public\r\n * @returns {Promise<void>} The promise of the void result.\r\n */\r\n public async stopSpeakingAsync(): Promise<void> {\r\n while (this.synthesisRequestQueue.length() > 0) {\r\n const request = await this.synthesisRequestQueue.dequeue();\r\n request.err(\"Synthesis is canceled by user.\");\r\n }\r\n return this.privAdapter.stopSpeaking();\r\n }\r\n\r\n /**\r\n * Stops the talking avatar session and closes the WebRTC connection.\r\n * For now, this is the same as close().\r\n * You need to create a new AvatarSynthesizer instance to start a new session.\r\n * @member AvatarSynthesizer.prototype.stopAvatarAsync\r\n * @function\r\n * @public\r\n * @returns {Promise<void>} The promise of the void result.\r\n */\r\n public async stopAvatarAsync(): Promise<void> {\r\n Contracts.throwIfDisposed(this.privDisposed);\r\n return this.dispose(true);\r\n }\r\n\r\n /**\r\n * Dispose of associated resources.\r\n * @member AvatarSynthesizer.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public async close(): Promise<void> {\r\n if (this.privDisposed) {\r\n return;\r\n }\r\n\r\n return this.dispose(true);\r\n }\r\n\r\n /**\r\n * Gets the ICE servers. Internal use only.\r\n */\r\n public get iceServers(): RTCIceServer[] {\r\n return this.privIceServers;\r\n }\r\n\r\n // Creates the synthesis adapter\r\n protected createSynthesisAdapter(\r\n authentication: IAuthentication,\r\n connectionFactory: ISynthesisConnectionFactory,\r\n synthesizerConfig: SynthesizerConfig): SynthesisAdapterBase {\r\n return new AvatarSynthesisAdapter(\r\n authentication,\r\n connectionFactory,\r\n synthesizerConfig,\r\n this,\r\n this.privAvatarConfig);\r\n }\r\n\r\n protected createRestSynthesisAdapter(\r\n _authentication: IAuthentication,\r\n _synthesizerConfig: SynthesizerConfig): SynthesisRestAdapter {\r\n return undefined;\r\n }\r\n\r\n protected createSynthesizerConfig(speechConfig: SpeechServiceConfig): SynthesizerConfig {\r\n const config = super.createSynthesizerConfig(speechConfig);\r\n config.avatarEnabled = true;\r\n return config;\r\n }\r\n\r\n protected async speak(text: string, isSSML: boolean): Promise<SpeechSynthesisResult> {\r\n const requestId = createNoDashGuid();\r\n const deferredResult = new Deferred<SpeechSynthesisResult>();\r\n this.synthesisRequestQueue.enqueue(new SynthesisRequest(requestId, text, isSSML,\r\n (e: SpeechSynthesisResult): void => {\r\n deferredResult.resolve(e);\r\n this.privSynthesizing = false;\r\n void this.adapterSpeak();\r\n },\r\n (e: string): void => {\r\n deferredResult.reject(e);\r\n this.privSynthesizing = false;\r\n }));\r\n void this.adapterSpeak();\r\n return deferredResult.promise;\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/* eslint-disable max-classes-per-file */\r\n\r\n/**\r\n * Defines a coordinate in 2D space.\r\n * @class Coordinate\r\n * Added in version 1.33.0\r\n */\r\nexport class Coordinate {\r\n public x: number;\r\n public y: number;\r\n\r\n public constructor(x: number, y: number) {\r\n this.x = x;\r\n this.y = y;\r\n }\r\n}\r\n\r\n/**\r\n * Defines the avatar output video format.\r\n * @class AvatarVideoFormat\r\n * Added in version 1.33.0\r\n *\r\n * @experimental This feature is experimental and might change in the future.\r\n */\r\nexport class AvatarVideoFormat {\r\n /**\r\n * Defines the video codec.\r\n * @default \"H264\"\r\n */\r\n public codec: string;\r\n /**\r\n * Defines the video bitrate.\r\n * @default 2000000\r\n */\r\n public bitrate: number;\r\n /**\r\n * Defines the video width.\r\n * @default 1920\r\n */\r\n public width: number;\r\n /**\r\n * Defines the video height.\r\n * @default 1080\r\n */\r\n public height: number;\r\n\r\n /**\r\n * Sets the video crop range.\r\n */\r\n public setCropRange(topLeft: Coordinate, bottomRight: Coordinate): void {\r\n this.cropRange = {\r\n bottomRight,\r\n topLeft,\r\n };\r\n }\r\n\r\n /**\r\n * Defines the video crop range.\r\n * @default undefined\r\n * @internal\r\n */\r\n public cropRange: {\r\n topLeft: Coordinate;\r\n bottomRight: Coordinate;\r\n };\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {string} codec - The video codec.\r\n * @param {number} bitrate - The video bitrate.\r\n * @param {number} width - The video width.\r\n * @param {number} height - The video height.\r\n */\r\n public constructor(codec: string = \"H264\",\r\n bitrate: number = 2000000,\r\n width: number = 1920,\r\n height: number = 1080,\r\n ) {\r\n this.codec = codec;\r\n this.bitrate = bitrate;\r\n this.width = width;\r\n this.height = height;\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 ResultReason,\r\n PropertyCollection,\r\n SynthesisResult\r\n} from \"./Exports.js\";\r\n\r\n/**\r\n * Defines the avatar WebRTC connection result.\r\n * @class AvatarWebRTCConnectionResult\r\n * Added in version 1.33.0\r\n *\r\n * @experimental This feature is experimental and might change in the future.\r\n */\r\nexport class AvatarWebRTCConnectionResult extends SynthesisResult {\r\n private readonly privSDPAnswer: RTCSessionDescriptionInit;\r\n\r\n /**\r\n * Creates and initializes an instance of this class.\r\n * @constructor\r\n * @param {RTCSessionDescriptionInit} SDPAnswer - The SDP answer of WebRTC connection.\r\n * @param {string} resultId - The result id.\r\n * @param {ResultReason} reason - The reason.\r\n * @param {string} errorDetails - Error details, if provided.\r\n * @param {PropertyCollection} properties - Additional properties, if provided.\r\n */\r\n public constructor(SDPAnswer?: RTCSessionDescriptionInit, resultId?: string, reason?: ResultReason, errorDetails?: string, properties?: PropertyCollection) {\r\n super(resultId, reason, errorDetails, properties);\r\n this.privSDPAnswer = SDPAnswer;\r\n }\r\n\r\n /**\r\n * Specifies SDP (Session Description Protocol) answer of WebRTC connection.\r\n * @member AvatarWebRTCConnectionResult.prototype.SDPAnswer\r\n * @function\r\n * @public\r\n * @returns {RTCSessionDescriptionInit} Specifies the SDP answer of WebRTC connection.\r\n */\r\n public get SDPAnswer(): RTCSessionDescriptionInit {\r\n return this.privSDPAnswer;\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 { ConsoleLoggingListener } from \"../common.browser/Exports.js\";\r\nimport { Events } from \"../common/Exports.js\";\r\nimport { LogLevel } from \"./LogLevel.js\";\r\n\r\ntype LogCallback = (s: string) => void;\r\n\r\n/**\r\n * Defines diagnostics API for managing console output\r\n * Added in version 1.21.0\r\n */\r\nexport class Diagnostics {\r\n private static privListener: ConsoleLoggingListener = undefined;\r\n\r\n public static SetLoggingLevel(logLevel: LogLevel): void {\r\n this.privListener = new ConsoleLoggingListener(logLevel);\r\n Events.instance.attachConsoleListener(this.privListener);\r\n }\r\n\r\n public static StartConsoleOutput(): void {\r\n if (!!this.privListener) {\r\n this.privListener.enableConsoleOutput = true;\r\n }\r\n }\r\n\r\n public static StopConsoleOutput(): void {\r\n if (!!this.privListener) {\r\n this.privListener.enableConsoleOutput = false;\r\n }\r\n }\r\n\r\n public static SetLogOutputPath(path: string): void {\r\n if (typeof window === \"undefined\") {\r\n if (!!this.privListener) {\r\n this.privListener.logPath = path;\r\n }\r\n } else {\r\n throw new Error(\"File system logging not available in browser.\");\r\n }\r\n }\r\n\r\n\r\n public static set onLogOutput( callback: LogCallback ) {\r\n if (!!this.privListener) {\r\n this.privListener.logCallback = callback;\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\nexport { AudioConfig } from \"./Audio/AudioConfig.js\";\r\nexport { AudioStreamFormat, AudioFormatTag } from \"./Audio/AudioStreamFormat.js\";\r\nexport { AudioInputStream, PullAudioInputStream, PushAudioInputStream } from \"./Audio/AudioInputStream.js\";\r\nexport { AudioOutputStream, PullAudioOutputStream, PushAudioOutputStream} from \"./Audio/AudioOutputStream.js\";\r\nexport { CancellationReason } from \"./CancellationReason.js\";\r\nexport { PullAudioInputStreamCallback } from \"./Audio/PullAudioInputStreamCallback.js\";\r\nexport { PushAudioOutputStreamCallback } from \"./Audio/PushAudioOutputStreamCallback.js\";\r\nexport { KeywordRecognitionModel } from \"./KeywordRecognitionModel.js\";\r\nexport { SessionEventArgs } from \"./SessionEventArgs.js\";\r\nexport { RecognitionEventArgs } from \"./RecognitionEventArgs.js\";\r\nexport { OutputFormat } from \"./OutputFormat.js\";\r\nexport { IntentRecognitionEventArgs } from \"./IntentRecognitionEventArgs.js\";\r\nexport { RecognitionResult } from \"./RecognitionResult.js\";\r\nexport { SpeechRecognitionResult } from \"./SpeechRecognitionResult.js\";\r\nexport { IntentRecognitionResult } from \"./IntentRecognitionResult.js\";\r\nexport { LanguageUnderstandingModel } from \"./LanguageUnderstandingModel.js\";\r\nexport { SpeechRecognitionEventArgs, ConversationTranscriptionEventArgs, MeetingTranscriptionEventArgs } from \"./SpeechRecognitionEventArgs.js\";\r\nexport { SpeechRecognitionCanceledEventArgs } from \"./SpeechRecognitionCanceledEventArgs.js\";\r\nexport { TranslationRecognitionEventArgs } from \"./TranslationRecognitionEventArgs.js\";\r\nexport { TranslationSynthesisEventArgs } from \"./TranslationSynthesisEventArgs.js\";\r\nexport { TranslationRecognitionResult } from \"./TranslationRecognitionResult.js\";\r\nexport { TranslationSynthesisResult } from \"./TranslationSynthesisResult.js\";\r\nexport { ResultReason } from \"./ResultReason.js\";\r\nexport { SpeechConfig, SpeechConfigImpl } from \"./SpeechConfig.js\";\r\nexport { SpeechTranslationConfig, SpeechTranslationConfigImpl } from \"./SpeechTranslationConfig.js\";\r\nexport { PropertyCollection } from \"./PropertyCollection.js\";\r\nexport { PropertyId } from \"./PropertyId.js\";\r\nexport { Recognizer } from \"./Recognizer.js\";\r\nexport { SpeechRecognizer } from \"./SpeechRecognizer.js\";\r\nexport { IntentRecognizer } from \"./IntentRecognizer.js\";\r\nexport { VoiceProfileType } from \"./VoiceProfileType.js\";\r\nexport { TranslationRecognizer } from \"./TranslationRecognizer.js\";\r\nexport { Translations } from \"./Translations.js\";\r\nexport { NoMatchReason } from \"./NoMatchReason.js\";\r\nexport { NoMatchDetails } from \"./NoMatchDetails.js\";\r\nexport { TranslationRecognitionCanceledEventArgs } from \"./TranslationRecognitionCanceledEventArgs.js\";\r\nexport { IntentRecognitionCanceledEventArgs } from \"./IntentRecognitionCanceledEventArgs.js\";\r\nexport { CancellationDetailsBase } from \"./CancellationDetailsBase.js\";\r\nexport { CancellationDetails } from \"./CancellationDetails.js\";\r\nexport { CancellationErrorCode } from \"./CancellationErrorCodes.js\";\r\nexport { ConnectionEventArgs } from \"./ConnectionEventArgs.js\";\r\nexport { ServiceEventArgs } from \"./ServiceEventArgs.js\";\r\nexport { Connection } from \"./Connection.js\";\r\nexport { PhraseListGrammar } from \"./PhraseListGrammar.js\";\r\nexport { DialogServiceConfig } from \"./DialogServiceConfig.js\";\r\nexport { BotFrameworkConfig } from \"./BotFrameworkConfig.js\";\r\nexport { CustomCommandsConfig } from \"./CustomCommandsConfig.js\";\r\nexport { DialogServiceConnector } from \"./DialogServiceConnector.js\";\r\nexport { ActivityReceivedEventArgs } from \"./ActivityReceivedEventArgs.js\";\r\nexport { TurnStatusReceivedEventArgs } from \"./TurnStatusReceivedEventArgs.js\";\r\nexport { ServicePropertyChannel } from \"./ServicePropertyChannel.js\";\r\nexport { ProfanityOption } from \"./ProfanityOption.js\";\r\nexport { BaseAudioPlayer } from \"./Audio/BaseAudioPlayer.js\";\r\nexport { ConnectionMessageEventArgs } from \"./ConnectionMessageEventArgs.js\";\r\nexport { ConnectionMessage } from \"./ConnectionMessage.js\";\r\nexport { VoiceProfile } from \"./VoiceProfile.js\";\r\nexport { VoiceProfileEnrollmentResult, VoiceProfileEnrollmentCancellationDetails } from \"./VoiceProfileEnrollmentResult.js\";\r\nexport { VoiceProfileResult, VoiceProfileCancellationDetails } from \"./VoiceProfileResult.js\";\r\nexport { VoiceProfilePhraseResult } from \"./VoiceProfilePhraseResult.js\";\r\nexport { VoiceProfileClient } from \"./VoiceProfileClient.js\";\r\nexport { SpeakerRecognizer } from \"./SpeakerRecognizer.js\";\r\nexport { SpeakerIdentificationModel } from \"./SpeakerIdentificationModel.js\";\r\nexport { SpeakerVerificationModel } from \"./SpeakerVerificationModel.js\";\r\nexport { AutoDetectSourceLanguageConfig } from \"./AutoDetectSourceLanguageConfig.js\";\r\nexport { AutoDetectSourceLanguageResult } from \"./AutoDetectSourceLanguageResult.js\";\r\nexport { SourceLanguageConfig } from \"./SourceLanguageConfig.js\";\r\nexport { SpeakerRecognitionResult, SpeakerRecognitionResultType, SpeakerRecognitionCancellationDetails } from \"./SpeakerRecognitionResult.js\";\r\nexport { Conversation,\r\n ConversationExpirationEventArgs,\r\n ConversationInfo,\r\n ConversationParticipantsChangedEventArgs,\r\n ConversationTranslationCanceledEventArgs,\r\n ConversationTranslationEventArgs,\r\n ConversationTranslationResult,\r\n ConversationTranslator,\r\n ConversationTranscriber,\r\n ConversationTranscriptionResult,\r\n Meeting,\r\n MeetingInfo,\r\n MeetingTranscriber,\r\n IParticipant,\r\n Participant,\r\n ParticipantChangedReason,\r\n User,\r\n VoiceSignature\r\n } from \"./Transcription/Exports.js\";\r\nexport { Synthesizer } from \"./Synthesizer.js\";\r\nexport { SpeechSynthesisOutputFormat } from \"./SpeechSynthesisOutputFormat.js\";\r\nexport { SpeechSynthesizer } from \"./SpeechSynthesizer.js\";\r\nexport { SynthesisResult } from \"./SynthesisResult.js\";\r\nexport { SpeechSynthesisResult } from \"./SpeechSynthesisResult.js\";\r\nexport { SpeechSynthesisEventArgs } from \"./SpeechSynthesisEventArgs.js\";\r\nexport { SpeechSynthesisWordBoundaryEventArgs } from \"./SpeechSynthesisWordBoundaryEventArgs.js\";\r\nexport { SpeechSynthesisBookmarkEventArgs } from \"./SpeechSynthesisBookmarkEventArgs.js\";\r\nexport { SpeechSynthesisVisemeEventArgs } from \"./SpeechSynthesisVisemeEventArgs.js\";\r\nexport { SpeechSynthesisBoundaryType } from \"./SpeechSynthesisBoundaryType.js\";\r\nexport { SynthesisVoicesResult } from \"./SynthesisVoicesResult.js\";\r\nexport { VoiceInfo } from \"./VoiceInfo.js\";\r\nexport { IPlayer } from \"./Audio/IPlayer.js\";\r\nexport { SpeakerAudioDestination } from \"./Audio/SpeakerAudioDestination.js\";\r\nexport { CancellationEventArgs } from \"./CancellationEventArgs.js\";\r\nexport { ConversationTranscriptionCanceledEventArgs } from \"./ConversationTranscriptionCanceledEventArgs.js\";\r\nexport { MeetingTranscriptionCanceledEventArgs } from \"./MeetingTranscriptionCanceledEventArgs.js\";\r\nexport { PronunciationAssessmentGradingSystem } from \"./PronunciationAssessmentGradingSystem.js\";\r\nexport { PronunciationAssessmentGranularity } from \"./PronunciationAssessmentGranularity.js\";\r\nexport { PronunciationAssessmentConfig } from \"./PronunciationAssessmentConfig.js\";\r\nexport { PronunciationAssessmentResult } from \"./PronunciationAssessmentResult.js\";\r\nexport { LanguageIdMode } from \"./LanguageIdMode.js\";\r\nexport { AvatarConfig } from \"./AvatarConfig.js\";\r\nexport { AvatarEventArgs } from \"./AvatarEventArgs.js\";\r\nexport { AvatarSynthesizer } from \"./AvatarSynthesizer.js\";\r\nexport { AvatarVideoFormat, Coordinate } from \"./AvatarVideoFormat.js\";\r\nexport { AvatarWebRTCConnectionResult } from \"./AvatarWebRTCConnectionResult.js\";\r\nexport { Diagnostics } from \"./Diagnostics.js\";\r\nexport { LogLevel } from \"./LogLevel.js\";\r\nexport { IVoiceJson } from \"./IVoiceJson.js\";\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.js\";\r\nimport { PropertyCollection, PropertyId } from \"../sdk/Exports.js\";\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","'use strict'\nconst encodings = new Set(['json', 'buffer', 'string'])\n\nmodule.exports = mkrequest => (...args) => {\n const statusCodes = new Set()\n let method\n let encoding\n let headers\n let baseurl = ''\n\n args.forEach(arg => {\n if (typeof arg === 'string') {\n if (arg.toUpperCase() === arg) {\n if (method) {\n const msg = `Can't set method to ${arg}, already set to ${method}.`\n throw new Error(msg)\n } else {\n method = arg\n }\n } else if (arg.startsWith('http:') || arg.startsWith('https:')) {\n baseurl = arg\n } else {\n if (encodings.has(arg)) {\n encoding = arg\n } else {\n throw new Error(`Unknown encoding, ${arg}`)\n }\n }\n } else if (typeof arg === 'number') {\n statusCodes.add(arg)\n } else if (typeof arg === 'object') {\n if (Array.isArray(arg) || arg instanceof Set) {\n arg.forEach(code => statusCodes.add(code))\n } else {\n if (headers) {\n throw new Error('Cannot set headers twice.')\n }\n headers = arg\n }\n } else {\n throw new Error(`Unknown type: ${typeof arg}`)\n }\n })\n\n if (!method) method = 'GET'\n if (statusCodes.size === 0) {\n statusCodes.add(200)\n }\n\n return mkrequest(statusCodes, method, encoding, headers, baseurl)\n}\n","'use strict'\n/* global fetch, btoa, Headers */\nconst core = require('./core')\n\nclass StatusError extends Error {\n constructor (res, ...params) {\n super(...params)\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, StatusError)\n }\n\n this.name = 'StatusError'\n this.message = res.statusMessage\n this.statusCode = res.status\n this.res = res\n this.json = res.json.bind(res)\n this.text = res.text.bind(res)\n this.arrayBuffer = res.arrayBuffer.bind(res)\n let buffer\n const get = () => {\n if (!buffer) buffer = this.arrayBuffer()\n return buffer\n }\n Object.defineProperty(this, 'responseBody', { get })\n // match Node.js headers object\n this.headers = {}\n for (const [key, value] of res.headers.entries()) {\n this.headers[key.toLowerCase()] = value\n }\n }\n}\n\nconst mkrequest = (statusCodes, method, encoding, headers, baseurl) => async (_url, body, _headers = {}) => {\n _url = baseurl + (_url || '')\n let parsed = new URL(_url)\n\n if (!headers) headers = {}\n if (parsed.username) {\n headers.Authorization = 'Basic ' + btoa(parsed.username + ':' + parsed.password)\n parsed = new URL(parsed.protocol + '//' + parsed.host + parsed.pathname + parsed.search)\n }\n if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {\n throw new Error(`Unknown protocol, ${parsed.protocol}`)\n }\n\n if (body) {\n if (body instanceof ArrayBuffer ||\n ArrayBuffer.isView(body) ||\n typeof body === 'string'\n ) {\n // noop\n } else if (typeof body === 'object') {\n body = JSON.stringify(body)\n headers['Content-Type'] = 'application/json'\n } else {\n throw new Error('Unknown body type.')\n }\n }\n\n _headers = new Headers({ ...(headers || {}), ..._headers })\n\n const resp = await fetch(parsed, { method, headers: _headers, body })\n resp.statusCode = resp.status\n\n if (!statusCodes.has(resp.status)) {\n throw new StatusError(resp)\n }\n\n if (encoding === 'json') return resp.json()\n else if (encoding === 'buffer') return resp.arrayBuffer()\n else if (encoding === 'string') return resp.text()\n else return resp\n}\n\nmodule.exports = core(mkrequest)\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport bent, { BentResponse, RequestBody } from \"bent\";\r\nimport {\r\n ArgumentNullError,\r\n Deferred\r\n} from \"../common/Exports.js\";\r\nimport { IRequestOptions } from \"./Exports.js\";\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: any;\r\n headers: string;\r\n}\r\n\r\ninterface JsonError {\r\n error?: {\r\n message: string;\r\n };\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 privIgnoreCache: boolean;\r\n private privHeaders: { [key: string]: string };\r\n\r\n public constructor(\r\n configParams: IRequestOptions\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.privIgnoreCache = configParams.ignoreCache;\r\n }\r\n\r\n public static extractHeaderValue(headerKey: string, headers: string): string {\r\n let headerValue: string = \"\";\r\n\r\n try {\r\n const arr = headers.trim().split(/[\\r\\n]+/);\r\n const headerMap: { [key: string]: string } = {};\r\n arr.forEach((line: string): void => {\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\n public set options(configParams: IRequestOptions) {\r\n this.privHeaders = configParams.headers;\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: { [key: string]: any } = {},\r\n body: any = null,\r\n ): Promise<IRestResponse> {\r\n\r\n const responseReceivedDeferral = new Deferred<IRestResponse>();\r\n\r\n const requestCommand = method === RestRequestType.File ? \"POST\" : method;\r\n const handleRestResponse = (data: BentResponse, j: JsonError = {}): IRestResponse => {\r\n const d: { statusText?: string; statusMessage?: string } = data;\r\n return {\r\n data: JSON.stringify(j),\r\n headers: JSON.stringify(data.headers),\r\n json: j,\r\n ok: data.statusCode >= 200 && data.statusCode < 300,\r\n status: data.statusCode,\r\n statusText: j.error ? j.error.message : d.statusText ? d.statusText : d.statusMessage\r\n };\r\n };\r\n\r\n const send = (postData: RequestBody): void => {\r\n const sendRequest = bent(uri, requestCommand, this.privHeaders, 200, 201, 202, 204, 400, 401, 402, 403, 404);\r\n const params = this.queryParams(queryParams) === \"\" ? \"\" : `?${this.queryParams(queryParams)}`;\r\n sendRequest(params, postData).then( async (data: BentResponse): Promise<void> => {\r\n if (method === RestRequestType.Delete || data.statusCode === 204) {\r\n // No JSON from Delete and reset (204) operations\r\n responseReceivedDeferral.resolve(handleRestResponse(data));\r\n } else {\r\n try {\r\n const j: JsonError = await data.json() as JsonError;\r\n responseReceivedDeferral.resolve(handleRestResponse(data, j));\r\n } catch {\r\n responseReceivedDeferral.resolve(handleRestResponse(data));\r\n }\r\n }\r\n }).catch((error: string): void => {\r\n responseReceivedDeferral.reject(error);\r\n });\r\n };\r\n\r\n if (this.privIgnoreCache) {\r\n this.privHeaders[\"Cache-Control\"] = \"no-cache\";\r\n }\r\n\r\n if (method === RestRequestType.Post && body) {\r\n this.privHeaders[\"content-type\"] = \"application/json\";\r\n this.privHeaders[\"Content-Type\"] = \"application/json\";\r\n }\r\n send(body as RequestBody);\r\n return responseReceivedDeferral.promise;\r\n }\r\n\r\n private queryParams(params: { [key: string]: string } = {}): string {\r\n return Object.keys(params)\r\n .map((k: string): string => encodeURIComponent(k) + \"=\" + encodeURIComponent(params[k]))\r\n .join(\"&\");\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.js\";\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\nexport * from \"./ConsoleLoggingListener.js\";\r\nexport * from \"./IRecorder.js\";\r\nexport * from \"./MicAudioSource.js\";\r\nexport * from \"./FileAudioSource.js\";\r\nexport * from \"./PCMRecorder.js\";\r\nexport * from \"./WebsocketConnection.js\";\r\nexport * from \"./WebsocketMessageAdapter.js\";\r\nexport * from \"./ReplayableAudioNode.js\";\r\nexport * from \"./ProxyInfo.js\";\r\nexport * from \"./RestMessageAdapter.js\";\r\nexport * from \"./RestConfigBase.js\";\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.js\";\r\nimport {\r\n IConnection,\r\n IStringDictionary\r\n} from \"../common/Exports.js\";\r\nimport {\r\n PropertyId\r\n} from \"../sdk/Exports.js\";\r\nimport {\r\n ConnectionFactoryBase\r\n} from \"./ConnectionFactoryBase.js\";\r\nimport {\r\n AuthInfo,\r\n RecognizerConfig,\r\n WebsocketMessageFormatter,\r\n} from \"./Exports.js\";\r\nimport { HeaderNames } from \"./HeaderNames.js\";\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: string = ConnectionFactoryBase.getHostSuffix(region);\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<string> = {\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<string> = {};\r\n if (authInfo.token !== undefined && authInfo.token !== \"\") {\r\n headers[authInfo.headerName] = authInfo.token;\r\n }\r\n headers[HeaderNames.ConnectionId] = connectionId;\r\n\r\n config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, endpoint);\r\n\r\n const enableCompression: boolean = config.parameters.getProperty(\"SPEECH-EnableWebsocketCompression\", \"false\") === \"true\";\r\n return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, 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\n/* eslint-disable max-classes-per-file */\r\n\r\nimport {\r\n ProxyInfo,\r\n WebsocketConnection,\r\n} from \"../common.browser/Exports.js\";\r\nimport {\r\n IConnection,\r\n IStringDictionary\r\n} from \"../common/Exports.js\";\r\nimport {\r\n PropertyId\r\n} from \"../sdk/Exports.js\";\r\nimport {\r\n ConnectionFactoryBase\r\n} from \"./ConnectionFactoryBase.js\";\r\nimport {\r\n AuthInfo,\r\n RecognizerConfig,\r\n WebsocketMessageFormatter,\r\n} from \"./Exports.js\";\r\nimport { HeaderNames } from \"./HeaderNames.js\";\r\n\r\nclass SpeakerRecognitionConnectionFactoryBase extends ConnectionFactoryBase {\r\n\r\n public create(\r\n config: RecognizerConfig,\r\n authInfo: AuthInfo,\r\n endpointPath: string,\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_Region);\r\n const hostSuffix: string = ConnectionFactoryBase.getHostSuffix(region);\r\n const host: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, `wss://${region}.spr-frontend.speech${hostSuffix}`);\r\n const scenario: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_SpeakerIdMode, \"TextIndependentIdentification\");\r\n endpoint = `${host}/speaker/ws/${this.scenarioToPath(scenario)}/${endpointPath}`;\r\n }\r\n\r\n const queryParams: IStringDictionary<string> = {\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<string> = {};\r\n if (authInfo.token !== undefined && authInfo.token !== \"\") {\r\n headers[authInfo.headerName] = authInfo.token;\r\n }\r\n headers[HeaderNames.ConnectionId] = connectionId;\r\n headers[HeaderNames.SpIDAuthKey] = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Key);\r\n\r\n config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, endpoint);\r\n\r\n const enableCompression: boolean = config.parameters.getProperty(\"SPEECH-EnableWebsocketCompression\", \"false\") === \"true\";\r\n return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, connectionId);\r\n }\r\n\r\n private scenarioToPath(mode: string): string {\r\n switch (mode) {\r\n case \"TextIndependentVerification\":\r\n case \"2\":\r\n return \"verification/text-independent\";\r\n case \"TextDependentVerification\":\r\n case \"1\":\r\n return \"verification/text-dependent\";\r\n default:\r\n return \"identification/text-independent\";\r\n }\r\n }\r\n}\r\n\r\nexport class SpeakerRecognitionConnectionFactory extends SpeakerRecognitionConnectionFactoryBase {\r\n public create( config: RecognizerConfig, authInfo: AuthInfo, connectionId?: string): IConnection {\r\n return super.create(config, authInfo, \"recognition\", connectionId);\r\n }\r\n}\r\n\r\nexport class VoiceProfileConnectionFactory extends SpeakerRecognitionConnectionFactoryBase {\r\n public create( config: RecognizerConfig, authInfo: AuthInfo, connectionId?: string): IConnection {\r\n return super.create(config, authInfo, \"profile\", 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/* eslint-disable max-classes-per-file */\r\n\r\nimport { EventType, PlatformEvent } from \"../common/Exports.js\";\r\n\r\nexport class SpeechRecognitionEvent extends PlatformEvent {\r\n private privRequestId: string;\r\n private privSessionId: string;\r\n\r\n public 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\nexport class RecognitionTriggeredEvent extends SpeechRecognitionEvent {\r\n private privAudioSourceId: string;\r\n private privAudioNodeId: string;\r\n\r\n public 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\nexport class ListeningStartedEvent extends SpeechRecognitionEvent {\r\n private privAudioSourceId: string;\r\n private privAudioNodeId: string;\r\n\r\n public 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\nexport class ConnectingToServiceEvent extends SpeechRecognitionEvent {\r\n private privAuthFetchEventid: string;\r\n\r\n public 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\nexport class RecognitionStartedEvent extends SpeechRecognitionEvent {\r\n private privAudioSourceId: string;\r\n private privAudioNodeId: string;\r\n private privAuthFetchEventId: string;\r\n\r\n public 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\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 public 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 { ArgumentNullError, ConnectionMessage, IStringDictionary, MessageType } from \"../common/Exports.js\";\r\nimport { HeaderNames } from \"./HeaderNames.js\";\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<string>;\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<string>,\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<string> = {};\r\n headers[HeaderNames.Path] = path;\r\n headers[HeaderNames.RequestId] = requestId;\r\n headers[HeaderNames.RequestTimestamp] = new Date().toISOString();\r\n if (contentType) {\r\n headers[HeaderNames.ContentType] = contentType;\r\n }\r\n\r\n if (streamId) {\r\n headers[HeaderNames.RequestStreamId] = 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<string> {\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<string> = {};\r\n\r\n if (message.headers) {\r\n for (const headerName in message.headers) {\r\n if (headerName) {\r\n if (headerName.toLowerCase() === HeaderNames.Path.toLowerCase()) {\r\n path = message.headers[headerName];\r\n } else if (headerName.toLowerCase() === HeaderNames.RequestId.toLowerCase()) {\r\n requestId = message.headers[headerName];\r\n // } else if (headerName.toLowerCase() === HeaderNames.RequestTimestamp.toLowerCase()) {\r\n // requestTimestamp = message.headers[headerName];\r\n } else if (headerName.toLowerCase() === HeaderNames.ContentType.toLowerCase()) {\r\n contentType = message.headers[headerName];\r\n } else if (headerName.toLowerCase() === HeaderNames.RequestStreamId.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 { ReplayableAudioNode } from \"../common.browser/Exports.js\";\r\nimport { ConnectionOpenResponse } from \"../common/ConnectionOpenResponse.js\";\r\nimport {\r\n ArgumentNullError,\r\n ConnectionClosedEvent,\r\n ConnectionEvent,\r\n ConnectionState,\r\n createNoDashGuid,\r\n EventSource,\r\n IAudioSource,\r\n IAudioStreamNode,\r\n IConnection,\r\n IDisposable,\r\n IStreamChunk,\r\n MessageType,\r\n ServiceEvent,\r\n Timeout\r\n} from \"../common/Exports.js\";\r\nimport { AudioStreamFormatImpl } from \"../sdk/Audio/AudioStreamFormat.js\";\r\nimport { SpeakerRecognitionModel } from \"../sdk/SpeakerRecognitionModel.js\";\r\nimport {\r\n CancellationErrorCode,\r\n CancellationReason,\r\n PropertyId,\r\n RecognitionEventArgs,\r\n Recognizer,\r\n SessionEventArgs,\r\n SpeakerRecognitionResult,\r\n SpeechRecognitionResult,\r\n OutputFormat\r\n} from \"../sdk/Exports.js\";\r\nimport { Callback } from \"../sdk/Transcription/IConversation.js\";\r\nimport {\r\n AgentConfig,\r\n DynamicGrammarBuilder,\r\n ISpeechConfigAudioDevice,\r\n RecognitionMode,\r\n RequestSession,\r\n SpeechContext,\r\n SpeechDetected,\r\n type,\r\n OutputFormatPropertyName\r\n} from \"./Exports.js\";\r\nimport {\r\n AuthInfo,\r\n IAuthentication,\r\n} from \"./IAuthentication.js\";\r\nimport { IConnectionFactory } from \"./IConnectionFactory.js\";\r\nimport { RecognizerConfig } from \"./RecognizerConfig.js\";\r\nimport { SpeechConnectionMessage } from \"./SpeechConnectionMessage.Internal.js\";\r\n\r\ninterface CustomModel {\r\n language: string;\r\n endpoint: string;\r\n}\r\n\r\nexport interface PhraseDetection {\r\n customModels?: CustomModel[];\r\n onInterim?: { action: string };\r\n onSuccess?: { action: string };\r\n mode?: string;\r\n INTERACTIVE?: Segmentation;\r\n CONVERSATION?: Segmentation;\r\n DICTATION?: Segmentation;\r\n speakerDiarization?: SpeakerDiarization;\r\n}\r\n\r\nexport interface SpeakerDiarization {\r\n mode?: string;\r\n audioSessionId?: string;\r\n audioOffsetMs?: number;\r\n identityProvider?: string;\r\n}\r\n\r\nexport interface Segmentation {\r\n segmentation: {\r\n mode: \"Custom\";\r\n segmentationSilenceTimeoutMs: number;\r\n };\r\n}\r\n\r\nexport abstract class ServiceRecognizerBase implements IDisposable {\r\n private privAuthentication: IAuthentication;\r\n private privConnectionFactory: IConnectionFactory;\r\n\r\n // A promise for a configured connection.\r\n // Do not consume directly, call fetchConnection instead.\r\n private privConnectionConfigurationPromise: Promise<IConnection> = undefined;\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<IConnection> = undefined;\r\n private privAuthFetchEventId: string;\r\n private privIsDisposed: boolean;\r\n private privMustReportEndOfStream: boolean;\r\n private privConnectionEvents: EventSource<ConnectionEvent>;\r\n private privServiceEvents: EventSource<ServiceEvent>;\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 private privAudioSource: IAudioSource;\r\n private privIsLiveAudio: boolean = false;\r\n private privAverageBytesPerMs: number = 0;\r\n protected privSpeechContext: SpeechContext;\r\n protected privRequestSession: RequestSession;\r\n protected privConnectionId: string;\r\n protected privDiarizationSessionId: 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 protected privEnableSpeakerId: boolean = false;\r\n protected privExpectContentAssessmentResponse: boolean = false;\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.privEnableSpeakerId = recognizerConfig.isSpeakerDiarizationEnabled;\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<ConnectionEvent>();\r\n this.privServiceEvents = new EventSource<ServiceEvent>();\r\n this.privDynamicGrammar = new DynamicGrammarBuilder();\r\n this.privSpeechContext = new SpeechContext(this.privDynamicGrammar);\r\n this.privAgentConfig = new AgentConfig();\r\n const webWorkerLoadType: string = this.privRecognizerConfig.parameters.getProperty(PropertyId.WebWorkerLoadType, \"on\").toLowerCase();\r\n if (webWorkerLoadType === \"on\" && typeof (Blob) !== \"undefined\" && typeof (Worker) !== \"undefined\") {\r\n this.privSetTimeout = Timeout.setTimeout;\r\n } else {\r\n if (typeof window !== \"undefined\") {\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\r\n this.privSetTimeout = window.setTimeout.bind(window);\r\n }\r\n }\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 if (connectionClosedEvent.statusCode === 1003 ||\r\n connectionClosedEvent.statusCode === 1007 ||\r\n connectionClosedEvent.statusCode === 1002 ||\r\n connectionClosedEvent.statusCode === 4000 ||\r\n this.privRequestSession.numConnectionAttempts > this.privRecognizerConfig.maxRetryCount\r\n ) {\r\n void this.cancelRecognitionLocal(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 if (this.privEnableSpeakerId) {\r\n this.privDiarizationSessionId = createNoDashGuid();\r\n }\r\n\r\n this.setLanguageIdJson();\r\n this.setOutputDetailLevelJson();\r\n }\r\n\r\n protected setTranslationJson(): void {\r\n const targetLanguages: string = this.privRecognizerConfig.parameters.getProperty(PropertyId.SpeechServiceConnection_TranslationToLanguages, undefined);\r\n if (targetLanguages !== undefined) {\r\n const languages = targetLanguages.split(\",\");\r\n const translationVoice: string = this.privRecognizerConfig.parameters.getProperty(PropertyId.SpeechServiceConnection_TranslationVoice, undefined);\r\n const action = ( translationVoice !== undefined ) ? \"Synthesize\" : \"None\";\r\n this.privSpeechContext.setSection(\"translation\", {\r\n onSuccess: { action },\r\n output: { interimResults: { mode: \"Always\" } },\r\n targetLanguages: languages,\r\n });\r\n\r\n if (translationVoice !== undefined) {\r\n const languageToVoiceMap: { [key: string]: string } = {};\r\n for (const lang of languages) {\r\n languageToVoiceMap[lang] = translationVoice;\r\n }\r\n this.privSpeechContext.setSection(\"synthesis\", {\r\n defaultVoices: languageToVoiceMap\r\n });\r\n }\r\n }\r\n }\r\n\r\n protected setSpeechSegmentationTimeoutJson(): void {\r\n const speechSegmentationTimeout: string = this.privRecognizerConfig.parameters.getProperty(PropertyId.Speech_SegmentationSilenceTimeoutMs, undefined);\r\n if (speechSegmentationTimeout !== undefined) {\r\n const mode = this.recognitionMode === RecognitionMode.Conversation ? \"CONVERSATION\" :\r\n this.recognitionMode === RecognitionMode.Dictation ? \"DICTATION\" : \"INTERACTIVE\";\r\n const segmentationSilenceTimeoutMs: number = parseInt(speechSegmentationTimeout, 10);\r\n const phraseDetection = this.privSpeechContext.getSection(\"phraseDetection\") as PhraseDetection;\r\n phraseDetection.mode = mode;\r\n phraseDetection[mode] = {\r\n segmentation: {\r\n mode: \"Custom\",\r\n segmentationSilenceTimeoutMs\r\n }\r\n };\r\n this.privSpeechContext.setSection(\"phraseDetection\", phraseDetection);\r\n }\r\n }\r\n\r\n protected setLanguageIdJson(): void {\r\n const phraseDetection = this.privSpeechContext.getSection(\"phraseDetection\") as PhraseDetection;\r\n if (this.privRecognizerConfig.autoDetectSourceLanguages !== undefined) {\r\n const sourceLanguages: string[] = this.privRecognizerConfig.autoDetectSourceLanguages.split(\",\");\r\n\r\n let speechContextLidMode;\r\n if (this.privRecognizerConfig.languageIdMode === \"Continuous\") {\r\n speechContextLidMode = \"DetectContinuous\";\r\n } else {// recognizerConfig.languageIdMode === \"AtStart\"\r\n speechContextLidMode = \"DetectAtAudioStart\";\r\n }\r\n\r\n this.privSpeechContext.setSection(\"languageId\", {\r\n Priority: \"PrioritizeLatency\",\r\n languages: sourceLanguages,\r\n mode: speechContextLidMode,\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 const customModels: CustomModel[] = this.privRecognizerConfig.sourceLanguageModels;\r\n if (customModels !== undefined) {\r\n phraseDetection.customModels = customModels;\r\n phraseDetection.onInterim = { action: \"None\" };\r\n phraseDetection.onSuccess = { action: \"None\" };\r\n }\r\n }\r\n const targetLanguages: string = this.privRecognizerConfig.parameters.getProperty(PropertyId.SpeechServiceConnection_TranslationToLanguages, undefined);\r\n if (targetLanguages !== undefined) {\r\n phraseDetection.onInterim = { action: \"Translate\" };\r\n phraseDetection.onSuccess = { action: \"Translate\" };\r\n this.privSpeechContext.setSection(\"phraseOutput\", {\r\n interimResults: {\r\n resultType: \"None\"\r\n },\r\n phraseResults: {\r\n resultType: \"None\"\r\n }\r\n });\r\n }\r\n\r\n this.privSpeechContext.setSection(\"phraseDetection\", phraseDetection);\r\n }\r\n\r\n protected setOutputDetailLevelJson(): void {\r\n if (this.privEnableSpeakerId) {\r\n const requestWordLevelTimestamps: string = this.privRecognizerConfig.parameters.getProperty(PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps, \"false\").toLowerCase();\r\n if (requestWordLevelTimestamps === \"true\") {\r\n this.privSpeechContext.setWordLevelTimings();\r\n } else {\r\n const outputFormat: string = this.privRecognizerConfig.parameters.getProperty(OutputFormatPropertyName, OutputFormat[OutputFormat.Simple]).toLowerCase();\r\n if (outputFormat === OutputFormat[OutputFormat.Detailed].toLocaleLowerCase()) {\r\n this.privSpeechContext.setDetailedOutputFormat();\r\n }\r\n }\r\n }\r\n }\r\n\r\n public get isSpeakerDiarizationEnabled(): boolean {\r\n return this.privEnableSpeakerId;\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 set voiceProfileType(type: string) {\r\n this.privRecognizerConfig.parameters.setProperty(PropertyId.SpeechServiceConnection_SpeakerIdMode, type);\r\n }\r\n\r\n public set authentication(auth: IAuthentication) {\r\n this.privAuthentication = auth;\r\n }\r\n\r\n public isDisposed(): boolean {\r\n return this.privIsDisposed;\r\n }\r\n\r\n public async dispose(reason?: string): Promise<void> {\r\n this.privIsDisposed = true;\r\n if (this.privConnectionConfigurationPromise !== undefined) {\r\n try {\r\n const connection: IConnection = await this.privConnectionConfigurationPromise;\r\n await connection.dispose(reason);\r\n } catch (error) {\r\n // The connection is in a bad state. But we're trying to kill it, so...\r\n return;\r\n }\r\n }\r\n }\r\n\r\n public get connectionEvents(): EventSource<ConnectionEvent> {\r\n return this.privConnectionEvents;\r\n }\r\n\r\n public get serviceEvents(): EventSource<ServiceEvent> {\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) => Promise<void> = undefined;\r\n\r\n public recognizeSpeaker: (model: SpeakerRecognitionModel) => Promise<SpeakerRecognitionResult> = undefined;\r\n\r\n public async recognize(\r\n recoMode: RecognitionMode,\r\n successCallback: (e: SpeechRecognitionResult) => void,\r\n errorCallBack: (e: string) => void,\r\n ): Promise<void> {\r\n\r\n if (this.recognizeOverride !== undefined) {\r\n await this.recognizeOverride(recoMode, successCallback, errorCallBack);\r\n return;\r\n }\r\n // Clear the existing configuration promise to force a re-transmission of config and context.\r\n this.privConnectionConfigurationPromise = undefined;\r\n this.privRecognizerConfig.recognitionMode = recoMode;\r\n this.setSpeechSegmentationTimeoutJson();\r\n this.setTranslationJson();\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 const conPromise: Promise<IConnection> = this.connectImpl();\r\n let audioNode: ReplayableAudioNode;\r\n\r\n try {\r\n const audioStreamNode: IAudioStreamNode = await this.audioSource.attach(this.privRequestSession.audioNodeId);\r\n const format: AudioStreamFormatImpl = await this.audioSource.format;\r\n const deviceInfo: ISpeechConfigAudioDevice = await this.audioSource.deviceInfo;\r\n this.privIsLiveAudio = deviceInfo.type && deviceInfo.type === type.Microphones;\r\n\r\n audioNode = new ReplayableAudioNode(audioStreamNode, format.avgBytesPerSec);\r\n await this.privRequestSession.onAudioSourceAttachCompleted(audioNode, false);\r\n this.privRecognizerConfig.SpeechServiceConfig.Context.audio = { source: deviceInfo };\r\n\r\n } catch (error) {\r\n await this.privRequestSession.onStopRecognizing();\r\n throw error;\r\n }\r\n\r\n try {\r\n await conPromise;\r\n } catch (error) {\r\n await this.cancelRecognitionLocal(CancellationReason.Error, CancellationErrorCode.ConnectionFailure, error as string);\r\n return;\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 void this.receiveMessage();\r\n const audioSendPromise = this.sendAudio(audioNode);\r\n\r\n audioSendPromise.catch(async (error: string): Promise<void> => {\r\n await this.cancelRecognitionLocal(CancellationReason.Error, CancellationErrorCode.RuntimeError, error);\r\n });\r\n\r\n return;\r\n }\r\n\r\n public async stopRecognizing(): Promise<void> {\r\n if (this.privRequestSession.isRecognizing) {\r\n try {\r\n await this.audioSource.turnOff();\r\n await this.sendFinalAudio();\r\n await this.privRequestSession.onStopRecognizing();\r\n await this.privRequestSession.turnCompletionPromise;\r\n } finally {\r\n await this.privRequestSession.dispose();\r\n }\r\n }\r\n return;\r\n }\r\n\r\n public async connect(): Promise<void> {\r\n await this.connectImpl();\r\n return Promise.resolve();\r\n }\r\n\r\n public connectAsync(cb?: Callback, err?: Callback): void {\r\n this.connectImpl().then((): void => {\r\n try {\r\n if (!!cb) {\r\n cb();\r\n }\r\n } catch (e) {\r\n if (!!err) {\r\n err(e);\r\n }\r\n }\r\n }, (reason: any): void => {\r\n try {\r\n if (!!err) {\r\n err(reason);\r\n }\r\n /* eslint-disable no-empty */\r\n } catch (error) {\r\n }\r\n });\r\n }\r\n\r\n protected disconnectOverride: () => Promise<void> = undefined;\r\n\r\n public async disconnect(): Promise<void> {\r\n await this.cancelRecognitionLocal(CancellationReason.Error,\r\n CancellationErrorCode.NoError,\r\n \"Disconnecting\");\r\n\r\n if (this.disconnectOverride !== undefined) {\r\n await this.disconnectOverride();\r\n }\r\n\r\n if (this.privConnectionPromise !== undefined) {\r\n try {\r\n await (await this.privConnectionPromise).dispose();\r\n } catch (error) {\r\n\r\n }\r\n }\r\n this.privConnectionPromise = undefined;\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 // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public sendMessage(message: string): Promise<void> {\r\n return;\r\n }\r\n\r\n public async sendNetworkMessage(path: string, payload: string | ArrayBuffer): Promise<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 const connection: IConnection = await this.fetchConnection();\r\n return connection.send(new SpeechConnectionMessage(type, path, this.privRequestSession.requestId, contentType, payload));\r\n }\r\n\r\n public set activityTemplate(messagePayload: string) {\r\n this.privActivityTemplate = messagePayload;\r\n }\r\n\r\n public get activityTemplate(): string {\r\n return this.privActivityTemplate;\r\n }\r\n\r\n public set expectContentAssessmentResponse(value: boolean) {\r\n this.privExpectContentAssessmentResponse = value;\r\n }\r\n\r\n protected abstract processTypeSpecificMessages(\r\n connectionMessage: SpeechConnectionMessage,\r\n successCallback?: (e: SpeechRecognitionResult) => void,\r\n errorCallBack?: (e: string) => void): Promise<boolean>;\r\n\r\n protected async sendTelemetryData(): Promise<void> {\r\n const telemetryData = this.privRequestSession.getTelemetry();\r\n if (ServiceRecognizerBase.telemetryDataEnabled !== true ||\r\n this.privIsDisposed ||\r\n null === telemetryData) {\r\n return;\r\n }\r\n\r\n if (!!ServiceRecognizerBase.telemetryData) {\r\n try {\r\n ServiceRecognizerBase.telemetryData(telemetryData);\r\n /* eslint-disable no-empty */\r\n } catch { }\r\n }\r\n\r\n const connection: IConnection = await this.fetchConnection();\r\n await 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 // 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 async cancelRecognitionLocal(\r\n cancellationReason: CancellationReason,\r\n errorCode: CancellationErrorCode,\r\n error: string): Promise<void> {\r\n\r\n if (!!this.privRequestSession.isRecognizing) {\r\n await 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: () => Promise<void> = undefined;\r\n\r\n protected async receiveMessage(): Promise<void> {\r\n try {\r\n if (this.privIsDisposed) {\r\n // We're done.\r\n return;\r\n }\r\n\r\n let connection = await this.fetchConnection();\r\n const message = await connection.read();\r\n\r\n if (this.receiveMessageOverride !== undefined) {\r\n return this.receiveMessageOverride();\r\n }\r\n\r\n // indicates we are draining the queue and it came with no message;\r\n if (!message) {\r\n return this.receiveMessage();\r\n }\r\n\r\n this.privServiceHasSentMessage = true;\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\r\n case \"speech.startdetected\":\r\n const speechStartDetected: SpeechDetected = SpeechDetected.fromJSON(connectionMessage.textBody);\r\n const speechStartEventArgs = new RecognitionEventArgs(speechStartDetected.Offset, this.privRequestSession.sessionId);\r\n if (!!this.privRecognizer.speechStartDetected) {\r\n this.privRecognizer.speechStartDetected(this.privRecognizer, speechStartEventArgs);\r\n }\r\n break;\r\n\r\n case \"speech.enddetected\":\r\n let json: string;\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 const speechStopDetected: SpeechDetected = SpeechDetected.fromJSON(json);\r\n const speechStopEventArgs = new RecognitionEventArgs(speechStopDetected.Offset + this.privRequestSession.currentTurnAudioOffset, this.privRequestSession.sessionId);\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 await this.sendTelemetryData();\r\n if (this.privRequestSession.isSpeechEnded && this.privMustReportEndOfStream) {\r\n this.privMustReportEndOfStream = false;\r\n await this.cancelRecognitionLocal(CancellationReason.EndOfStream, CancellationErrorCode.NoError, undefined);\r\n }\r\n const sessionStopEventArgs: SessionEventArgs = new SessionEventArgs(this.privRequestSession.sessionId);\r\n await this.privRequestSession.onServiceTurnEndResponse(this.privRecognizerConfig.isContinuousRecognition);\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 return;\r\n } else {\r\n connection = await this.fetchConnection();\r\n await this.sendPrePayloadJSON(connection);\r\n }\r\n break;\r\n\r\n default:\r\n if (!await 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 return this.receiveMessage();\r\n } catch (error) {\r\n return null;\r\n }\r\n }\r\n\r\n private updateSpeakerDiarizationAudioOffset(): void {\r\n const bytesSent: number = this.privRequestSession.recognitionBytesSent;\r\n const audioOffsetMs: number = bytesSent / this.privAverageBytesPerMs;\r\n this.privSpeechContext.setSpeakerDiarizationAudioOffsetMs(audioOffsetMs);\r\n }\r\n\r\n protected sendSpeechContext(connection: IConnection, generateNewRequestId: boolean): Promise<void> {\r\n if (this.privEnableSpeakerId) {\r\n this.updateSpeakerDiarizationAudioOffset();\r\n }\r\n const speechContextJson = this.speechContext.toJSON();\r\n if (generateNewRequestId) {\r\n this.privRequestSession.onSpeechContext();\r\n }\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;\r\n }\r\n\r\n protected sendPrePayloadJSONOverride: (connection: IConnection) => Promise<void> = undefined;\r\n\r\n protected noOp(): Promise<void> {\r\n // operation not supported\r\n return;\r\n }\r\n\r\n // Encapsulated for derived service recognizers that need to send additional JSON\r\n protected async sendPrePayloadJSON(connection: IConnection, generateNewRequestId: boolean = true): Promise<void> {\r\n if (this.sendPrePayloadJSONOverride !== undefined) {\r\n return this.sendPrePayloadJSONOverride(connection);\r\n }\r\n\r\n await this.sendSpeechContext(connection, generateNewRequestId);\r\n await this.sendWaveHeader(connection);\r\n return;\r\n }\r\n\r\n protected async sendWaveHeader(connection: IConnection): Promise<void> {\r\n const format: AudioStreamFormatImpl = await this.audioSource.format;\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 protected postConnectImplOverride: (connection: Promise<IConnection>) => Promise<IConnection> = undefined;\r\n\r\n // Establishes a websocket connection to the end point.\r\n protected connectImpl(): Promise<IConnection> {\r\n if (this.privConnectionPromise !== undefined) {\r\n return this.privConnectionPromise.then((connection: IConnection): Promise<IConnection> => {\r\n if (connection.state() === ConnectionState.Disconnected) {\r\n this.privConnectionId = null;\r\n this.privConnectionPromise = undefined;\r\n this.privServiceHasSentMessage = false;\r\n return this.connectImpl();\r\n }\r\n return this.privConnectionPromise;\r\n }, (): Promise<IConnection> => {\r\n this.privConnectionId = null;\r\n this.privConnectionPromise = undefined;\r\n this.privServiceHasSentMessage = false;\r\n return this.connectImpl();\r\n });\r\n }\r\n\r\n this.privConnectionPromise = this.retryableConnect();\r\n\r\n // Attach an empty handler to allow the promise to run in the background while\r\n // other startup events happen. It'll eventually be awaited on.\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n this.privConnectionPromise.catch((): void => { });\r\n\r\n if (this.postConnectImplOverride !== undefined) {\r\n return this.postConnectImplOverride(this.privConnectionPromise);\r\n }\r\n\r\n return this.privConnectionPromise;\r\n }\r\n\r\n protected configConnectionOverride: (connection: IConnection) => Promise<IConnection> = undefined;\r\n protected handleSpeechPhraseMessage: (textBody: string) => Promise<void> = undefined;\r\n protected handleSpeechHypothesisMessage: (textBody: string) => void = undefined;\r\n\r\n protected sendSpeechServiceConfig(connection: IConnection, requestSession: RequestSession, SpeechServiceConfigJson: string): Promise<void> {\r\n requestSession.onSpeechContext();\r\n // filter out anything that is not required for the service to work.\r\n if (ServiceRecognizerBase.telemetryDataEnabled !== true) {\r\n const withTelemetry: { context: { system: string } } = JSON.parse(SpeechServiceConfigJson) as { context: { system: string } };\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 (this.privRecognizerConfig.parameters.getProperty(\"f0f5debc-f8c9-4892-ac4b-90a7ab359fd2\", \"false\").toLowerCase() === \"true\") {\r\n const json: { context: { DisableReferenceChannel: string; MicSpec: string } } = JSON.parse(SpeechServiceConfigJson) as { context: { DisableReferenceChannel: string; MicSpec: string } };\r\n json.context.DisableReferenceChannel = \"True\";\r\n json.context.MicSpec = \"1_0_0\";\r\n SpeechServiceConfigJson = JSON.stringify(json);\r\n }\r\n\r\n if (SpeechServiceConfigJson) {\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;\r\n }\r\n\r\n protected async fetchConnection(): Promise<IConnection> {\r\n if (this.privConnectionConfigurationPromise !== undefined) {\r\n return this.privConnectionConfigurationPromise.then((connection: IConnection): Promise<IConnection> => {\r\n if (connection.state() === ConnectionState.Disconnected) {\r\n this.privConnectionId = null;\r\n this.privConnectionConfigurationPromise = undefined;\r\n this.privServiceHasSentMessage = false;\r\n return this.fetchConnection();\r\n }\r\n return this.privConnectionConfigurationPromise;\r\n }, (): Promise<IConnection> => {\r\n this.privConnectionId = null;\r\n this.privConnectionConfigurationPromise = undefined;\r\n this.privServiceHasSentMessage = false;\r\n return this.fetchConnection();\r\n });\r\n }\r\n\r\n this.privConnectionConfigurationPromise = this.configureConnection();\r\n return await this.privConnectionConfigurationPromise;\r\n }\r\n\r\n protected async sendAudio(audioStreamNode: IAudioStreamNode): Promise<void> {\r\n const audioFormat: AudioStreamFormatImpl = await this.audioSource.format;\r\n this.privAverageBytesPerMs = audioFormat.avgBytesPerSec / 1000;\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 = async (): Promise<void> => {\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\r\n const connection: IConnection = await this.fetchConnection();\r\n const audioStreamChunk: IStreamChunk<ArrayBuffer> = await audioStreamNode.read();\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 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\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 if (0 !== sendDelay) {\r\n await this.delay(sendDelay);\r\n }\r\n\r\n if (payload !== null) {\r\n nextSendTime = Date.now() + (payload.byteLength * 1000 / (audioFormat.avgBytesPerSec * 2));\r\n }\r\n\r\n // Are we still alive?\r\n if (!this.privIsDisposed &&\r\n !this.privRequestSession.isSpeechEnded &&\r\n this.privRequestSession.isRecognizing &&\r\n this.privRequestSession.recogNumber === startRecogNumber) {\r\n connection.send(\r\n new SpeechConnectionMessage(MessageType.Binary, \"audio\", this.privRequestSession.requestId, null, payload)\r\n ).catch((): void => {\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n this.privRequestSession.onServiceTurnEndResponse(this.privRecognizerConfig.isContinuousRecognition).catch((): void => { });\r\n });\r\n\r\n if (!audioStreamChunk?.isEnd) {\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 return readAndUploadCycle();\r\n } else {\r\n // the audio stream has been closed, no need to schedule next\r\n // read-upload cycle.\r\n if (!this.privIsLiveAudio) {\r\n this.privRequestSession.onSpeechEnded();\r\n }\r\n }\r\n }\r\n }\r\n };\r\n\r\n return readAndUploadCycle();\r\n }\r\n\r\n private async retryableConnect(): Promise<IConnection> {\r\n let isUnAuthorized: boolean = false;\r\n\r\n this.privAuthFetchEventId = createNoDashGuid();\r\n const sessionId: string = this.privRequestSession.sessionId;\r\n this.privConnectionId = (sessionId !== undefined) ? sessionId : createNoDashGuid();\r\n\r\n this.privRequestSession.onPreConnectionStart(this.privAuthFetchEventId, this.privConnectionId);\r\n let lastStatusCode: number = 0;\r\n let lastReason: string = \"\";\r\n\r\n while (this.privRequestSession.numConnectionAttempts <= this.privRecognizerConfig.maxRetryCount) {\r\n\r\n // Get the auth information for the connection. This is a bit of overkill for the current API surface, but leaving the plumbing in place to be able to raise a developer-customer\r\n // facing event when a connection fails to let them try and provide new auth information.\r\n const authPromise = isUnAuthorized ? this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId) : this.privAuthentication.fetch(this.privAuthFetchEventId);\r\n const auth: AuthInfo = await authPromise;\r\n\r\n await this.privRequestSession.onAuthCompleted(false);\r\n\r\n // Create the connection\r\n const connection: IConnection = this.privConnectionFactory.create(this.privRecognizerConfig, auth, this.privConnectionId);\r\n // Attach the telemetry handlers.\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): void => {\r\n this.connectionEvents.onEvent(event);\r\n });\r\n\r\n const response: ConnectionOpenResponse = await connection.open();\r\n // 200 == everything is fine.\r\n if (response.statusCode === 200) {\r\n await this.privRequestSession.onConnectionEstablishCompleted(response.statusCode);\r\n return Promise.resolve(connection);\r\n } else if (response.statusCode === 1006) {\r\n isUnAuthorized = true;\r\n }\r\n\r\n lastStatusCode = response.statusCode;\r\n lastReason = response.reason;\r\n\r\n this.privRequestSession.onRetryConnection();\r\n }\r\n\r\n await this.privRequestSession.onConnectionEstablishCompleted(lastStatusCode, lastReason);\r\n return Promise.reject(`Unable to contact server. StatusCode: ${lastStatusCode}, ${this.privRecognizerConfig.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint)} Reason: ${lastReason}`);\r\n }\r\n\r\n private delay(delayMs: number): Promise<void> {\r\n return new Promise((resolve: () => void): number => this.privSetTimeout(resolve, delayMs));\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 if (((i + 1) % 16) === 0) {\r\n // eslint-disable-next-line no-console\r\n console.info(out);\r\n out = \"\";\r\n }\r\n }\r\n }\r\n // eslint-disable-next-line no-console\r\n console.info(out);\r\n }\r\n\r\n private async sendFinalAudio(): Promise<void> {\r\n const connection: IConnection = await this.fetchConnection();\r\n await connection.send(new SpeechConnectionMessage(MessageType.Binary, \"audio\", this.privRequestSession.requestId, null, null));\r\n return;\r\n }\r\n\r\n // Takes an established websocket connection to the endpoint and sends speech configuration information.\r\n private async configureConnection(): Promise<IConnection> {\r\n const connection: IConnection = await this.connectImpl();\r\n if (this.configConnectionOverride !== undefined) {\r\n return this.configConnectionOverride(connection);\r\n }\r\n await this.sendSpeechServiceConfig(connection, this.privRequestSession, this.privRecognizerConfig.SpeechServiceConfig.serialize());\r\n await this.sendPrePayloadJSON(connection, false);\r\n return connection;\r\n }\r\n}\r\n","import { IAudioSource } from \"../common/Exports.js\";\r\nimport {\r\n CancellationErrorCode,\r\n CancellationReason,\r\n OutputFormat,\r\n PropertyCollection,\r\n PropertyId,\r\n Recognizer,\r\n ResultReason,\r\n SpeechRecognitionResult\r\n} from \"../sdk/Exports.js\";\r\nimport {\r\n DetailedSpeechPhrase,\r\n EnumTranslation,\r\n IAuthentication,\r\n IConnectionFactory,\r\n OutputFormatPropertyName,\r\n RecognitionStatus,\r\n RecognizerConfig,\r\n ServiceRecognizerBase,\r\n SimpleSpeechPhrase,\r\n SpeechHypothesis\r\n} from \"./Exports.js\";\r\nimport { SpeechConnectionMessage } from \"./SpeechConnectionMessage.Internal.js\";\r\n\r\nexport class ConversationServiceRecognizer extends ServiceRecognizerBase {\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 super(authentication, connectionFactory, audioSource, recognizerConfig, recognizer);\r\n this.handleSpeechPhraseMessage = async (textBody: string): Promise<void> => this.handleSpeechPhrase(textBody);\r\n this.handleSpeechHypothesisMessage = (textBody: string): void => this.handleSpeechHypothesis(textBody);\r\n }\r\n\r\n protected processTypeSpecificMessages(connectionMessage: SpeechConnectionMessage): Promise<boolean> {\r\n void connectionMessage;\r\n return;\r\n }\r\n\r\n protected handleRecognizedCallback(result: SpeechRecognitionResult, offset: number, sessionId: string): void {\r\n void result;\r\n void offset;\r\n void sessionId;\r\n return;\r\n }\r\n\r\n protected handleRecognizingCallback(result: SpeechRecognitionResult, duration: number, sessionId: string): void {\r\n void result;\r\n void duration;\r\n void sessionId;\r\n return;\r\n }\r\n\r\n protected async processSpeechMessages(connectionMessage: SpeechConnectionMessage): Promise<boolean> {\r\n let processed: boolean = false;\r\n switch (connectionMessage.path.toLowerCase()) {\r\n case \"speech.hypothesis\":\r\n case \"speech.fragment\":\r\n if (!!this.handleSpeechHypothesisMessage) {\r\n this.handleSpeechHypothesisMessage(connectionMessage.textBody);\r\n }\r\n processed = true;\r\n break;\r\n case \"speech.phrase\":\r\n if (!!this.handleSpeechPhraseMessage) {\r\n await this.handleSpeechPhraseMessage(connectionMessage.textBody);\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 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 // Implementing to allow inheritance\r\n void sessionId;\r\n void requestId;\r\n void cancellationReason;\r\n void errorCode;\r\n void error;\r\n }\r\n\r\n protected async handleSpeechPhrase(textBody: string): Promise<void> {\r\n\r\n const simple: SimpleSpeechPhrase = SimpleSpeechPhrase.fromJSON(textBody);\r\n const resultReason: ResultReason = EnumTranslation.implTranslateRecognitionResult(simple.RecognitionStatus);\r\n let result: SpeechRecognitionResult;\r\n const resultProps: PropertyCollection = new PropertyCollection();\r\n resultProps.setProperty(PropertyId.SpeechServiceResponse_JsonResult, textBody);\r\n const simpleOffset = simple.Offset + this.privRequestSession.currentTurnAudioOffset;\r\n let offset = simpleOffset;\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 const cancellationErrorCode: CancellationErrorCode = EnumTranslation.implTranslateCancelErrorCode(simple.RecognitionStatus);\r\n\r\n await this.cancelRecognitionLocal(\r\n cancelReason,\r\n cancellationErrorCode,\r\n EnumTranslation.implTranslateErrorDetails(cancellationErrorCode));\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 simpleOffset,\r\n simple.Language,\r\n simple.LanguageDetectionConfidence,\r\n simple.SpeakerId,\r\n undefined,\r\n textBody,\r\n resultProps);\r\n } else {\r\n const detailed: DetailedSpeechPhrase = DetailedSpeechPhrase.fromJSON(textBody);\r\n const totalOffset: number = detailed.Offset + this.privRequestSession.currentTurnAudioOffset;\r\n const offsetCorrectedJson: string = detailed.getJsonWithCorrectedOffsets(totalOffset);\r\n\r\n result = new SpeechRecognitionResult(\r\n this.privRequestSession.requestId,\r\n resultReason,\r\n detailed.Text,\r\n detailed.Duration,\r\n totalOffset,\r\n detailed.Language,\r\n detailed.LanguageDetectionConfidence,\r\n detailed.SpeakerId,\r\n undefined,\r\n offsetCorrectedJson,\r\n resultProps);\r\n\r\n offset = result.offset;\r\n }\r\n\r\n this.handleRecognizedCallback(result, offset, this.privRequestSession.sessionId);\r\n }\r\n }\r\n }\r\n\r\n protected handleSpeechHypothesis(textBody: string): void {\r\n const hypothesis: SpeechHypothesis = SpeechHypothesis.fromJSON(textBody);\r\n const offset: number = hypothesis.Offset + this.privRequestSession.currentTurnAudioOffset;\r\n const resultProps: PropertyCollection = new PropertyCollection();\r\n resultProps.setProperty(PropertyId.SpeechServiceResponse_JsonResult, textBody);\r\n\r\n const 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 hypothesis.SpeakerId,\r\n undefined,\r\n textBody,\r\n resultProps);\r\n\r\n this.privRequestSession.onHypothesis(offset);\r\n\r\n this.handleRecognizingCallback(result, hypothesis.Duration, this.privRequestSession.sessionId);\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/* eslint-disable max-classes-per-file */\r\n\r\nimport { PropertyCollection, PropertyId } from \"../sdk/Exports.js\";\r\nimport { Context, SpeechServiceConfig } from \"./Exports.js\";\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;\r\n private privLanguageIdMode: string;\r\n private privSpeechServiceConfig: SpeechServiceConfig;\r\n private privRecognitionActivityTimeout: number;\r\n private privParameters: PropertyCollection;\r\n private privMaxRetryCount: number;\r\n private privEnableSpeakerId: boolean;\r\n\r\n public 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 this.privMaxRetryCount = parseInt(parameters.getProperty(\"SPEECH-Error-MaxRetryCount\", \"4\"), 10);\r\n this.privLanguageIdMode = parameters.getProperty(PropertyId.SpeechServiceConnection_LanguageIdMode, undefined);\r\n this.privEnableSpeakerId = false;\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 languageIdMode(): string {\r\n return this.privLanguageIdMode;\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 public get recognitionEndpointVersion(): string {\r\n return this.parameters.getProperty(PropertyId.SpeechServiceConnection_RecognitionEndpointVersion, undefined);\r\n }\r\n\r\n public get sourceLanguageModels(): { language: string; endpoint: string }[] {\r\n const models: { language: string; endpoint: string }[] = [];\r\n let modelsExist: boolean = false;\r\n if (this.autoDetectSourceLanguages !== undefined) {\r\n for (const language of this.autoDetectSourceLanguages.split(\",\")) {\r\n const customProperty = language + PropertyId.SpeechServiceConnection_EndpointId.toString();\r\n const modelId: string = this.parameters.getProperty(customProperty, undefined);\r\n if (modelId !== undefined) {\r\n models.push( { language, endpoint: modelId });\r\n modelsExist = true;\r\n } else {\r\n models.push( { language, endpoint: \"\" } );\r\n }\r\n }\r\n }\r\n return modelsExist ? models : undefined;\r\n }\r\n\r\n public get maxRetryCount(): number {\r\n return this.privMaxRetryCount;\r\n }\r\n\r\n public get isSpeakerDiarizationEnabled(): boolean {\r\n return this.privEnableSpeakerId;\r\n }\r\n\r\n public set isSpeakerDiarizationEnabled(value: boolean) {\r\n this.privEnableSpeakerId = value;\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 RawWebsocketMessage,\r\n} from \"../common/Exports.js\";\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<ConnectionMessage> {\r\n const deferral = new Deferred<ConnectionMessage>();\r\n\r\n try {\r\n if (message.messageType === MessageType.Text) {\r\n const textMessage: string = message.textContent;\r\n let headers: IStringDictionary<string> = {};\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<string> = {};\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 as string}`);\r\n }\r\n\r\n return deferral.promise;\r\n }\r\n\r\n public fromConnectionMessage(message: ConnectionMessage): Promise<RawWebsocketMessage> {\r\n const deferral = new Deferred<RawWebsocketMessage>();\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 headerBuffer = this.stringToArrayBuffer(headersString);\r\n const headerInt8Array = new Int8Array(headerBuffer);\r\n const headerLength = headerInt8Array.byteLength;\r\n\r\n const payloadInt8Array = new Int8Array(2 + headerLength + (content ? content.byteLength : 0));\r\n payloadInt8Array[0] = ((headerLength >> 8) & 0xff);\r\n payloadInt8Array[1] = headerLength & 0xff;\r\n payloadInt8Array.set(headerInt8Array, 2);\r\n\r\n if (content) {\r\n const bodyInt8Array = new Int8Array(content);\r\n payloadInt8Array.set(bodyInt8Array, 2 + headerLength);\r\n }\r\n\r\n const payload: ArrayBuffer = payloadInt8Array.buffer;\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 as string}`);\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<string> {\r\n const headers: IStringDictionary<string> = {};\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.js\";\r\nimport {\r\n ForceDictationPropertyName,\r\n OutputFormatPropertyName,\r\n} from \"../common.speech/Exports.js\";\r\nimport {\r\n IConnection,\r\n IStringDictionary\r\n} from \"../common/Exports.js\";\r\nimport {\r\n OutputFormat,\r\n PropertyId\r\n} from \"../sdk/Exports.js\";\r\nimport {\r\n ConnectionFactoryBase\r\n} from \"./ConnectionFactoryBase.js\";\r\nimport {\r\n AuthInfo,\r\n RecognitionMode,\r\n RecognizerConfig,\r\n WebsocketMessageFormatter\r\n} from \"./Exports.js\";\r\nimport { HeaderNames } from \"./HeaderNames.js\";\r\nimport {\r\n QueryParameterNames\r\n} from \"./QueryParameterNames.js\";\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 private readonly universalUri: string = \"/speech/universal/v\";\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 = ConnectionFactoryBase.getHostSuffix(region);\r\n const host: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, \"wss://\" + region + \".stt.speech\" + hostSuffix);\r\n const queryParams: IStringDictionary<string> = {};\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.CustomSpeechDeploymentId) === -1) {\r\n queryParams[QueryParameterNames.CustomSpeechDeploymentId] = endpointId;\r\n }\r\n } else if (language) {\r\n if (!endpoint || endpoint.search(QueryParameterNames.Language) === -1) {\r\n queryParams[QueryParameterNames.Language] = language;\r\n }\r\n }\r\n\r\n if (!endpoint || endpoint.search(QueryParameterNames.Format) === -1) {\r\n queryParams[QueryParameterNames.Format] = 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 if (config.recognitionEndpointVersion !== undefined && parseInt(config.recognitionEndpointVersion, 10) > 1) {\r\n endpoint = `${host}${this.universalUri}${config.recognitionEndpointVersion}`;\r\n } else {\r\n endpoint = host + this.conversationRelativeUri;\r\n }\r\n }\r\n break;\r\n case RecognitionMode.Dictation:\r\n endpoint = host + this.dictationRelativeUri;\r\n break;\r\n default:\r\n if (config.recognitionEndpointVersion !== undefined && parseInt(config.recognitionEndpointVersion, 10) > 1) {\r\n endpoint = `${host}${this.universalUri}${config.recognitionEndpointVersion}`;\r\n } else {\r\n endpoint = host + this.interactiveRelativeUri; // default is interactive\r\n }\r\n break;\r\n }\r\n }\r\n\r\n const headers: IStringDictionary<string> = {};\r\n if (authInfo.token !== undefined && authInfo.token !== \"\") {\r\n headers[authInfo.headerName] = authInfo.token;\r\n }\r\n headers[HeaderNames.ConnectionId] = connectionId;\r\n\r\n const enableCompression: boolean = config.parameters.getProperty(\"SPEECH-EnableWebsocketCompression\", \"false\") === \"true\";\r\n\r\n const webSocketConnection = new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, connectionId);\r\n\r\n // Set the value of SpeechServiceConnection_Url to webSocketConnection.uri (and not to `endpoint`), since this value is the final\r\n // URI that was used to make the connection (including query parameters).\r\n const uri: string = webSocketConnection.uri;\r\n config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, uri);\r\n\r\n return webSocketConnection;\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.js\";\r\nimport {\r\n IConnection,\r\n IStringDictionary\r\n} from \"../common/Exports.js\";\r\nimport {\r\n PropertyId\r\n} from \"../sdk/Exports.js\";\r\nimport {\r\n ServicePropertiesPropertyName\r\n} from \"../common.speech/Exports.js\";\r\nimport {\r\n ConnectionFactoryBase\r\n} from \"./ConnectionFactoryBase.js\";\r\nimport {\r\n AuthInfo,\r\n RecognizerConfig,\r\n WebsocketMessageFormatter\r\n} from \"./Exports.js\";\r\nimport { HeaderNames } from \"./HeaderNames.js\";\r\nimport {\r\n QueryParameterNames\r\n} from \"./QueryParameterNames.js\";\r\n\r\nexport class ConversationTranscriberConnectionFactory extends ConnectionFactoryBase {\r\n private readonly universalUri: string = \"/speech/universal/v2\";\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 = ConnectionFactoryBase.getHostSuffix(region);\r\n const host: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, \"wss://\" + region + \".stt.speech\" + hostSuffix);\r\n const queryParams: IStringDictionary<string> = {};\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.CustomSpeechDeploymentId) === -1) {\r\n queryParams[QueryParameterNames.CustomSpeechDeploymentId] = endpointId;\r\n }\r\n } else if (language) {\r\n if (!endpoint || endpoint.search(QueryParameterNames.Language) === -1) {\r\n queryParams[QueryParameterNames.Language] = language;\r\n }\r\n }\r\n\r\n if (config.autoDetectSourceLanguages !== undefined) {\r\n queryParams[QueryParameterNames.EnableLanguageId] = \"true\";\r\n }\r\n\r\n this.setV2UrlParams(config, queryParams, endpoint);\r\n\r\n if (!endpoint) {\r\n endpoint = `${host}${this.universalUri}`;\r\n }\r\n\r\n const headers: IStringDictionary<string> = {};\r\n if (authInfo.token !== undefined && authInfo.token !== \"\") {\r\n headers[authInfo.headerName] = authInfo.token;\r\n }\r\n headers[HeaderNames.ConnectionId] = connectionId;\r\n\r\n const enableCompression: boolean = config.parameters.getProperty(\"SPEECH-EnableWebsocketCompression\", \"false\") === \"true\";\r\n\r\n const webSocketConnection = new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, connectionId);\r\n\r\n // Set the value of SpeechServiceConnection_Url to webSocketConnection.uri (and not to `endpoint`), since this value is the final\r\n // URI that was used to make the connection (including query parameters).\r\n const uri: string = webSocketConnection.uri;\r\n config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, uri);\r\n\r\n return webSocketConnection;\r\n }\r\n\r\n protected setV2UrlParams(\r\n config: RecognizerConfig,\r\n queryParams: IStringDictionary<string>,\r\n endpoint: string): void {\r\n\r\n const propertyIdToParameterMap: Map<number, string> = new Map([\r\n [PropertyId.Speech_SegmentationSilenceTimeoutMs, QueryParameterNames.SegmentationSilenceTimeoutMs],\r\n [PropertyId.SpeechServiceConnection_EnableAudioLogging, QueryParameterNames.EnableAudioLogging],\r\n [PropertyId.SpeechServiceConnection_EndSilenceTimeoutMs, QueryParameterNames.EndSilenceTimeoutMs],\r\n [PropertyId.SpeechServiceConnection_InitialSilenceTimeoutMs, QueryParameterNames.InitialSilenceTimeoutMs],\r\n [PropertyId.SpeechServiceResponse_PostProcessingOption, QueryParameterNames.Postprocessing],\r\n [PropertyId.SpeechServiceResponse_ProfanityOption, QueryParameterNames.Profanity],\r\n [PropertyId.SpeechServiceResponse_StablePartialResultThreshold, QueryParameterNames.StableIntermediateThreshold],\r\n ]);\r\n\r\n propertyIdToParameterMap.forEach((parameterName: string, propertyId: PropertyId): void => {\r\n this.setUrlParameter(propertyId, parameterName, config, queryParams, endpoint);\r\n });\r\n\r\n\r\n const serviceProperties: IStringDictionary<string> = JSON.parse(config.parameters.getProperty(ServicePropertiesPropertyName, \"{}\")) as IStringDictionary<string>;\r\n\r\n Object.keys(serviceProperties).forEach((value: string): void => {\r\n queryParams[value] = serviceProperties[value];\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.js\";\r\nimport {\r\n IConnection,\r\n IStringDictionary\r\n} from \"../common/Exports.js\";\r\nimport {\r\n OutputFormat,\r\n PropertyId\r\n} from \"../sdk/Exports.js\";\r\nimport {\r\n ConnectionFactoryBase\r\n} from \"./ConnectionFactoryBase.js\";\r\nimport {\r\n AuthInfo,\r\n OutputFormatPropertyName,\r\n RecognizerConfig,\r\n WebsocketMessageFormatter\r\n} from \"./Exports.js\";\r\nimport { HeaderNames } from \"./HeaderNames.js\";\r\nimport {\r\n QueryParameterNames\r\n} from \"./QueryParameterNames.js\";\r\n\r\nexport class TranscriberConnectionFactory extends ConnectionFactoryBase {\r\n\r\n private readonly multiaudioRelativeUri: string = \"/speech/recognition/multiaudio\";\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, \"centralus\");\r\n const hostSuffix: string = ConnectionFactoryBase.getHostSuffix(region);\r\n const hostDefault: string = \"wss://transcribe.\" + region + \".cts.speech\" + hostSuffix + this.multiaudioRelativeUri;\r\n const host: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, hostDefault);\r\n\r\n const queryParams: IStringDictionary<string> = {};\r\n this.setQueryParams(queryParams, config, endpoint);\r\n\r\n if (!endpoint) {\r\n endpoint = host;\r\n }\r\n\r\n const headers: IStringDictionary<string> = {};\r\n if (authInfo.token !== undefined && authInfo.token !== \"\") {\r\n headers[authInfo.headerName] = authInfo.token;\r\n }\r\n headers[HeaderNames.ConnectionId] = connectionId;\r\n\r\n config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, endpoint);\r\n\r\n const enableCompression: boolean = config.parameters.getProperty(\"SPEECH-EnableWebsocketCompression\", \"false\") === \"true\";\r\n return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, connectionId);\r\n }\r\n\r\n public setQueryParams(queryParams: IStringDictionary<string>, config: RecognizerConfig, endpointUrl: string): void {\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 && !(QueryParameterNames.CustomSpeechDeploymentId in queryParams)) {\r\n queryParams[QueryParameterNames.CustomSpeechDeploymentId] = endpointId;\r\n }\r\n\r\n if (language && !(QueryParameterNames.Language in queryParams)) {\r\n queryParams[QueryParameterNames.Language] = language;\r\n }\r\n\r\n const wordLevelTimings: boolean = config.parameters.getProperty(PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps, \"false\").toLowerCase() === \"true\";\r\n const detailed: boolean = config.parameters.getProperty(OutputFormatPropertyName, OutputFormat[OutputFormat.Simple]) !== OutputFormat[OutputFormat.Simple];\r\n if (wordLevelTimings || detailed) {\r\n queryParams[QueryParameterNames.Format] = OutputFormat[OutputFormat.Detailed].toLowerCase();\r\n }\r\n\r\n this.setCommonUrlParams(config, queryParams, endpointUrl);\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.js\";\r\nimport {\r\n IConnection,\r\n IStringDictionary,\r\n} from \"../common/Exports.js\";\r\nimport { StringUtils } from \"../common/StringUtils.js\";\r\nimport {\r\n PropertyId\r\n} from \"../sdk/Exports.js\";\r\nimport {\r\n ConnectionFactoryBase\r\n} from \"./ConnectionFactoryBase.js\";\r\nimport {\r\n AuthInfo,\r\n RecognitionMode,\r\n RecognizerConfig,\r\n WebsocketMessageFormatter,\r\n} from \"./Exports.js\";\r\nimport { HeaderNames } from \"./HeaderNames.js\";\r\nimport { QueryParameterNames } from \"./QueryParameterNames.js\";\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 const endpoint: string = this.getEndpointUrl(config);\r\n\r\n const queryParams: IStringDictionary<string> = {};\r\n\r\n if (config.autoDetectSourceLanguages !== undefined) {\r\n queryParams[QueryParameterNames.EnableLanguageId] = \"true\";\r\n }\r\n this.setQueryParams(queryParams, config, endpoint);\r\n\r\n const headers: IStringDictionary<string> = {};\r\n if (authInfo.token !== undefined && authInfo.token !== \"\") {\r\n headers[authInfo.headerName] = authInfo.token;\r\n }\r\n headers[HeaderNames.ConnectionId] = connectionId;\r\n\r\n config.parameters.setProperty(PropertyId.SpeechServiceConnection_Url, endpoint);\r\n\r\n const enableCompression: boolean = config.parameters.getProperty(\"SPEECH-EnableWebsocketCompression\", \"false\") === \"true\";\r\n return new WebsocketConnection(endpoint, queryParams, headers, new WebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, connectionId);\r\n }\r\n\r\n public getEndpointUrl(config: RecognizerConfig, returnRegionPlaceholder?: boolean): string {\r\n\r\n const region: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Region);\r\n const hostSuffix: string = ConnectionFactoryBase.getHostSuffix(region);\r\n\r\n let endpointUrl: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Endpoint, undefined);\r\n if (!endpointUrl) {\r\n if (config.autoDetectSourceLanguages !== undefined) {\r\n const host: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, \"wss://{region}.stt.speech\" + hostSuffix);\r\n endpointUrl = host + \"/speech/universal/v2\";\r\n } else {\r\n const host: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, \"wss://{region}.s2s.speech\" + hostSuffix);\r\n endpointUrl = host + \"/speech/translation/cognitiveservices/v1\";\r\n }\r\n }\r\n\r\n if (returnRegionPlaceholder === true) {\r\n return endpointUrl;\r\n }\r\n\r\n return StringUtils.formatString(endpointUrl, { region });\r\n }\r\n\r\n public setQueryParams(queryParams: IStringDictionary<string>, config: RecognizerConfig, endpointUrl: string): void {\r\n\r\n queryParams.from = config.parameters.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage);\r\n queryParams.to = config.parameters.getProperty(PropertyId.SpeechServiceConnection_TranslationToLanguages);\r\n queryParams.scenario = config.recognitionMode === RecognitionMode.Interactive ? \"interactive\" :\r\n config.recognitionMode === RecognitionMode.Conversation ? \"conversation\" : \"\";\r\n\r\n this.setCommonUrlParams(config, queryParams, endpointUrl);\r\n this.setUrlParameter(\r\n PropertyId.SpeechServiceResponse_TranslationRequestStablePartialResult,\r\n QueryParameterNames.StableTranslation,\r\n config,\r\n queryParams,\r\n endpointUrl\r\n );\r\n\r\n const translationVoice: string = config.parameters.getProperty(PropertyId.SpeechServiceConnection_TranslationVoice, undefined);\r\n if (translationVoice !== undefined) {\r\n queryParams.voice = translationVoice;\r\n queryParams.features = \"texttospeech\";\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 CancellationErrorCode,\r\n CancellationReason,\r\n ResultReason\r\n} from \"../sdk/Exports.js\";\r\nimport { RecognitionStatus } from \"./Exports.js\";\r\n\r\nexport class EnumTranslation {\r\n public static implTranslateRecognitionResult(recognitionStatus: RecognitionStatus, expectEndOfDictation: boolean = false): 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.EndOfDictation:\r\n // If we need the result in EndOfDictation (typically some session level result),\r\n // translate into RecognizedSpeech, otherwise NoMatch\r\n reason = expectEndOfDictation ? ResultReason.RecognizedSpeech : ResultReason.NoMatch;\r\n break;\r\n case RecognitionStatus.NoMatch:\r\n case RecognitionStatus.InitialSilenceTimeout:\r\n case RecognitionStatus.BabbleTimeout:\r\n reason = ResultReason.NoMatch;\r\n break;\r\n case RecognitionStatus.Error:\r\n case RecognitionStatus.BadRequest:\r\n case RecognitionStatus.Forbidden:\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 case RecognitionStatus.BadRequest:\r\n case RecognitionStatus.Forbidden:\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 case RecognitionStatus.BadRequest:\r\n reason = CancellationErrorCode.BadRequestParameters;\r\n break;\r\n case RecognitionStatus.Forbidden:\r\n reason = CancellationErrorCode.Forbidden;\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 public static implTranslateErrorDetails(cancellationErrorCode: CancellationErrorCode): string {\r\n let errorDetails: string = \"The speech service encountered an internal error and could not continue.\";\r\n switch (cancellationErrorCode) {\r\n case CancellationErrorCode.Forbidden:\r\n errorDetails = \"The recognizer is using a free subscription that ran out of quota.\";\r\n break;\r\n case CancellationErrorCode.BadRequestParameters:\r\n errorDetails = \"Invalid parameter or unsupported audio format in the request.\";\r\n break;\r\n case CancellationErrorCode.TooManyRequests:\r\n errorDetails = \"The number of parallel requests exceeded the number of allowed concurrent transcriptions.\";\r\n break;\r\n default:\r\n break;\r\n }\r\n return errorDetails;\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 BadRequest,\r\n Forbidden,\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.js\";\r\n\r\n// translation.synthesis.end\r\nexport interface ITranslationSynthesisEnd {\r\n SynthesisStatus?: SynthesisStatus;\r\n FailureReason?: string;\r\n Status?: SynthesisStatus;\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) as ITranslationSynthesisEnd;\r\n if (!!this.privSynthesisEnd.SynthesisStatus) {\r\n this.privSynthesisEnd.SynthesisStatus = SynthesisStatus[this.privSynthesisEnd.SynthesisStatus as unknown as keyof typeof SynthesisStatus];\r\n }\r\n if (!!this.privSynthesisEnd.Status) {\r\n this.privSynthesisEnd.SynthesisStatus = SynthesisStatus[this.privSynthesisEnd.Status as unknown as keyof typeof SynthesisStatus];\r\n }\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 { Contracts } from \"../../sdk/Contracts.js\";\r\nimport { IPrimaryLanguage, ITranslations } from \"../Exports.js\";\r\nimport { TranslationStatus } from \"../TranslationStatus.js\";\r\n\r\n// translation.hypothesis\r\nexport interface ITranslationHypothesis {\r\n Duration: number;\r\n Offset: number;\r\n PrimaryLanguage?: IPrimaryLanguage;\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(hypothesis: ITranslationHypothesis) {\r\n this.privTranslationHypothesis = hypothesis;\r\n this.privTranslationHypothesis.Translation.TranslationStatus = TranslationStatus[this.privTranslationHypothesis.Translation.TranslationStatus as unknown as keyof typeof TranslationStatus];\r\n }\r\n\r\n public static fromJSON(json: string): TranslationHypothesis {\r\n return new TranslationHypothesis(JSON.parse(json) as ITranslationHypothesis);\r\n }\r\n\r\n public static fromTranslationResponse(translationHypothesis: { SpeechHypothesis: ITranslationHypothesis }): TranslationHypothesis {\r\n Contracts.throwIfNullOrUndefined(translationHypothesis, \"translationHypothesis\");\r\n const hypothesis: ITranslationHypothesis = translationHypothesis.SpeechHypothesis;\r\n translationHypothesis.SpeechHypothesis = undefined;\r\n hypothesis.Translation = (translationHypothesis as unknown as ITranslations);\r\n return new TranslationHypothesis(hypothesis);\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 public get Language(): string {\r\n return this.privTranslationHypothesis.PrimaryLanguage?.Language;\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 \"../../sdk/Contracts.js\";\r\nimport { IPrimaryLanguage, ITranslations, RecognitionStatus } from \"../Exports.js\";\r\nimport { TranslationStatus } from \"../TranslationStatus.js\";\r\n\r\n// translation.phrase\r\nexport interface ITranslationPhrase {\r\n RecognitionStatus: RecognitionStatus;\r\n Offset: number;\r\n Duration: number;\r\n Translation?: ITranslations;\r\n Text?: string;\r\n DisplayText?: string;\r\n PrimaryLanguage?: IPrimaryLanguage;\r\n}\r\n\r\nexport class TranslationPhrase implements ITranslationPhrase {\r\n private privTranslationPhrase: ITranslationPhrase;\r\n\r\n private constructor(phrase: ITranslationPhrase) {\r\n this.privTranslationPhrase = phrase;\r\n this.privTranslationPhrase.RecognitionStatus = RecognitionStatus[this.privTranslationPhrase.RecognitionStatus as unknown as keyof typeof RecognitionStatus];\r\n if (this.privTranslationPhrase.Translation !== undefined) {\r\n this.privTranslationPhrase.Translation.TranslationStatus = TranslationStatus[this.privTranslationPhrase.Translation.TranslationStatus as unknown as keyof typeof TranslationStatus];\r\n }\r\n }\r\n\r\n public static fromJSON(json: string): TranslationPhrase {\r\n return new TranslationPhrase(JSON.parse(json) as ITranslationPhrase);\r\n }\r\n\r\n public static fromTranslationResponse(translationResponse: { SpeechPhrase: ITranslationPhrase }): TranslationPhrase {\r\n Contracts.throwIfNullOrUndefined(translationResponse, \"translationResponse\");\r\n const phrase: ITranslationPhrase = translationResponse.SpeechPhrase;\r\n translationResponse.SpeechPhrase = undefined;\r\n phrase.Translation = (translationResponse as unknown as ITranslations);\r\n phrase.Text = phrase.DisplayText;\r\n return new TranslationPhrase(phrase);\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 | undefined {\r\n return this.privTranslationPhrase.Text;\r\n }\r\n\r\n public get Language(): string | undefined {\r\n return this.privTranslationPhrase.PrimaryLanguage?.Language;\r\n }\r\n\r\n public get Confidence(): string | undefined {\r\n return this.privTranslationPhrase.PrimaryLanguage?.Confidence;\r\n }\r\n\r\n public get Translation(): ITranslations | undefined {\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 ConnectionEvent,\r\n IAudioSource,\r\n MessageType,\r\n TranslationStatus,\r\n} from \"../common/Exports.js\";\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.js\";\r\nimport {\r\n CancellationErrorCodePropertyName,\r\n ConversationServiceRecognizer,\r\n EnumTranslation,\r\n ITranslationHypothesis,\r\n RecognitionStatus,\r\n SynthesisStatus,\r\n TranslationHypothesis,\r\n TranslationPhrase,\r\n TranslationSynthesisEnd,\r\n} from \"./Exports.js\";\r\nimport { IAuthentication } from \"./IAuthentication.js\";\r\nimport { IConnectionFactory } from \"./IConnectionFactory.js\";\r\nimport { RecognizerConfig } from \"./RecognizerConfig.js\";\r\nimport { ITranslationPhrase } from \"./ServiceMessages/TranslationPhrase.js\";\r\nimport { SpeechConnectionMessage } from \"./SpeechConnectionMessage.Internal.js\";\r\n\r\n// eslint-disable-next-line max-classes-per-file\r\nexport class TranslationServiceRecognizer extends ConversationServiceRecognizer {\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 this.connectionEvents.attach((connectionEvent: ConnectionEvent): void => {\r\n if (connectionEvent.name === \"ConnectionEstablishedEvent\") {\r\n this.privTranslationRecognizer.onConnection();\r\n }\r\n });\r\n\r\n }\r\n\r\n protected async processTypeSpecificMessages(connectionMessage: SpeechConnectionMessage): Promise<boolean> {\r\n\r\n const resultProps: PropertyCollection = new PropertyCollection();\r\n let processed: boolean = await this.processSpeechMessages(connectionMessage);\r\n if (processed) {\r\n return true;\r\n }\r\n\r\n const handleTranslationPhrase = async (translatedPhrase: TranslationPhrase): Promise<void> => {\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 /* eslint-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 as string);\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 } 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 translatedPhrase.Language,\r\n translatedPhrase.Confidence,\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 const cancellationErrorCode: CancellationErrorCode = EnumTranslation.implTranslateCancelErrorCode(translatedPhrase.RecognitionStatus);\r\n\r\n await this.cancelRecognitionLocal(\r\n cancelReason,\r\n cancellationErrorCode,\r\n EnumTranslation.implTranslateErrorDetails(cancellationErrorCode));\r\n\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 /* eslint-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 as string);\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 }\r\n\r\n };\r\n\r\n const handleTranslationHypothesis = (hypothesis: TranslationHypothesis, resultProperties: PropertyCollection): void => {\r\n const result: TranslationRecognitionEventArgs = this.fireEventForResult(hypothesis, resultProperties);\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 /* eslint-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 };\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 handleTranslationHypothesis(TranslationHypothesis.fromJSON(connectionMessage.textBody), resultProps);\r\n break;\r\n\r\n case \"translation.response\":\r\n const phrase: { SpeechPhrase: ITranslationPhrase } = JSON.parse(connectionMessage.textBody) as { SpeechPhrase: ITranslationPhrase };\r\n if (!!phrase.SpeechPhrase) {\r\n await handleTranslationPhrase(TranslationPhrase.fromTranslationResponse(phrase));\r\n } else {\r\n const hypothesis: { SpeechHypothesis: ITranslationHypothesis } = JSON.parse(connectionMessage.textBody) as { SpeechHypothesis: ITranslationHypothesis };\r\n if (!!hypothesis.SpeechHypothesis) {\r\n handleTranslationHypothesis(TranslationHypothesis.fromTranslationResponse(hypothesis), resultProps);\r\n }\r\n }\r\n break;\r\n case \"translation.phrase\":\r\n await handleTranslationPhrase(TranslationPhrase.fromJSON(connectionMessage.textBody));\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 \"audio.end\":\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 /* eslint-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 /* eslint-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 /* eslint-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 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 /* eslint-disable no-empty */\r\n this.privSuccessCallback = undefined;\r\n } catch { }\r\n }\r\n }\r\n\r\n protected handleRecognizingCallback(result: SpeechRecognitionResult, duration: number, sessionId: string): void {\r\n try {\r\n const ev = new TranslationRecognitionEventArgs(TranslationRecognitionResult.fromSpeechRecognitionResult(result), duration, sessionId);\r\n this.privTranslationRecognizer.recognizing(this.privTranslationRecognizer, ev);\r\n /* eslint-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 protected handleRecognizedCallback(result: SpeechRecognitionResult, offset: number, sessionId: string): void {\r\n try {\r\n const ev = new TranslationRecognitionEventArgs(TranslationRecognitionResult.fromSpeechRecognitionResult(result), offset, sessionId);\r\n this.privTranslationRecognizer.recognized(this.privTranslationRecognizer, 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 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 || translation.DisplayText);\r\n }\r\n }\r\n\r\n let resultReason: ResultReason;\r\n let confidence: string;\r\n if (serviceResult instanceof TranslationPhrase) {\r\n if (!!serviceResult.Translation && serviceResult.Translation.TranslationStatus === TranslationStatus.Success) {\r\n resultReason = ResultReason.TranslatedSpeech;\r\n } else {\r\n resultReason = ResultReason.RecognizedSpeech;\r\n }\r\n confidence = serviceResult.Confidence;\r\n } else {\r\n resultReason = ResultReason.TranslatingSpeech;\r\n }\r\n const language = serviceResult.Language;\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 language,\r\n confidence,\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 /* eslint-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) as ISpeechDetected;\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.js\";\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 SpeakerId?: string;\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) as ISpeechHypothesis;\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 public get SpeakerId(): string {\r\n return this.privSpeechHypothesis.SpeakerId;\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.keyword\r\nexport interface ISpeechKeyword {\r\n Status: string;\r\n Text: string;\r\n Offset: number;\r\n Duration: number;\r\n}\r\n\r\nexport class SpeechKeyword implements ISpeechKeyword {\r\n private privSpeechKeyword: ISpeechKeyword;\r\n\r\n private constructor(json: string) {\r\n this.privSpeechKeyword = JSON.parse(json) as ISpeechKeyword;\r\n }\r\n\r\n public static fromJSON(json: string): SpeechKeyword {\r\n return new SpeechKeyword(json);\r\n }\r\n\r\n public get Status(): string {\r\n return this.privSpeechKeyword.Status;\r\n }\r\n\r\n public get Text(): string {\r\n return this.privSpeechKeyword.Text;\r\n }\r\n\r\n public get Offset(): number {\r\n return this.privSpeechKeyword.Offset;\r\n }\r\n\r\n public get Duration(): number {\r\n return this.privSpeechKeyword.Duration;\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.js\";\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.js\";\r\nimport {\r\n CancellationErrorCodePropertyName,\r\n DetailedSpeechPhrase,\r\n EnumTranslation,\r\n OutputFormatPropertyName,\r\n RecognitionStatus,\r\n ServiceRecognizerBase,\r\n SimpleSpeechPhrase,\r\n SpeechHypothesis,\r\n} from \"./Exports.js\";\r\nimport { IAuthentication } from \"./IAuthentication.js\";\r\nimport { IConnectionFactory } from \"./IConnectionFactory.js\";\r\nimport { RecognizerConfig } from \"./RecognizerConfig.js\";\r\nimport { SpeechConnectionMessage } from \"./SpeechConnectionMessage.Internal.js\";\r\n\r\n// eslint-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\r\n }\r\n\r\n protected async processTypeSpecificMessages(connectionMessage: SpeechConnectionMessage): Promise<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, // Speaker Id\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 /* eslint-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, this.privExpectContentAssessmentResponse);\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 const cancellationErrorCode: CancellationErrorCode = EnumTranslation.implTranslateCancelErrorCode(simple.RecognitionStatus);\r\n\r\n await this.cancelRecognitionLocal(\r\n cancelReason,\r\n cancellationErrorCode,\r\n EnumTranslation.implTranslateErrorDetails(cancellationErrorCode));\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, // Speaker Id\r\n undefined,\r\n connectionMessage.textBody,\r\n resultProps);\r\n } else {\r\n const detailed: DetailedSpeechPhrase = DetailedSpeechPhrase.fromJSON(connectionMessage.textBody);\r\n const totalOffset: number = detailed.Offset + this.privRequestSession.currentTurnAudioOffset;\r\n const offsetCorrectedJson: string = detailed.getJsonWithCorrectedOffsets(totalOffset);\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 totalOffset,\r\n detailed.Language,\r\n detailed.LanguageDetectionConfidence,\r\n undefined, // Speaker Id\r\n undefined,\r\n offsetCorrectedJson,\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 /* eslint-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 as string);\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 /* eslint-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 undefined, // Speaker Id\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 /* eslint-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 { IAudioSource } from \"../common/Exports.js\";\r\nimport {\r\n CancellationErrorCode,\r\n CancellationReason,\r\n OutputFormat,\r\n PropertyCollection,\r\n PropertyId,\r\n ResultReason,\r\n ConversationTranscriptionCanceledEventArgs,\r\n ConversationTranscriptionEventArgs,\r\n ConversationTranscriptionResult,\r\n ConversationTranscriber,\r\n} from \"../sdk/Exports.js\";\r\nimport {\r\n CancellationErrorCodePropertyName,\r\n DetailedSpeechPhrase,\r\n EnumTranslation,\r\n OutputFormatPropertyName,\r\n RecognitionStatus,\r\n ServiceRecognizerBase,\r\n SimpleSpeechPhrase,\r\n SpeechHypothesis,\r\n} from \"./Exports.js\";\r\nimport { IAuthentication } from \"./IAuthentication.js\";\r\nimport { IConnectionFactory } from \"./IConnectionFactory.js\";\r\nimport { RecognizerConfig } from \"./RecognizerConfig.js\";\r\nimport { SpeechConnectionMessage } from \"./SpeechConnectionMessage.Internal.js\";\r\nimport { PhraseDetection, SpeakerDiarization } from \"./ServiceRecognizerBase.js\";\r\n\r\n// eslint-disable-next-line max-classes-per-file\r\nexport class ConversationTranscriptionServiceRecognizer extends ServiceRecognizerBase {\r\n\r\n private privConversationTranscriber: ConversationTranscriber;\r\n\r\n public constructor(\r\n authentication: IAuthentication,\r\n connectionFactory: IConnectionFactory,\r\n audioSource: IAudioSource,\r\n recognizerConfig: RecognizerConfig,\r\n conversationTranscriber: ConversationTranscriber) {\r\n super(authentication, connectionFactory, audioSource, recognizerConfig, conversationTranscriber);\r\n this.privConversationTranscriber = conversationTranscriber;\r\n this.setSpeakerDiarizationJson();\r\n }\r\n\r\n protected setSpeakerDiarizationJson(): void {\r\n if (this.privEnableSpeakerId) {\r\n const phraseDetection = this.privSpeechContext.getSection(\"phraseDetection\") as PhraseDetection;\r\n phraseDetection.mode = \"Conversation\";\r\n const speakerDiarization: SpeakerDiarization = {};\r\n speakerDiarization.mode = \"Anonymous\";\r\n speakerDiarization.audioSessionId = this.privDiarizationSessionId;\r\n speakerDiarization.audioOffsetMs = 0;\r\n phraseDetection.speakerDiarization = speakerDiarization;\r\n this.privSpeechContext.setSection(\"phraseDetection\", phraseDetection);\r\n }\r\n }\r\n\r\n protected async processTypeSpecificMessages(connectionMessage: SpeechConnectionMessage): Promise<boolean> {\r\n\r\n let result: ConversationTranscriptionResult;\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 ConversationTranscriptionResult(\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, // Speaker Id\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 ConversationTranscriptionEventArgs(result, hypothesis.Duration, this.privRequestSession.sessionId);\r\n\r\n if (!!this.privConversationTranscriber.transcribing) {\r\n try {\r\n this.privConversationTranscriber.transcribing(this.privConversationTranscriber, ev);\r\n /* eslint-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 const cancellationErrorCode: CancellationErrorCode = EnumTranslation.implTranslateCancelErrorCode(simple.RecognitionStatus);\r\n\r\n await this.cancelRecognitionLocal(\r\n cancelReason,\r\n cancellationErrorCode,\r\n EnumTranslation.implTranslateErrorDetails(cancellationErrorCode));\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 ConversationTranscriptionResult(\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 simple.SpeakerId,\r\n undefined,\r\n connectionMessage.textBody,\r\n resultProps);\r\n } else {\r\n const detailed: DetailedSpeechPhrase = DetailedSpeechPhrase.fromJSON(connectionMessage.textBody);\r\n const totalOffset: number = detailed.Offset + this.privRequestSession.currentTurnAudioOffset;\r\n const offsetCorrectedJson: string = detailed.getJsonWithCorrectedOffsets(totalOffset);\r\n\r\n result = new ConversationTranscriptionResult(\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 totalOffset,\r\n detailed.Language,\r\n detailed.LanguageDetectionConfidence,\r\n simple.SpeakerId,\r\n undefined,\r\n offsetCorrectedJson,\r\n resultProps);\r\n }\r\n\r\n const event: ConversationTranscriptionEventArgs = new ConversationTranscriptionEventArgs(result, result.offset, this.privRequestSession.sessionId);\r\n\r\n if (!!this.privConversationTranscriber.transcribed) {\r\n try {\r\n this.privConversationTranscriber.transcribed(this.privConversationTranscriber, event);\r\n /* eslint-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 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.privConversationTranscriber.canceled) {\r\n const cancelEvent: ConversationTranscriptionCanceledEventArgs = new ConversationTranscriptionCanceledEventArgs(\r\n cancellationReason,\r\n error,\r\n errorCode,\r\n undefined,\r\n sessionId);\r\n try {\r\n this.privConversationTranscriber.canceled(this.privConversationTranscriber, cancelEvent);\r\n /* eslint-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 {\r\n IAudioSource,\r\n IConnection,\r\n MessageType\r\n} from \"../common/Exports.js\";\r\nimport {\r\n CancellationErrorCode,\r\n CancellationReason,\r\n ConversationTranscriptionCanceledEventArgs,\r\n MeetingTranscriptionCanceledEventArgs,\r\n PropertyCollection,\r\n PropertyId,\r\n ResultReason,\r\n SpeechRecognitionEventArgs,\r\n SpeechRecognitionResult,\r\n} from \"../sdk/Exports.js\";\r\nimport { ConversationInfo, MeetingInfo } from \"../sdk/Transcription/Exports.js\";\r\nimport { ConversationProperties } from \"../sdk/Transcription/IConversation.js\";\r\nimport { MeetingProperties } from \"../sdk/Transcription/IMeeting.js\";\r\nimport {\r\n CancellationErrorCodePropertyName,\r\n ConversationServiceRecognizer,\r\n TranscriberRecognizer\r\n} from \"./Exports.js\";\r\nimport { IAuthentication } from \"./IAuthentication.js\";\r\nimport { IConnectionFactory } from \"./IConnectionFactory.js\";\r\nimport { RecognizerConfig } from \"./RecognizerConfig.js\";\r\nimport { SpeechConnectionMessage } from \"./SpeechConnectionMessage.Internal.js\";\r\n\r\n// eslint-disable-next-line max-classes-per-file\r\nexport class TranscriptionServiceRecognizer extends ConversationServiceRecognizer {\r\n\r\n private privTranscriberRecognizer: TranscriberRecognizer;\r\n\r\n public constructor(\r\n authentication: IAuthentication,\r\n connectionFactory: IConnectionFactory,\r\n audioSource: IAudioSource,\r\n recognizerConfig: RecognizerConfig,\r\n transcriber: TranscriberRecognizer) {\r\n super(authentication, connectionFactory, audioSource, recognizerConfig, transcriber);\r\n this.privTranscriberRecognizer = transcriber;\r\n this.sendPrePayloadJSONOverride = (connection: IConnection): Promise<void> => this.sendTranscriptionStartJSON(connection);\r\n if (this.privRecognizerConfig.parameters.getProperty(PropertyId.SpeechServiceResponse_RequestWordLevelTimestamps) === \"true\") {\r\n this.privSpeechContext.setWordLevelTimings();\r\n }\r\n }\r\n\r\n public async sendSpeechEventAsync(info: ConversationInfo, command: string): Promise<void> {\r\n if (!!this.privRequestSession.isRecognizing) {\r\n const connection: IConnection = await this.fetchConnection();\r\n await this.sendSpeechEvent(connection, this.createSpeechEventPayload(info, command));\r\n }\r\n }\r\n\r\n public async sendMeetingSpeechEventAsync(info: MeetingInfo, command: string): Promise<void> {\r\n if (!!this.privRequestSession.isRecognizing) {\r\n const connection: IConnection = await this.fetchConnection();\r\n await this.sendSpeechEvent(connection, this.createMeetingSpeechEventPayload(info, command));\r\n }\r\n }\r\n\r\n protected processTypeSpecificMessages(connectionMessage: SpeechConnectionMessage): Promise<boolean> {\r\n return this.processSpeechMessages(connectionMessage);\r\n }\r\n\r\n protected handleRecognizedCallback(result: SpeechRecognitionResult, offset: number, sessionId: string): void {\r\n try {\r\n const event: SpeechRecognitionEventArgs = new SpeechRecognitionEventArgs(result, offset, sessionId);\r\n this.privTranscriberRecognizer.recognized(this.privTranscriberRecognizer, event);\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 as string);\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 /* eslint-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 protected handleRecognizingCallback(result: SpeechRecognitionResult, duration: number, sessionId: string): void {\r\n try {\r\n const ev = new SpeechRecognitionEventArgs(result, duration, sessionId);\r\n this.privTranscriberRecognizer.recognizing(this.privTranscriberRecognizer, ev);\r\n /* eslint-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 // 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.privTranscriberRecognizer.IsMeetingRecognizer()) {\r\n if (!!this.privTranscriberRecognizer.canceled) {\r\n const cancelEvent: MeetingTranscriptionCanceledEventArgs = new MeetingTranscriptionCanceledEventArgs(\r\n cancellationReason,\r\n error,\r\n errorCode,\r\n undefined,\r\n sessionId);\r\n try {\r\n this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer, cancelEvent);\r\n /* eslint-disable no-empty */\r\n } catch { }\r\n }\r\n } else {\r\n if (!!this.privTranscriberRecognizer.canceled) {\r\n const cancelEvent: ConversationTranscriptionCanceledEventArgs = new ConversationTranscriptionCanceledEventArgs(\r\n cancellationReason,\r\n error,\r\n errorCode,\r\n undefined,\r\n sessionId);\r\n try {\r\n this.privTranscriberRecognizer.canceled(this.privTranscriberRecognizer, cancelEvent);\r\n /* eslint-disable no-empty */\r\n } catch { }\r\n }\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 undefined, // Speaker Id\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 /* eslint-disable no-empty */\r\n } catch { }\r\n }\r\n }\r\n\r\n // Encapsulated for derived service recognizers that need to send additional JSON\r\n protected async sendTranscriptionStartJSON(connection: IConnection): Promise<void> {\r\n await this.sendSpeechContext(connection, true);\r\n if (this.privTranscriberRecognizer.IsMeetingRecognizer()) {\r\n const info: MeetingInfo = this.privTranscriberRecognizer.getMeetingInfo();\r\n const payload: { [id: string]: any } = this.createMeetingSpeechEventPayload(info, \"start\");\r\n await this.sendSpeechEvent(connection, payload);\r\n } else {\r\n const info: ConversationInfo = this.privTranscriberRecognizer.getConversationInfo();\r\n const payload: { [id: string]: any } = this.createSpeechEventPayload(info, \"start\");\r\n await this.sendSpeechEvent(connection, payload);\r\n }\r\n await this.sendWaveHeader(connection);\r\n return;\r\n }\r\n\r\n protected sendSpeechEvent(connection: IConnection, payload: { [id: string]: any }): Promise<void> {\r\n const speechEventJson = JSON.stringify(payload);\r\n\r\n if (speechEventJson) {\r\n return connection.send(new SpeechConnectionMessage(\r\n MessageType.Text,\r\n \"speech.event\",\r\n this.privRequestSession.requestId,\r\n \"application/json\",\r\n speechEventJson));\r\n }\r\n return;\r\n }\r\n\r\n private createSpeechEventPayload(info: ConversationInfo, command: string): { [id: string]: any } {\r\n const eventDict: { id: string; name: string; meeting: ConversationProperties } = { id: \"meeting\", name: command, meeting: info.conversationProperties };\r\n eventDict.meeting.id = info.id;\r\n eventDict.meeting.attendees = info.participants;\r\n return eventDict;\r\n }\r\n\r\n private createMeetingSpeechEventPayload(info: MeetingInfo, command: string): { [id: string]: any } {\r\n const eventDict: { id: string; name: string; meeting: MeetingProperties } = { id: \"meeting\", name: command, meeting: info.meetingProperties };\r\n eventDict.meeting.id = info.id;\r\n eventDict.meeting.attendees = info.participants;\r\n return eventDict;\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.js\";\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 DisplayText?: string;\r\n SpeakerId?: string;\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 DisplayText?: string;\r\n Words?: IWord[];\r\n DisplayWords?: IWord[];\r\n}\r\n\r\nexport interface IWord {\r\n Word: string;\r\n Offset: number;\r\n Duration: number;\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) as IDetailedSpeechPhrase;\r\n this.privDetailedSpeechPhrase.RecognitionStatus = RecognitionStatus[this.privDetailedSpeechPhrase.RecognitionStatus as unknown as keyof typeof 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 getJsonWithCorrectedOffsets(baseOffset: number): string {\r\n if (!!this.privDetailedSpeechPhrase.NBest) {\r\n let firstWordOffset: number;\r\n for (const phrase of this.privDetailedSpeechPhrase.NBest) {\r\n if (!!phrase.Words && !!phrase.Words[0]) {\r\n firstWordOffset = phrase.Words[0].Offset;\r\n break;\r\n }\r\n }\r\n if (!!firstWordOffset && firstWordOffset < baseOffset) {\r\n const offset: number = baseOffset - firstWordOffset;\r\n for (const details of this.privDetailedSpeechPhrase.NBest) {\r\n if (!!details.Words) {\r\n for (const word of details.Words) {\r\n word.Offset += offset;\r\n }\r\n }\r\n if (!!details.DisplayWords) {\r\n for (const word of details.DisplayWords) {\r\n word.Offset += offset;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n return JSON.stringify(this.privDetailedSpeechPhrase);\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 public get Text(): string {\r\n if (!!this.privDetailedSpeechPhrase.NBest && this.privDetailedSpeechPhrase.NBest[0]) {\r\n return this.privDetailedSpeechPhrase.NBest[0].Display || this.privDetailedSpeechPhrase.NBest[0].DisplayText;\r\n }\r\n return this.privDetailedSpeechPhrase.DisplayText;\r\n }\r\n public get SpeakerId(): string {\r\n return this.privDetailedSpeechPhrase.SpeakerId;\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.js\";\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 SpeakerId?: string;\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) as ISimpleSpeechPhrase;\r\n this.privSimpleSpeechPhrase.RecognitionStatus = RecognitionStatus[this.privSimpleSpeechPhrase.RecognitionStatus as unknown as keyof typeof 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 public get SpeakerId(): string {\r\n return this.privSimpleSpeechPhrase.SpeakerId;\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.js\";\r\n\r\n/**\r\n * @class AddedLmIntent\r\n */\r\n// eslint-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 Deferred,\r\n IAudioSource,\r\n MessageType,\r\n} from \"../common/Exports.js\";\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} from \"../sdk/Exports.js\";\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.js\";\r\nimport { IAuthentication } from \"./IAuthentication.js\";\r\nimport { IConnectionFactory } from \"./IConnectionFactory.js\";\r\nimport { RecognizerConfig } from \"./RecognizerConfig.js\";\r\nimport { SpeechConnectionMessage } from \"./SpeechConnectionMessage.Internal.js\";\r\n\r\n// eslint-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): Promise<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 /* eslint-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 = (): void => {\r\n if (!!this.privIntentRecognizer.recognized) {\r\n try {\r\n this.privIntentRecognizer.recognized(this.privIntentRecognizer, ev);\r\n /* eslint-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 as string);\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, 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\r\n if (null !== intentResponse && !!intentResponse.topScoringIntent && !!intentResponse.topScoringIntent.intent) {\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 (!!addedIntent) {\r\n const intentId = addedIntent === undefined || 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 }\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 /* eslint-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 as string);\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 const defferal = new Deferred<boolean>();\r\n defferal.resolve(processed);\r\n return defferal.promise;\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 /* eslint-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 /* eslint-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 if (json === \"\") {\r\n this.privIntentResponse = {};\r\n } else {\r\n this.privIntentResponse = JSON.parse(json) as IIntentResponse;\r\n }\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\n/* eslint-disable max-classes-per-file */\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.js\";\r\nimport { ConnectingToServiceEvent, RecognitionTriggeredEvent } from \"./RecognitionEvents.js\";\r\n\r\nexport interface ITelemetry {\r\n Metrics: IMetric[];\r\n ReceivedMessages: IStringDictionary<string[]>;\r\n}\r\n\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\nexport class ServiceTelemetryListener implements IEventListener<PlatformEvent> {\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<string[]>;\r\n private privPhraseLatencies: number[];\r\n private privHypothesisLatencies: number[];\r\n\r\n public 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<string>();\r\n }\r\n const maxMessagesToSend = 50;\r\n if (this.privReceivedMessages[e.message.headers.path].length < maxMessagesToSend) {\r\n this.privReceivedMessages[e.message.headers.path].push(e.networkReceivedTime);\r\n }\r\n }\r\n }\r\n }\r\n\r\n public getTelemetry(): string {\r\n const metrics = new Array<IMetric>();\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 { ReplayableAudioNode } from \"../common.browser/Exports.js\";\r\nimport {\r\n createNoDashGuid,\r\n Deferred,\r\n Events,\r\n IDetachable,\r\n IEventSource,\r\n PlatformEvent\r\n} from \"../common/Exports.js\";\r\nimport {\r\n ConnectingToServiceEvent,\r\n ListeningStartedEvent,\r\n RecognitionStartedEvent,\r\n RecognitionTriggeredEvent,\r\n SpeechRecognitionEvent,\r\n} from \"./RecognitionEvents.js\";\r\nimport { ServiceTelemetryListener } from \"./ServiceTelemetryListener.Internal.js\";\r\n\r\nexport class RequestSession {\r\n private privIsDisposed: boolean = false;\r\n private privServiceTelemetryListener: ServiceTelemetryListener;\r\n private privDetachables: IDetachable[] = new Array<IDetachable>();\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 privRecognitionBytesSent: number = 0;\r\n private privRecogNumber: number = 0;\r\n private privSessionId: string;\r\n private privTurnDeferral: Deferred<void>;\r\n private privInTurn: boolean = false;\r\n private privConnectionAttempts: number = 0;\r\n\r\n public constructor(audioSourceId: string) {\r\n this.privAudioSourceId = audioSourceId;\r\n this.privRequestId = createNoDashGuid();\r\n this.privAudioNodeId = createNoDashGuid();\r\n this.privTurnDeferral = new Deferred<void>();\r\n\r\n // We're not in a turn, so resolve.\r\n this.privTurnDeferral.resolve();\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<void> {\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 public get numConnectionAttempts(): number {\r\n return this.privConnectionAttempts;\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\r\n // The number of bytes sent for the current recognition.\r\n // Counter is reset to 0 each time recognition is started.\r\n public get recognitionBytesSent(): number {\r\n return this.privRecognitionBytesSent;\r\n }\r\n\r\n public listenForServiceTelemetry(eventSource: IEventSource<PlatformEvent>): 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.privRecognitionBytesSent = 0;\r\n this.privIsSpeechEnded = false;\r\n this.privIsRecognizing = true;\r\n this.privTurnStartAudioOffset = 0;\r\n this.privLastRecoOffset = 0;\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 async onAudioSourceAttachCompleted(audioNode: ReplayableAudioNode, isError: boolean): Promise<void> {\r\n this.privAudioNode = audioNode;\r\n this.privIsAudioNodeDetached = false;\r\n\r\n if (isError) {\r\n await 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 async onAuthCompleted(isError: boolean): Promise<void> {\r\n if (isError) {\r\n await this.onComplete();\r\n }\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public async onConnectionEstablishCompleted(statusCode: number, reason?: string): Promise<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 await this.onComplete();\r\n }\r\n }\r\n\r\n public async onServiceTurnEndResponse(continuousRecognition: boolean): Promise<void> {\r\n this.privTurnDeferral.resolve();\r\n\r\n if (!continuousRecognition || this.isSpeechEnded) {\r\n await this.onComplete();\r\n this.privInTurn = false;\r\n } else {\r\n // Start a new request set.\r\n this.privTurnStartAudioOffset = this.privLastRecoOffset;\r\n this.privAudioNode.replay();\r\n }\r\n }\r\n\r\n public onSpeechContext(): void {\r\n this.privRequestId = createNoDashGuid();\r\n }\r\n\r\n public onServiceTurnStartResponse(): void {\r\n if (!!this.privTurnDeferral && !!this.privInTurn) {\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 // Avoid UnhandledPromiseRejection if privTurnDeferral is not being awaited\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n this.privTurnDeferral.promise.then().catch((): void => { });\r\n }\r\n this.privInTurn = true;\r\n this.privTurnDeferral = new Deferred<void>();\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 this.privConnectionAttempts = 0;\r\n }\r\n\r\n public onAudioSent(bytesSent: number): void {\r\n this.privBytesSent += bytesSent;\r\n this.privRecognitionBytesSent += bytesSent;\r\n }\r\n\r\n public onRetryConnection(): void {\r\n this.privConnectionAttempts++;\r\n }\r\n\r\n public async dispose(): Promise<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 await detachable.detach();\r\n }\r\n\r\n if (!!this.privServiceTelemetryListener) {\r\n this.privServiceTelemetryListener.dispose();\r\n }\r\n this.privIsRecognizing = false;\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 async onStopRecognizing(): Promise<void> {\r\n await 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 async onComplete(): Promise<void> {\r\n if (!!this.privIsRecognizing) {\r\n this.privIsRecognizing = false;\r\n await this.detachAudioNode();\r\n }\r\n }\r\n\r\n private async detachAudioNode(): Promise<void> {\r\n if (!this.privIsAudioNodeDetached) {\r\n this.privIsAudioNodeDetached = true;\r\n if (this.privAudioNode) {\r\n await 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 DynamicGrammarBuilder,\r\n IDynamicGrammar,\r\n} from \"./Exports.js\";\r\n\r\ninterface Context {\r\n [section: string]: any;\r\n}\r\n\r\ninterface PhraseContext {\r\n [section: string]: any;\r\n phraseDetection?: {\r\n enrichment?: {\r\n pronunciationAssessment: any;\r\n contentAssessment?: {\r\n topic: string;\r\n };\r\n };\r\n speakerDiarization?: {\r\n mode?: string;\r\n audioSessionId?: string;\r\n audioOffsetMs?: number;\r\n identityProvider?: string;\r\n };\r\n mode?: string;\r\n };\r\n phraseOutput?: {\r\n detailed?: {\r\n options?: string[];\r\n };\r\n format?: any;\r\n };\r\n}\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: PhraseContext = {};\r\n private privDynamicGrammar: DynamicGrammarBuilder;\r\n\r\n public constructor(dynamicGrammar: DynamicGrammarBuilder) {\r\n this.privDynamicGrammar = dynamicGrammar;\r\n }\r\n\r\n /**\r\n * Gets a section of the speech.context object.\r\n * @param sectionName Name of the section to get.\r\n * @return string or Context JSON serializable object that represents the value.\r\n */\r\n public getSection(sectionName: string): string | Context {\r\n return (this.privContext[sectionName] || {}) as string | Context;\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: string | Context): void {\r\n this.privContext[sectionName] = value;\r\n }\r\n\r\n /**\r\n * @Internal\r\n * This is only used by pronunciation assessment config.\r\n * Do not use externally, object returned will change without warning or notice.\r\n */\r\n public setPronunciationAssessmentParams(params: string,\r\n contentAssessmentTopic: string,\r\n isSpeakerDiarizationEnabled: boolean = false): void {\r\n if (this.privContext.phraseDetection === undefined) {\r\n this.privContext.phraseDetection = {\r\n enrichment: {\r\n pronunciationAssessment: {}\r\n }\r\n };\r\n }\r\n if (this.privContext.phraseDetection.enrichment === undefined) {\r\n this.privContext.phraseDetection.enrichment = {\r\n pronunciationAssessment: {}\r\n };\r\n }\r\n this.privContext.phraseDetection.enrichment.pronunciationAssessment = JSON.parse(params) as Context;\r\n if (isSpeakerDiarizationEnabled) {\r\n this.privContext.phraseDetection.mode = \"Conversation\";\r\n }\r\n this.setWordLevelTimings();\r\n this.privContext.phraseOutput.detailed.options.push(\"PronunciationAssessment\");\r\n if (this.privContext.phraseOutput.detailed.options.indexOf(\"SNR\") === -1) {\r\n this.privContext.phraseOutput.detailed.options.push(\"SNR\");\r\n }\r\n if (!!contentAssessmentTopic) {\r\n this.privContext.phraseDetection.enrichment.contentAssessment = {\r\n topic: contentAssessmentTopic\r\n };\r\n this.privContext.phraseOutput.detailed.options.push(\"ContentAssessment\");\r\n }\r\n }\r\n\r\n public setDetailedOutputFormat(): void {\r\n if (this.privContext.phraseOutput === undefined) {\r\n this.privContext.phraseOutput = {\r\n detailed: {\r\n options: []\r\n },\r\n format: {}\r\n };\r\n }\r\n if (this.privContext.phraseOutput.detailed === undefined) {\r\n this.privContext.phraseOutput.detailed = {\r\n options: []\r\n };\r\n }\r\n this.privContext.phraseOutput.format = \"Detailed\";\r\n }\r\n\r\n public setWordLevelTimings(): void {\r\n if (this.privContext.phraseOutput === undefined) {\r\n this.privContext.phraseOutput = {\r\n detailed: {\r\n options: []\r\n },\r\n format: {}\r\n };\r\n }\r\n if (this.privContext.phraseOutput.detailed === undefined) {\r\n this.privContext.phraseOutput.detailed = {\r\n options: []\r\n };\r\n }\r\n this.privContext.phraseOutput.format = \"Detailed\";\r\n if (this.privContext.phraseOutput.detailed.options.indexOf(\"WordTimings\") === -1) {\r\n this.privContext.phraseOutput.detailed.options.push(\"WordTimings\");\r\n }\r\n }\r\n\r\n public setSpeakerDiarizationAudioOffsetMs(audioOffsetMs: number): void {\r\n this.privContext.phraseDetection.speakerDiarization.audioOffsetMs = audioOffsetMs;\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.js\";\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);\r\n } else {\r\n this.privPhrases.push(phrase);\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);\r\n } else {\r\n this.privGrammars.push(grammar);\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): 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// response\r\n\r\nexport interface IActivityPayloadResponse {\r\n conversationId: string;\r\n messageDataStreamType: number;\r\n messagePayload: string | object;\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) as IActivityPayloadResponse;\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(): string | object {\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\nimport { AudioOutputFormatImpl } from \"../sdk/Audio/AudioOutputFormat.js\";\r\nimport { AudioOutputStream, PullAudioOutputStreamImpl } from \"../sdk/Audio/AudioOutputStream.js\";\r\nimport { DialogServiceTurnStateManager } from \"./DialogServiceTurnStateManager.js\";\r\nimport { ActivityPayloadResponse, MessageDataStreamType } from \"./ServiceMessages/ActivityResponsePayload.js\";\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 public 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 }\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 }\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 // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\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 // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\r\n clearTimeout(this.privTimeoutToken);\r\n }\r\n this.privTimeoutToken = setTimeout((): void => {\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\r\nimport { InvalidOperationError } from \"../common/Error.js\";\r\nimport { DialogServiceTurnState } from \"./DialogServiceTurnState.js\";\r\n\r\nexport class DialogServiceTurnStateManager {\r\n private privTurnMap: Map<string, DialogServiceTurnState>;\r\n\r\n public constructor() {\r\n this.privTurnMap = new Map<string, DialogServiceTurnState>();\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 {\r\n ReplayableAudioNode\r\n} from \"../common.browser/Exports.js\";\r\nimport { SendingAgentContextMessageEvent } from \"../common/DialogEvents.js\";\r\nimport {\r\n BackgroundEvent,\r\n ConnectionEvent,\r\n ConnectionMessage,\r\n createGuid,\r\n createNoDashGuid,\r\n Deferred,\r\n DialogEvent,\r\n Events,\r\n EventSource,\r\n IAudioSource,\r\n IAudioStreamNode,\r\n IConnection,\r\n MessageType,\r\n ServiceEvent,\r\n} from \"../common/Exports.js\";\r\nimport { AudioOutputFormatImpl } from \"../sdk/Audio/AudioOutputFormat.js\";\r\nimport { PullAudioOutputStreamImpl } from \"../sdk/Audio/AudioOutputStream.js\";\r\nimport { AudioStreamFormatImpl } from \"../sdk/Audio/AudioStreamFormat.js\";\r\nimport {\r\n ActivityReceivedEventArgs,\r\n CancellationErrorCode,\r\n CancellationReason,\r\n DialogServiceConfig,\r\n DialogServiceConnector,\r\n PropertyCollection,\r\n PropertyId,\r\n RecognitionEventArgs,\r\n ResultReason,\r\n SessionEventArgs,\r\n SpeechRecognitionCanceledEventArgs,\r\n SpeechRecognitionEventArgs,\r\n SpeechRecognitionResult,\r\n TurnStatusReceivedEventArgs,\r\n} from \"../sdk/Exports.js\";\r\nimport { DialogServiceTurnStateManager } from \"./DialogServiceTurnStateManager.js\";\r\nimport {\r\n CancellationErrorCodePropertyName,\r\n EnumTranslation,\r\n ISpeechConfigAudioDevice,\r\n RecognitionStatus,\r\n ServiceRecognizerBase,\r\n SimpleSpeechPhrase,\r\n SpeechDetected,\r\n SpeechHypothesis,\r\n SpeechKeyword,\r\n} from \"./Exports.js\";\r\nimport { IAuthentication } from \"./IAuthentication.js\";\r\nimport { IConnectionFactory } from \"./IConnectionFactory.js\";\r\nimport { RecognitionMode, RecognizerConfig } from \"./RecognizerConfig.js\";\r\nimport { ActivityPayloadResponse } from \"./ServiceMessages/ActivityResponsePayload.js\";\r\nimport { SpeechConnectionMessage } from \"./SpeechConnectionMessage.Internal.js\";\r\n\r\nexport class DialogServiceAdapter extends ServiceRecognizerBase {\r\n private privDialogServiceConnector: DialogServiceConnector;\r\n\r\n private privDialogAudioSource: IAudioSource;\r\n\r\n private privConnectionLoop: Promise<void>;\r\n private terminateMessageLoop: boolean;\r\n private agentConfigSent: boolean;\r\n private privLastResult: SpeechRecognitionResult;\r\n private privEvents: EventSource<DialogEvent>;\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.privEvents = new EventSource<DialogEvent>();\r\n this.privDialogServiceConnector = dialogServiceConnector;\r\n this.receiveMessageOverride = (): Promise<void> => this.receiveDialogMessageOverride();\r\n this.privTurnStateManager = new DialogServiceTurnStateManager();\r\n this.recognizeOverride =\r\n (recoMode: RecognitionMode, successCallback: (e: SpeechRecognitionResult) => void, errorCallback: (e: string) => void): Promise<void> =>\r\n this.listenOnce(recoMode, successCallback, errorCallback);\r\n this.postConnectImplOverride = (connection: Promise<IConnection>): Promise<IConnection> => this.dialogConnectImpl(connection);\r\n this.configConnectionOverride = (connection: IConnection): Promise<IConnection> => this.configConnection(connection);\r\n this.disconnectOverride = (): Promise<void> => this.privDisconnect();\r\n this.privDialogAudioSource = audioSource;\r\n\r\n this.agentConfigSent = false;\r\n this.privLastResult = null;\r\n this.connectionEvents.attach((connectionEvent: ConnectionEvent): void => {\r\n if (connectionEvent.name === \"ConnectionClosedEvent\") {\r\n this.terminateMessageLoop = true;\r\n }\r\n });\r\n }\r\n\r\n public async sendMessage(message: string): Promise<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 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\r\n messagePayload: JSON.parse(message),\r\n version: 0.5\r\n };\r\n\r\n const agentMessageJson = JSON.stringify(agentMessage);\r\n const connection: IConnection = await this.fetchConnection();\r\n await 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 async privDisconnect(): Promise<void> {\r\n await this.cancelRecognition(this.privRequestSession.sessionId,\r\n this.privRequestSession.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 return;\r\n }\r\n\r\n protected processTypeSpecificMessages(connectionMessage: SpeechConnectionMessage): Promise<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.privRequestSession.onPhraseRecognized(this.privRequestSession.currentTurnAudioOffset + speechPhrase.Offset + speechPhrase.Duration);\r\n\r\n if (speechPhrase.RecognitionStatus !== RecognitionStatus.TooManyRequests && speechPhrase.RecognitionStatus !== RecognitionStatus.Error) {\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 /* eslint-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.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 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.privDialogServiceConnector.recognizing) {\r\n try {\r\n this.privDialogServiceConnector.recognizing(this.privDialogServiceConnector, ev);\r\n /* eslint-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.keyword\":\r\n const keyword: SpeechKeyword = SpeechKeyword.fromJSON(connectionMessage.textBody);\r\n\r\n result = new SpeechRecognitionResult(\r\n this.privRequestSession.requestId,\r\n keyword.Status === \"Accepted\" ? ResultReason.RecognizedKeyword : ResultReason.NoMatch,\r\n keyword.Text,\r\n keyword.Duration,\r\n keyword.Offset,\r\n undefined,\r\n undefined,\r\n undefined,\r\n undefined,\r\n connectionMessage.textBody,\r\n resultProps);\r\n\r\n if (keyword.Status !== \"Accepted\") {\r\n this.privLastResult = result;\r\n }\r\n\r\n const event = new SpeechRecognitionEventArgs(result, result.duration, result.resultId);\r\n\r\n if (!!this.privDialogServiceConnector.recognized) {\r\n try {\r\n this.privDialogServiceConnector.recognized(this.privDialogServiceConnector, event);\r\n /* eslint-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 \"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 this.handleResponseMessage(connectionMessage);\r\n\r\n }\r\n processed = true;\r\n break;\r\n\r\n default:\r\n break;\r\n }\r\n const defferal = new Deferred<boolean>();\r\n defferal.resolve(processed);\r\n return defferal.promise;\r\n }\r\n\r\n // Cancels recognition.\r\n protected async cancelRecognition(\r\n sessionId: string,\r\n requestId: string,\r\n cancellationReason: CancellationReason,\r\n errorCode: CancellationErrorCode,\r\n error: string): Promise<void> {\r\n\r\n this.terminateMessageLoop = true;\r\n\r\n if (!!this.privRequestSession.isRecognizing) {\r\n await this.privRequestSession.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 /* eslint-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, // Duration\r\n undefined, // Offset\r\n undefined, // Language\r\n undefined, // Language Detection Confidence\r\n undefined, // Speaker Id\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 /* eslint-disable no-empty */\r\n } catch { }\r\n }\r\n }\r\n }\r\n\r\n protected async listenOnce(\r\n recoMode: RecognitionMode,\r\n successCallback: (e: SpeechRecognitionResult) => void,\r\n errorCallback: (e: string) => void\r\n ): Promise<void> {\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.privDialogAudioSource.events);\r\n\r\n this.privRecognizerConfig.parameters.setProperty(PropertyId.Speech_SessionId, this.privRequestSession.sessionId);\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 const conPromise: Promise<IConnection> = this.connectImpl();\r\n\r\n const preAudioPromise: Promise<void> = this.sendPreAudioMessages();\r\n\r\n const node: IAudioStreamNode = await this.privDialogAudioSource.attach(this.privRequestSession.audioNodeId);\r\n const format: AudioStreamFormatImpl = await this.privDialogAudioSource.format;\r\n const deviceInfo: ISpeechConfigAudioDevice = await this.privDialogAudioSource.deviceInfo;\r\n\r\n const audioNode = new ReplayableAudioNode(node, format.avgBytesPerSec);\r\n await this.privRequestSession.onAudioSourceAttachCompleted(audioNode, false);\r\n\r\n this.privRecognizerConfig.SpeechServiceConfig.Context.audio = { source: deviceInfo };\r\n\r\n try {\r\n await conPromise;\r\n await preAudioPromise;\r\n } catch (error) {\r\n await this.cancelRecognition(this.privRequestSession.sessionId, this.privRequestSession.requestId, CancellationReason.Error, CancellationErrorCode.ConnectionFailure, error as string);\r\n return Promise.resolve();\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 audioSendPromise = this.sendAudio(audioNode);\r\n\r\n // /* eslint-disable no-empty */\r\n audioSendPromise.then((): void => { /* add? return true;*/ }, async (error: string): Promise<void> => {\r\n await this.cancelRecognition(this.privRequestSession.sessionId, this.privRequestSession.requestId, CancellationReason.Error, CancellationErrorCode.RuntimeError, error);\r\n });\r\n }\r\n\r\n // Establishes a websocket connection to the end point.\r\n private dialogConnectImpl(connection: Promise<IConnection>): Promise<IConnection> {\r\n this.privConnectionLoop = this.startMessageLoop();\r\n return connection;\r\n }\r\n\r\n private receiveDialogMessageOverride(): Promise<void> {\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<void> = new Deferred<void>();\r\n\r\n const loop = async (): Promise<void> => {\r\n try {\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;\r\n }\r\n\r\n const connection: IConnection = await this.fetchConnection();\r\n const message: ConnectionMessage = await connection.read();\r\n\r\n if (!message) {\r\n return loop();\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.privRequestSession.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.privRequestSession.onServiceTurnStartResponse();\r\n }\r\n }\r\n break;\r\n\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\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.privRequestSession.onServiceRecognized(speechStopDetected.Offset + this.privRequestSession.currentTurnAudioOffset);\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\r\n case \"turn.end\":\r\n {\r\n const turnEndRequestId = connectionMessage.requestId.toUpperCase();\r\n\r\n const audioSessionReqId = this.privRequestSession.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.privRequestSession.sessionId);\r\n await this.privRequestSession.onServiceTurnEndResponse(false);\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\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 as string);\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 try {\r\n const processed = await this.processTypeSpecificMessages(connectionMessage);\r\n if (!processed) {\r\n if (!!this.serviceEvents) {\r\n this.serviceEvents.onEvent(new ServiceEvent(connectionMessage.path.toLowerCase(), connectionMessage.textBody));\r\n }\r\n }\r\n } catch (e) {\r\n //\r\n }\r\n }\r\n const ret: Promise<void> = loop();\r\n\r\n return ret;\r\n } catch (error) {\r\n this.terminateMessageLoop = true;\r\n communicationCustodian.resolve();\r\n }\r\n };\r\n\r\n loop().catch((reason: string): void => {\r\n Events.instance.onEvent(new BackgroundEvent(reason));\r\n });\r\n\r\n return communicationCustodian.promise;\r\n }\r\n\r\n private async startMessageLoop(): Promise<void> {\r\n\r\n this.terminateMessageLoop = false;\r\n\r\n try {\r\n await this.receiveDialogMessageOverride();\r\n } catch (error) {\r\n await this.cancelRecognition(this.privRequestSession.sessionId, this.privRequestSession.requestId, CancellationReason.Error, CancellationErrorCode.RuntimeError, error as string);\r\n }\r\n\r\n return Promise.resolve();\r\n }\r\n\r\n // Takes an established websocket connection to the endpoint and sends speech configuration information.\r\n private async configConnection(connection: IConnection): Promise<IConnection> {\r\n if (this.terminateMessageLoop) {\r\n this.terminateMessageLoop = false;\r\n return Promise.reject(\"Connection to service terminated.\");\r\n }\r\n\r\n await this.sendSpeechServiceConfig(connection, this.privRequestSession, this.privRecognizerConfig.SpeechServiceConfig.serialize());\r\n await this.sendAgentConfig(connection);\r\n return connection;\r\n }\r\n\r\n private async sendPreAudioMessages(): Promise<void> {\r\n const connection: IConnection = await this.fetchConnection();\r\n this.addKeywordContextData();\r\n await this.sendSpeechContext(connection, true);\r\n await this.sendAgentContext(connection);\r\n await this.sendWaveHeader(connection);\r\n }\r\n\r\n private sendAgentConfig(connection: IConnection): Promise<void> {\r\n if (this.agentConfig && !this.agentConfigSent) {\r\n\r\n if (this.privRecognizerConfig\r\n .parameters\r\n .getProperty(PropertyId.Conversation_DialogType) === DialogServiceConfig.DialogTypes.CustomCommands) {\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 this.onEvent(new SendingAgentContextMessageEvent(this.agentConfig));\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.privRequestSession.requestId,\r\n \"application/json\",\r\n agentConfigJson));\r\n }\r\n\r\n return;\r\n }\r\n\r\n private sendAgentContext(connection: IConnection): Promise<void> {\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.privRequestSession.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.privRequestSession.currentTurnAudioOffset;\r\n\r\n const result = new SpeechRecognitionResult(\r\n this.privRequestSession.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 undefined,\r\n JSON.stringify(serviceResult),\r\n properties);\r\n\r\n const ev = new SpeechRecognitionEventArgs(result, offset, this.privRequestSession.sessionId);\r\n return ev;\r\n }\r\n\r\n private handleResponseMessage(responseMessage: SpeechConnectionMessage): void {\r\n // \"response\" messages can contain either \"message\" (activity) or \"MessageStatus\" data. Fire the appropriate\r\n // event according to the message type that's specified.\r\n const responsePayload: { messageType: string } = JSON.parse(responseMessage.textBody) as { messageType: string };\r\n switch (responsePayload.messageType.toLowerCase()) {\r\n case \"message\":\r\n const responseRequestId = responseMessage.requestId.toUpperCase();\r\n const activityPayload: ActivityPayloadResponse = ActivityPayloadResponse.fromJSON(responseMessage.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(\r\n activityPayload,\r\n AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString(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 /* eslint-disable-next-line 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\r\n case \"messagestatus\":\r\n if (!!this.privDialogServiceConnector.turnStatusReceived) {\r\n try {\r\n this.privDialogServiceConnector.turnStatusReceived(\r\n this.privDialogServiceConnector,\r\n new TurnStatusReceivedEventArgs(responseMessage.textBody));\r\n /* eslint-disable-next-line 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\r\n default:\r\n Events.instance.onEvent(\r\n new BackgroundEvent(`Unexpected response of type ${responsePayload.messageType}. Ignoring.`));\r\n break;\r\n }\r\n }\r\n\r\n private onEvent(event: DialogEvent): void {\r\n this.privEvents.onEvent(event);\r\n Events.instance.onEvent(event);\r\n }\r\n\r\n private addKeywordContextData(): void {\r\n const keywordPropertyValue: string = this.privRecognizerConfig.parameters.getProperty(\"SPEECH-KeywordsToDetect\");\r\n if (keywordPropertyValue === undefined) {\r\n return;\r\n }\r\n\r\n const keywordOffsetPropertyValue: string = this.privRecognizerConfig.parameters\r\n .getProperty(\"SPEECH-KeywordsToDetect-Offsets\");\r\n const keywordDurationPropertyValue: string = this.privRecognizerConfig.parameters\r\n .getProperty(\"SPEECH-KeywordsToDetect-Durations\");\r\n\r\n const keywords = keywordPropertyValue.split(\";\");\r\n const keywordOffsets = keywordOffsetPropertyValue === undefined ? [] : keywordOffsetPropertyValue.split(\";\");\r\n const keywordDurations = keywordDurationPropertyValue === undefined ? [] : keywordDurationPropertyValue.split(\";\");\r\n\r\n const keywordDefinitionArray = [];\r\n for (let i = 0; i < keywords.length; i++) {\r\n const definition: { [section: string]: any } = {};\r\n definition.text = keywords[i];\r\n if (i < keywordOffsets.length) {\r\n definition.offset = Number(keywordOffsets[i]);\r\n }\r\n if (i < keywordDurations.length) {\r\n definition.duration = Number(keywordDurations[i]);\r\n }\r\n keywordDefinitionArray.push(definition);\r\n }\r\n\r\n this.speechContext.setSection(\"invocationSource\", \"VoiceActivationWithKeyword\");\r\n this.speechContext.setSection(\"keywordDetection\", [{\r\n clientDetectedKeywords: keywordDefinitionArray,\r\n onReject: { action: \"EndOfTurn\" },\r\n type: \"startTrigger\"\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 * 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","\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.js\";\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 privTranscriptionEventKeys: string[] = [\"iCalUid\", \"callId\", \"organizer\", \"FLAC\", \"MTUri\", \"DifferentiateGuestSpeakers\", \"audiorecording\", \"Threadid\", \"OrganizerMri\", \"OrganizerTenantId\", \"UserToken\"];\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 transcriptionEventKeys(): string[] {\r\n return ConversationConnectionConfig.privTranscriptionEventKeys;\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 IRequestOptions,\r\n IRestParams,\r\n IRestResponse,\r\n RestMessageAdapter,\r\n RestRequestType\r\n} from \"../../common.browser/Exports.js\";\r\nimport { IErrorMessages, IStringDictionary } from \"../../common/Exports.js\";\r\nimport { Contracts } from \"../../sdk/Contracts.js\";\r\nimport { PropertyCollection, PropertyId } from \"../../sdk/Exports.js\";\r\nimport { ConversationConnectionConfig } from \"./ConversationConnectionConfig.js\";\r\nimport { IConversationResponseError, IInternalConversation } from \"./ConversationTranslatorInterfaces.js\";\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 private privRestAdapter: RestMessageAdapter;\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 this.privRestAdapter = new RestMessageAdapter({});\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?: (c: any) => void, err?: (e: string) => void): 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, \"conversation_host\");\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<string> = {};\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<string> = {};\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 this.privRestAdapter.options = config;\r\n\r\n const endpoint: string = `https://${endpointHost}${this.privRestPath}`;\r\n\r\n // TODO: support a proxy and certificate validation\r\n this.privRestAdapter.request(RestRequestType.Post, endpoint, queryParams, null).then((response: IRestResponse): void => {\r\n\r\n const requestId: string = RestMessageAdapter.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 as string);\r\n }\r\n }\r\n cb = undefined;\r\n }\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n }).catch( (): void => { });\r\n\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error;\r\n err(typedError.name + \": \" + typedError.message);\r\n\r\n } else {\r\n err(error as string);\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): Promise<void> {\r\n return new Promise<void>((resolve: () => void, reject: (reason: string) => void): void => {\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<string> = {};\r\n queryParams[this.privRequestParams.apiVersion] = this.privApiVersion;\r\n queryParams[this.privRequestParams.sessionToken] = sessionToken;\r\n\r\n const headers: IStringDictionary<string> = {};\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 this.privRestAdapter.options = config;\r\n\r\n const endpoint: string = `https://${endpointHost}${this.privRestPath}`;\r\n\r\n // TODO: support a proxy and certificate validation\r\n this.privRestAdapter.request(RestRequestType.Delete, endpoint, queryParams, null).then((response: IRestResponse): void => {\r\n\r\n if (!response.ok) {\r\n // ignore errors on delete\r\n }\r\n\r\n resolve();\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n }).catch( (): void => {});\r\n\r\n } catch (error) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error;\r\n reject(typedError.name + \": \" + typedError.message);\r\n\r\n } else {\r\n reject(error as string);\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 { ConnectionMessage, IStringDictionary, MessageType } from \"../../common/Exports.js\";\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<string>,\r\n id?: string) {\r\n super(messageType, body, headers, id);\r\n const json: { type: string } = JSON.parse(this.textBody) as { type: string };\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 ConnectionMessage,\r\n Deferred,\r\n IWebsocketMessageFormatter,\r\n MessageType,\r\n RawWebsocketMessage,\r\n} from \"../../common/Exports.js\";\r\nimport { ConversationConnectionMessage } from \"./ConversationConnectionMessage.js\";\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<ConversationConnectionMessage> {\r\n const deferral = new Deferred<ConversationConnectionMessage>();\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 as string}`);\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<RawWebsocketMessage> {\r\n\r\n const deferral = new Deferred<RawWebsocketMessage>();\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 as string}`);\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 { ProxyInfo, WebsocketConnection } from \"../../common.browser/Exports.js\";\r\nimport { createGuid, IConnection, IStringDictionary } from \"../../common/Exports.js\";\r\nimport { Contracts } from \"../../sdk/Contracts.js\";\r\nimport { PropertyId } from \"../../sdk/Exports.js\";\r\nimport { ConnectionFactoryBase } from \"../ConnectionFactoryBase.js\";\r\nimport { AuthInfo, RecognizerConfig } from \"../Exports.js\";\r\nimport { ConversationConnectionConfig } from \"./ConversationConnectionConfig.js\";\r\nimport { ConversationWebsocketMessageFormatter } from \"./ConversationWebsocketMessageFormatter.js\";\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<string> = {};\r\n queryParams[ConversationConnectionConfig.configParams.apiVersion] = ConversationConnectionConfig.apiVersion;\r\n queryParams[ConversationConnectionConfig.configParams.token] = token;\r\n queryParams[ConversationConnectionConfig.configParams.correlationId] = correlationId;\r\n const enableCompression: boolean = config.parameters.getProperty(\"SPEECH-EnableWebsocketCompression\", \"false\") === \"true\";\r\n return new WebsocketConnection(endpoint, queryParams, {}, new ConversationWebsocketMessageFormatter(), ProxyInfo.fromRecognizerConfig(config), enableCompression, 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 createNoDashGuid,\r\n Deferred,\r\n IDetachable,\r\n} from \"../../common/Exports.js\";\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<IDetachable>();\r\n private privRequestId: string;\r\n private privRequestCompletionDeferral: Deferred<void>;\r\n private privSessionId: string;\r\n\r\n public constructor(sessionId: string) {\r\n this.privSessionId = sessionId;\r\n this.privRequestId = createNoDashGuid();\r\n this.privRequestCompletionDeferral = new Deferred<void>();\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<void> {\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): void {\r\n if (isError) {\r\n this.onComplete();\r\n }\r\n }\r\n\r\n public onConnectionEstablishCompleted(statusCode: number): 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 async dispose(): Promise<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 await 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\n/* eslint-disable max-classes-per-file */\r\nimport { ConversationTranslationResult, SessionEventArgs } from \"../../sdk/Exports.js\";\r\nimport { IInternalParticipant } from \"./ConversationTranslatorInterfaces.js\";\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\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\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\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\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\nexport class ConversationReceivedTranslationEventArgs {\r\n private privPayload: ConversationTranslationResult;\r\n private privCommand: string;\r\n private privSessionId: string;\r\n\r\n public constructor(command: string, payload: ConversationTranslationResult, 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(): ConversationTranslationResult {\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 ConnectionEventArgs,\r\n ConversationExpirationEventArgs,\r\n ConversationTranslationCanceledEventArgs,\r\n SessionEventArgs,\r\n } from \"../../sdk/Exports.js\";\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.js\";\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 // set programmatically\r\n isHost: boolean;\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 profanity?: boolean;\r\n preferredLanguage?: string;\r\n translateToLanguages?: string[];\r\n voice?: string;\r\n}\r\n\r\n/** Users participating in the conversation */\r\nexport class InternalParticipants {\r\n\r\n public 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): boolean => 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): boolean => 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): boolean => 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): boolean => 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 ConversationRecognizer {\r\n isDisposed(): boolean;\r\n sendRequest: (command: string, cb?: () => void, err?: (e: string) => void) => void;\r\n cancelSpeech?: () => Promise<void>;\r\n close?: () => Promise<void>;\r\n conversationExpiration?: (sender: ConversationRecognizer, event: ConversationExpirationEventArgs) => void;\r\n connected?: (e: ConnectionEventArgs) => void;\r\n disconnected?: (e: ConnectionEventArgs) => void;\r\n canceled?: (sender: ConversationRecognizer, event: ConversationTranslationCanceledEventArgs) => void;\r\n connectionOpened?: (sender: ConversationRecognizer, event: SessionEventArgs) => void;\r\n connectionClosed?: (sender: ConversationRecognizer, event: SessionEventArgs) => void;\r\n participantsListReceived?: (sender: ConversationRecognizer, event: ParticipantsListEventArgs) => void;\r\n translationReceived?: (sender: ConversationRecognizer, event: ConversationReceivedTranslationEventArgs) => void;\r\n lockRoomCommandReceived?: (sender: ConversationRecognizer, event: LockRoomEventArgs) => void;\r\n muteAllCommandReceived?: (sender: ConversationRecognizer, event: MuteAllEventArgs) => void;\r\n participantJoinCommandReceived?: (sender: ConversationRecognizer, event: ParticipantEventArgs) => void;\r\n participantLeaveCommandReceived?: (sender: ConversationRecognizer, event: ParticipantEventArgs) => void;\r\n participantUpdateCommandReceived?: (sender: ConversationRecognizer, event: ParticipantAttributeEventArgs) => void;\r\n connect?: (token: string, cb?: () => void, err?: (e: string) => void) => 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 keepAlive: \"keep_alive\",\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>() => T;\r\n headers: 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 * 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 token?: string;\r\n}\r\n\r\nconst parseCommandResponse = (json: string): ICommandResponsePayload => JSON.parse(json) as ICommandResponsePayload;\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 = parseCommandResponse(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 public get token(): string {\r\n return this.privCommandResponse.token;\r\n }\r\n\r\n public static fromJSON(json: string): CommandResponsePayload {\r\n return new CommandResponsePayload(json);\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/* eslint-disable max-classes-per-file */\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\nconst parseListResponse = (json: string): IParticipantsListPayloadResponse => JSON.parse(json) as IParticipantsListPayloadResponse;\r\nconst parseParticipantResponse = (json: string): IParticipantPayloadResponse => JSON.parse(json) as IParticipantPayloadResponse;\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 = parseListResponse(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 public static fromJSON(json: string): ParticipantsListPayloadResponse {\r\n return new ParticipantsListPayloadResponse(json);\r\n }\r\n\r\n}\r\n\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 = parseParticipantResponse(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 public static fromJSON(json: string): ParticipantPayloadResponse {\r\n return new ParticipantPayloadResponse(json);\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/* eslint-disable max-classes-per-file */\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\nconst parseSpeechResponse = (json: string): ISpeechResponsePayload => JSON.parse(json) as ISpeechResponsePayload;\r\nconst parseTextResponse = (json: string): ITextResponsePayload => JSON.parse(json) as ITextResponsePayload;\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 = parseSpeechResponse(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 public static fromJSON(json: string): SpeechResponsePayload {\r\n return new SpeechResponsePayload(json);\r\n }\r\n\r\n}\r\n\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 = parseTextResponse(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 public static fromJSON(json: string): TextResponsePayload {\r\n return new TextResponsePayload(json);\r\n }\r\n\r\n}\r\n","export { CommandResponsePayload } from \"./CommandResponsePayload.js\";\r\nexport { IParticipantsListPayloadResponse, IParticipantPayloadResponse, ParticipantsListPayloadResponse, ParticipantPayloadResponse } from \"./ParticipantResponsePayload.js\";\r\nexport { ITranslationResponsePayload, SpeechResponsePayload, TextResponsePayload } from \"./TranslationResponsePayload.js\";\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n ConnectionState,\r\n createNoDashGuid,\r\n Deferred,\r\n IAudioSource,\r\n IConnection,\r\n MessageType,\r\n} from \"../../common/Exports.js\";\r\nimport {\r\n CancellationErrorCode,\r\n CancellationReason,\r\n ConversationExpirationEventArgs,\r\n ConversationTranslationCanceledEventArgs,\r\n ConversationTranslationResult,\r\n ResultReason,\r\n Translations\r\n} from \"../../sdk/Exports.js\";\r\nimport {\r\n CognitiveTokenAuthentication,\r\n IAuthentication,\r\n IConnectionFactory,\r\n RecognizerConfig,\r\n ServiceRecognizerBase\r\n} from \"../Exports.js\";\r\nimport { ConversationConnectionMessage } from \"./ConversationConnectionMessage.js\";\r\nimport { ConversationRequestSession } from \"./ConversationRequestSession.js\";\r\nimport {\r\n ConversationReceivedTranslationEventArgs,\r\n LockRoomEventArgs,\r\n MuteAllEventArgs,\r\n ParticipantAttributeEventArgs,\r\n ParticipantEventArgs,\r\n ParticipantsListEventArgs\r\n} from \"./ConversationTranslatorEventArgs.js\";\r\nimport {\r\n ConversationTranslatorCommandTypes,\r\n ConversationTranslatorMessageTypes,\r\n IInternalParticipant\r\n} from \"./ConversationTranslatorInterfaces.js\";\r\nimport { ConversationTranslatorRecognizer } from \"./ConversationTranslatorRecognizer.js\";\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.js\";\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<IConnection> = undefined;\r\n private privConnectionLoop: Promise<void>;\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.privLastPartialUtteranceId = \"\";\r\n this.privConversationServiceConnector = conversationServiceConnector;\r\n this.privConversationAuthentication = authentication;\r\n this.receiveMessageOverride = (): Promise<void> => this.receiveConversationMessageOverride();\r\n this.recognizeOverride = (): Promise<void> => this.noOp();\r\n this.postConnectImplOverride = (connection: Promise<IConnection>): Promise<IConnection> => this.conversationConnectImpl(connection);\r\n this.configConnectionOverride = (): Promise<IConnection> => this.configConnection();\r\n this.disconnectOverride = (): Promise<void> => 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 super.isDisposed() || this.privConversationIsDisposed;\r\n }\r\n\r\n public async dispose(reason?: string): Promise<void> {\r\n this.privConversationIsDisposed = true;\r\n if (this.privConnectionConfigPromise !== undefined) {\r\n const connection: IConnection = await this.privConnectionConfigPromise;\r\n await connection.dispose(reason);\r\n }\r\n await super.dispose(reason);\r\n }\r\n\r\n public async sendMessage(message: string): Promise<void> {\r\n const connection: IConnection = await this.fetchConnection();\r\n return connection.send(new ConversationConnectionMessage(\r\n MessageType.Text,\r\n message));\r\n }\r\n\r\n public async sendMessageAsync(message: string): Promise<void> {\r\n const connection: IConnection = await this.fetchConnection();\r\n\r\n await connection.send(new ConversationConnectionMessage(MessageType.Text, message));\r\n }\r\n\r\n protected privDisconnect(): Promise<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 return Promise.resolve();\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/require-await\r\n protected async processTypeSpecificMessages(): Promise<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 /**\r\n * Establishes a websocket connection to the end point.\r\n */\r\n protected async conversationConnectImpl(connection: Promise<IConnection>): Promise<IConnection> {\r\n this.privConnectionLoop = this.startMessageLoop();\r\n return connection;\r\n }\r\n\r\n /**\r\n * Process incoming websocket messages\r\n */\r\n private async receiveConversationMessageOverride(): Promise<void> {\r\n if (this.isDisposed() || this.terminateMessageLoop) {\r\n return Promise.resolve();\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<void> = new Deferred<void>();\r\n\r\n try {\r\n const connection: IConnection = await this.fetchConnection();\r\n const message: ConversationConnectionMessage = await connection.read() as ConversationConnectionMessage;\r\n if (this.isDisposed() || this.terminateMessageLoop) {\r\n // We're done.\r\n communicationCustodian.resolve();\r\n return Promise.resolve();\r\n }\r\n\r\n if (!message) {\r\n return this.receiveConversationMessageOverride();\r\n }\r\n\r\n const sessionId: string = this.privConversationRequestSession.sessionId;\r\n const conversationMessageType: string = message.conversationMessageType.toLowerCase();\r\n let sendFinal: boolean = false;\r\n\r\n try {\r\n switch (conversationMessageType) {\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): IInternalParticipant => {\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.value, 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 // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n const disconnectParticipant: IInternalParticipant = {\r\n id: commandPayload.participantId\r\n };\r\n\r\n break;\r\n\r\n case \"token\":\r\n const token = new CognitiveTokenAuthentication(\r\n (): Promise<string> => {\r\n const authorizationToken = commandPayload.token;\r\n return Promise.resolve(authorizationToken);\r\n },\r\n (): Promise<string> => {\r\n const authorizationToken = commandPayload.token;\r\n return Promise.resolve(authorizationToken);\r\n });\r\n this.authentication = token;\r\n this.privConversationServiceConnector.onToken(token);\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 const conversationResultReason: ResultReason = (conversationMessageType === \"final\") ? ResultReason.TranslatedParticipantSpeech : ResultReason.TranslatingParticipantSpeech;\r\n\r\n const speechResult: ConversationTranslationResult = new ConversationTranslationResult(speechPayload.participantId,\r\n this.getTranslations(speechPayload.translations),\r\n speechPayload.language,\r\n speechPayload.id,\r\n conversationResultReason,\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 // TODO: (Native parity) a result reason should be set based whether the participantId is ours or not\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 } catch (e) {\r\n this.terminateMessageLoop = true;\r\n }\r\n\r\n return communicationCustodian.promise;\r\n }\r\n\r\n private async startMessageLoop(): Promise<void> {\r\n if (this.isDisposed()) {\r\n return Promise.resolve();\r\n }\r\n this.terminateMessageLoop = false;\r\n\r\n const messageRetrievalPromise = this.receiveConversationMessageOverride();\r\n\r\n try {\r\n const r = await messageRetrievalPromise;\r\n return r;\r\n } catch (error) {\r\n this.cancelRecognition(this.privRequestSession ? this.privRequestSession.sessionId : \"\", this.privRequestSession ? this.privRequestSession.requestId : \"\", CancellationReason.Error, CancellationErrorCode.RuntimeError, error as string);\r\n return null;\r\n }\r\n }\r\n\r\n // Takes an established websocket connection to the endpoint\r\n private configConnection(): Promise<IConnection> {\r\n if (this.isDisposed()) {\r\n return Promise.resolve<IConnection>(undefined);\r\n }\r\n if (this.privConnectionConfigPromise !== undefined) {\r\n return this.privConnectionConfigPromise.then((connection: IConnection): Promise<IConnection> => {\r\n if (connection.state() === ConnectionState.Disconnected) {\r\n this.privConnectionId = null;\r\n this.privConnectionConfigPromise = undefined;\r\n return this.configConnection();\r\n }\r\n return this.privConnectionConfigPromise;\r\n }, (): Promise<IConnection> => {\r\n this.privConnectionId = null;\r\n this.privConnectionConfigPromise = undefined;\r\n return this.configConnection();\r\n });\r\n }\r\n if (this.terminateMessageLoop) {\r\n return Promise.resolve<IConnection>(undefined);\r\n }\r\n\r\n this.privConnectionConfigPromise = this.connectImpl().then((connection: IConnection): IConnection => 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","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n// eslint-disable-next-line max-classes-per-file\r\nimport {\r\n IAuthentication,\r\n IConnectionFactory,\r\n RecognizerConfig,\r\n ServiceRecognizerBase,\r\n SpeechServiceConfig\r\n} from \"../../common.speech/Exports.js\";\r\nimport {\r\n BackgroundEvent,\r\n Events,\r\n Timeout,\r\n} from \"../../common/Exports.js\";\r\nimport { AudioConfigImpl } from \"../../sdk/Audio/AudioConfig.js\";\r\nimport { Contracts } from \"../../sdk/Contracts.js\";\r\nimport {\r\n AudioConfig,\r\n Connection,\r\n ConnectionEventArgs,\r\n ConversationExpirationEventArgs,\r\n ConversationParticipantsChangedEventArgs,\r\n ConversationTranslationCanceledEventArgs,\r\n PropertyCollection,\r\n PropertyId,\r\n Recognizer,\r\n SessionEventArgs,\r\n SpeechTranslationConfig\r\n} from \"../../sdk/Exports.js\";\r\nimport { SpeechTranslationConfigImpl } from \"../../sdk/SpeechTranslationConfig.js\";\r\nimport { ConversationImpl } from \"../../sdk/Transcription/Conversation.js\";\r\nimport { Callback, IConversation } from \"../../sdk/Transcription/IConversation.js\";\r\nimport { ConversationConnectionFactory } from \"./ConversationConnectionFactory.js\";\r\nimport { ConversationServiceAdapter } from \"./ConversationServiceAdapter.js\";\r\nimport {\r\n ConversationReceivedTranslationEventArgs,\r\n LockRoomEventArgs,\r\n MuteAllEventArgs,\r\n ParticipantAttributeEventArgs,\r\n ParticipantEventArgs,\r\n ParticipantsListEventArgs\r\n} from \"./ConversationTranslatorEventArgs.js\";\r\nimport {\r\n ConversationRecognizer,\r\n} from \"./ConversationTranslatorInterfaces.js\";\r\n\r\nexport class ConversationRecognizerFactory {\r\n public static fromConfig(conversation: IConversation, speechConfig: SpeechTranslationConfig, audioConfig?: AudioConfig): ConversationRecognizer {\r\n return new ConversationTranslatorRecognizer(conversation, speechConfig, audioConfig);\r\n }\r\n}\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 ConversationRecognizer {\r\n\r\n private privIsDisposed: boolean;\r\n private privSpeechRecognitionLanguage: string;\r\n private privConnection: Connection;\r\n private privConversation: ConversationImpl;\r\n private privTimeoutToken: any;\r\n private privSetTimeout: (cb: () => void, delay: number) => number;\r\n private privClearTimeout: (id: number) => void;\r\n\r\n public constructor(conversation: IConversation, speechConfig: SpeechTranslationConfig, audioConfig?: AudioConfig) {\r\n const serviceConfigImpl = speechConfig as SpeechTranslationConfigImpl;\r\n Contracts.throwIfNull(serviceConfigImpl, \"speechConfig\");\r\n const conversationImpl = conversation as ConversationImpl;\r\n Contracts.throwIfNull(conversationImpl, \"conversationImpl\");\r\n\r\n super(audioConfig, serviceConfigImpl.properties, new ConversationConnectionFactory());\r\n\r\n this.privConversation = conversationImpl;\r\n this.privIsDisposed = false;\r\n this.privProperties = serviceConfigImpl.properties.clone();\r\n this.privConnection = Connection.fromRecognizer(this);\r\n const webWorkerLoadType: string = this.privProperties.getProperty(PropertyId.WebWorkerLoadType, \"on\").toLowerCase();\r\n if (webWorkerLoadType === \"on\" && typeof (Blob) !== \"undefined\" && typeof (Worker) !== \"undefined\") {\r\n this.privSetTimeout = Timeout.setTimeout;\r\n this.privClearTimeout = Timeout.clearTimeout;\r\n } else {\r\n if (typeof window !== \"undefined\") {\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\r\n this.privSetTimeout = window.setTimeout.bind(window);\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\r\n this.privClearTimeout = window.clearTimeout.bind(window);\r\n } else {\r\n this.privSetTimeout = setTimeout;\r\n this.privClearTimeout = clearTimeout;\r\n }\r\n }\r\n }\r\n\r\n public canceled: (sender: ConversationRecognizer, event: ConversationTranslationCanceledEventArgs) => void;\r\n public conversationExpiration: (sender: ConversationRecognizer, event: ConversationExpirationEventArgs) => void;\r\n public lockRoomCommandReceived: (sender: ConversationRecognizer, event: LockRoomEventArgs) => void;\r\n public muteAllCommandReceived: (sender: ConversationRecognizer, event: MuteAllEventArgs) => void;\r\n public participantJoinCommandReceived: (sender: ConversationRecognizer, event: ParticipantEventArgs) => void;\r\n public participantLeaveCommandReceived: (sender: ConversationRecognizer, event: ParticipantEventArgs) => void;\r\n public participantUpdateCommandReceived: (sender: ConversationRecognizer, event: ParticipantAttributeEventArgs) => void;\r\n public connectionOpened: (sender: ConversationRecognizer, event: SessionEventArgs) => void;\r\n public connectionClosed: (sender: ConversationRecognizer, event: SessionEventArgs) => void;\r\n public translationReceived: (sender: ConversationRecognizer, event: ConversationReceivedTranslationEventArgs) => void;\r\n public participantsListReceived: (sender: ConversationRecognizer, event: ParticipantsListEventArgs) => void;\r\n public participantsChanged: (sender: ConversationRecognizer, event: ConversationParticipantsChangedEventArgs) => void;\r\n\r\n public set connected(cb: (e: ConnectionEventArgs) => void) {\r\n this.privConnection.connected = cb;\r\n }\r\n\r\n public set disconnected(cb: (e: ConnectionEventArgs) => void) {\r\n this.privConnection.disconnected = cb;\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.resetConversationTimeout();\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;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error as string);\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 if (this.privTimeoutToken !== undefined) {\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\r\n this.privClearTimeout(this.privTimeoutToken);\r\n }\r\n this.privReco.disconnect().then((): void => {\r\n if (!!cb) {\r\n cb();\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;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error as string);\r\n }\r\n }\r\n // Destroy the recognizer.\r\n this.dispose(true).catch((reason: string): void => {\r\n Events.instance.onEvent(new BackgroundEvent(reason));\r\n });\r\n\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 sendRequest(command: string, cb?: () => void, err?: (e: string) => void): void {\r\n try {\r\n Contracts.throwIfDisposed(this.privIsDisposed);\r\n this.sendMessage(command, cb, err);\r\n } catch (error) {\r\n if (!!err) {\r\n if (error instanceof Error) {\r\n const typedError: Error = error;\r\n err(typedError.name + \": \" + typedError.message);\r\n } else {\r\n err(error as string);\r\n }\r\n }\r\n\r\n // Destroy the recognizer.\r\n this.dispose(true).catch((reason: string): void => {\r\n Events.instance.onEvent(new BackgroundEvent(reason));\r\n });\r\n\r\n }\r\n }\r\n\r\n /**\r\n * Handle update of service auth token (#694)\r\n */\r\n public onToken(token: IAuthentication): void {\r\n this.privConversation.onToken(token);\r\n }\r\n\r\n /**\r\n * Close and dispose the recognizer\r\n */\r\n public async close(): Promise<void> {\r\n if (!this.privIsDisposed) {\r\n if (!!this.privConnection) {\r\n this.privConnection.closeConnection();\r\n this.privConnection.close();\r\n }\r\n this.privConnection = undefined;\r\n await this.dispose(true);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the recognizer\r\n * @param disposing\r\n */\r\n protected async dispose(disposing: boolean): Promise<void> {\r\n if (this.privIsDisposed) {\r\n return;\r\n }\r\n if (disposing) {\r\n if (this.privTimeoutToken !== undefined) {\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\r\n this.privClearTimeout(this.privTimeoutToken);\r\n }\r\n this.privIsDisposed = true;\r\n if (!!this.privConnection) {\r\n this.privConnection.closeConnection();\r\n this.privConnection.close();\r\n this.privConnection = undefined;\r\n }\r\n await 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 const PromiseToEmptyCallback = <T>(promise: Promise<T>, cb?: Callback, err?: Callback): void => {\r\n if (promise !== undefined) {\r\n promise.then((): void => {\r\n try {\r\n if (!!cb) {\r\n cb();\r\n }\r\n } catch (e) {\r\n if (!!err) {\r\n err(`'Unhandled error on promise callback: ${e as string}'`);\r\n }\r\n }\r\n }, (reason: any): void => {\r\n try {\r\n if (!!err) {\r\n err(reason);\r\n }\r\n // eslint-disable-next-line no-empty\r\n } catch (error) { }\r\n });\r\n } else {\r\n if (!!err) {\r\n err(\"Null promise\");\r\n }\r\n }\r\n };\r\n\r\n PromiseToEmptyCallback(withAsync.sendMessageAsync(msg), cb, err);\r\n this.resetConversationTimeout();\r\n }\r\n\r\n private resetConversationTimeout(): void {\r\n if (this.privTimeoutToken !== undefined) {\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\r\n this.privClearTimeout(this.privTimeoutToken);\r\n }\r\n\r\n this.privTimeoutToken = this.privSetTimeout((): void => {\r\n this.sendRequest(this.privConversation.getKeepAlive());\r\n }, 60000);\r\n }\r\n\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\nimport { marshalPromiseToCallbacks } from \"../../common/Exports.js\";\r\nimport { AudioConfigImpl } from \"../../sdk/Audio/AudioConfig.js\";\r\nimport { AudioStreamFormatImpl } from \"../../sdk/Audio/AudioStreamFormat.js\";\r\nimport { Contracts } from \"../../sdk/Contracts.js\";\r\nimport {\r\n AudioConfig,\r\n CancellationEventArgs,\r\n Conversation,\r\n ConversationInfo,\r\n Meeting,\r\n MeetingInfo,\r\n MeetingTranscriber,\r\n PropertyCollection,\r\n PropertyId,\r\n Recognizer,\r\n SessionEventArgs,\r\n SpeechRecognitionEventArgs,\r\n SpeechTranslationConfig,\r\n SpeechTranslationConfigImpl,\r\n} from \"../../sdk/Exports.js\";\r\nimport {\r\n IAuthentication,\r\n IConnectionFactory,\r\n RecognitionMode,\r\n RecognizerConfig,\r\n ServiceRecognizerBase,\r\n SpeechServiceConfig,\r\n TranscriberConnectionFactory,\r\n TranscriptionServiceRecognizer,\r\n} from \"../Exports.js\";\r\n\r\nexport class TranscriberRecognizer extends Recognizer {\r\n\r\n public recognizing: (sender: Recognizer, event: SpeechRecognitionEventArgs) => void;\r\n\r\n public recognized: (sender: Recognizer, event: SpeechRecognitionEventArgs) => void;\r\n\r\n public canceled: (sender: Recognizer, event: CancellationEventArgs) => void;\r\n\r\n private privDisposedRecognizer: boolean;\r\n private privConversation: Conversation;\r\n private privMeeting: Meeting;\r\n private isMeetingRecognizer: boolean;\r\n\r\n /**\r\n * TranscriberRecognizer constructor.\r\n * @constructor\r\n * @param {SpeechTranslationConfig} speechTranslationConfig - Non-audio configuration associated with the recognizer\r\n * @param {AudioConfig} audioConfig - An audio configuration associated with the recognizer\r\n */\r\n public constructor(speechTranslationConfig: SpeechTranslationConfig, audioConfig: AudioConfig) {\r\n const speechTranslationConfigImpl: SpeechTranslationConfigImpl = speechTranslationConfig as SpeechTranslationConfigImpl;\r\n Contracts.throwIfNull(speechTranslationConfigImpl, \"speechTranslationConfig\");\r\n\r\n const audioConfigImpl: AudioConfigImpl = audioConfig as AudioConfigImpl;\r\n Contracts.throwIfNull(audioConfigImpl, \"audioConfigImpl\");\r\n\r\n Contracts.throwIfNullOrWhitespace(\r\n speechTranslationConfigImpl.speechRecognitionLanguage,\r\n PropertyId[PropertyId.SpeechServiceConnection_RecoLanguage]);\r\n\r\n super(audioConfig, speechTranslationConfigImpl.properties, new TranscriberConnectionFactory());\r\n this.privDisposedRecognizer = false;\r\n this.isMeetingRecognizer = false;\r\n }\r\n\r\n public get speechRecognitionLanguage(): string {\r\n Contracts.throwIfDisposed(this.privDisposedRecognizer);\r\n\r\n return this.properties.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage);\r\n }\r\n\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n public get authorizationToken(): string {\r\n return this.properties.getProperty(PropertyId.SpeechServiceAuthorization_Token);\r\n }\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 public set conversation(c: Conversation) {\r\n Contracts.throwIfNullOrUndefined(c, \"Conversation\");\r\n this.isMeetingRecognizer = false;\r\n this.privConversation = c;\r\n }\r\n\r\n public getConversationInfo(): ConversationInfo {\r\n Contracts.throwIfNullOrUndefined(this.privConversation, \"Conversation\");\r\n return this.privConversation.conversationInfo;\r\n }\r\n\r\n public set meeting(m: Meeting) {\r\n Contracts.throwIfNullOrUndefined(m, \"Meeting\");\r\n this.isMeetingRecognizer = true;\r\n this.privMeeting = m;\r\n }\r\n\r\n public getMeetingInfo(): MeetingInfo {\r\n Contracts.throwIfNullOrUndefined(this.privMeeting, \"Meeting\");\r\n return this.privMeeting.meetingInfo;\r\n }\r\n\r\n public IsMeetingRecognizer(): boolean {\r\n return this.isMeetingRecognizer;\r\n }\r\n\r\n public startContinuousRecognitionAsync(cb?: () => void, err?: (e: string) => void): void {\r\n marshalPromiseToCallbacks(this.startContinuousRecognitionAsyncImpl(RecognitionMode.Conversation), cb, err);\r\n }\r\n\r\n public stopContinuousRecognitionAsync(cb?: () => void, err?: (e: string) => void): void {\r\n marshalPromiseToCallbacks(this.stopContinuousRecognitionAsyncImpl(), cb, err);\r\n }\r\n\r\n public async close(): Promise<void> {\r\n if (!this.privDisposedRecognizer) {\r\n await this.dispose(true);\r\n }\r\n }\r\n\r\n // Push async join/leave conversation message via serviceRecognizer\r\n public async pushConversationEvent(conversationInfo: ConversationInfo, command: string): Promise<void> {\r\n const reco = (this.privReco) as TranscriptionServiceRecognizer;\r\n Contracts.throwIfNullOrUndefined(reco, \"serviceRecognizer\");\r\n await reco.sendSpeechEventAsync(conversationInfo, command);\r\n }\r\n\r\n // Push async join/leave meeting message via serviceRecognizer\r\n public async pushMeetingEvent(meetingInfo: MeetingInfo, command: string): Promise<void> {\r\n const reco = (this.privReco) as TranscriptionServiceRecognizer;\r\n Contracts.throwIfNullOrUndefined(reco, \"serviceRecognizer\");\r\n await reco.sendMeetingSpeechEventAsync(meetingInfo, command);\r\n }\r\n\r\n public async enforceAudioGating(): Promise<void> {\r\n const audioConfigImpl = this.audioConfig as AudioConfigImpl;\r\n const format: AudioStreamFormatImpl = await audioConfigImpl.format;\r\n const channels = format.channels;\r\n if (channels === 1) {\r\n if (this.properties.getProperty(\"f0f5debc-f8c9-4892-ac4b-90a7ab359fd2\", \"false\").toLowerCase() !== \"true\") {\r\n throw new Error(\"Single channel audio configuration for MeetingTranscriber is currently under private preview, please contact diarizationrequest@microsoft.com for more details\");\r\n }\r\n } else if (channels !== 8) {\r\n throw new Error(`Unsupported audio configuration: Detected ${channels}-channel audio`);\r\n }\r\n return;\r\n }\r\n\r\n public connectMeetingCallbacks(transcriber: MeetingTranscriber): void {\r\n this.isMeetingRecognizer = true;\r\n this.canceled = (s: any, e: CancellationEventArgs): void => {\r\n if (!!transcriber.canceled) {\r\n transcriber.canceled(transcriber, e);\r\n }\r\n };\r\n this.recognizing = (s: any, e: SpeechRecognitionEventArgs): void => {\r\n if (!!transcriber.transcribing) {\r\n transcriber.transcribing(transcriber, e);\r\n }\r\n };\r\n this.recognized = (s: any, e: SpeechRecognitionEventArgs): void => {\r\n if (!!transcriber.transcribed) {\r\n transcriber.transcribed(transcriber, e);\r\n }\r\n };\r\n this.sessionStarted = (s: any, e: SessionEventArgs): void => {\r\n if (!!transcriber.sessionStarted) {\r\n transcriber.sessionStarted(transcriber, e);\r\n }\r\n };\r\n this.sessionStopped = (s: any, e: SessionEventArgs): void => {\r\n if (!!transcriber.sessionStopped) {\r\n transcriber.sessionStopped(transcriber, e);\r\n }\r\n };\r\n }\r\n\r\n public disconnectCallbacks(): void {\r\n this.canceled = undefined;\r\n this.recognizing = undefined;\r\n this.recognized = undefined;\r\n this.sessionStarted = undefined;\r\n this.sessionStopped = undefined;\r\n }\r\n\r\n /**\r\n * Disposes any resources held by the object.\r\n * @member ConversationTranscriber.prototype.dispose\r\n * @function\r\n * @public\r\n * @param {boolean} disposing - true if disposing the object.\r\n */\r\n protected async dispose(disposing: boolean): Promise<void> {\r\n if (this.privDisposedRecognizer) {\r\n return;\r\n }\r\n\r\n if (disposing) {\r\n this.privDisposedRecognizer = true;\r\n await this.implRecognizerStop();\r\n }\r\n\r\n await 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 TranscriptionServiceRecognizer(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\nexport { ConversationManager } from \"./ConversationManager.js\";\r\nexport { ConversationConnectionConfig } from \"./ConversationConnectionConfig.js\";\r\nexport { ConversationRecognizerFactory } from \"./ConversationTranslatorRecognizer.js\";\r\nexport { TranscriberRecognizer } from \"./TranscriberRecognizer.js\";\r\nexport {\r\n ConversationReceivedTranslationEventArgs,\r\n LockRoomEventArgs,\r\n MuteAllEventArgs,\r\n ParticipantAttributeEventArgs,\r\n ParticipantEventArgs,\r\n ParticipantsListEventArgs } from \"./ConversationTranslatorEventArgs.js\";\r\nexport {\r\n ConversationRecognizer,\r\n ConversationTranslatorCommandTypes,\r\n ConversationTranslatorMessageTypes,\r\n IInternalConversation,\r\n IInternalParticipant,\r\n InternalParticipants} from \"./ConversationTranslatorInterfaces.js\";\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { SpeechSynthesisBoundaryType } from \"../../sdk/Exports.js\";\r\n\r\nexport enum MetadataType {\r\n WordBoundary = \"WordBoundary\",\r\n Bookmark = \"Bookmark\",\r\n Viseme = \"Viseme\",\r\n SentenceBoundary = \"SentenceBoundary\",\r\n SessionEnd = \"SessionEnd\",\r\n AvatarSignal = \"TalkingAvatarSignal\",\r\n}\r\n\r\nexport interface ISynthesisMetadata {\r\n Type: MetadataType;\r\n Data: {\r\n Offset: number;\r\n Duration: number;\r\n text: {\r\n Text: string;\r\n Length: number;\r\n BoundaryType: SpeechSynthesisBoundaryType;\r\n };\r\n Bookmark: string;\r\n VisemeId: number;\r\n AnimationChunk: string;\r\n IsLastAnimation: boolean;\r\n Name: string;\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) as ISynthesisAudioMetadata;\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\n/* eslint-disable max-classes-per-file */\r\n\r\nimport { EventType, PlatformEvent } from \"../common/Exports.js\";\r\n\r\nexport class SpeechSynthesisEvent extends PlatformEvent {\r\n private privRequestId: string;\r\n\r\n public 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\nexport class SynthesisTriggeredEvent extends SpeechSynthesisEvent {\r\n private privSessionAudioDestinationId: string;\r\n private privTurnAudioDestinationId: string;\r\n\r\n public 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\nexport class ConnectingToSynthesisServiceEvent extends SpeechSynthesisEvent {\r\n private privAuthFetchEventId: string;\r\n\r\n public 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\nexport class SynthesisStartedEvent extends SpeechSynthesisEvent {\r\n private privAuthFetchEventId: string;\r\n\r\n public 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 {\r\n createNoDashGuid,\r\n Deferred,\r\n Events,\r\n IAudioDestination\r\n} from \"../common/Exports.js\";\r\nimport { AudioOutputFormatImpl } from \"../sdk/Audio/AudioOutputFormat.js\";\r\nimport { PullAudioOutputStreamImpl } from \"../sdk/Audio/AudioOutputStream.js\";\r\nimport {\r\n PropertyCollection,\r\n PropertyId,\r\n ResultReason,\r\n SpeechSynthesisResult,\r\n} from \"../sdk/Exports.js\";\r\nimport { ISynthesisMetadata, MetadataType } from \"./ServiceMessages/SynthesisAudioMetadata.js\";\r\nimport {\r\n ConnectingToSynthesisServiceEvent,\r\n SpeechSynthesisEvent,\r\n SynthesisStartedEvent,\r\n SynthesisTriggeredEvent,\r\n} from \"./SynthesisEvents.js\";\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 webrtc: {\r\n connectionString: string;\r\n };\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<void> {\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 public get currentSentenceOffset(): number {\r\n return this.privSentenceOffset;\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 audioDuration(): number {\r\n return this.privAudioDuration;\r\n }\r\n\r\n public get extraProperties(): PropertyCollection {\r\n if (!!this.privWebRTCSDP) {\r\n const properties = new PropertyCollection();\r\n properties.setProperty(PropertyId.TalkingAvatarService_WebRTC_SDP, this.privWebRTCSDP);\r\n return properties;\r\n }\r\n\r\n return undefined;\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<void>;\r\n private privInTurn: boolean = false;\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 privSentenceOffset: number = 0;\r\n private privNextSearchSentenceIndex: number = 0;\r\n private privPartialVisemeAnimation: string;\r\n private privRawText: string;\r\n private privIsSSML: boolean;\r\n private privTurnAudioDestination: IAudioDestination;\r\n private privAudioDuration: number;\r\n private privWebRTCSDP: string;\r\n\r\n public constructor() {\r\n this.privRequestId = createNoDashGuid();\r\n this.privTurnDeferral = new Deferred<void>();\r\n\r\n // We're not in a turn, so resolve.\r\n this.privTurnDeferral.resolve();\r\n }\r\n\r\n public async getAllReceivedAudio(): Promise<ArrayBuffer> {\r\n if (!!this.privReceivedAudio) {\r\n return Promise.resolve(this.privReceivedAudio);\r\n }\r\n if (!this.privIsSynthesisEnded) {\r\n return null;\r\n }\r\n await this.readAllAudioFromStream();\r\n return Promise.resolve(this.privReceivedAudio);\r\n }\r\n\r\n public async getAllReceivedAudioWithHeader(): Promise<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 const audio: ArrayBuffer = await this.getAllReceivedAudio();\r\n this.privReceivedAudioWithHeader = this.audioOutputFormat.addHeader(audio);\r\n return this.privReceivedAudioWithHeader;\r\n } else {\r\n return this.getAllReceivedAudio();\r\n }\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 this.privSentenceOffset = 0;\r\n this.privNextSearchSentenceIndex = 0;\r\n this.privPartialVisemeAnimation = \"\";\r\n this.privWebRTCSDP = \"\";\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): 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): void {\r\n if (isError) {\r\n this.onComplete();\r\n }\r\n }\r\n\r\n public onConnectionEstablishCompleted(statusCode: number): 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) as ISynthesisResponse;\r\n this.streamId = response.audio.streamId;\r\n }\r\n\r\n public onServiceTurnEndResponse(): void {\r\n this.privInTurn = false;\r\n this.privTurnDeferral.resolve();\r\n this.onComplete();\r\n }\r\n\r\n public onServiceTurnStartResponse(responseJson: string): void {\r\n if (!!this.privTurnDeferral && !!this.privInTurn) {\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 // Avoid UnhandledPromiseRejection if privTurnDeferral is not being awaited\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n this.privTurnDeferral.promise.then().catch((): void => { });\r\n }\r\n this.privInTurn = true;\r\n this.privTurnDeferral = new Deferred<void>();\r\n const response: ISynthesisResponse = JSON.parse(responseJson) as ISynthesisResponse;\r\n if (!!response.webrtc) {\r\n this.privWebRTCSDP = response.webrtc.connectionString;\r\n }\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 onTextBoundaryEvent(metadata: ISynthesisMetadata): void {\r\n this.updateTextOffset(metadata.Data.text.Text, metadata.Type);\r\n }\r\n\r\n public onVisemeMetadataReceived(metadata: ISynthesisMetadata): void {\r\n if (metadata.Data.AnimationChunk !== undefined) {\r\n this.privPartialVisemeAnimation += metadata.Data.AnimationChunk;\r\n }\r\n }\r\n\r\n public onSessionEnd(metadata: ISynthesisMetadata): void {\r\n this.privAudioDuration = metadata.Data.Offset;\r\n }\r\n\r\n public async constructSynthesisResult(): Promise<SpeechSynthesisResult> {\r\n const audioBuffer: ArrayBuffer = await this.getAllReceivedAudioWithHeader();\r\n return new SpeechSynthesisResult(\r\n this.requestId,\r\n ResultReason.SynthesizingAudioCompleted,\r\n audioBuffer,\r\n undefined,\r\n this.extraProperties,\r\n this.audioDuration\r\n );\r\n }\r\n\r\n public dispose(): 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 /**\r\n * Gets the viseme animation string (merged from animation chunk), and clears the internal\r\n * partial animation.\r\n */\r\n public getAndClearVisemeAnimation(): string {\r\n const animation: string = this.privPartialVisemeAnimation;\r\n this.privPartialVisemeAnimation = \"\";\r\n return animation;\r\n }\r\n\r\n protected onEvent(event: SpeechSynthesisEvent): void {\r\n Events.instance.onEvent(event);\r\n }\r\n\r\n /**\r\n * Check if the text is an XML(SSML) tag\r\n * @param text\r\n * @private\r\n */\r\n private static isXmlTag(text: string): boolean {\r\n return text.length >= 2 && text[0] === \"<\" && text[text.length - 1] === \">\";\r\n }\r\n\r\n private updateTextOffset(text: string, type: MetadataType): void {\r\n if (type === MetadataType.WordBoundary) {\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 if (this.privIsSSML) {\r\n if (this.withinXmlTag(this.privTextOffset) && !SynthesisTurn.isXmlTag(text)) {\r\n this.updateTextOffset(text, type);\r\n }\r\n }\r\n }\r\n } else {\r\n this.privSentenceOffset = this.privRawText.indexOf(text, this.privNextSearchSentenceIndex);\r\n if (this.privSentenceOffset >= 0) {\r\n this.privNextSearchSentenceIndex = this.privSentenceOffset + text.length;\r\n if (this.privIsSSML) {\r\n if (this.withinXmlTag(this.privSentenceOffset) && !SynthesisTurn.isXmlTag(text)) {\r\n this.updateTextOffset(text, type);\r\n }\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 this.privInTurn = false;\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 async readAllAudioFromStream(): Promise<void> {\r\n if (this.privIsSynthesisEnded) {\r\n this.privReceivedAudio = new ArrayBuffer(this.bytesReceived);\r\n try {\r\n await 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 /**\r\n * Check if current idx is in XML(SSML) tag\r\n * @param idx\r\n * @private\r\n */\r\n private withinXmlTag(idx: number): boolean {\r\n return this.privRawText.indexOf(\"<\", idx + 1) > this.privRawText.indexOf(\">\", idx + 1);\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 ConnectionState,\r\n createNoDashGuid,\r\n EventSource,\r\n IAudioDestination,\r\n IConnection,\r\n IDisposable,\r\n MessageType,\r\n ServiceEvent,\r\n} from \"../common/Exports.js\";\r\nimport { AudioOutputFormatImpl } from \"../sdk/Audio/AudioOutputFormat.js\";\r\nimport {\r\n CancellationErrorCode,\r\n CancellationReason,\r\n PropertyCollection,\r\n PropertyId,\r\n ResultReason,\r\n SpeechSynthesisBookmarkEventArgs,\r\n SpeechSynthesisResult,\r\n SpeechSynthesisVisemeEventArgs,\r\n SpeechSynthesisWordBoundaryEventArgs,\r\n Synthesizer,\r\n} from \"../sdk/Exports.js\";\r\nimport {\r\n AgentConfig,\r\n CancellationErrorCodePropertyName,\r\n ISynthesisConnectionFactory,\r\n ISynthesisMetadata,\r\n MetadataType,\r\n SynthesisAudioMetadata,\r\n SynthesisContext,\r\n SynthesisTurn,\r\n SynthesizerConfig\r\n} from \"./Exports.js\";\r\nimport { AuthInfo, IAuthentication } from \"./IAuthentication.js\";\r\nimport { SpeechConnectionMessage } from \"./SpeechConnectionMessage.Internal.js\";\r\n\r\nexport abstract class SynthesisAdapterBase implements IDisposable {\r\n protected privSynthesisTurn: SynthesisTurn;\r\n protected privConnectionId: string;\r\n protected privSynthesizerConfig: SynthesizerConfig;\r\n protected privSynthesizer: Synthesizer;\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<ConnectionEvent> {\r\n return this.privConnectionEvents;\r\n }\r\n\r\n public get serviceEvents(): EventSource<ServiceEvent> {\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) => void = 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) {\r\n this.privActivityTemplate = messagePayload;\r\n }\r\n public get activityTemplate(): string {\r\n return this.privActivityTemplate;\r\n }\r\n\r\n protected receiveMessageOverride: () => void = undefined;\r\n\r\n protected connectImplOverride: (isUnAuthorized: boolean) => void = undefined;\r\n\r\n protected configConnectionOverride: (connection: IConnection) => Promise<IConnection> = 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<IConnection> = undefined;\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<IConnection>;\r\n private privAuthFetchEventId: string;\r\n private privIsDisposed: boolean;\r\n private privConnectionEvents: EventSource<ConnectionEvent>;\r\n private privServiceEvents: EventSource<ServiceEvent>;\r\n protected privSynthesisContext: SynthesisContext;\r\n private privAgentConfig: AgentConfig;\r\n private privActivityTemplate: string;\r\n protected 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 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.privSessionAudioDestination = audioDestination;\r\n this.privSynthesisTurn = new SynthesisTurn();\r\n this.privConnectionEvents = new EventSource<ConnectionEvent>();\r\n this.privServiceEvents = new EventSource<ServiceEvent>();\r\n this.privSynthesisContext = new SynthesisContext();\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 if (connectionClosedEvent.statusCode !== 1000) {\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\r\n public isDisposed(): boolean {\r\n return this.privIsDisposed;\r\n }\r\n\r\n public async dispose(reason?: string): Promise<void> {\r\n this.privIsDisposed = true;\r\n if (this.privSessionAudioDestination !== undefined) {\r\n this.privSessionAudioDestination.close();\r\n }\r\n if (this.privConnectionConfigurationPromise !== undefined) {\r\n const connection: IConnection = await this.privConnectionConfigurationPromise;\r\n await connection.dispose(reason);\r\n }\r\n }\r\n\r\n public async connect(): Promise<void> {\r\n await this.connectImpl();\r\n }\r\n\r\n public async sendNetworkMessage(path: string, payload: string | ArrayBuffer): Promise<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 const connection: IConnection = await this.fetchConnection();\r\n return connection.send(new SpeechConnectionMessage(type, path, this.privSynthesisTurn.requestId, contentType, payload));\r\n }\r\n\r\n public async 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<void> {\r\n\r\n let ssml: string;\r\n\r\n if (isSSML) {\r\n ssml = text;\r\n } else {\r\n ssml = this.privSynthesizer.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 try {\r\n await this.connectImpl();\r\n const connection: IConnection = await this.fetchConnection();\r\n await this.sendSynthesisContext(connection);\r\n await this.sendSsmlMessage(connection, ssml, requestId);\r\n this.onSynthesisStarted(requestId);\r\n\r\n void this.receiveMessage();\r\n } catch (e) {\r\n this.cancelSynthesisLocal(CancellationReason.Error, CancellationErrorCode.ConnectionFailure, e as string);\r\n return Promise.reject(e);\r\n }\r\n }\r\n\r\n public async stopSpeaking(): Promise<void> {\r\n await this.connectImpl();\r\n const connection: IConnection = await this.fetchConnection();\r\n\r\n return connection.send(new SpeechConnectionMessage(\r\n MessageType.Text,\r\n \"synthesis.control\",\r\n this.privSynthesisTurn.requestId,\r\n \"application/json\",\r\n JSON.stringify({\r\n action: \"stop\"\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 this.onSynthesisCancelled(result);\r\n\r\n if (!!this.privSuccessCallback) {\r\n try {\r\n this.privSuccessCallback(result);\r\n /* eslint-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 // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n protected processTypeSpecificMessages(_connectionMessage: SpeechConnectionMessage): boolean {\r\n return true;\r\n }\r\n\r\n protected async receiveMessage(): Promise<void> {\r\n try {\r\n const connection: IConnection = await this.fetchConnection();\r\n const message: ConnectionMessage = await connection.read();\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;\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;\r\n } else {\r\n return this.receiveMessage();\r\n }\r\n }\r\n\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(connectionMessage.textBody);\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 this.onSynthesizing(connectionMessage.binaryBody);\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 switch (metadata.Type) {\r\n case MetadataType.WordBoundary:\r\n case MetadataType.SentenceBoundary:\r\n this.privSynthesisTurn.onTextBoundaryEvent(metadata);\r\n const wordBoundaryEventArgs: SpeechSynthesisWordBoundaryEventArgs = new SpeechSynthesisWordBoundaryEventArgs(\r\n metadata.Data.Offset,\r\n metadata.Data.Duration,\r\n metadata.Data.text.Text,\r\n metadata.Data.text.Length,\r\n metadata.Type === MetadataType.WordBoundary\r\n ? this.privSynthesisTurn.currentTextOffset : this.privSynthesisTurn.currentSentenceOffset,\r\n metadata.Data.text.BoundaryType);\r\n this.onWordBoundary(wordBoundaryEventArgs);\r\n break;\r\n case MetadataType.Bookmark:\r\n const bookmarkEventArgs: SpeechSynthesisBookmarkEventArgs = new SpeechSynthesisBookmarkEventArgs(\r\n metadata.Data.Offset,\r\n metadata.Data.Bookmark);\r\n this.onBookmarkReached(bookmarkEventArgs);\r\n break;\r\n case MetadataType.Viseme:\r\n this.privSynthesisTurn.onVisemeMetadataReceived(metadata);\r\n if (metadata.Data.IsLastAnimation) {\r\n const visemeEventArgs: SpeechSynthesisVisemeEventArgs = new SpeechSynthesisVisemeEventArgs(\r\n metadata.Data.Offset,\r\n metadata.Data.VisemeId,\r\n this.privSynthesisTurn.getAndClearVisemeAnimation());\r\n this.onVisemeReceived(visemeEventArgs);\r\n }\r\n break;\r\n case MetadataType.AvatarSignal:\r\n this.onAvatarEvent(metadata);\r\n break;\r\n case MetadataType.SessionEnd:\r\n this.privSynthesisTurn.onSessionEnd(metadata);\r\n break;\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 = await this.privSynthesisTurn.constructSynthesisResult();\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 as string);\r\n }\r\n }\r\n this.onSynthesisCompleted(result);\r\n break;\r\n\r\n default:\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 } catch (e) {\r\n // TODO: What goes here?\r\n }\r\n }\r\n\r\n protected sendSynthesisContext(connection: IConnection): Promise<void> {\r\n this.setSynthesisContextSynthesisSection();\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;\r\n }\r\n\r\n protected abstract setSynthesisContextSynthesisSection(): void;\r\n\r\n protected setSpeechConfigSynthesisSection(): void {\r\n return;\r\n }\r\n\r\n protected connectImpl(isUnAuthorized: boolean = false): Promise<IConnection> {\r\n if (this.privConnectionPromise != null) {\r\n return this.privConnectionPromise.then((connection: IConnection): Promise<IConnection> => {\r\n if (connection.state() === ConnectionState.Disconnected) {\r\n this.privConnectionId = null;\r\n this.privConnectionPromise = null;\r\n return this.connectImpl();\r\n }\r\n return this.privConnectionPromise;\r\n }, (): Promise<IConnection> => {\r\n this.privConnectionId = null;\r\n this.privConnectionPromise = null;\r\n return this.connectImpl();\r\n });\r\n }\r\n this.privAuthFetchEventId = createNoDashGuid();\r\n this.privConnectionId = createNoDashGuid();\r\n\r\n this.privSynthesisTurn.onPreConnectionStart(this.privAuthFetchEventId);\r\n\r\n const authPromise = isUnAuthorized ? this.privAuthentication.fetchOnExpiry(this.privAuthFetchEventId) : this.privAuthentication.fetch(this.privAuthFetchEventId);\r\n\r\n this.privConnectionPromise = authPromise.then(async (result: AuthInfo): Promise<IConnection> => {\r\n this.privSynthesisTurn.onAuthCompleted(false);\r\n\r\n const connection: IConnection = this.privConnectionFactory.create(this.privSynthesizerConfig, 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): void => {\r\n this.connectionEvents.onEvent(event);\r\n });\r\n const response = await connection.open();\r\n if (response.statusCode === 200) {\r\n this.privSynthesisTurn.onConnectionEstablishCompleted(response.statusCode);\r\n return Promise.resolve(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);\r\n return Promise.reject(\r\n `Unable to contact server. StatusCode: ${response.statusCode},\r\n ${this.privSynthesizerConfig.parameters.getProperty(PropertyId.SpeechServiceConnection_Url)} Reason: ${response.reason}`);\r\n }\r\n }, (error: string): Promise<IConnection> => {\r\n this.privSynthesisTurn.onAuthCompleted(true);\r\n throw new Error(error);\r\n });\r\n\r\n // Attach an empty handler to allow the promise to run in the background while\r\n // other startup events happen. It'll eventually be awaited on.\r\n // eslint-disable-next-line @typescript-eslint/no-empty-function\r\n this.privConnectionPromise.catch((): void => { });\r\n\r\n return this.privConnectionPromise;\r\n }\r\n protected sendSpeechServiceConfig(connection: IConnection, SpeechServiceConfigJson: string): Promise<void> {\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\r\n protected sendSsmlMessage(connection: IConnection, ssml: string, requestId: string): Promise<void> {\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 async fetchConnection(): Promise<IConnection> {\r\n if (this.privConnectionConfigurationPromise !== undefined) {\r\n return this.privConnectionConfigurationPromise.then((connection: IConnection): Promise<IConnection> => {\r\n if (connection.state() === ConnectionState.Disconnected) {\r\n this.privConnectionId = null;\r\n this.privConnectionConfigurationPromise = undefined;\r\n return this.fetchConnection();\r\n }\r\n return this.privConnectionConfigurationPromise;\r\n }, (): Promise<IConnection> => {\r\n this.privConnectionId = null;\r\n this.privConnectionConfigurationPromise = undefined;\r\n return this.fetchConnection();\r\n });\r\n }\r\n this.privConnectionConfigurationPromise = this.configureConnection();\r\n return await this.privConnectionConfigurationPromise;\r\n }\r\n\r\n // Takes an established websocket connection to the endpoint and sends speech configuration information.\r\n private async configureConnection(): Promise<IConnection> {\r\n const connection: IConnection = await this.connectImpl();\r\n if (this.configConnectionOverride !== undefined) {\r\n return this.configConnectionOverride(connection);\r\n }\r\n this.setSpeechConfigSynthesisSection();\r\n await this.sendSpeechServiceConfig(connection, this.privSynthesizerConfig.SpeechServiceConfig.serialize());\r\n return connection;\r\n }\r\n\r\n protected onAvatarEvent(_metadata: ISynthesisMetadata): void {\r\n return;\r\n }\r\n\r\n protected onSynthesisStarted(_requestId: string): void {\r\n return;\r\n }\r\n\r\n protected onSynthesizing(_audio: ArrayBuffer): void {\r\n return;\r\n }\r\n\r\n protected onSynthesisCancelled(_result: SpeechSynthesisResult): void {\r\n return;\r\n }\r\n\r\n protected onSynthesisCompleted(_result: SpeechSynthesisResult): void {\r\n return;\r\n }\r\n\r\n protected onWordBoundary(_wordBoundaryEventArgs: SpeechSynthesisWordBoundaryEventArgs): void {\r\n return;\r\n }\r\n\r\n protected onVisemeReceived(_visemeEventArgs: SpeechSynthesisVisemeEventArgs): void {\r\n return;\r\n }\r\n\r\n protected onBookmarkReached(_bookmarkEventArgs: SpeechSynthesisBookmarkEventArgs): void {\r\n return;\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 AvatarConfig,\r\n AvatarEventArgs,\r\n AvatarSynthesizer,\r\n PropertyId,\r\n Synthesizer,\r\n} from \"../sdk/Exports.js\";\r\nimport {\r\n ISynthesisConnectionFactory,\r\n ISynthesisMetadata,\r\n ISynthesisSectionVideo,\r\n SynthesisAdapterBase,\r\n SynthesizerConfig\r\n} from \"./Exports.js\";\r\nimport { IAuthentication } from \"./IAuthentication.js\";\r\n\r\nexport class AvatarSynthesisAdapter extends SynthesisAdapterBase {\r\n private readonly privAvatarSynthesizer: AvatarSynthesizer;\r\n private readonly privAvatarConfig: AvatarConfig;\r\n\r\n public constructor(\r\n authentication: IAuthentication,\r\n connectionFactory: ISynthesisConnectionFactory,\r\n synthesizerConfig: SynthesizerConfig,\r\n avatarSynthesizer: AvatarSynthesizer,\r\n avatarConfig: AvatarConfig,\r\n ) {\r\n\r\n super(authentication, connectionFactory,\r\n synthesizerConfig, undefined);\r\n this.privAvatarSynthesizer = avatarSynthesizer;\r\n this.privSynthesizer = avatarSynthesizer as Synthesizer;\r\n this.privAvatarConfig = avatarConfig;\r\n }\r\n\r\n protected setSynthesisContextSynthesisSection(): void {\r\n this.privSynthesisContext.setSynthesisSection(undefined);\r\n }\r\n\r\n protected setSpeechConfigSynthesisSection(): void {\r\n this.privSynthesizerConfig.synthesisVideoSection = {\r\n format: {\r\n bitrate: this.privAvatarConfig.videoFormat?.bitrate,\r\n codec: this.privAvatarConfig.videoFormat?.codec,\r\n crop: {\r\n bottomRight: {\r\n x: this.privAvatarConfig.videoFormat?.cropRange?.bottomRight?.x,\r\n y: this.privAvatarConfig.videoFormat?.cropRange?.bottomRight?.y,\r\n },\r\n topLeft: {\r\n x: this.privAvatarConfig.videoFormat?.cropRange?.topLeft?.x,\r\n y: this.privAvatarConfig.videoFormat?.cropRange?.topLeft?.y,\r\n },\r\n },\r\n resolution: {\r\n height: this.privAvatarConfig.videoFormat?.height,\r\n width: this.privAvatarConfig.videoFormat?.width,\r\n },\r\n },\r\n protocol: {\r\n name: \"WebRTC\",\r\n webrtcConfig: {\r\n clientDescription: btoa(this.privSynthesizerConfig.parameters.getProperty(PropertyId.TalkingAvatarService_WebRTC_SDP)),\r\n iceServers: this.privAvatarSynthesizer.iceServers,\r\n },\r\n },\r\n talkingAvatar: {\r\n background: {\r\n color: this.privAvatarConfig.backgroundColor,\r\n },\r\n character: this.privAvatarConfig.character,\r\n customized: this.privAvatarConfig.customized,\r\n style: this.privAvatarConfig.style,\r\n }\r\n } as ISynthesisSectionVideo;\r\n }\r\n\r\n\r\n protected onAvatarEvent(metadata: ISynthesisMetadata): void {\r\n if (!!this.privAvatarSynthesizer.avatarEventReceived) {\r\n const avatarEventArgs: AvatarEventArgs = new AvatarEventArgs(\r\n metadata.Data.Offset,\r\n metadata.Data.Name);\r\n try {\r\n this.privAvatarSynthesizer.avatarEventReceived(this.privAvatarSynthesizer, avatarEventArgs);\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","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { IAudioDestination } from \"../common/Exports.js\";\r\nimport {\r\n ResultReason,\r\n SpeechSynthesisBookmarkEventArgs,\r\n SpeechSynthesisEventArgs,\r\n SpeechSynthesisResult,\r\n SpeechSynthesisVisemeEventArgs,\r\n SpeechSynthesisWordBoundaryEventArgs,\r\n SpeechSynthesizer,\r\n Synthesizer,\r\n} from \"../sdk/Exports.js\";\r\nimport {\r\n IAuthentication,\r\n ISynthesisConnectionFactory,\r\n SynthesisAdapterBase,\r\n SynthesizerConfig\r\n} from \"./Exports.js\";\r\n\r\nexport class SpeechSynthesisAdapter extends SynthesisAdapterBase {\r\n private privSpeechSynthesizer: SpeechSynthesizer;\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 super(authentication, connectionFactory, synthesizerConfig, audioDestination);\r\n this.privSpeechSynthesizer = speechSynthesizer;\r\n this.privSynthesizer = speechSynthesizer as Synthesizer;\r\n }\r\n\r\n protected setSynthesisContextSynthesisSection(): void {\r\n this.privSynthesisContext.setSynthesisSection(this.privSpeechSynthesizer);\r\n }\r\n\r\n protected onSynthesisStarted(requestId: string): void {\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\r\n protected onSynthesizing(audio: ArrayBuffer): void {\r\n if (!!this.privSpeechSynthesizer.synthesizing) {\r\n try {\r\n const audioWithHeader = this.privSynthesisTurn.audioOutputFormat.addHeader(audio);\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 }\r\n\r\n protected onSynthesisCancelled(result: SpeechSynthesisResult): void {\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 /* eslint-disable no-empty */\r\n } catch { }\r\n }\r\n }\r\n\r\n protected onSynthesisCompleted(result: SpeechSynthesisResult): void {\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 }\r\n\r\n protected onWordBoundary(wordBoundaryEventArgs: SpeechSynthesisWordBoundaryEventArgs): void {\r\n if (!!this.privSpeechSynthesizer.wordBoundary) {\r\n try {\r\n this.privSpeechSynthesizer.wordBoundary(this.privSpeechSynthesizer, wordBoundaryEventArgs);\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 protected onVisemeReceived(visemeEventArgs: SpeechSynthesisVisemeEventArgs): void {\r\n if (!!this.privSpeechSynthesizer.visemeReceived) {\r\n try {\r\n this.privSpeechSynthesizer.visemeReceived(this.privSpeechSynthesizer, visemeEventArgs);\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 protected onBookmarkReached(bookmarkEventArgs: SpeechSynthesisBookmarkEventArgs): void {\r\n if (!!this.privSpeechSynthesizer.bookmarkReached) {\r\n try {\r\n this.privSpeechSynthesizer.bookmarkReached(this.privSpeechSynthesizer, bookmarkEventArgs);\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","import {\r\n IRequestOptions,\r\n IRestResponse,\r\n RestConfigBase,\r\n RestMessageAdapter,\r\n RestRequestType,\r\n} from \"../common.browser/Exports.js\";\r\nimport {\r\n PropertyId,\r\n} from \"../sdk/Exports.js\";\r\nimport { ConnectionFactoryBase } from \"./ConnectionFactoryBase.js\";\r\nimport { AuthInfo, IAuthentication, SynthesizerConfig } from \"./Exports.js\";\r\nimport { HeaderNames } from \"./HeaderNames.js\";\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 SynthesisRestAdapter\r\n */\r\nexport class SynthesisRestAdapter {\r\n private privRestAdapter: RestMessageAdapter;\r\n private privUri: string;\r\n private privAuthentication: IAuthentication;\r\n\r\n public constructor(config: SynthesizerConfig, authentication: IAuthentication) {\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 = ConnectionFactoryBase.getHostSuffix(region);\r\n endpoint = config.parameters.getProperty(PropertyId.SpeechServiceConnection_Host, `https://${region}.tts.speech${hostSuffix}`);\r\n }\r\n this.privUri = `${endpoint}/cognitiveservices/voices/list`;\r\n\r\n const options: IRequestOptions = RestConfigBase.requestOptions;\r\n this.privRestAdapter = new RestMessageAdapter(options);\r\n this.privAuthentication = authentication;\r\n }\r\n\r\n /**\r\n * Sends list voices request to endpoint.\r\n * @function\r\n * @public\r\n * @param connectionId - guid for connectionId\r\n * @returns {Promise<IRestResponse>} rest response to status request\r\n */\r\n public getVoicesList(connectionId: string): Promise<IRestResponse> {\r\n this.privRestAdapter.setHeaders(HeaderNames.ConnectionId, connectionId);\r\n return this.privAuthentication.fetch(connectionId).then((authInfo: AuthInfo): Promise<IRestResponse> => {\r\n this.privRestAdapter.setHeaders(authInfo.headerName, authInfo.token);\r\n return this.privRestAdapter.request(RestRequestType.Get, this.privUri);\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 { PropertyCollection } from \"../sdk/Exports.js\";\r\nimport {\r\n Context,\r\n ISynthesisSectionVideo,\r\n SpeechServiceConfig\r\n } from \"./Exports.js\";\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 public avatarEnabled: boolean = false;\r\n\r\n public 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 set synthesisVideoSection(value: ISynthesisSectionVideo) {\r\n this.privSpeechServiceConfig.Context.synthesis = {\r\n video: value\r\n };\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.js\";\r\nimport { PropertyId, SpeechSynthesizer } from \"../sdk/Exports.js\";\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 privAudioOutputFormat: AudioOutputFormatImpl;\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: string | object): 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 return JSON.stringify(this.privContext);\r\n }\r\n\r\n public setSynthesisSection(speechSynthesizer: SpeechSynthesizer): void {\r\n const synthesisSection: ISynthesisSection = this.buildSynthesisContext(speechSynthesizer);\r\n this.setSection(\"synthesis\", synthesisSection);\r\n }\r\n\r\n private buildSynthesisContext(speechSynthesizer: SpeechSynthesizer): ISynthesisSection {\r\n return {\r\n audio: {\r\n metadataOptions: {\r\n bookmarkEnabled: (!!speechSynthesizer?.bookmarkReached),\r\n punctuationBoundaryEnabled: speechSynthesizer?.properties.getProperty(\r\n PropertyId.SpeechServiceResponse_RequestPunctuationBoundary, (!!speechSynthesizer?.wordBoundary)),\r\n sentenceBoundaryEnabled: speechSynthesizer?.properties.getProperty(\r\n PropertyId.SpeechServiceResponse_RequestSentenceBoundary, false),\r\n sessionEndEnabled: true,\r\n visemeEnabled: (!!speechSynthesizer?.visemeReceived),\r\n wordBoundaryEnabled: speechSynthesizer?.properties.getProperty(\r\n PropertyId.SpeechServiceResponse_RequestWordBoundary, (!!speechSynthesizer?.wordBoundary)),\r\n },\r\n outputFormat: this.privAudioOutputFormat.requestAudioFormatString,\r\n },\r\n language: {\r\n autoDetection: speechSynthesizer?.autoDetectSourceLanguage\r\n }\r\n } as ISynthesisSection;\r\n }\r\n}\r\n\r\ninterface ISynthesisSection {\r\n audio: {\r\n outputFormat: string;\r\n metadataOptions: {\r\n bookmarkEnabled: boolean;\r\n wordBoundaryEnabled: string;\r\n punctuationBoundaryEnabled: string;\r\n visemeEnabled: boolean;\r\n sentenceBoundaryEnabled: string;\r\n sessionEndEnabled: 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.js\";\r\nimport { Context } from \"./Exports.js\";\r\n\r\nexport class SpeakerRecognitionConfig {\r\n private privParameters: PropertyCollection;\r\n private privContext: Context;\r\n\r\n public 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","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { ReplayableAudioNode } from \"../common.browser/Exports.js\";\r\nimport {\r\n Deferred,\r\n IAudioSource,\r\n IAudioStreamNode,\r\n IConnection,\r\n MessageType,\r\n} from \"../common/Exports.js\";\r\nimport { AudioStreamFormatImpl } from \"../sdk/Audio/AudioStreamFormat.js\";\r\nimport { SpeakerRecognitionModel } from \"../sdk/SpeakerRecognitionModel.js\";\r\nimport {\r\n CancellationErrorCode,\r\n CancellationReason,\r\n SpeakerRecognitionResult,\r\n SpeakerRecognizer,\r\n PropertyCollection,\r\n PropertyId,\r\n ResultReason,\r\n SessionEventArgs,\r\n} from \"../sdk/Exports.js\";\r\nimport {\r\n CancellationErrorCodePropertyName,\r\n ISpeechConfigAudioDevice,\r\n SpeakerResponse,\r\n ServiceRecognizerBase,\r\n} from \"./Exports.js\";\r\nimport { IAuthentication } from \"./IAuthentication.js\";\r\nimport { IConnectionFactory } from \"./IConnectionFactory.js\";\r\nimport { RecognizerConfig } from \"./RecognizerConfig.js\";\r\nimport { SpeechConnectionMessage } from \"./SpeechConnectionMessage.Internal.js\";\r\n\r\ninterface SpeakerContext {\r\n scenario: string;\r\n profileIds: string[];\r\n features: {\r\n interimResult: string;\r\n progressiveDetection: string;\r\n };\r\n}\r\n\r\n// eslint-disable-next-line max-classes-per-file\r\nexport class SpeakerServiceRecognizer extends ServiceRecognizerBase {\r\n private privSpeakerRecognizer: SpeakerRecognizer;\r\n private privSpeakerAudioSource: IAudioSource;\r\n private privResultDeferral: Deferred<SpeakerRecognitionResult>;\r\n private privSpeakerModel: SpeakerRecognitionModel;\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: SpeakerRecognizer) {\r\n super(authentication, connectionFactory, audioSource, recognizerConfig, recognizer);\r\n this.privSpeakerRecognizer = recognizer;\r\n this.privSpeakerAudioSource = audioSource;\r\n this.recognizeSpeaker = (model: SpeakerRecognitionModel): Promise<SpeakerRecognitionResult> => this.recognizeSpeakerOnce(model);\r\n this.sendPrePayloadJSONOverride = (): Promise<void> => this.noOp();\r\n }\r\n\r\n protected processTypeSpecificMessages(connectionMessage: SpeechConnectionMessage): Promise<boolean> {\r\n\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 \"speaker.response\":\r\n const response: SpeakerResponse = JSON.parse(connectionMessage.textBody) as SpeakerResponse;\r\n let result: SpeakerRecognitionResult;\r\n if (response.status.statusCode.toLowerCase() !== \"success\") {\r\n result = new SpeakerRecognitionResult(\r\n response,\r\n ResultReason.Canceled,\r\n CancellationErrorCode.ServiceError,\r\n response.status.reason\r\n );\r\n } else {\r\n result = new SpeakerRecognitionResult(\r\n response,\r\n ResultReason.RecognizedSpeaker,\r\n );\r\n }\r\n if (!!this.privResultDeferral) {\r\n this.privResultDeferral.resolve(result);\r\n }\r\n processed = true;\r\n break;\r\n default:\r\n break;\r\n }\r\n const defferal = new Deferred<boolean>();\r\n defferal.resolve(processed);\r\n return defferal.promise;\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.privResultDeferral) {\r\n const result: SpeakerRecognitionResult = new SpeakerRecognitionResult(\r\n {\r\n scenario: this.privSpeakerModel.scenario,\r\n status: { statusCode: error, reason: error }\r\n },\r\n ResultReason.Canceled,\r\n errorCode,\r\n error\r\n );\r\n try {\r\n this.privResultDeferral.resolve(result);\r\n } catch (error) {\r\n this.privResultDeferral.reject(error as string);\r\n }\r\n }\r\n }\r\n\r\n public async recognizeSpeakerOnce(model: SpeakerRecognitionModel): Promise<SpeakerRecognitionResult> {\r\n this.privSpeakerModel = model;\r\n this.voiceProfileType = model.scenario;\r\n if (!this.privResultDeferral) {\r\n this.privResultDeferral = new Deferred<SpeakerRecognitionResult>();\r\n }\r\n this.privRequestSession.startNewRecognition();\r\n this.privRequestSession.listenForServiceTelemetry(this.privSpeakerAudioSource.events);\r\n\r\n this.privRecognizerConfig.parameters.setProperty(PropertyId.Speech_SessionId, this.privRequestSession.sessionId);\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 const conPromise: Promise<IConnection> = this.connectImpl();\r\n\r\n const preAudioPromise: Promise<void> = this.sendPreAudioMessages(this.extractSpeakerContext(model));\r\n\r\n const node: IAudioStreamNode = await this.privSpeakerAudioSource.attach(this.privRequestSession.audioNodeId);\r\n const format: AudioStreamFormatImpl = await this.privSpeakerAudioSource.format;\r\n const deviceInfo: ISpeechConfigAudioDevice = await this.privSpeakerAudioSource.deviceInfo;\r\n\r\n const audioNode = new ReplayableAudioNode(node, format.avgBytesPerSec);\r\n await this.privRequestSession.onAudioSourceAttachCompleted(audioNode, false);\r\n\r\n this.privRecognizerConfig.SpeechServiceConfig.Context.audio = { source: deviceInfo };\r\n\r\n try {\r\n await conPromise;\r\n await preAudioPromise;\r\n } catch (err) {\r\n this.cancelRecognition(this.privRequestSession.sessionId, this.privRequestSession.requestId, CancellationReason.Error, CancellationErrorCode.ConnectionFailure, err as string);\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 void this.receiveMessage();\r\n const audioSendPromise = this.sendAudio(audioNode);\r\n\r\n // /* eslint-disable no-empty */\r\n audioSendPromise.then((): void => { /* add? return true;*/ }, (error: string): void => {\r\n this.cancelRecognition(this.privRequestSession.sessionId, this.privRequestSession.requestId, CancellationReason.Error, CancellationErrorCode.RuntimeError, error);\r\n });\r\n\r\n return this.privResultDeferral.promise;\r\n }\r\n\r\n private async sendPreAudioMessages(context: SpeakerContext): Promise<void> {\r\n const connection: IConnection = await this.fetchConnection();\r\n await this.sendSpeakerRecognition(connection, context);\r\n // await this.sendWaveHeader(connection);\r\n }\r\n\r\n private async sendSpeakerRecognition(connection: IConnection, context: SpeakerContext): Promise<void> {\r\n const speakerContextJson = JSON.stringify(context);\r\n return connection.send(new SpeechConnectionMessage(\r\n MessageType.Text,\r\n \"speaker.context\",\r\n this.privRequestSession.requestId,\r\n \"application/json; charset=utf-8\",\r\n speakerContextJson));\r\n }\r\n\r\n private extractSpeakerContext(model: SpeakerRecognitionModel): SpeakerContext {\r\n return {\r\n features: {\r\n interimResult: \"enabled\",\r\n progressiveDetection: \"disabled\",\r\n },\r\n profileIds: model.profileIds,\r\n scenario: model.scenario,\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 { ReplayableAudioNode } from \"../common.browser/Exports.js\";\r\nimport {\r\n DeferralMap,\r\n Deferred,\r\n IAudioSource,\r\n IAudioStreamNode,\r\n IConnection,\r\n MessageType,\r\n} from \"../common/Exports.js\";\r\nimport { AudioStreamFormatImpl } from \"../sdk/Audio/AudioStreamFormat.js\";\r\nimport { SpeakerRecognitionModel } from \"../sdk/SpeakerRecognitionModel.js\";\r\nimport {\r\n CancellationErrorCode,\r\n CancellationReason,\r\n VoiceProfileClient,\r\n PropertyCollection,\r\n PropertyId,\r\n ResultReason,\r\n SessionEventArgs,\r\n VoiceProfileEnrollmentResult,\r\n VoiceProfilePhraseResult,\r\n VoiceProfileResult,\r\n VoiceProfileType,\r\n VoiceProfile\r\n} from \"../sdk/Exports.js\";\r\nimport {\r\n CancellationErrorCodePropertyName,\r\n EnrollmentResponse,\r\n IProfile,\r\n ISpeechConfigAudioDevice,\r\n ProfilePhraseResponse,\r\n ProfileResponse,\r\n ServiceRecognizerBase,\r\n} from \"./Exports.js\";\r\nimport { IAuthentication } from \"./IAuthentication.js\";\r\nimport { IConnectionFactory } from \"./IConnectionFactory.js\";\r\nimport { RecognizerConfig } from \"./RecognizerConfig.js\";\r\nimport { SpeechConnectionMessage } from \"./SpeechConnectionMessage.Internal.js\";\r\n\r\ninterface CreateProfile {\r\n scenario: string;\r\n locale: string;\r\n number: string;\r\n}\r\n\r\ninterface PhraseRequest {\r\n scenario: string;\r\n locale: string;\r\n}\r\n\r\ninterface SpeakerContext {\r\n scenario: string;\r\n profileIds: string[];\r\n features: {\r\n interimResult: string;\r\n progressiveDetection: string;\r\n };\r\n}\r\n\r\n// eslint-disable-next-line max-classes-per-file\r\nexport class VoiceServiceRecognizer extends ServiceRecognizerBase {\r\n private privSpeakerAudioSource: IAudioSource;\r\n private privDeferralMap: DeferralMap = new DeferralMap();\r\n private privExpectedProfileId: string;\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: VoiceProfileClient) {\r\n super(authentication, connectionFactory, audioSource, recognizerConfig, recognizer);\r\n this.privSpeakerAudioSource = audioSource;\r\n this.sendPrePayloadJSONOverride = (): Promise<void> => this.noOp();\r\n }\r\n\r\n public set SpeakerAudioSource(audioSource: IAudioSource) {\r\n this.privSpeakerAudioSource = audioSource;\r\n }\r\n\r\n protected processTypeSpecificMessages(connectionMessage: SpeechConnectionMessage): Promise<boolean> {\r\n\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 // Profile management response for create, fetch, delete, reset\r\n case \"speaker.profiles\":\r\n const response: ProfileResponse = JSON.parse(connectionMessage.textBody) as ProfileResponse;\r\n switch (response.operation.toLowerCase()) {\r\n case \"create\":\r\n this.handleCreateResponse(response, connectionMessage.requestId);\r\n break;\r\n\r\n case \"delete\":\r\n case \"reset\":\r\n this.handleResultResponse(response, connectionMessage.requestId);\r\n break;\r\n\r\n case \"fetch\":\r\n const enrollmentResponse: EnrollmentResponse = JSON.parse(connectionMessage.textBody) as EnrollmentResponse;\r\n this.handleFetchResponse(enrollmentResponse, connectionMessage.requestId);\r\n break;\r\n\r\n default:\r\n break;\r\n }\r\n processed = true;\r\n break;\r\n // Activation and authorization phrase response\r\n case \"speaker.phrases\":\r\n const phraseResponse: ProfilePhraseResponse = JSON.parse(connectionMessage.textBody) as ProfilePhraseResponse;\r\n this.handlePhrasesResponse(phraseResponse, connectionMessage.requestId);\r\n processed = true;\r\n break;\r\n // Enrollment response\r\n case \"speaker.profile.enrollment\":\r\n const enrollmentResponse: EnrollmentResponse = JSON.parse(connectionMessage.textBody) as EnrollmentResponse;\r\n const result: VoiceProfileEnrollmentResult = new VoiceProfileEnrollmentResult(\r\n this.enrollmentReasonFrom(!!enrollmentResponse.enrollment ? enrollmentResponse.enrollment.enrollmentStatus : enrollmentResponse.status.statusCode),\r\n !!enrollmentResponse.enrollment ? JSON.stringify(enrollmentResponse.enrollment) : undefined,\r\n enrollmentResponse.status.reason,\r\n );\r\n if (!!this.privDeferralMap.getId(connectionMessage.requestId)) {\r\n this.privDeferralMap.complete<VoiceProfileEnrollmentResult>(connectionMessage.requestId, result);\r\n }\r\n this.privRequestSession.onSpeechEnded();\r\n processed = true;\r\n break;\r\n default:\r\n break;\r\n }\r\n const defferal = new Deferred<boolean>();\r\n defferal.resolve(processed);\r\n return defferal.promise;\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 // const enrollmentResponse: EnrollmentResponse = JSON.parse(connectionMessage.textBody) as EnrollmentResponse;\r\n properties.setProperty(CancellationErrorCodePropertyName, CancellationErrorCode[errorCode]);\r\n\r\n const result: VoiceProfileEnrollmentResult = new VoiceProfileEnrollmentResult(\r\n ResultReason.Canceled,\r\n error,\r\n error,\r\n );\r\n if (!!this.privDeferralMap.getId(requestId)) {\r\n this.privDeferralMap.complete<VoiceProfileEnrollmentResult>(requestId, result);\r\n }\r\n }\r\n\r\n public async createProfile(profileType: VoiceProfileType, locale: string): Promise<string[]> {\r\n // Start the connection to the service. The promise this will create is stored and will be used by configureConnection().\r\n this.voiceProfileType = profileType.toString();\r\n const conPromise: Promise<IConnection> = this.connectImpl();\r\n try {\r\n const createProfileDeferral = new Deferred<string[]>();\r\n await conPromise;\r\n await this.sendCreateProfile(createProfileDeferral, profileType, locale);\r\n void this.receiveMessage();\r\n return createProfileDeferral.promise;\r\n } catch (err) {\r\n throw err;\r\n }\r\n }\r\n\r\n public async resetProfile(profile: VoiceProfile): Promise<VoiceProfileResult> {\r\n this.voiceProfileType = profile.profileType.toString();\r\n return this.sendCommonRequest<VoiceProfileResult>(\"reset\", profile.profileType, profile);\r\n }\r\n\r\n public async deleteProfile(profile: VoiceProfile): Promise<VoiceProfileResult> {\r\n this.voiceProfileType = profile.profileType.toString();\r\n return this.sendCommonRequest<VoiceProfileResult>(\"delete\", profile.profileType, profile);\r\n }\r\n\r\n public async retrieveEnrollmentResult(profile: VoiceProfile): Promise<VoiceProfileEnrollmentResult> {\r\n this.voiceProfileType = profile.profileType.toString();\r\n this.privExpectedProfileId = profile.profileId;\r\n return this.sendCommonRequest<VoiceProfileEnrollmentResult>(\"fetch\", profile.profileType, profile);\r\n }\r\n\r\n public async getAllProfiles(profileType: VoiceProfileType): Promise<VoiceProfileEnrollmentResult[]> {\r\n this.voiceProfileType = profileType.toString();\r\n return this.sendCommonRequest<VoiceProfileEnrollmentResult[]>(\"fetch\", profileType);\r\n }\r\n\r\n public async getActivationPhrases(profileType: VoiceProfileType, lang: string): Promise<VoiceProfilePhraseResult> {\r\n this.voiceProfileType = profileType.toString();\r\n // Start the connection to the service. The promise this will create is stored and will be used by configureConnection().\r\n const conPromise: Promise<IConnection> = this.connectImpl();\r\n try {\r\n const getPhrasesDeferral = new Deferred<VoiceProfilePhraseResult>();\r\n await conPromise;\r\n await this.sendPhrasesRequest(getPhrasesDeferral, profileType, lang);\r\n void this.receiveMessage();\r\n return getPhrasesDeferral.promise;\r\n } catch (err) {\r\n throw err;\r\n }\r\n }\r\n\r\n public async enrollProfile(profile: VoiceProfile): Promise<VoiceProfileEnrollmentResult> {\r\n this.voiceProfileType = profile.profileType.toString();\r\n const enrollmentDeferral = new Deferred<VoiceProfileEnrollmentResult>();\r\n this.privRequestSession.startNewRecognition();\r\n this.privRequestSession.listenForServiceTelemetry(this.privSpeakerAudioSource.events);\r\n\r\n this.privRecognizerConfig.parameters.setProperty(PropertyId.Speech_SessionId, this.privRequestSession.sessionId);\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 const conPromise: Promise<IConnection> = this.connectImpl();\r\n\r\n const preAudioPromise: Promise<void> = this.sendPreAudioMessages(profile, enrollmentDeferral);\r\n\r\n const node: IAudioStreamNode = await this.privSpeakerAudioSource.attach(this.privRequestSession.audioNodeId);\r\n const format: AudioStreamFormatImpl = await this.privSpeakerAudioSource.format;\r\n const deviceInfo: ISpeechConfigAudioDevice = await this.privSpeakerAudioSource.deviceInfo;\r\n\r\n const audioNode = new ReplayableAudioNode(node, format.avgBytesPerSec);\r\n await this.privRequestSession.onAudioSourceAttachCompleted(audioNode, false);\r\n\r\n this.privRecognizerConfig.SpeechServiceConfig.Context.audio = { source: deviceInfo };\r\n\r\n try {\r\n await conPromise;\r\n await preAudioPromise;\r\n } catch (err) {\r\n this.cancelRecognition(this.privRequestSession.sessionId, this.privRequestSession.requestId, CancellationReason.Error, CancellationErrorCode.ConnectionFailure, err as string);\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 void this.receiveMessage();\r\n const audioSendPromise = this.sendAudio(audioNode);\r\n\r\n // /* eslint-disable no-empty */\r\n audioSendPromise.then((): void => { /* add? return true;*/ }, (error: string): void => {\r\n this.cancelRecognition(this.privRequestSession.sessionId, this.privRequestSession.requestId, CancellationReason.Error, CancellationErrorCode.RuntimeError, error);\r\n });\r\n\r\n return enrollmentDeferral.promise;\r\n }\r\n\r\n private async sendPreAudioMessages(profile: VoiceProfile, enrollmentDeferral: Deferred<VoiceProfileEnrollmentResult>): Promise<void> {\r\n const connection: IConnection = await this.fetchConnection();\r\n this.privRequestSession.onSpeechContext();\r\n this.privDeferralMap.add<VoiceProfileEnrollmentResult>(this.privRequestSession.requestId, enrollmentDeferral);\r\n await this.sendBaseRequest(connection, \"enroll\", this.scenarioFrom(profile.profileType), profile);\r\n }\r\n\r\n private async sendPhrasesRequest(getPhrasesDeferral: Deferred<VoiceProfilePhraseResult>, profileType: VoiceProfileType, locale: string): Promise<void> {\r\n const connection: IConnection = await this.fetchConnection();\r\n this.privRequestSession.onSpeechContext();\r\n this.privDeferralMap.add<VoiceProfilePhraseResult>(this.privRequestSession.requestId, getPhrasesDeferral);\r\n const scenario = this.scenarioFrom(profileType);\r\n\r\n const profileCreateRequest: PhraseRequest = {\r\n locale,\r\n scenario,\r\n };\r\n return connection.send(new SpeechConnectionMessage(\r\n MessageType.Text,\r\n \"speaker.profile.phrases\",\r\n this.privRequestSession.requestId,\r\n \"application/json; charset=utf-8\",\r\n JSON.stringify(profileCreateRequest)));\r\n }\r\n\r\n private async sendCreateProfile(createProfileDeferral: Deferred<string[]>, profileType: VoiceProfileType, locale: string): Promise<void> {\r\n\r\n const connection: IConnection = await this.fetchConnection();\r\n this.privRequestSession.onSpeechContext();\r\n this.privDeferralMap.add<string[]>(this.privRequestSession.requestId, createProfileDeferral);\r\n const scenario = profileType === VoiceProfileType.TextIndependentIdentification ? \"TextIndependentIdentification\" :\r\n profileType === VoiceProfileType.TextIndependentVerification ? \"TextIndependentVerification\" : \"TextDependentVerification\";\r\n\r\n const profileCreateRequest: CreateProfile = {\r\n locale,\r\n number: \"1\",\r\n scenario,\r\n };\r\n return connection.send(new SpeechConnectionMessage(\r\n MessageType.Text,\r\n \"speaker.profile.create\",\r\n this.privRequestSession.requestId,\r\n \"application/json; charset=utf-8\",\r\n JSON.stringify(profileCreateRequest)));\r\n }\r\n\r\n private async sendCommonRequest<T>(operation: string, profileType: VoiceProfileType, profile: VoiceProfile = undefined): Promise<T> {\r\n // Start the connection to the service. The promise this will create is stored and will be used by configureConnection().\r\n const conPromise: Promise<IConnection> = this.connectImpl();\r\n try {\r\n const deferral = new Deferred<T>();\r\n this.privRequestSession.onSpeechContext();\r\n await conPromise;\r\n const connection: IConnection = await this.fetchConnection();\r\n this.privDeferralMap.add<T>(this.privRequestSession.requestId, deferral);\r\n await this.sendBaseRequest(connection, operation, this.scenarioFrom(profileType), profile);\r\n void this.receiveMessage();\r\n return deferral.promise;\r\n } catch (err) {\r\n throw err;\r\n }\r\n }\r\n\r\n private async sendBaseRequest(connection: IConnection, operation: string, scenario: string, profile: VoiceProfile): Promise<void> {\r\n const profileRequest: { maxPageSize?: number; profileIds?: string[]; scenario: string } = {\r\n scenario\r\n };\r\n if (!!profile) {\r\n profileRequest.profileIds = [ profile.profileId ];\r\n } else {\r\n profileRequest.maxPageSize = -1;\r\n }\r\n return connection.send(new SpeechConnectionMessage(\r\n MessageType.Text,\r\n `speaker.profile.${operation}`,\r\n this.privRequestSession.requestId,\r\n \"application/json; charset=utf-8\",\r\n JSON.stringify(profileRequest)));\r\n }\r\n\r\n private extractSpeakerContext(model: SpeakerRecognitionModel): SpeakerContext {\r\n return {\r\n features: {\r\n interimResult: \"enabled\",\r\n progressiveDetection: \"disabled\",\r\n },\r\n profileIds: model.profileIds,\r\n scenario: model.scenario,\r\n };\r\n }\r\n\r\n private handlePhrasesResponse(response: ProfilePhraseResponse, requestId: string): void {\r\n if (!!this.privDeferralMap.getId(requestId)) {\r\n if (response.status.statusCode.toLowerCase() !== \"success\") {\r\n const reason: ResultReason = ResultReason.Canceled;\r\n const result = new VoiceProfilePhraseResult(reason, response.status.statusCode, response.passPhraseType, []);\r\n this.privDeferralMap.complete<VoiceProfilePhraseResult>(requestId, result);\r\n } else if (!!response.phrases && response.phrases.length > 0) {\r\n const reason: ResultReason = ResultReason.EnrollingVoiceProfile;\r\n const result = new VoiceProfilePhraseResult(reason, response.status.statusCode, response.passPhraseType, response.phrases);\r\n this.privDeferralMap.complete<VoiceProfilePhraseResult>(requestId, result);\r\n } else {\r\n throw new Error(\"Voice Profile get activation phrases failed, no phrases received\");\r\n }\r\n } else {\r\n throw new Error(`Voice Profile get activation phrases request for requestID ${requestId} not found`);\r\n }\r\n }\r\n\r\n private handleCreateResponse(response: ProfileResponse, requestId: string): void {\r\n if (!!response.profiles && response.profiles.length > 0) {\r\n if (!!this.privDeferralMap.getId(requestId)) {\r\n const profileIds: string[] = response.profiles.map((profile: IProfile): string => profile.profileId);\r\n this.privDeferralMap.complete<string[]>(requestId, profileIds);\r\n } else {\r\n throw new Error(`Voice Profile create request for requestID ${requestId} not found`);\r\n }\r\n } else {\r\n throw new Error(\"Voice Profile create failed, no profile id received\");\r\n }\r\n }\r\n\r\n private handleResultResponse(response: ProfileResponse, requestId: string): void {\r\n if (!!this.privDeferralMap.getId(requestId)) {\r\n const successReason: ResultReason = response.operation.toLowerCase() === \"delete\" ? ResultReason.DeletedVoiceProfile : ResultReason.ResetVoiceProfile;\r\n const reason: ResultReason = response.status.statusCode.toLowerCase() === \"success\" ? successReason : ResultReason.Canceled;\r\n const result = new VoiceProfileResult(reason, `statusCode: ${response.status.statusCode}, errorDetails: ${response.status.reason}`);\r\n this.privDeferralMap.complete<VoiceProfileResult>(requestId, result);\r\n } else {\r\n throw new Error(`Voice Profile create request for requestID ${requestId} not found`);\r\n }\r\n }\r\n\r\n private handleFetchResponse(enrollmentResponse: EnrollmentResponse, requestId: string): void {\r\n if (!!this.privDeferralMap.getId(requestId) && !!enrollmentResponse.profiles[0]) {\r\n if (!!this.privExpectedProfileId && enrollmentResponse.profiles.length === 1 && enrollmentResponse.profiles[0].profileId === this.privExpectedProfileId) {\r\n this.privExpectedProfileId = undefined;\r\n const profileInfo: IProfile = enrollmentResponse.profiles[0];\r\n const result: VoiceProfileEnrollmentResult = new VoiceProfileEnrollmentResult(\r\n this.enrollmentReasonFrom(profileInfo.enrollmentStatus),\r\n JSON.stringify(profileInfo),\r\n enrollmentResponse.status.reason,\r\n );\r\n this.privDeferralMap.complete<VoiceProfileEnrollmentResult>(requestId, result);\r\n } else if (enrollmentResponse.profiles.length > 0) {\r\n const iProfiles: IProfile[] = enrollmentResponse.profiles;\r\n const profileResults: VoiceProfileEnrollmentResult[] = [];\r\n for (const profile of iProfiles) {\r\n profileResults.push( new VoiceProfileEnrollmentResult(\r\n this.enrollmentReasonFrom(profile.enrollmentStatus),\r\n JSON.stringify(profile),\r\n enrollmentResponse.status.reason,\r\n ));\r\n }\r\n this.privDeferralMap.complete<VoiceProfileEnrollmentResult[]>(requestId, profileResults);\r\n }\r\n } else {\r\n throw new Error(`Voice Profile fetch request for requestID ${requestId} not found`);\r\n }\r\n }\r\n\r\n private enrollmentReasonFrom(statusCode: string): ResultReason {\r\n switch (statusCode.toLowerCase()) {\r\n case \"enrolled\":\r\n return ResultReason.EnrolledVoiceProfile;\r\n case \"invalidlocale\":\r\n case \"invalidphrase\":\r\n case \"invalidaudioformat\":\r\n case \"invalidscenario\":\r\n case \"invalidprofilecount\":\r\n case \"invalidoperation\":\r\n case \"audiotooshort\":\r\n case \"audiotoolong\":\r\n case \"toomanyenrollments\":\r\n case \"storageconflict\":\r\n case \"profilenotfound\":\r\n case \"incompatibleprofiles\":\r\n case \"incompleteenrollment\":\r\n return ResultReason.Canceled;\r\n default:\r\n return ResultReason.EnrollingVoiceProfile;\r\n }\r\n }\r\n\r\n private scenarioFrom(profileType: VoiceProfileType): string {\r\n return profileType === VoiceProfileType.TextIndependentIdentification ? \"TextIndependentIdentification\" :\r\n profileType === VoiceProfileType.TextIndependentVerification ? \"TextIndependentVerification\" : \"TextDependentVerification\";\r\n }\r\n}\r\n","// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\n/* eslint-disable max-classes-per-file */\r\n\r\n// The config is serialized and sent as the Speech.Config\r\nexport class SpeechServiceConfig {\r\n private context: Context;\r\n private recognition: string;\r\n\r\n public 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: { [k: string]: any }): any => {\r\n if (value && typeof value === \"object\" && !Array.isArray(value)) {\r\n const replacement: { [k: string ]: any } = {};\r\n for (const k in value) {\r\n if (Object.hasOwnProperty.call(value, k)) {\r\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\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\nexport class Context {\r\n public system: System;\r\n public os: OS;\r\n public audio: ISpeechConfigAudio;\r\n public synthesis: {\r\n video: ISynthesisSectionVideo;\r\n };\r\n\r\n public constructor(os: OS) {\r\n this.system = new System();\r\n this.os = os;\r\n }\r\n}\r\n\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 public constructor() {\r\n // Note: below will be patched for official builds.\r\n const SPEECHSDK_CLIENTSDK_VERSION = \"1.36.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\nexport class OS {\r\n public platform: string;\r\n public name: string;\r\n public version: string;\r\n\r\n public 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\nexport class Device {\r\n public manufacturer: string;\r\n public model: string;\r\n public version: string;\r\n\r\n public 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\r\nexport interface ICoordinate {\r\n x: number;\r\n y: number;\r\n}\r\n\r\n// For avatar synthesis\r\nexport interface ISynthesisSectionVideo {\r\n protocol: {\r\n name: string;\r\n webrtcConfig: {\r\n clientDescription: string;\r\n iceServers: {\r\n urls: string[];\r\n username: string;\r\n credential: string;\r\n }[];\r\n };\r\n };\r\n format: {\r\n bitrate: number;\r\n codec: string;\r\n crop: {\r\n topLeft: ICoordinate;\r\n bottomRight: ICoordinate;\r\n };\r\n resolution: {\r\n width: number;\r\n height: number;\r\n };\r\n };\r\n talkingAvatar: {\r\n character: string;\r\n customized: boolean;\r\n style: string;\r\n background: {\r\n color: string;\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.js\";\r\nexport * from \"./CognitiveTokenAuthentication.js\";\r\nexport * from \"./IAuthentication.js\";\r\nexport * from \"./IConnectionFactory.js\";\r\nexport * from \"./ISynthesisConnectionFactory.js\";\r\nexport * from \"./IntentConnectionFactory.js\";\r\nexport * from \"./SpeakerRecognitionConnectionFactory.js\";\r\nexport * from \"./RecognitionEvents.js\";\r\nexport * from \"./ServiceRecognizerBase.js\";\r\nexport * from \"./ConversationServiceRecognizer.js\";\r\nexport * from \"./RecognizerConfig.js\";\r\nexport * from \"./SpeechServiceInterfaces.js\";\r\nexport * from \"./WebsocketMessageFormatter.js\";\r\nexport * from \"./SpeechConnectionFactory.js\";\r\nexport * from \"./ConversationTranscriberConnectionFactory.js\";\r\nexport * from \"./TranscriberConnectionFactory.js\";\r\nexport * from \"./TranslationConnectionFactory.js\";\r\nexport * from \"./SpeechSynthesisConnectionFactory.js\";\r\nexport * from \"./EnumTranslation.js\";\r\nexport * from \"./ServiceMessages/Enums.js\";\r\nexport * from \"./ServiceMessages/TranslationSynthesisEnd.js\";\r\nexport * from \"./ServiceMessages/TranslationHypothesis.js\";\r\nexport * from \"./ServiceMessages/TranslationPhrase.js\";\r\nexport * from \"./TranslationServiceRecognizer.js\";\r\nexport * from \"./ServiceMessages/SpeechDetected.js\";\r\nexport * from \"./ServiceMessages/SpeechHypothesis.js\";\r\nexport * from \"./ServiceMessages/SpeechKeyword.js\";\r\nexport * from \"./SpeechServiceRecognizer.js\";\r\nexport * from \"./ConversationTranscriptionServiceRecognizer.js\";\r\nexport * from \"./TranscriptionServiceRecognizer.js\";\r\nexport * from \"./ServiceMessages/DetailedSpeechPhrase.js\";\r\nexport * from \"./ServiceMessages/SimpleSpeechPhrase.js\";\r\nexport * from \"./AddedLmIntent.js\";\r\nexport * from \"./IntentServiceRecognizer.js\";\r\nexport * from \"./ServiceMessages/IntentResponse.js\";\r\nexport * from \"./ServiceMessages/SpeakerResponse.js\";\r\nexport * from \"./RequestSession.js\";\r\nexport * from \"./SpeechContext.js\";\r\nexport * from \"./DynamicGrammarBuilder.js\";\r\nexport * from \"./DynamicGrammarInterfaces.js\";\r\nexport * from \"./DialogServiceAdapter.js\";\r\nexport * from \"./AgentConfig.js\";\r\nexport * from \"./Transcription/Exports.js\";\r\nexport * from \"./ServiceMessages/SynthesisAudioMetadata.js\";\r\nexport * from \"./SynthesisTurn.js\";\r\nexport * from \"./SynthesisAdapterBase.js\";\r\nexport { AvatarSynthesisAdapter } from \"./AvatarSynthesisAdapter.js\";\r\nexport { SpeechSynthesisAdapter } from \"./SpeechSynthesisAdapter.js\";\r\nexport * from \"./SynthesisRestAdapter.js\";\r\nexport * from \"./SynthesizerConfig.js\";\r\nexport * from \"./SynthesisContext.js\";\r\nexport * from \"./SpeakerRecognitionConfig.js\";\r\nexport * from \"./SpeakerServiceRecognizer.js\";\r\nexport * from \"./VoiceServiceRecognizer.js\";\r\nexport * from \"./SpeechServiceConfig.js\";\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 = \"ForceDictation\";\r\nexport const AutoDetectSourceLanguagesOpenRangeOptionName: string = \"OpenRange\";\r\n","/* eslint-disable @typescript-eslint/no-unused-vars */\r\n// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\nimport { AgentConfig } from \"./src/common.speech/Exports.js\";\r\n\r\n// Note: this instantiation ensures the above import isn't\r\n// removed on compile. The import being absent causes an error on running\r\nvoid new AgentConfig();\r\n\r\n// Speech SDK API\r\nexport * from \"./src/sdk/Exports.js\";\r\n","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = onErrorResumeNext;\n\nfunction onErrorResumeNext(fn) {\n var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n\n try {\n var result = fn.call(context);\n\n if (typeof result.then === 'function') {\n return new Promise(function (resolve) {\n result.then(resolve, function () {\n return resolve();\n });\n });\n } else {\n return result;\n }\n } catch (err) {}\n}\n\nmodule.exports = exports.default;\nmodule.exports.default = exports.default;","// The MIT License (MIT)\n//\n// Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\n// This piece of code is adopted from https://github.com/sindresorhus/p-defer\n\n// The reason why we need to fork it is because:\n// - The original package published to NPM is not ES5-compliant\n// - Due to the use of arrow functions\n// - create-react-app@1 does not play nice with packages that are not ES5-compliant\n// - create-react-app@2 do play nice, but it was so new that most of the people are still on @1\n\n// Criteria to remove this package:\n// - When create-react-app@2 become mainstream, or,\n// - When p-defer start publishing a ES5-compliant version on NPM\n\n'use strict';\n\nmodule.exports = function () {\n const ret = {};\n\n ret.promise = new Promise(function (resolve, reject) {\n ret.resolve = resolve;\n ret.reject = reject;\n });\n\n return ret;\n};\n","import createDeferred from './external/p-defer';\n\nexport default class EventAsPromise {\n constructor(options = {}) {\n this.defers = [];\n this.upcomingDeferred = null;\n this.eventListener = this.eventListener.bind(this);\n this.options = options;\n\n this.one = this.one.bind(this);\n this.upcoming = this.upcoming.bind(this);\n\n this[Symbol.iterator] = () => ({\n next: () => ({\n done: false,\n value: this.upcoming()\n })\n });\n }\n\n eventListener(event) {\n const deferred = this.defers.shift();\n const args = this.options.array ? [].slice.call(arguments) : event;\n\n deferred && deferred.resolve(args);\n\n if (this.upcomingDeferred) {\n this.upcomingDeferred.resolve(args);\n this.upcomingDeferred = null;\n }\n }\n\n one() {\n const deferred = createDeferred();\n\n this.defers.push(deferred);\n\n return deferred.promise;\n }\n\n upcoming() {\n if (!this.upcomingDeferred) {\n this.upcomingDeferred = createDeferred();\n }\n\n return this.upcomingDeferred.promise;\n }\n}\n","/**\n * Assert a condition.\n * @param condition The condition that it should satisfy.\n * @param message The error message.\n * @param args The arguments for replacing placeholders in the message.\n */\nexport function assertType(\n condition: boolean,\n message: string,\n ...args: any[]\n): asserts condition {\n if (!condition) {\n throw new TypeError(format(message, args))\n }\n}\n\n/**\n * Convert a text and arguments to one string.\n * @param message The formating text\n * @param args The arguments.\n */\nexport function format(message: string, args: any[]): string {\n let i = 0\n return message.replace(/%[os]/gu, () => anyToString(args[i++]))\n}\n\n/**\n * Convert a value to a string representation.\n * @param x The value to get the string representation.\n */\nexport function anyToString(x: any): string {\n if (typeof x !== \"object\" || x === null) {\n return String(x)\n }\n return Object.prototype.toString.call(x)\n}\n","import { anyToString, assertType } from \"./misc\"\n\ndeclare const console: any\ndeclare const dispatchEvent: any\ndeclare const ErrorEvent: any\ndeclare const process: any\n\nlet currentErrorHandler: setErrorHandler.ErrorHandler | undefined\n\n/**\n * Set the error handler.\n * @param value The error handler to set.\n */\nexport function setErrorHandler(\n value: setErrorHandler.ErrorHandler | undefined,\n): void {\n assertType(\n typeof value === \"function\" || value === undefined,\n \"The error handler must be a function or undefined, but got %o.\",\n value,\n )\n currentErrorHandler = value\n}\nexport namespace setErrorHandler {\n /**\n * The error handler.\n * @param error The thrown error object.\n */\n export type ErrorHandler = (error: Error) => void\n}\n\n/**\n * Print a error message.\n * @param maybeError The error object.\n */\nexport function reportError(maybeError: unknown): void {\n try {\n const error =\n maybeError instanceof Error\n ? maybeError\n : new Error(anyToString(maybeError))\n\n // Call the user-defined error handler if exists.\n if (currentErrorHandler) {\n currentErrorHandler(error)\n return\n }\n\n // Dispatch an `error` event if this is on a browser.\n if (\n typeof dispatchEvent === \"function\" &&\n typeof ErrorEvent === \"function\"\n ) {\n dispatchEvent(\n new ErrorEvent(\"error\", { error, message: error.message }),\n )\n }\n\n // Emit an `uncaughtException` event if this is on Node.js.\n //istanbul ignore else\n else if (\n typeof process !== \"undefined\" &&\n typeof process.emit === \"function\"\n ) {\n process.emit(\"uncaughtException\", error)\n return\n }\n\n // Otherwise, print the error.\n console.error(error)\n } catch {\n // ignore.\n }\n}\n","declare const globalThis: any\ndeclare const window: any\ndeclare const self: any\ndeclare const global: any\n\n/**\n * The global object.\n */\n//istanbul ignore next\nexport const Global: any =\n typeof window !== \"undefined\"\n ? window\n : typeof self !== \"undefined\"\n ? self\n : typeof global !== \"undefined\"\n ? global\n : typeof globalThis !== \"undefined\"\n ? globalThis\n : undefined\n","import { assertType } from \"./misc\"\n\ndeclare const console: any\n\nlet currentWarnHandler: setWarningHandler.WarningHandler | undefined\n\n/**\n * Set the warning handler.\n * @param value The warning handler to set.\n */\nexport function setWarningHandler(\n value: setWarningHandler.WarningHandler | undefined,\n): void {\n assertType(\n typeof value === \"function\" || value === undefined,\n \"The warning handler must be a function or undefined, but got %o.\",\n value,\n )\n currentWarnHandler = value\n}\nexport namespace setWarningHandler {\n /**\n * The warning information.\n */\n export interface Warning {\n /**\n * The code of this warning.\n */\n code: string\n /**\n * The message in English.\n */\n message: string\n /**\n * The arguments for replacing placeholders in the text.\n */\n args: any[]\n }\n\n /**\n * The warning handler.\n * @param warning The warning.\n */\n export type WarningHandler = (warning: Warning) => void\n}\n\n/**\n * The warning information.\n */\nexport class Warning<TArgs extends any[]> {\n readonly code: string\n readonly message: string\n\n constructor(code: string, message: string) {\n this.code = code\n this.message = message\n }\n\n /**\n * Report this warning.\n * @param args The arguments of the warning.\n */\n warn(...args: TArgs): void {\n try {\n // Call the user-defined warning handler if exists.\n if (currentWarnHandler) {\n currentWarnHandler({ ...this, args })\n return\n }\n\n // Otherwise, print the warning.\n const stack = (new Error().stack ?? \"\").replace(\n /^(?:.+?\\n){2}/gu,\n \"\\n\",\n )\n console.warn(this.message, ...args, stack)\n } catch {\n // Ignore.\n }\n }\n}\n","import { EventTarget } from \"./event-target\" // Used as only type, so no circular.\nimport { Warning } from \"./warning-handler\"\n\nexport const InitEventWasCalledWhileDispatching = new Warning<[]>(\n \"W01\",\n \"Unable to initialize event under dispatching.\",\n)\n\nexport const FalsyWasAssignedToCancelBubble = new Warning<[]>(\n \"W02\",\n \"Assigning any falsy value to 'cancelBubble' property has no effect.\",\n)\n\nexport const TruthyWasAssignedToReturnValue = new Warning<[]>(\n \"W03\",\n \"Assigning any truthy value to 'returnValue' property has no effect.\",\n)\n\nexport const NonCancelableEventWasCanceled = new Warning<[]>(\n \"W04\",\n \"Unable to preventDefault on non-cancelable events.\",\n)\n\nexport const CanceledInPassiveListener = new Warning<[]>(\n \"W05\",\n \"Unable to preventDefault inside passive event listener invocation.\",\n)\n\nexport const EventListenerWasDuplicated = new Warning<\n [type: \"bubble\" | \"capture\", callback: EventTarget.EventListener<any, any>]\n>(\n \"W06\",\n \"An event listener wasn't added because it has been added already: %o, %o\",\n)\n\nexport const OptionWasIgnored = new Warning<\n [name: \"passive\" | \"once\" | \"signal\"]\n>(\n \"W07\",\n \"The %o option value was abandoned because the event listener wasn't added as duplicated.\",\n)\n\nexport const InvalidEventListener = new Warning<\n [callback: EventTarget.EventListener<any, any> | {} | null | undefined]\n>(\n \"W08\",\n \"The 'callback' argument must be a function or an object that has 'handleEvent' method: %o\",\n)\n\nexport const InvalidAttributeHandler = new Warning<\n [callback: EventTarget.EventListener<any, any> | {}]\n>(\"W09\", \"Event attribute handler must be a function: %o\")\n","import { EventTarget } from \"./event-target\" // Used as only type, so no circular.\nimport { Global } from \"./global\"\nimport { assertType } from \"./misc\"\nimport {\n CanceledInPassiveListener,\n FalsyWasAssignedToCancelBubble,\n InitEventWasCalledWhileDispatching,\n NonCancelableEventWasCanceled,\n TruthyWasAssignedToReturnValue,\n} from \"./warnings\"\n\n/*eslint-disable class-methods-use-this */\n\n/**\n * An implementation of `Event` interface, that wraps a given event object.\n * `EventTarget` shim can control the internal state of this `Event` objects.\n * @see https://dom.spec.whatwg.org/#event\n */\nexport class Event<TEventType extends string = string> {\n /**\n * @see https://dom.spec.whatwg.org/#dom-event-none\n */\n static get NONE(): number {\n return NONE\n }\n\n /**\n * @see https://dom.spec.whatwg.org/#dom-event-capturing_phase\n */\n static get CAPTURING_PHASE(): number {\n return CAPTURING_PHASE\n }\n\n /**\n * @see https://dom.spec.whatwg.org/#dom-event-at_target\n */\n static get AT_TARGET(): number {\n return AT_TARGET\n }\n\n /**\n * @see https://dom.spec.whatwg.org/#dom-event-bubbling_phase\n */\n static get BUBBLING_PHASE(): number {\n return BUBBLING_PHASE\n }\n\n /**\n * Initialize this event instance.\n * @param type The type of this event.\n * @param eventInitDict Options to initialize.\n * @see https://dom.spec.whatwg.org/#dom-event-event\n */\n constructor(type: TEventType, eventInitDict?: Event.EventInit) {\n Object.defineProperty(this, \"isTrusted\", {\n value: false,\n enumerable: true,\n })\n\n const opts = eventInitDict ?? {}\n internalDataMap.set(this, {\n type: String(type),\n bubbles: Boolean(opts.bubbles),\n cancelable: Boolean(opts.cancelable),\n composed: Boolean(opts.composed),\n target: null,\n currentTarget: null,\n stopPropagationFlag: false,\n stopImmediatePropagationFlag: false,\n canceledFlag: false,\n inPassiveListenerFlag: false,\n dispatchFlag: false,\n timeStamp: Date.now(),\n })\n }\n\n /**\n * The type of this event.\n * @see https://dom.spec.whatwg.org/#dom-event-type\n */\n get type(): TEventType {\n return $(this).type as TEventType\n }\n\n /**\n * The event target of the current dispatching.\n * @see https://dom.spec.whatwg.org/#dom-event-target\n */\n get target(): EventTarget | null {\n return $(this).target\n }\n\n /**\n * The event target of the current dispatching.\n * @deprecated Use the `target` property instead.\n * @see https://dom.spec.whatwg.org/#dom-event-srcelement\n */\n get srcElement(): EventTarget | null {\n return $(this).target\n }\n\n /**\n * The event target of the current dispatching.\n * @see https://dom.spec.whatwg.org/#dom-event-currenttarget\n */\n get currentTarget(): EventTarget | null {\n return $(this).currentTarget\n }\n\n /**\n * The event target of the current dispatching.\n * This doesn't support node tree.\n * @see https://dom.spec.whatwg.org/#dom-event-composedpath\n */\n composedPath(): EventTarget[] {\n const currentTarget = $(this).currentTarget\n if (currentTarget) {\n return [currentTarget]\n }\n return []\n }\n\n /**\n * @see https://dom.spec.whatwg.org/#dom-event-none\n */\n get NONE(): number {\n return NONE\n }\n\n /**\n * @see https://dom.spec.whatwg.org/#dom-event-capturing_phase\n */\n get CAPTURING_PHASE(): number {\n return CAPTURING_PHASE\n }\n\n /**\n * @see https://dom.spec.whatwg.org/#dom-event-at_target\n */\n get AT_TARGET(): number {\n return AT_TARGET\n }\n\n /**\n * @see https://dom.spec.whatwg.org/#dom-event-bubbling_phase\n */\n get BUBBLING_PHASE(): number {\n return BUBBLING_PHASE\n }\n\n /**\n * The current event phase.\n * @see https://dom.spec.whatwg.org/#dom-event-eventphase\n */\n get eventPhase(): number {\n return $(this).dispatchFlag ? 2 : 0\n }\n\n /**\n * Stop event bubbling.\n * Because this shim doesn't support node tree, this merely changes the `cancelBubble` property value.\n * @see https://dom.spec.whatwg.org/#dom-event-stoppropagation\n */\n stopPropagation(): void {\n $(this).stopPropagationFlag = true\n }\n\n /**\n * `true` if event bubbling was stopped.\n * @deprecated\n * @see https://dom.spec.whatwg.org/#dom-event-cancelbubble\n */\n get cancelBubble(): boolean {\n return $(this).stopPropagationFlag\n }\n\n /**\n * Stop event bubbling if `true` is set.\n * @deprecated Use the `stopPropagation()` method instead.\n * @see https://dom.spec.whatwg.org/#dom-event-cancelbubble\n */\n set cancelBubble(value: boolean) {\n if (value) {\n $(this).stopPropagationFlag = true\n } else {\n FalsyWasAssignedToCancelBubble.warn()\n }\n }\n\n /**\n * Stop event bubbling and subsequent event listener callings.\n * @see https://dom.spec.whatwg.org/#dom-event-stopimmediatepropagation\n */\n stopImmediatePropagation(): void {\n const data = $(this)\n data.stopPropagationFlag = data.stopImmediatePropagationFlag = true\n }\n\n /**\n * `true` if this event will bubble.\n * @see https://dom.spec.whatwg.org/#dom-event-bubbles\n */\n get bubbles(): boolean {\n return $(this).bubbles\n }\n\n /**\n * `true` if this event can be canceled by the `preventDefault()` method.\n * @see https://dom.spec.whatwg.org/#dom-event-cancelable\n */\n get cancelable(): boolean {\n return $(this).cancelable\n }\n\n /**\n * `true` if the default behavior will act.\n * @deprecated Use the `defaultPrevented` proeprty instead.\n * @see https://dom.spec.whatwg.org/#dom-event-returnvalue\n */\n get returnValue(): boolean {\n return !$(this).canceledFlag\n }\n\n /**\n * Cancel the default behavior if `false` is set.\n * @deprecated Use the `preventDefault()` method instead.\n * @see https://dom.spec.whatwg.org/#dom-event-returnvalue\n */\n set returnValue(value: boolean) {\n if (!value) {\n setCancelFlag($(this))\n } else {\n TruthyWasAssignedToReturnValue.warn()\n }\n }\n\n /**\n * Cancel the default behavior.\n * @see https://dom.spec.whatwg.org/#dom-event-preventdefault\n */\n preventDefault(): void {\n setCancelFlag($(this))\n }\n\n /**\n * `true` if the default behavior was canceled.\n * @see https://dom.spec.whatwg.org/#dom-event-defaultprevented\n */\n get defaultPrevented(): boolean {\n return $(this).canceledFlag\n }\n\n /**\n * @see https://dom.spec.whatwg.org/#dom-event-composed\n */\n get composed(): boolean {\n return $(this).composed\n }\n\n /**\n * @see https://dom.spec.whatwg.org/#dom-event-istrusted\n */\n //istanbul ignore next\n get isTrusted(): boolean {\n return false\n }\n\n /**\n * @see https://dom.spec.whatwg.org/#dom-event-timestamp\n */\n get timeStamp(): number {\n return $(this).timeStamp\n }\n\n /**\n * @deprecated Don't use this method. The constructor did initialization.\n */\n initEvent(type: string, bubbles = false, cancelable = false) {\n const data = $(this)\n if (data.dispatchFlag) {\n InitEventWasCalledWhileDispatching.warn()\n return\n }\n\n internalDataMap.set(this, {\n ...data,\n type: String(type),\n bubbles: Boolean(bubbles),\n cancelable: Boolean(cancelable),\n target: null,\n currentTarget: null,\n stopPropagationFlag: false,\n stopImmediatePropagationFlag: false,\n canceledFlag: false,\n })\n }\n}\n\n/*eslint-enable class-methods-use-this */\n\nexport namespace Event {\n /**\n * The options of the `Event` constructor.\n * @see https://dom.spec.whatwg.org/#dictdef-eventinit\n */\n export interface EventInit {\n bubbles?: boolean\n cancelable?: boolean\n composed?: boolean\n }\n}\n\nexport { $ as getEventInternalData }\n\n//------------------------------------------------------------------------------\n// Helpers\n//------------------------------------------------------------------------------\n\nconst NONE = 0\nconst CAPTURING_PHASE = 1\nconst AT_TARGET = 2\nconst BUBBLING_PHASE = 3\n\n/**\n * Private data.\n */\ninterface EventInternalData {\n /**\n * The value of `type` attribute.\n */\n readonly type: string\n /**\n * The value of `bubbles` attribute.\n */\n readonly bubbles: boolean\n /**\n * The value of `cancelable` attribute.\n */\n readonly cancelable: boolean\n /**\n * The value of `composed` attribute.\n */\n readonly composed: boolean\n /**\n * The value of `timeStamp` attribute.\n */\n readonly timeStamp: number\n\n /**\n * @see https://dom.spec.whatwg.org/#dom-event-target\n */\n target: EventTarget | null\n /**\n * @see https://dom.spec.whatwg.org/#dom-event-currenttarget\n */\n currentTarget: EventTarget | null\n /**\n * @see https://dom.spec.whatwg.org/#stop-propagation-flag\n */\n stopPropagationFlag: boolean\n /**\n * @see https://dom.spec.whatwg.org/#stop-immediate-propagation-flag\n */\n stopImmediatePropagationFlag: boolean\n /**\n * @see https://dom.spec.whatwg.org/#canceled-flag\n */\n canceledFlag: boolean\n /**\n * @see https://dom.spec.whatwg.org/#in-passive-listener-flag\n */\n inPassiveListenerFlag: boolean\n /**\n * @see https://dom.spec.whatwg.org/#dispatch-flag\n */\n dispatchFlag: boolean\n}\n\n/**\n * Private data for event wrappers.\n */\nconst internalDataMap = new WeakMap<any, EventInternalData>()\n\n/**\n * Get private data.\n * @param event The event object to get private data.\n * @param name The variable name to report.\n * @returns The private data of the event.\n */\nfunction $(event: unknown, name = \"this\"): EventInternalData {\n const retv = internalDataMap.get(event)\n assertType(\n retv != null,\n \"'%s' must be an object that Event constructor created, but got another one: %o\",\n name,\n event,\n )\n return retv\n}\n\n/**\n * https://dom.spec.whatwg.org/#set-the-canceled-flag\n * @param data private data.\n */\nfunction setCancelFlag(data: EventInternalData) {\n if (data.inPassiveListenerFlag) {\n CanceledInPassiveListener.warn()\n return\n }\n if (!data.cancelable) {\n NonCancelableEventWasCanceled.warn()\n return\n }\n\n data.canceledFlag = true\n}\n\n// Set enumerable\nObject.defineProperty(Event, \"NONE\", { enumerable: true })\nObject.defineProperty(Event, \"CAPTURING_PHASE\", { enumerable: true })\nObject.defineProperty(Event, \"AT_TARGET\", { enumerable: true })\nObject.defineProperty(Event, \"BUBBLING_PHASE\", { enumerable: true })\nconst keys = Object.getOwnPropertyNames(Event.prototype)\nfor (let i = 0; i < keys.length; ++i) {\n if (keys[i] === \"constructor\") {\n continue\n }\n Object.defineProperty(Event.prototype, keys[i], { enumerable: true })\n}\n\n// Ensure `event instanceof window.Event` is `true`.\nif (typeof Global !== \"undefined\" && typeof Global.Event !== \"undefined\") {\n Object.setPrototypeOf(Event.prototype, Global.Event.prototype)\n}\n","import { Global } from \"./global\"\n\n/**\n * Create a new InvalidStateError instance.\n * @param message The error message.\n */\nexport function createInvalidStateError(message: string): Error {\n if (Global.DOMException) {\n return new Global.DOMException(message, \"InvalidStateError\")\n }\n\n if (DOMException == null) {\n DOMException = class DOMException extends Error {\n constructor(msg: string) {\n super(msg)\n if ((Error as any).captureStackTrace) {\n ;(Error as any).captureStackTrace(this, DOMException)\n }\n }\n // eslint-disable-next-line class-methods-use-this\n get code() {\n return 11\n }\n // eslint-disable-next-line class-methods-use-this\n get name() {\n return \"InvalidStateError\"\n }\n }\n Object.defineProperties(DOMException.prototype, {\n code: { enumerable: true },\n name: { enumerable: true },\n })\n defineErrorCodeProperties(DOMException)\n defineErrorCodeProperties(DOMException.prototype)\n }\n return new DOMException(message)\n}\n\n//------------------------------------------------------------------------------\n// Helpers\n//------------------------------------------------------------------------------\n\nlet DOMException: { new (message: string): Error } | undefined\n\nconst ErrorCodeMap = {\n INDEX_SIZE_ERR: 1,\n DOMSTRING_SIZE_ERR: 2,\n HIERARCHY_REQUEST_ERR: 3,\n WRONG_DOCUMENT_ERR: 4,\n INVALID_CHARACTER_ERR: 5,\n NO_DATA_ALLOWED_ERR: 6,\n NO_MODIFICATION_ALLOWED_ERR: 7,\n NOT_FOUND_ERR: 8,\n NOT_SUPPORTED_ERR: 9,\n INUSE_ATTRIBUTE_ERR: 10,\n INVALID_STATE_ERR: 11,\n SYNTAX_ERR: 12,\n INVALID_MODIFICATION_ERR: 13,\n NAMESPACE_ERR: 14,\n INVALID_ACCESS_ERR: 15,\n VALIDATION_ERR: 16,\n TYPE_MISMATCH_ERR: 17,\n SECURITY_ERR: 18,\n NETWORK_ERR: 19,\n ABORT_ERR: 20,\n URL_MISMATCH_ERR: 21,\n QUOTA_EXCEEDED_ERR: 22,\n TIMEOUT_ERR: 23,\n INVALID_NODE_TYPE_ERR: 24,\n DATA_CLONE_ERR: 25,\n}\ntype ErrorCodeMap = typeof ErrorCodeMap\n\nfunction defineErrorCodeProperties(obj: any): void {\n const keys = Object.keys(ErrorCodeMap) as (keyof ErrorCodeMap)[]\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i]\n const value = ErrorCodeMap[key]\n Object.defineProperty(obj, key, {\n get() {\n return value\n },\n configurable: true,\n enumerable: true,\n })\n }\n}\n","import { Event } from \"./event\"\nimport { Global } from \"./global\"\nimport { assertType } from \"./misc\"\n\n/**\n * An implementation of `Event` interface, that wraps a given event object.\n * This class controls the internal state of `Event`.\n * @see https://dom.spec.whatwg.org/#interface-event\n */\nexport class EventWrapper<TEventType extends string> extends Event<TEventType> {\n /**\n * Wrap a given event object to control states.\n * @param event The event-like object to wrap.\n */\n static wrap<T extends EventLike>(event: T): EventWrapperOf<T> {\n return new (getWrapperClassOf(event))(event)\n }\n\n protected constructor(event: Event<TEventType>) {\n super(event.type, {\n bubbles: event.bubbles,\n cancelable: event.cancelable,\n composed: event.composed,\n })\n\n if (event.cancelBubble) {\n super.stopPropagation()\n }\n if (event.defaultPrevented) {\n super.preventDefault()\n }\n\n internalDataMap.set(this, { original: event })\n\n // Define accessors\n const keys = Object.keys(event)\n for (let i = 0; i < keys.length; ++i) {\n const key = keys[i]\n if (!(key in this)) {\n Object.defineProperty(\n this,\n key,\n defineRedirectDescriptor(event, key),\n )\n }\n }\n }\n\n stopPropagation(): void {\n super.stopPropagation()\n\n const { original } = $(this)\n if (\"stopPropagation\" in original) {\n original.stopPropagation!()\n }\n }\n\n get cancelBubble(): boolean {\n return super.cancelBubble\n }\n set cancelBubble(value: boolean) {\n super.cancelBubble = value\n\n const { original } = $(this)\n if (\"cancelBubble\" in original) {\n original.cancelBubble = value\n }\n }\n\n stopImmediatePropagation(): void {\n super.stopImmediatePropagation()\n\n const { original } = $(this)\n if (\"stopImmediatePropagation\" in original) {\n original.stopImmediatePropagation!()\n }\n }\n\n get returnValue(): boolean {\n return super.returnValue\n }\n set returnValue(value: boolean) {\n super.returnValue = value\n\n const { original } = $(this)\n if (\"returnValue\" in original) {\n original.returnValue = value\n }\n }\n\n preventDefault(): void {\n super.preventDefault()\n\n const { original } = $(this)\n if (\"preventDefault\" in original) {\n original.preventDefault!()\n }\n }\n\n get timeStamp(): number {\n const { original } = $(this)\n if (\"timeStamp\" in original) {\n return original.timeStamp!\n }\n return super.timeStamp\n }\n}\n\n//------------------------------------------------------------------------------\n// Helpers\n//------------------------------------------------------------------------------\n\ntype EventLike = { readonly type: string } & Partial<Event>\ntype EventWrapperOf<T extends EventLike> = Event<T[\"type\"]> &\n Omit<T, keyof Event>\n\ninterface EventWrapperInternalData {\n readonly original: EventLike\n}\n\n/**\n * Private data for event wrappers.\n */\nconst internalDataMap = new WeakMap<any, EventWrapperInternalData>()\n\n/**\n * Get private data.\n * @param event The event object to get private data.\n * @returns The private data of the event.\n */\nfunction $(event: unknown): EventWrapperInternalData {\n const retv = internalDataMap.get(event)\n assertType(\n retv != null,\n \"'this' is expected an Event object, but got\",\n event,\n )\n return retv\n}\n\n/**\n * Cache for wrapper classes.\n * @type {WeakMap<Object, Function>}\n * @private\n */\nconst wrapperClassCache = new WeakMap()\n\n// Make association for wrappers.\nwrapperClassCache.set(Object.prototype, EventWrapper)\nif (typeof Global !== \"undefined\" && typeof Global.Event !== \"undefined\") {\n wrapperClassCache.set(Global.Event.prototype, EventWrapper)\n}\n\n/**\n * Get the wrapper class of a given prototype.\n * @param originalEvent The event object to wrap.\n */\nfunction getWrapperClassOf<T extends EventLike>(\n originalEvent: T,\n): { new (e: T): EventWrapperOf<T> } {\n const prototype = Object.getPrototypeOf(originalEvent)\n if (prototype == null) {\n return EventWrapper as any\n }\n\n let wrapper: any = wrapperClassCache.get(prototype)\n if (wrapper == null) {\n wrapper = defineWrapper(getWrapperClassOf(prototype), prototype)\n wrapperClassCache.set(prototype, wrapper)\n }\n\n return wrapper\n}\n\n/**\n * Define new wrapper class.\n * @param BaseEventWrapper The base wrapper class.\n * @param originalPrototype The prototype of the original event.\n */\nfunction defineWrapper(BaseEventWrapper: any, originalPrototype: any): any {\n class CustomEventWrapper extends BaseEventWrapper {}\n\n const keys = Object.keys(originalPrototype)\n for (let i = 0; i < keys.length; ++i) {\n Object.defineProperty(\n CustomEventWrapper.prototype,\n keys[i],\n defineRedirectDescriptor(originalPrototype, keys[i]),\n )\n }\n\n return CustomEventWrapper\n}\n\n/**\n * Get the property descriptor to redirect a given property.\n */\nfunction defineRedirectDescriptor(obj: any, key: string): PropertyDescriptor {\n const d = Object.getOwnPropertyDescriptor(obj, key)!\n return {\n get() {\n const original: any = $(this).original\n const value = original[key]\n if (typeof value === \"function\") {\n return value.bind(original)\n }\n return value\n },\n set(value: any) {\n const original: any = $(this).original\n original[key] = value\n },\n configurable: d.configurable,\n enumerable: d.enumerable,\n }\n}\n","import { reportError } from \"./error-handler\"\nimport { Event } from \"./event\" // Used as only type, so no circular.\nimport { EventTarget } from \"./event-target\" // Used as only type, so no circular.\n\n/**\n * The event listener concept.\n * @see https://dom.spec.whatwg.org/#concept-event-listener\n */\nexport interface Listener {\n /**\n * The callback function.\n */\n readonly callback: Listener.Callback<any, any>\n /**\n * The flags of this listener.\n * This is writable to add the removed flag.\n */\n flags: ListenerFlags\n /**\n * The `AbortSignal` to remove this listener.\n */\n readonly signal: Listener.AbortSignal | undefined\n /**\n * The `abort` event listener for the `signal`.\n * To remove it from the `signal`.\n */\n readonly signalListener: (() => void) | undefined\n}\n\nexport namespace Listener {\n export type Callback<\n TEventTarget extends EventTarget<any, any>,\n TEvent extends Event\n > = CallbackFunction<TEventTarget, TEvent> | CallbackObject<TEvent>\n\n export interface CallbackFunction<\n TEventTarget extends EventTarget<any, any>,\n TEvent extends Event\n > {\n (this: TEventTarget, event: TEvent): void\n }\n\n export interface CallbackObject<TEvent extends Event> {\n handleEvent(event: TEvent): void\n }\n\n export interface AbortSignal {\n addEventListener(type: string, callback: Callback<any, Event>): void\n removeEventListener(type: string, callback: Callback<any, Event>): void\n }\n}\n\n/**\n * Create a new listener.\n * @param callback The callback function.\n * @param capture The capture flag.\n * @param passive The passive flag.\n * @param once The once flag.\n * @param signal The abort signal.\n * @param signalListener The abort event listener for the abort signal.\n */\nexport function createListener(\n callback: Listener.Callback<any, any>,\n capture: boolean,\n passive: boolean,\n once: boolean,\n signal: Listener.AbortSignal | undefined,\n signalListener: (() => void) | undefined,\n): Listener {\n return {\n callback,\n flags:\n (capture ? ListenerFlags.Capture : 0) |\n (passive ? ListenerFlags.Passive : 0) |\n (once ? ListenerFlags.Once : 0),\n signal,\n signalListener,\n }\n}\n\n/**\n * Set the `removed` flag to the given listener.\n * @param listener The listener to check.\n */\nexport function setRemoved(listener: Listener): void {\n listener.flags |= ListenerFlags.Removed\n}\n\n/**\n * Check if the given listener has the `capture` flag or not.\n * @param listener The listener to check.\n */\nexport function isCapture(listener: Listener): boolean {\n return (listener.flags & ListenerFlags.Capture) === ListenerFlags.Capture\n}\n\n/**\n * Check if the given listener has the `passive` flag or not.\n * @param listener The listener to check.\n */\nexport function isPassive(listener: Listener): boolean {\n return (listener.flags & ListenerFlags.Passive) === ListenerFlags.Passive\n}\n\n/**\n * Check if the given listener has the `once` flag or not.\n * @param listener The listener to check.\n */\nexport function isOnce(listener: Listener): boolean {\n return (listener.flags & ListenerFlags.Once) === ListenerFlags.Once\n}\n\n/**\n * Check if the given listener has the `removed` flag or not.\n * @param listener The listener to check.\n */\nexport function isRemoved(listener: Listener): boolean {\n return (listener.flags & ListenerFlags.Removed) === ListenerFlags.Removed\n}\n\n/**\n * Call an event listener.\n * @param listener The listener to call.\n * @param target The event target object for `thisArg`.\n * @param event The event object for the first argument.\n * @param attribute `true` if this callback is an event attribute handler.\n */\nexport function invokeCallback(\n { callback }: Listener,\n target: EventTarget<any, any>,\n event: Event<any>,\n): void {\n try {\n if (typeof callback === \"function\") {\n callback.call(target, event)\n } else if (typeof callback.handleEvent === \"function\") {\n callback.handleEvent(event)\n }\n } catch (thrownError) {\n reportError(thrownError)\n }\n}\n\n//------------------------------------------------------------------------------\n// Helpers\n//------------------------------------------------------------------------------\n\n/**\n * The flags of listeners.\n */\nconst enum ListenerFlags {\n Capture = 0x01,\n Passive = 0x02,\n Once = 0x04,\n Removed = 0x08,\n}\n","import { createListener, isCapture, Listener, setRemoved } from \"./listener\"\n\n/**\n * Information of an listener list.\n */\nexport interface ListenerList {\n /**\n * The callback function of the event attribute handler.\n */\n attrCallback: Listener.CallbackFunction<any, any> | undefined\n /**\n * The listener of the event attribute handler.\n */\n attrListener: Listener | undefined\n /**\n * `true` if the `dispatchEvent` method is traversing the current `listeners` array.\n */\n cow: boolean\n /**\n * The listeners.\n * This is writable for copy-on-write.\n */\n listeners: Listener[]\n}\n\n/**\n * Find the index of given listener.\n * This returns `-1` if not found.\n * @param list The listener list.\n * @param callback The callback function to find.\n * @param capture The capture flag to find.\n */\nexport function findIndexOfListener(\n { listeners }: ListenerList,\n callback: Listener.Callback<any, any>,\n capture: boolean,\n): number {\n for (let i = 0; i < listeners.length; ++i) {\n if (\n listeners[i].callback === callback &&\n isCapture(listeners[i]) === capture\n ) {\n return i\n }\n }\n return -1\n}\n\n/**\n * Add the given listener.\n * Does copy-on-write if needed.\n * @param list The listener list.\n * @param callback The callback function.\n * @param capture The capture flag.\n * @param passive The passive flag.\n * @param once The once flag.\n * @param signal The abort signal.\n */\nexport function addListener(\n list: ListenerList,\n callback: Listener.Callback<any, any>,\n capture: boolean,\n passive: boolean,\n once: boolean,\n signal: Listener.AbortSignal | undefined,\n): Listener {\n let signalListener: (() => void) | undefined\n if (signal) {\n signalListener = removeListener.bind(null, list, callback, capture)\n signal.addEventListener(\"abort\", signalListener)\n }\n\n const listener = createListener(\n callback,\n capture,\n passive,\n once,\n signal,\n signalListener,\n )\n\n if (list.cow) {\n list.cow = false\n list.listeners = [...list.listeners, listener]\n } else {\n list.listeners.push(listener)\n }\n\n return listener\n}\n\n/**\n * Remove a listener.\n * @param list The listener list.\n * @param callback The callback function to find.\n * @param capture The capture flag to find.\n * @returns `true` if it mutated the list directly.\n */\nexport function removeListener(\n list: ListenerList,\n callback: Listener.Callback<any, any>,\n capture: boolean,\n): boolean {\n const index = findIndexOfListener(list, callback, capture)\n if (index !== -1) {\n return removeListenerAt(list, index)\n }\n return false\n}\n\n/**\n * Remove a listener.\n * @param list The listener list.\n * @param index The index of the target listener.\n * @param disableCow Disable copy-on-write if true.\n * @returns `true` if it mutated the `listeners` array directly.\n */\nexport function removeListenerAt(\n list: ListenerList,\n index: number,\n disableCow = false,\n): boolean {\n const listener = list.listeners[index]\n\n // Set the removed flag.\n setRemoved(listener)\n\n // Dispose the abort signal listener if exists.\n if (listener.signal) {\n listener.signal.removeEventListener(\"abort\", listener.signalListener!)\n }\n\n // Remove it from the array.\n if (list.cow && !disableCow) {\n list.cow = false\n list.listeners = list.listeners.filter((_, i) => i !== index)\n return false\n }\n list.listeners.splice(index, 1)\n return true\n}\n","import { ListenerList } from \"./listener-list\"\n\n/**\n * The map from event types to each listener list.\n */\nexport interface ListenerListMap {\n [type: string]: ListenerList | undefined\n}\n\n/**\n * Create a new `ListenerListMap` object.\n */\nexport function createListenerListMap(): ListenerListMap {\n return Object.create(null)\n}\n\n/**\n * Get the listener list of the given type.\n * If the listener list has not been initialized, initialize and return it.\n * @param listenerMap The listener list map.\n * @param type The event type to get.\n */\nexport function ensureListenerList(\n listenerMap: Record<string, ListenerList | undefined>,\n type: string,\n): ListenerList {\n return (listenerMap[type] ??= {\n attrCallback: undefined,\n attrListener: undefined,\n cow: false,\n listeners: [],\n })\n}\n","import { createInvalidStateError } from \"./dom-exception\"\nimport { Event, getEventInternalData } from \"./event\"\nimport { EventWrapper } from \"./event-wrapper\"\nimport { Global } from \"./global\"\nimport {\n invokeCallback,\n isCapture,\n isOnce,\n isPassive,\n isRemoved,\n Listener,\n} from \"./listener\"\nimport {\n addListener,\n findIndexOfListener,\n removeListener,\n removeListenerAt,\n} from \"./listener-list\"\nimport {\n createListenerListMap,\n ensureListenerList,\n ListenerListMap,\n} from \"./listener-list-map\"\nimport { assertType, format } from \"./misc\"\nimport {\n EventListenerWasDuplicated,\n InvalidEventListener,\n OptionWasIgnored,\n} from \"./warnings\"\n\n/**\n * An implementation of the `EventTarget` interface.\n * @see https://dom.spec.whatwg.org/#eventtarget\n */\nexport class EventTarget<\n TEventMap extends Record<string, Event> = Record<string, Event>,\n TMode extends \"standard\" | \"strict\" = \"standard\"\n> {\n /**\n * Initialize this instance.\n */\n constructor() {\n internalDataMap.set(this, createListenerListMap())\n }\n\n /**\n * Add an event listener.\n * @param type The event type.\n * @param callback The event listener.\n * @param options Options.\n */\n addEventListener<T extends string & keyof TEventMap>(\n type: T,\n callback?: EventTarget.EventListener<this, TEventMap[T]> | null,\n options?: EventTarget.AddOptions,\n ): void\n\n /**\n * Add an event listener.\n * @param type The event type.\n * @param callback The event listener.\n * @param options Options.\n */\n addEventListener(\n type: string,\n callback?: EventTarget.FallbackEventListener<this, TMode>,\n options?: EventTarget.AddOptions,\n ): void\n\n /**\n * Add an event listener.\n * @param type The event type.\n * @param callback The event listener.\n * @param capture The capture flag.\n * @deprecated Use `{capture: boolean}` object instead of a boolean value.\n */\n addEventListener<T extends string & keyof TEventMap>(\n type: T,\n callback:\n | EventTarget.EventListener<this, TEventMap[T]>\n | null\n | undefined,\n capture: boolean,\n ): void\n\n /**\n * Add an event listener.\n * @param type The event type.\n * @param callback The event listener.\n * @param capture The capture flag.\n * @deprecated Use `{capture: boolean}` object instead of a boolean value.\n */\n addEventListener(\n type: string,\n callback: EventTarget.FallbackEventListener<this, TMode>,\n capture: boolean,\n ): void\n\n // Implementation\n addEventListener<T extends string & keyof TEventMap>(\n type0: T,\n callback0?: EventTarget.EventListener<this, TEventMap[T]> | null,\n options0?: boolean | EventTarget.AddOptions,\n ): void {\n const listenerMap = $(this)\n const {\n callback,\n capture,\n once,\n passive,\n signal,\n type,\n } = normalizeAddOptions(type0, callback0, options0)\n if (callback == null || signal?.aborted) {\n return\n }\n const list = ensureListenerList(listenerMap, type)\n\n // Find existing listener.\n const i = findIndexOfListener(list, callback, capture)\n if (i !== -1) {\n warnDuplicate(list.listeners[i], passive, once, signal)\n return\n }\n\n // Add the new listener.\n addListener(list, callback, capture, passive, once, signal)\n }\n\n /**\n * Remove an added event listener.\n * @param type The event type.\n * @param callback The event listener.\n * @param options Options.\n */\n removeEventListener<T extends string & keyof TEventMap>(\n type: T,\n callback?: EventTarget.EventListener<this, TEventMap[T]> | null,\n options?: EventTarget.Options,\n ): void\n\n /**\n * Remove an added event listener.\n * @param type The event type.\n * @param callback The event listener.\n * @param options Options.\n */\n removeEventListener(\n type: string,\n callback?: EventTarget.FallbackEventListener<this, TMode>,\n options?: EventTarget.Options,\n ): void\n\n /**\n * Remove an added event listener.\n * @param type The event type.\n * @param callback The event listener.\n * @param capture The capture flag.\n * @deprecated Use `{capture: boolean}` object instead of a boolean value.\n */\n removeEventListener<T extends string & keyof TEventMap>(\n type: T,\n callback:\n | EventTarget.EventListener<this, TEventMap[T]>\n | null\n | undefined,\n capture: boolean,\n ): void\n\n /**\n * Remove an added event listener.\n * @param type The event type.\n * @param callback The event listener.\n * @param capture The capture flag.\n * @deprecated Use `{capture: boolean}` object instead of a boolean value.\n */\n removeEventListener(\n type: string,\n callback: EventTarget.FallbackEventListener<this, TMode>,\n capture: boolean,\n ): void\n\n // Implementation\n removeEventListener<T extends string & keyof TEventMap>(\n type0: T,\n callback0?: EventTarget.EventListener<this, TEventMap[T]> | null,\n options0?: boolean | EventTarget.Options,\n ): void {\n const listenerMap = $(this)\n const { callback, capture, type } = normalizeOptions(\n type0,\n callback0,\n options0,\n )\n const list = listenerMap[type]\n\n if (callback != null && list) {\n removeListener(list, callback, capture)\n }\n }\n\n /**\n * Dispatch an event.\n * @param event The `Event` object to dispatch.\n */\n dispatchEvent<T extends string & keyof TEventMap>(\n event: EventTarget.EventData<TEventMap, TMode, T>,\n ): boolean\n\n /**\n * Dispatch an event.\n * @param event The `Event` object to dispatch.\n */\n dispatchEvent(event: EventTarget.FallbackEvent<TMode>): boolean\n\n // Implementation\n dispatchEvent(\n e:\n | EventTarget.EventData<TEventMap, TMode, string>\n | EventTarget.FallbackEvent<TMode>,\n ): boolean {\n const list = $(this)[String(e.type)]\n if (list == null) {\n return true\n }\n\n const event = e instanceof Event ? e : EventWrapper.wrap(e)\n const eventData = getEventInternalData(event, \"event\")\n if (eventData.dispatchFlag) {\n throw createInvalidStateError(\"This event has been in dispatching.\")\n }\n\n eventData.dispatchFlag = true\n eventData.target = eventData.currentTarget = this\n\n if (!eventData.stopPropagationFlag) {\n const { cow, listeners } = list\n\n // Set copy-on-write flag.\n list.cow = true\n\n // Call listeners.\n for (let i = 0; i < listeners.length; ++i) {\n const listener = listeners[i]\n\n // Skip if removed.\n if (isRemoved(listener)) {\n continue\n }\n\n // Remove this listener if has the `once` flag.\n if (isOnce(listener) && removeListenerAt(list, i, !cow)) {\n // Because this listener was removed, the next index is the\n // same as the current value.\n i -= 1\n }\n\n // Call this listener with the `passive` flag.\n eventData.inPassiveListenerFlag = isPassive(listener)\n invokeCallback(listener, this, event)\n eventData.inPassiveListenerFlag = false\n\n // Stop if the `event.stopImmediatePropagation()` method was called.\n if (eventData.stopImmediatePropagationFlag) {\n break\n }\n }\n\n // Restore copy-on-write flag.\n if (!cow) {\n list.cow = false\n }\n }\n\n eventData.target = null\n eventData.currentTarget = null\n eventData.stopImmediatePropagationFlag = false\n eventData.stopPropagationFlag = false\n eventData.dispatchFlag = false\n\n return !eventData.canceledFlag\n }\n}\n\nexport namespace EventTarget {\n /**\n * The event listener.\n */\n export type EventListener<\n TEventTarget extends EventTarget<any, any>,\n TEvent extends Event\n > = CallbackFunction<TEventTarget, TEvent> | CallbackObject<TEvent>\n\n /**\n * The event listener function.\n */\n export interface CallbackFunction<\n TEventTarget extends EventTarget<any, any>,\n TEvent extends Event\n > {\n (this: TEventTarget, event: TEvent): void\n }\n\n /**\n * The event listener object.\n * @see https://dom.spec.whatwg.org/#callbackdef-eventlistener\n */\n export interface CallbackObject<TEvent extends Event> {\n handleEvent(event: TEvent): void\n }\n\n /**\n * The common options for both `addEventListener` and `removeEventListener` methods.\n * @see https://dom.spec.whatwg.org/#dictdef-eventlisteneroptions\n */\n export interface Options {\n capture?: boolean\n }\n\n /**\n * The options for the `addEventListener` methods.\n * @see https://dom.spec.whatwg.org/#dictdef-addeventlisteneroptions\n */\n export interface AddOptions extends Options {\n passive?: boolean\n once?: boolean\n signal?: AbortSignal | null | undefined\n }\n\n /**\n * The abort signal.\n * @see https://dom.spec.whatwg.org/#abortsignal\n */\n export interface AbortSignal extends EventTarget<{ abort: Event }> {\n readonly aborted: boolean\n onabort: CallbackFunction<this, Event> | null\n }\n\n /**\n * The event data to dispatch in strict mode.\n */\n export type EventData<\n TEventMap extends Record<string, Event>,\n TMode extends \"standard\" | \"strict\",\n TEventType extends string\n > = TMode extends \"strict\"\n ? IsValidEventMap<TEventMap> extends true\n ? ExplicitType<TEventType> &\n Omit<TEventMap[TEventType], keyof Event> &\n Partial<Omit<Event, \"type\">>\n : never\n : never\n\n /**\n * Define explicit `type` property if `T` is a string literal.\n * Otherwise, never.\n */\n export type ExplicitType<T extends string> = string extends T\n ? never\n : { readonly type: T }\n\n /**\n * The event listener type in standard mode.\n * Otherwise, never.\n */\n export type FallbackEventListener<\n TEventTarget extends EventTarget<any, any>,\n TMode extends \"standard\" | \"strict\"\n > = TMode extends \"standard\"\n ? EventListener<TEventTarget, Event> | null | undefined\n : never\n\n /**\n * The event type in standard mode.\n * Otherwise, never.\n */\n export type FallbackEvent<\n TMode extends \"standard\" | \"strict\"\n > = TMode extends \"standard\" ? Event : never\n\n /**\n * Check if given event map is valid.\n * It's valid if the keys of the event map are narrower than `string`.\n */\n export type IsValidEventMap<T> = string extends keyof T ? false : true\n}\n\nexport { $ as getEventTargetInternalData }\n\n//------------------------------------------------------------------------------\n// Helpers\n//------------------------------------------------------------------------------\n\n/**\n * Internal data for EventTarget\n */\ntype EventTargetInternalData = ListenerListMap\n\n/**\n * Internal data.\n */\nconst internalDataMap = new WeakMap<any, EventTargetInternalData>()\n\n/**\n * Get private data.\n * @param target The event target object to get private data.\n * @param name The variable name to report.\n * @returns The private data of the event.\n */\nfunction $(target: any, name = \"this\"): EventTargetInternalData {\n const retv = internalDataMap.get(target)\n assertType(\n retv != null,\n \"'%s' must be an object that EventTarget constructor created, but got another one: %o\",\n name,\n target,\n )\n return retv\n}\n\n/**\n * Normalize options.\n * @param options The options to normalize.\n */\nfunction normalizeAddOptions(\n type: string,\n callback: EventTarget.EventListener<any, any> | null | undefined,\n options: boolean | EventTarget.AddOptions | undefined,\n): {\n type: string\n callback: EventTarget.EventListener<any, any> | undefined\n capture: boolean\n passive: boolean\n once: boolean\n signal: EventTarget.AbortSignal | undefined\n} {\n assertCallback(callback)\n\n if (typeof options === \"object\" && options !== null) {\n return {\n type: String(type),\n callback: callback ?? undefined,\n capture: Boolean(options.capture),\n passive: Boolean(options.passive),\n once: Boolean(options.once),\n signal: options.signal ?? undefined,\n }\n }\n\n return {\n type: String(type),\n callback: callback ?? undefined,\n capture: Boolean(options),\n passive: false,\n once: false,\n signal: undefined,\n }\n}\n\n/**\n * Normalize options.\n * @param options The options to normalize.\n */\nfunction normalizeOptions(\n type: string,\n callback: EventTarget.EventListener<any, any> | null | undefined,\n options: boolean | EventTarget.Options | undefined,\n): {\n type: string\n callback: EventTarget.EventListener<any, any> | undefined\n capture: boolean\n} {\n assertCallback(callback)\n\n if (typeof options === \"object\" && options !== null) {\n return {\n type: String(type),\n callback: callback ?? undefined,\n capture: Boolean(options.capture),\n }\n }\n\n return {\n type: String(type),\n callback: callback ?? undefined,\n capture: Boolean(options),\n }\n}\n\n/**\n * Assert the type of 'callback' argument.\n * @param callback The callback to check.\n */\nfunction assertCallback(callback: any): void {\n if (\n typeof callback === \"function\" ||\n (typeof callback === \"object\" &&\n callback !== null &&\n typeof callback.handleEvent === \"function\")\n ) {\n return\n }\n if (callback == null || typeof callback === \"object\") {\n InvalidEventListener.warn(callback)\n return\n }\n\n throw new TypeError(format(InvalidEventListener.message, [callback]))\n}\n\n/**\n * Print warning for duplicated.\n * @param listener The current listener that is duplicated.\n * @param passive The passive flag of the new duplicated listener.\n * @param once The once flag of the new duplicated listener.\n * @param signal The signal object of the new duplicated listener.\n */\nfunction warnDuplicate(\n listener: Listener,\n passive: boolean,\n once: boolean,\n signal: EventTarget.AbortSignal | undefined,\n): void {\n EventListenerWasDuplicated.warn(\n isCapture(listener) ? \"capture\" : \"bubble\",\n listener.callback,\n )\n\n if (isPassive(listener) !== passive) {\n OptionWasIgnored.warn(\"passive\")\n }\n if (isOnce(listener) !== once) {\n OptionWasIgnored.warn(\"once\")\n }\n if (listener.signal !== signal) {\n OptionWasIgnored.warn(\"signal\")\n }\n}\n\n// Set enumerable\nconst keys = Object.getOwnPropertyNames(EventTarget.prototype)\nfor (let i = 0; i < keys.length; ++i) {\n if (keys[i] === \"constructor\") {\n continue\n }\n Object.defineProperty(EventTarget.prototype, keys[i], { enumerable: true })\n}\n\n// Ensure `eventTarget instanceof window.EventTarget` is `true`.\nif (\n typeof Global !== \"undefined\" &&\n typeof Global.EventTarget !== \"undefined\"\n) {\n Object.setPrototypeOf(EventTarget.prototype, Global.EventTarget.prototype)\n}\n","import { Event } from \"./event\"\nimport { EventTarget, getEventTargetInternalData } from \"./event-target\"\nimport { addListener, ListenerList, removeListener } from \"./listener-list\"\nimport { ensureListenerList } from \"./listener-list-map\"\nimport { InvalidAttributeHandler } from \"./warnings\"\n\n/**\n * Get the current value of a given event attribute.\n * @param target The `EventTarget` object to get.\n * @param type The event type.\n */\nexport function getEventAttributeValue<\n TEventTarget extends EventTarget<any, any>,\n TEvent extends Event\n>(\n target: TEventTarget,\n type: string,\n): EventTarget.CallbackFunction<TEventTarget, TEvent> | null {\n const listMap = getEventTargetInternalData(target, \"target\")\n return listMap[type]?.attrCallback ?? null\n}\n\n/**\n * Set an event listener to a given event attribute.\n * @param target The `EventTarget` object to set.\n * @param type The event type.\n * @param callback The event listener.\n */\nexport function setEventAttributeValue(\n target: EventTarget<any, any>,\n type: string,\n callback: EventTarget.CallbackFunction<any, any> | null,\n): void {\n if (callback != null && typeof callback !== \"function\") {\n InvalidAttributeHandler.warn(callback)\n }\n\n if (\n typeof callback === \"function\" ||\n (typeof callback === \"object\" && callback !== null)\n ) {\n upsertEventAttributeListener(target, type, callback)\n } else {\n removeEventAttributeListener(target, type)\n }\n}\n\n//------------------------------------------------------------------------------\n// Helpers\n//------------------------------------------------------------------------------\n\n/**\n * Update or insert the given event attribute handler.\n * @param target The `EventTarget` object to set.\n * @param type The event type.\n * @param callback The event listener.\n */\nfunction upsertEventAttributeListener<\n TEventTarget extends EventTarget<any, any>\n>(\n target: TEventTarget,\n type: string,\n callback: EventTarget.CallbackFunction<TEventTarget, any>,\n): void {\n const list = ensureListenerList(\n getEventTargetInternalData(target, \"target\"),\n String(type),\n )\n list.attrCallback = callback\n\n if (list.attrListener == null) {\n list.attrListener = addListener(\n list,\n defineEventAttributeCallback(list),\n false,\n false,\n false,\n undefined,\n )\n }\n}\n\n/**\n * Remove the given event attribute handler.\n * @param target The `EventTarget` object to remove.\n * @param type The event type.\n * @param callback The event listener.\n */\nfunction removeEventAttributeListener(\n target: EventTarget<any, any>,\n type: string,\n): void {\n const listMap = getEventTargetInternalData(target, \"target\")\n const list = listMap[String(type)]\n if (list && list.attrListener) {\n removeListener(list, list.attrListener.callback, false)\n list.attrCallback = list.attrListener = undefined\n }\n}\n\n/**\n * Define the callback function for the given listener list object.\n * It calls `attrCallback` property if the property value is a function.\n * @param list The `ListenerList` object.\n */\nfunction defineEventAttributeCallback(\n list: ListenerList,\n): EventTarget.CallbackFunction<any, any> {\n return function (event) {\n const callback = list.attrCallback\n if (typeof callback === \"function\") {\n callback.call(this, event)\n }\n }\n}\n","import { Event } from \"./event\"\nimport {\n getEventAttributeValue,\n setEventAttributeValue,\n} from \"./event-attribute-handler\"\nimport { EventTarget } from \"./event-target\"\n\n/**\n * Define an `EventTarget` class that has event attibutes.\n * @param types The types to define event attributes.\n * @deprecated Use `getEventAttributeValue`/`setEventAttributeValue` pair on your derived class instead because of static analysis friendly.\n */\nexport function defineCustomEventTarget<\n TEventMap extends Record<string, Event>,\n TMode extends \"standard\" | \"strict\" = \"standard\"\n>(\n ...types: (string & keyof TEventMap)[]\n): defineCustomEventTarget.CustomEventTargetConstructor<TEventMap, TMode> {\n class CustomEventTarget extends EventTarget {}\n for (let i = 0; i < types.length; ++i) {\n defineEventAttribute(CustomEventTarget.prototype, types[i])\n }\n\n return CustomEventTarget as any\n}\n\nexport namespace defineCustomEventTarget {\n /**\n * The interface of CustomEventTarget constructor.\n */\n export type CustomEventTargetConstructor<\n TEventMap extends Record<string, Event>,\n TMode extends \"standard\" | \"strict\"\n > = {\n /**\n * Create a new instance.\n */\n new (): CustomEventTarget<TEventMap, TMode>\n /**\n * prototype object.\n */\n prototype: CustomEventTarget<TEventMap, TMode>\n }\n\n /**\n * The interface of CustomEventTarget.\n */\n export type CustomEventTarget<\n TEventMap extends Record<string, Event>,\n TMode extends \"standard\" | \"strict\"\n > = EventTarget<TEventMap, TMode> &\n defineEventAttribute.EventAttributes<any, TEventMap>\n}\n\n/**\n * Define an event attribute.\n * @param target The `EventTarget` object to define an event attribute.\n * @param type The event type to define.\n * @param _eventClass Unused, but to infer `Event` class type.\n * @deprecated Use `getEventAttributeValue`/`setEventAttributeValue` pair on your derived class instead because of static analysis friendly.\n */\nexport function defineEventAttribute<\n TEventTarget extends EventTarget,\n TEventType extends string,\n TEventConstrucor extends typeof Event\n>(\n target: TEventTarget,\n type: TEventType,\n _eventClass?: TEventConstrucor,\n): asserts target is TEventTarget &\n defineEventAttribute.EventAttributes<\n TEventTarget,\n Record<TEventType, InstanceType<TEventConstrucor>>\n > {\n Object.defineProperty(target, `on${type}`, {\n get() {\n return getEventAttributeValue(this, type)\n },\n set(value) {\n setEventAttributeValue(this, type, value)\n },\n configurable: true,\n enumerable: true,\n })\n}\n\nexport namespace defineEventAttribute {\n /**\n * Definition of event attributes.\n */\n export type EventAttributes<\n TEventTarget extends EventTarget<any, any>,\n TEventMap extends Record<string, Event>\n > = {\n [P in string &\n keyof TEventMap as `on${P}`]: EventTarget.CallbackFunction<\n TEventTarget,\n TEventMap[P]\n > | null\n }\n}\n","export default function (array, extras) {\n const map = {\n ...[].reduce.call(\n array,\n (map, value, index) => {\n map[index] = value;\n\n return map;\n },\n {}\n ),\n ...extras,\n length: array.length,\n [Symbol.iterator]: () => [].slice.call(map)[Symbol.iterator]()\n };\n\n return map;\n}\n","// We are only importing what we need.\n\nimport {\n AudioConfig,\n OutputFormat,\n ResultReason,\n SpeechConfig,\n SpeechRecognizer\n} from 'microsoft-cognitiveservices-speech-sdk/distrib/lib/microsoft.cognitiveservices.speech.sdk';\n\nexport default {\n AudioConfig,\n OutputFormat,\n ResultReason,\n SpeechConfig,\n SpeechRecognizer\n};\n","import arrayToMap from '../../Util/arrayToMap';\nimport SpeechSDK from '../SpeechSDK';\n\nconst {\n ResultReason: { RecognizingSpeech, RecognizedSpeech }\n} = SpeechSDK;\n\nexport default function (result, { maxAlternatives = Infinity, textNormalization = 'display' } = {}) {\n if (result.reason === RecognizingSpeech || (result.reason === RecognizedSpeech && !result.json.NBest)) {\n const resultList = [\n {\n confidence: 0.5,\n transcript: result.text\n }\n ];\n\n if (result.reason === RecognizedSpeech) {\n resultList.isFinal = true;\n }\n\n return resultList;\n } else if (result.reason === RecognizedSpeech) {\n const resultList = arrayToMap(\n (result.json.NBest || [])\n .slice(0, maxAlternatives)\n .map(({ Confidence: confidence, Display: display, ITN: itn, Lexical: lexical, MaskedITN: maskedITN }) => ({\n confidence,\n transcript:\n textNormalization === 'itn'\n ? itn\n : textNormalization === 'lexical'\n ? lexical\n : textNormalization === 'maskeditn'\n ? maskedITN\n : display\n })),\n { isFinal: true }\n );\n\n return resultList;\n }\n\n return [];\n}\n","export default function pDefer() {\n\tconst deferred = {};\n\n\tdeferred.promise = new Promise((resolve, reject) => {\n\t\tdeferred.resolve = resolve;\n\t\tdeferred.reject = reject;\n\t});\n\n\treturn deferred;\n}\n","import createDeferred from 'p-defer';\n\nexport default function () {\n let shiftDeferred;\n const queue = [];\n\n const push = value => {\n if (shiftDeferred) {\n const { resolve } = shiftDeferred;\n\n shiftDeferred = null;\n resolve(value);\n } else {\n queue.push(value);\n }\n };\n\n const shift = () => {\n if (queue.length) {\n return Promise.resolve(queue.shift());\n }\n\n return (shiftDeferred || (shiftDeferred = createDeferred())).promise;\n };\n\n return {\n push,\n shift\n };\n}\n","function isFunction(value: unknown): value is () => unknown {\n return typeof value === 'function';\n}\n\nexport default function resolveFunctionOrReturnValue<T>(\n fnOrValue: (() => Promise<T> | T) | Promise<T> | T\n): Promise<T> | T {\n return isFunction(fnOrValue) ? fnOrValue() : fnOrValue;\n}\n","import resolveFunctionOrReturnValue from './resolveFunctionOrReturnValue';\n\nlet shouldWarnOnSubscriptionKey = true;\n\nexport default function patchOptions({\n authorizationToken,\n credentials,\n looseEvent,\n looseEvents,\n region = 'westus',\n subscriptionKey,\n ...otherOptions\n} = {}) {\n if (typeof looseEvent !== 'undefined') {\n console.warn('web-speech-cognitive-services: The option \"looseEvent\" should be named as \"looseEvents\".');\n\n looseEvents = looseEvent;\n }\n\n if (!credentials) {\n if (!authorizationToken && !subscriptionKey) {\n throw new Error('web-speech-cognitive-services: Credentials must be specified.');\n } else {\n console.warn(\n 'web-speech-cognitive-services: We are deprecating authorizationToken, region, and subscriptionKey. Please use credentials instead. The deprecated option will be removed on or after 2020-11-14.'\n );\n\n credentials = async () =>\n authorizationToken\n ? { authorizationToken: await resolveFunctionOrReturnValue(authorizationToken), region }\n : { region, subscriptionKey: await resolveFunctionOrReturnValue(subscriptionKey) };\n }\n }\n\n return {\n ...otherOptions,\n fetchCredentials: async () => {\n const {\n authorizationToken,\n customVoiceHostname,\n region,\n speechRecognitionHostname,\n speechSynthesisHostname,\n subscriptionKey\n } = await resolveFunctionOrReturnValue(credentials);\n\n if ((!authorizationToken && !subscriptionKey) || (authorizationToken && subscriptionKey)) {\n throw new Error(\n 'web-speech-cognitive-services: Either \"authorizationToken\" or \"subscriptionKey\" must be provided.'\n );\n } else if (!region && !(speechRecognitionHostname && speechSynthesisHostname)) {\n throw new Error(\n 'web-speech-cognitive-services: Either \"region\" or \"speechRecognitionHostname\" and \"speechSynthesisHostname\" must be set.'\n );\n } else if (region && (customVoiceHostname || speechRecognitionHostname || speechSynthesisHostname)) {\n throw new Error(\n 'web-speech-cognitive-services: Only either \"region\" or \"customVoiceHostname\", \"speechRecognitionHostname\" and \"speechSynthesisHostname\" can be set.'\n );\n } else if (authorizationToken) {\n if (typeof authorizationToken !== 'string') {\n throw new Error('web-speech-cognitive-services: \"authorizationToken\" must be a string.');\n }\n } else if (typeof subscriptionKey !== 'string') {\n throw new Error('web-speech-cognitive-services: \"subscriptionKey\" must be a string.');\n }\n\n if (shouldWarnOnSubscriptionKey && subscriptionKey) {\n console.warn(\n 'web-speech-cognitive-services: In production environment, subscription key should not be used, authorization token should be used instead.'\n );\n\n shouldWarnOnSubscriptionKey = false;\n }\n\n const resolvedCredentials = authorizationToken ? { authorizationToken } : { subscriptionKey };\n\n if (region) {\n resolvedCredentials.region = region;\n } else {\n resolvedCredentials.customVoiceHostname = customVoiceHostname;\n resolvedCredentials.speechRecognitionHostname = speechRecognitionHostname;\n resolvedCredentials.speechSynthesisHostname = speechSynthesisHostname;\n }\n\n return resolvedCredentials;\n },\n looseEvents\n };\n}\n","/* eslint class-methods-use-this: \"off\" */\n\nexport default class {\n constructor() {\n this._phrases = [];\n }\n\n addFromString() {\n throw new Error('JSGF is not supported');\n }\n\n get phrases() {\n return this._phrases;\n }\n\n set phrases(value) {\n if (Array.isArray(value)) {\n this._phrases = value;\n } else if (typeof value === 'string') {\n this._phrases = [value];\n } else {\n throw new Error(`The provided value is not an array or of type 'string'`);\n }\n }\n}\n","/* eslint class-methods-use-this: \"off\" */\n/* eslint complexity: [\"error\", 70] */\n/* eslint no-await-in-loop: \"off\" */\n/* eslint no-empty-function: \"off\" */\n/* eslint no-magic-numbers: [\"error\", { \"ignore\": [0, 100, 150] }] */\n\nimport { Event, EventTarget, getEventAttributeValue, setEventAttributeValue } from 'event-target-shim';\n\nimport cognitiveServiceEventResultToWebSpeechRecognitionResultList from './cognitiveServiceEventResultToWebSpeechRecognitionResultList';\nimport createPromiseQueue from '../../Util/createPromiseQueue';\nimport patchOptions from '../patchOptions';\nimport SpeechGrammarList from './SpeechGrammarList';\nimport SpeechSDK from '../SpeechSDK';\n\n// https://docs.microsoft.com/en-us/javascript/api/microsoft-cognitiveservices-speech-sdk/speechconfig?view=azure-node-latest#outputformat\n// {\n// \"RecognitionStatus\": \"Success\",\n// \"Offset\": 900000,\n// \"Duration\": 49000000,\n// \"NBest\": [\n// {\n// \"Confidence\": 0.738919,\n// \"Lexical\": \"second\",\n// \"ITN\": \"second\",\n// \"MaskedITN\": \"second\",\n// \"Display\": \"Second.\"\n// }\n// ]\n// }\n\n// {\n// \"RecognitionStatus\": \"InitialSilenceTimeout\",\n// \"Offset\": 50000000,\n// \"Duration\": 0\n// }\n\nconst { AudioConfig, OutputFormat, ResultReason, SpeechConfig, SpeechRecognizer } = SpeechSDK;\n\nfunction serializeRecognitionResult({ duration, errorDetails, json, offset, properties, reason, resultId, text }) {\n return {\n duration,\n errorDetails,\n json: JSON.parse(json),\n offset,\n properties,\n reason,\n resultId,\n text\n };\n}\n\nfunction averageAmplitude(arrayBuffer) {\n const array = new Int16Array(arrayBuffer);\n\n return (\n [].reduce.call(array, (averageAmplitude, amplitude) => averageAmplitude + Math.abs(amplitude), 0) / array.length\n );\n}\n\nfunction cognitiveServicesAsyncToPromise(fn) {\n return (...args) => new Promise((resolve, reject) => fn(...args, resolve, reject));\n}\n\nclass SpeechRecognitionEvent extends Event {\n constructor(type, { data, emma, interpretation, resultIndex, results } = {}) {\n super(type);\n\n this.data = data;\n this.emma = emma;\n this.interpretation = interpretation;\n this.resultIndex = resultIndex;\n this.results = results;\n }\n}\n\nfunction prepareAudioConfig(audioConfig) {\n const originalAttach = audioConfig.attach;\n const boundOriginalAttach = audioConfig.attach.bind(audioConfig);\n let firstChunk;\n let muted;\n\n // We modify \"attach\" function and detect when audible chunk is read.\n // We will only modify \"attach\" function once.\n audioConfig.attach = async () => {\n const reader = await boundOriginalAttach();\n\n return {\n ...reader,\n read: async () => {\n const chunk = await reader.read();\n\n // The magic number 150 is measured by:\n // 1. Set microphone volume to 0\n // 2. Observe the amplitude (100-110) for the first few chunks\n // (There is a short static caught when turning on the microphone)\n // 3. Set the number a bit higher than the observation\n\n if (!firstChunk && averageAmplitude(chunk.buffer) > 150) {\n audioConfig.events.onEvent({ name: 'FirstAudibleChunk' });\n firstChunk = true;\n }\n\n if (muted) {\n return { buffer: new ArrayBuffer(0), isEnd: true, timeReceived: Date.now() };\n }\n\n return chunk;\n }\n };\n };\n\n return {\n audioConfig,\n pause: () => {\n muted = true;\n },\n unprepare: () => {\n audioConfig.attach = originalAttach;\n }\n };\n}\n\nexport function createSpeechRecognitionPonyfillFromRecognizer({\n createRecognizer,\n enableTelemetry,\n looseEvents,\n referenceGrammars,\n textNormalization\n}) {\n // If enableTelemetry is set to null or non-boolean, we will default to true.\n SpeechRecognizer.enableTelemetry(enableTelemetry !== false);\n\n class SpeechRecognition extends EventTarget {\n constructor() {\n super();\n\n this._continuous = false;\n this._interimResults = false;\n this._lang =\n typeof window !== 'undefined'\n ? window.document.documentElement.getAttribute('lang') || window.navigator.language\n : 'en-US';\n this._grammars = new SpeechGrammarList();\n this._maxAlternatives = 1;\n }\n\n emitCognitiveServices(type, event) {\n this.dispatchEvent(\n new SpeechRecognitionEvent('cognitiveservices', {\n data: {\n ...event,\n type\n }\n })\n );\n }\n\n get continuous() {\n return this._continuous;\n }\n\n set continuous(value) {\n this._continuous = value;\n }\n\n get grammars() {\n return this._grammars;\n }\n\n set grammars(value) {\n if (value instanceof SpeechGrammarList) {\n this._grammars = value;\n } else {\n throw new Error(`The provided value is not of type 'SpeechGrammarList'`);\n }\n }\n\n get interimResults() {\n return this._interimResults;\n }\n\n set interimResults(value) {\n this._interimResults = value;\n }\n\n get maxAlternatives() {\n return this._maxAlternatives;\n }\n\n set maxAlternatives(value) {\n this._maxAlternatives = value;\n }\n\n get lang() {\n return this._lang;\n }\n\n set lang(value) {\n this._lang = value;\n }\n\n get onaudioend() {\n return getEventAttributeValue(this, 'audioend');\n }\n\n set onaudioend(value) {\n setEventAttributeValue(this, 'audioend', value);\n }\n\n get onaudiostart() {\n return getEventAttributeValue(this, 'audiostart');\n }\n\n set onaudiostart(value) {\n setEventAttributeValue(this, 'audiostart', value);\n }\n\n get oncognitiveservices() {\n return getEventAttributeValue(this, 'cognitiveservices');\n }\n\n set oncognitiveservices(value) {\n setEventAttributeValue(this, 'cognitiveservices', value);\n }\n\n get onend() {\n return getEventAttributeValue(this, 'end');\n }\n\n set onend(value) {\n setEventAttributeValue(this, 'end', value);\n }\n\n get onerror() {\n return getEventAttributeValue(this, 'error');\n }\n\n set onerror(value) {\n setEventAttributeValue(this, 'error', value);\n }\n\n get onresult() {\n return getEventAttributeValue(this, 'result');\n }\n\n set onresult(value) {\n setEventAttributeValue(this, 'result', value);\n }\n\n get onsoundend() {\n return getEventAttributeValue(this, 'soundend');\n }\n\n set onsoundend(value) {\n setEventAttributeValue(this, 'soundend', value);\n }\n\n get onsoundstart() {\n return getEventAttributeValue(this, 'soundstart');\n }\n\n set onsoundstart(value) {\n setEventAttributeValue(this, 'soundstart', value);\n }\n\n get onspeechend() {\n return getEventAttributeValue(this, 'speechend');\n }\n\n set onspeechend(value) {\n setEventAttributeValue(this, 'speechend', value);\n }\n\n get onspeechstart() {\n return getEventAttributeValue(this, 'speechstart');\n }\n\n set onspeechstart(value) {\n setEventAttributeValue(this, 'speechstart', value);\n }\n\n get onstart() {\n return getEventAttributeValue(this, 'start');\n }\n\n set onstart(value) {\n setEventAttributeValue(this, 'start', value);\n }\n\n start() {\n this._startOnce().catch(err => {\n this.dispatchEvent(new ErrorEvent('error', { error: err, message: err && (err.stack || err.message) }));\n });\n }\n\n async _startOnce() {\n // TODO: [P2] Should check if recognition is active, we should not start recognition twice\n const recognizer = await createRecognizer(this.lang);\n\n const { pause, unprepare } = prepareAudioConfig(recognizer.audioConfig);\n\n try {\n const queue = createPromiseQueue();\n let soundStarted;\n let speechStarted;\n let stopping;\n\n const { detach: detachAudioConfigEvent } = recognizer.audioConfig.events.attach(event => {\n const { name } = event;\n\n if (name === 'AudioSourceReadyEvent') {\n queue.push({ audioSourceReady: {} });\n } else if (name === 'AudioSourceOffEvent') {\n queue.push({ audioSourceOff: {} });\n } else if (name === 'FirstAudibleChunk') {\n queue.push({ firstAudibleChunk: {} });\n }\n });\n\n recognizer.canceled = (_, { errorDetails, offset, reason, sessionId }) => {\n queue.push({\n canceled: {\n errorDetails,\n offset,\n reason,\n sessionId\n }\n });\n };\n\n recognizer.recognized = (_, { offset, result, sessionId }) => {\n queue.push({\n recognized: {\n offset,\n result: serializeRecognitionResult(result),\n sessionId\n }\n });\n };\n\n recognizer.recognizing = (_, { offset, result, sessionId }) => {\n queue.push({\n recognizing: {\n offset,\n result: serializeRecognitionResult(result),\n sessionId\n }\n });\n };\n\n recognizer.sessionStarted = (_, { sessionId }) => {\n queue.push({ sessionStarted: { sessionId } });\n };\n\n recognizer.sessionStopped = (_, { sessionId }) => {\n // \"sessionStopped\" is never fired, probably because we are using startContinuousRecognitionAsync instead of recognizeOnceAsync.\n queue.push({ sessionStopped: { sessionId } });\n };\n\n recognizer.speechStartDetected = (_, { offset, sessionId }) => {\n queue.push({ speechStartDetected: { offset, sessionId } });\n };\n\n recognizer.speechEndDetected = (_, { sessionId }) => {\n // \"speechEndDetected\" is never fired, probably because we are using startContinuousRecognitionAsync instead of recognizeOnceAsync.\n // Update: \"speechEndDetected\" is fired for DLSpeech.listenOnceAsync()\n queue.push({ speechEndDetected: { sessionId } });\n };\n\n const { phrases } = this.grammars;\n\n // HACK: We are using the internal of SpeechRecognizer because they did not expose it\n const { dynamicGrammar } = recognizer.privReco;\n\n referenceGrammars && referenceGrammars.length && dynamicGrammar.addReferenceGrammar(referenceGrammars);\n phrases && phrases.length && dynamicGrammar.addPhrase(phrases);\n\n await cognitiveServicesAsyncToPromise(recognizer.startContinuousRecognitionAsync.bind(recognizer))();\n\n if (recognizer.stopContinuousRecognitionAsync) {\n this.abort = () => queue.push({ abort: {} });\n this.stop = () => queue.push({ stop: {} });\n } else {\n this.abort = this.stop = undefined;\n }\n\n let audioStarted;\n let finalEvent;\n let finalizedResults = [];\n\n for (let loop = 0; !stopping || audioStarted; loop++) {\n const event = await queue.shift();\n const {\n abort,\n audioSourceOff,\n audioSourceReady,\n canceled,\n firstAudibleChunk,\n recognized,\n recognizing,\n stop\n } = event;\n\n // We are emitting event \"cognitiveservices\" for debugging purpose.\n Object.keys(event).forEach(name => this.emitCognitiveServices(name, event[name]));\n\n const errorMessage = canceled && canceled.errorDetails;\n\n if (/Permission\\sdenied/u.test(errorMessage || '')) {\n // If microphone is not allowed, we should not emit \"start\" event.\n\n finalEvent = {\n error: 'not-allowed',\n type: 'error'\n };\n\n break;\n }\n\n if (!loop) {\n this.dispatchEvent(new SpeechRecognitionEvent('start'));\n }\n\n if (errorMessage) {\n if (/1006/u.test(errorMessage)) {\n if (!audioStarted) {\n this.dispatchEvent(new SpeechRecognitionEvent('audiostart'));\n this.dispatchEvent(new SpeechRecognitionEvent('audioend'));\n }\n\n finalEvent = {\n error: 'network',\n type: 'error'\n };\n } else {\n finalEvent = {\n error: 'unknown',\n type: 'error'\n };\n }\n\n break;\n } else if (abort || stop) {\n if (abort) {\n finalEvent = {\n error: 'aborted',\n type: 'error'\n };\n\n // If we are aborting, we will ignore lingering recognizing/recognized events. But if we are stopping, we need them.\n stopping = 'abort';\n } else {\n // When we pause, we will send { isEnd: true }, Speech Services will send us \"recognized\" event.\n pause();\n stopping = 'stop';\n }\n\n // Abort should not be dispatched without support of \"stopContinuousRecognitionAsync\".\n // But for defensive purpose, we make sure \"stopContinuousRecognitionAsync\" is available before we can call.\n if (abort && recognizer.stopContinuousRecognitionAsync) {\n await cognitiveServicesAsyncToPromise(recognizer.stopContinuousRecognitionAsync.bind(recognizer))();\n }\n } else if (audioSourceReady) {\n this.dispatchEvent(new SpeechRecognitionEvent('audiostart'));\n\n audioStarted = true;\n } else if (firstAudibleChunk) {\n this.dispatchEvent(new SpeechRecognitionEvent('soundstart'));\n\n soundStarted = true;\n } else if (audioSourceOff) {\n // Looks like we don't need this line and all the tests are still working.\n // Guessing probably stopping is already truthy.\n // stopping = true;\n\n speechStarted && this.dispatchEvent(new SpeechRecognitionEvent('speechend'));\n soundStarted && this.dispatchEvent(new SpeechRecognitionEvent('soundend'));\n audioStarted && this.dispatchEvent(new SpeechRecognitionEvent('audioend'));\n\n audioStarted = soundStarted = speechStarted = false;\n\n break;\n } else if (stopping !== 'abort') {\n if (recognized && recognized.result && recognized.result.reason === ResultReason.NoMatch) {\n finalEvent = {\n error: 'no-speech',\n type: 'error'\n };\n } else if (recognized || recognizing) {\n if (!audioStarted) {\n // Unconfirmed prevention of quirks\n this.dispatchEvent(new SpeechRecognitionEvent('audiostart'));\n\n audioStarted = true;\n }\n\n if (!soundStarted) {\n this.dispatchEvent(new SpeechRecognitionEvent('soundstart'));\n\n soundStarted = true;\n }\n\n if (!speechStarted) {\n this.dispatchEvent(new SpeechRecognitionEvent('speechstart'));\n\n speechStarted = true;\n }\n\n if (recognized) {\n const result = cognitiveServiceEventResultToWebSpeechRecognitionResultList(recognized.result, {\n maxAlternatives: this.maxAlternatives,\n textNormalization\n });\n\n const recognizable = !!result[0].transcript;\n\n if (recognizable) {\n finalizedResults = [...finalizedResults, result];\n\n this.continuous &&\n this.dispatchEvent(\n new SpeechRecognitionEvent('result', {\n results: finalizedResults\n })\n );\n }\n\n // If it is continuous, we just sent the finalized results. So we don't need to send it again after \"audioend\" event.\n if (this.continuous && recognizable) {\n finalEvent = null;\n } else {\n finalEvent = {\n results: finalizedResults,\n type: 'result'\n };\n }\n\n if (!this.continuous && recognizer.stopContinuousRecognitionAsync) {\n await cognitiveServicesAsyncToPromise(recognizer.stopContinuousRecognitionAsync.bind(recognizer))();\n }\n\n // If event order can be loosened, we can send the recognized event as soon as we receive it.\n // 1. If it is not recognizable (no-speech), we should send an \"error\" event just before \"end\" event. We will not loosen \"error\" events.\n if (looseEvents && finalEvent && recognizable) {\n this.dispatchEvent(new SpeechRecognitionEvent(finalEvent.type, finalEvent));\n finalEvent = null;\n }\n } else if (recognizing) {\n this.interimResults &&\n this.dispatchEvent(\n new SpeechRecognitionEvent('result', {\n results: [\n ...finalizedResults,\n cognitiveServiceEventResultToWebSpeechRecognitionResultList(recognizing.result, {\n maxAlternatives: this.maxAlternatives,\n textNormalization\n })\n ]\n })\n );\n }\n }\n }\n }\n\n if (speechStarted) {\n this.dispatchEvent(new SpeechRecognitionEvent('speechend'));\n }\n\n if (soundStarted) {\n this.dispatchEvent(new SpeechRecognitionEvent('soundend'));\n }\n\n if (audioStarted) {\n this.dispatchEvent(new SpeechRecognitionEvent('audioend'));\n }\n\n if (finalEvent) {\n if (finalEvent.type === 'result' && !finalEvent.results.length) {\n finalEvent = {\n error: 'no-speech',\n type: 'error'\n };\n }\n\n if (finalEvent.type === 'error') {\n this.dispatchEvent(new ErrorEvent('error', finalEvent));\n } else {\n this.dispatchEvent(new SpeechRecognitionEvent(finalEvent.type, finalEvent));\n }\n }\n\n // Even though there is no \"start\" event emitted, we will still emit \"end\" event\n // This is mainly for \"microphone blocked\" story.\n this.dispatchEvent(new SpeechRecognitionEvent('end'));\n\n detachAudioConfigEvent();\n } catch (err) {\n // Logging out the erorr because Speech SDK would fail silently.\n console.error(err);\n\n throw err;\n } finally {\n unprepare();\n recognizer.dispose();\n }\n }\n }\n\n return {\n SpeechGrammarList,\n SpeechRecognition,\n SpeechRecognitionEvent\n };\n}\n\nexport default options => {\n const {\n audioConfig = AudioConfig.fromDefaultMicrophoneInput(),\n\n // We set telemetry to true to honor the default telemetry settings of Speech SDK\n // https://github.com/Microsoft/cognitive-services-speech-sdk-js#data--telemetry\n enableTelemetry = true,\n\n fetchCredentials,\n looseEvents,\n referenceGrammars,\n speechRecognitionEndpointId,\n textNormalization = 'display'\n } = patchOptions(options);\n\n if (!audioConfig && (!window.navigator.mediaDevices || !window.navigator.mediaDevices.getUserMedia)) {\n console.warn(\n 'web-speech-cognitive-services: This browser does not support WebRTC and it will not work with Cognitive Services Speech Services.'\n );\n\n return {};\n }\n\n const createRecognizer = async lang => {\n const { authorizationToken, region, speechRecognitionHostname, subscriptionKey } = await fetchCredentials();\n let speechConfig;\n\n if (speechRecognitionHostname) {\n const host = { hostname: speechRecognitionHostname, port: 443, protocol: 'wss:' };\n\n if (authorizationToken) {\n speechConfig = SpeechConfig.fromHost(host);\n speechConfig.authorizationToken = authorizationToken;\n } else {\n speechConfig = SpeechConfig.fromHost(host, subscriptionKey);\n }\n } else {\n speechConfig = authorizationToken\n ? SpeechConfig.fromAuthorizationToken(authorizationToken, region)\n : SpeechConfig.fromSubscription(subscriptionKey, region);\n }\n\n if (speechRecognitionEndpointId) {\n speechConfig.endpointId = speechRecognitionEndpointId;\n }\n\n speechConfig.outputFormat = OutputFormat.Detailed;\n speechConfig.speechRecognitionLanguage = lang || 'en-US';\n\n return new SpeechRecognizer(speechConfig, audioConfig);\n };\n\n return createSpeechRecognitionPonyfillFromRecognizer({\n audioConfig,\n createRecognizer,\n enableTelemetry,\n looseEvents,\n referenceGrammars,\n textNormalization\n });\n};\n","import createSpeechRecognitionPonyfill, {\n createSpeechRecognitionPonyfillFromRecognizer\n} from './SpeechToText/createSpeechRecognitionPonyfill';\n\nexport default createSpeechRecognitionPonyfill;\n\nexport { createSpeechRecognitionPonyfillFromRecognizer };\n","/* eslint class-methods-use-this: 0 */\n\nimport { EventTarget, getEventAttributeValue, setEventAttributeValue } from 'event-target-shim';\nimport createDeferred from 'p-defer';\nimport onErrorResumeNext from 'on-error-resume-next';\n\nimport AudioContextQueue from './AudioContextQueue';\nimport fetchCustomVoices from './fetchCustomVoices';\nimport fetchVoices from './fetchVoices';\nimport patchOptions from '../patchOptions';\nimport SpeechSynthesisEvent from './SpeechSynthesisEvent';\nimport SpeechSynthesisUtterance from './SpeechSynthesisUtterance';\n\n// Supported output format can be found at https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/rest-text-to-speech#audio-outputs\nconst DEFAULT_OUTPUT_FORMAT = 'audio-24khz-160kbitrate-mono-mp3';\nconst EMPTY_ARRAY = [];\n\nexport default options => {\n const {\n audioContext,\n fetchCredentials,\n ponyfill = {\n AudioContext: window.AudioContext || window.webkitAudioContext\n },\n speechSynthesisDeploymentId,\n speechSynthesisOutputFormat = DEFAULT_OUTPUT_FORMAT\n } = patchOptions(options);\n\n if (!audioContext && !ponyfill.AudioContext) {\n console.warn(\n 'web-speech-cognitive-services: This browser does not support Web Audio and it will not work with Cognitive Services Speech Services.'\n );\n\n return {};\n }\n\n class SpeechSynthesis extends EventTarget {\n constructor() {\n super();\n\n this.queue = new AudioContextQueue({ audioContext, ponyfill });\n\n this.updateVoices();\n }\n\n cancel() {\n this.queue.stop();\n }\n\n getVoices() {\n return EMPTY_ARRAY;\n }\n\n get onvoiceschanged() {\n return getEventAttributeValue(this, 'voiceschanged');\n }\n\n set onvoiceschanged(value) {\n setEventAttributeValue(this, 'voiceschanged', value);\n }\n\n pause() {\n this.queue.pause();\n }\n\n resume() {\n this.queue.resume();\n }\n\n speak(utterance) {\n if (!(utterance instanceof SpeechSynthesisUtterance)) {\n throw new Error('invalid utterance');\n }\n\n const { reject, resolve, promise } = createDeferred();\n const handleError = ({ error: errorCode, message }) => {\n const error = new Error(errorCode);\n\n error.stack = message;\n\n reject(error);\n };\n\n utterance.addEventListener('end', resolve);\n utterance.addEventListener('error', handleError);\n\n utterance.preload({\n deploymentId: speechSynthesisDeploymentId,\n fetchCredentials,\n outputFormat: speechSynthesisOutputFormat\n });\n\n this.queue.push(utterance);\n\n return promise.finally(() => {\n utterance.removeEventListener('end', resolve);\n utterance.removeEventListener('error', handleError);\n });\n }\n\n get speaking() {\n return this.queue.speaking;\n }\n\n async updateVoices() {\n const { customVoiceHostname, region, speechSynthesisHostname, subscriptionKey } = await fetchCredentials();\n\n if (speechSynthesisDeploymentId) {\n if (subscriptionKey) {\n console.warn(\n 'web-speech-cognitive-services: Listing of custom voice models are only available when using subscription key.'\n );\n\n await onErrorResumeNext(async () => {\n const voices = await fetchCustomVoices({\n customVoiceHostname,\n deploymentId: speechSynthesisDeploymentId,\n region,\n speechSynthesisHostname,\n subscriptionKey\n });\n\n this.getVoices = () => voices;\n });\n }\n } else {\n // If fetch voice list failed, we will not emit \"voiceschanged\" event.\n // In the spec, there is no \"error\" event.\n\n await onErrorResumeNext(async () => {\n const voices = await fetchVoices(await fetchCredentials());\n\n this.getVoices = () => voices;\n });\n }\n\n this.dispatchEvent(new SpeechSynthesisEvent('voiceschanged'));\n }\n }\n\n return {\n speechSynthesis: new SpeechSynthesis(),\n SpeechSynthesisEvent,\n SpeechSynthesisUtterance\n };\n};\n","var safeIsNaN = Number.isNaN ||\n function ponyfill(value) {\n return typeof value === 'number' && value !== value;\n };\nfunction isEqual(first, second) {\n if (first === second) {\n return true;\n }\n if (safeIsNaN(first) && safeIsNaN(second)) {\n return true;\n }\n return false;\n}\nfunction areInputsEqual(newInputs, lastInputs) {\n if (newInputs.length !== lastInputs.length) {\n return false;\n }\n for (var i = 0; i < newInputs.length; i++) {\n if (!isEqual(newInputs[i], lastInputs[i])) {\n return false;\n }\n }\n return true;\n}\n\nfunction memoizeOne(resultFn, isEqual) {\n if (isEqual === void 0) { isEqual = areInputsEqual; }\n var cache = null;\n function memoized() {\n var newArgs = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n newArgs[_i] = arguments[_i];\n }\n if (cache && cache.lastThis === this && isEqual(newArgs, cache.lastArgs)) {\n return cache.lastResult;\n }\n var lastResult = resultFn.apply(this, newArgs);\n cache = {\n lastResult: lastResult,\n lastArgs: newArgs,\n lastThis: this,\n };\n return lastResult;\n }\n memoized.clear = function clear() {\n cache = null;\n };\n return memoized;\n}\n\nexport { memoizeOne as default };\n","/* eslint no-await-in-loop: \"off\" */\n\nexport default class {\n constructor(audioContext) {\n this.audioContext = audioContext;\n }\n\n pause() {\n this.audioContext && this.audioContext.suspend();\n this.playingUtterance && this.playingUtterance.dispatchEvent(new CustomEvent('pause'));\n }\n\n resume() {\n this.audioContext && this.audioContext.resume();\n this.playingUtterance && this.playingUtterance.dispatchEvent(new CustomEvent('resume'));\n }\n\n async start(queue) {\n let utterance;\n\n while ((utterance = queue.shift())) {\n this.playingUtterance = utterance;\n\n await utterance.play(this.audioContext);\n\n this.playingUtterance = null;\n }\n }\n\n stop() {\n this.playingUtterance && this.playingUtterance.stop();\n\n if (this.audioContext.state === 'suspended') {\n // Play -> Pause -> Cancel (stop)\n // This would generate these events: \"start\", \"pause\", \"end\"\n\n // Without this code, the \"end\" event will not emit until resume() is called\n // Cancelling an unstarted utterance will not emit any \"start\" or \"end\" event\n this.audioContext.resume();\n }\n }\n}\n","/* eslint no-await-in-loop: \"off\" */\n\nimport memoize from 'memoize-one';\n\nimport AudioContextConsumer from './AudioContextConsumer';\n\nexport default class {\n constructor({ audioContext, ponyfill }) {\n this.consumer = null;\n this.paused = false;\n this.queue = [];\n\n this.getAudioContext = memoize(() => audioContext || new ponyfill.AudioContext());\n }\n\n pause() {\n this.paused = true;\n this.consumer && this.consumer.pause();\n }\n\n push(utterance) {\n this.queue.push(utterance);\n this.startConsumer();\n }\n\n resume() {\n this.paused = false;\n\n if (this.consumer) {\n this.consumer.resume();\n } else {\n this.startConsumer();\n }\n }\n\n get speaking() {\n return !!this.consumer;\n }\n\n async startConsumer() {\n while (!this.paused && this.queue.length && !this.consumer) {\n this.consumer = new AudioContextConsumer(this.getAudioContext());\n\n await this.consumer.start(this.queue);\n\n this.consumer = null;\n }\n }\n\n stop() {\n this.queue.splice(0);\n this.consumer && this.consumer.stop();\n }\n}\n","export default class {\n constructor({ gender, lang, voiceURI }) {\n this._default = false;\n this._gender = gender;\n this._lang = lang;\n this._localService = false;\n this._name = voiceURI;\n this._voiceURI = voiceURI;\n }\n\n get default() {\n return this._default;\n }\n\n get gender() {\n return this._gender;\n }\n\n get lang() {\n return this._lang;\n }\n\n get localService() {\n return this._localService;\n }\n\n get name() {\n return this._name;\n }\n\n get voiceURI() {\n return this._voiceURI;\n }\n}\n","/* eslint no-magic-numbers: [\"error\", { \"ignore\": [0, 1, -1] }] */\n\nimport SpeechSynthesisVoice from './SpeechSynthesisVoice';\n\nasync function fetchCustomVoices({ customVoiceHostname, deploymentId, region, subscriptionKey }) {\n const hostname = customVoiceHostname || `${region}.customvoice.api.speech.microsoft.com`;\n\n // Although encodeURI on a hostname doesn't work as expected for hostname, at least, it will fail peacefully.\n const res = await fetch(\n `https://${encodeURI(hostname)}/api/texttospeech/v2.0/endpoints/${encodeURIComponent(deploymentId)}`,\n {\n headers: {\n accept: 'application/json',\n 'ocp-apim-subscription-key': subscriptionKey\n }\n }\n );\n\n if (!res.ok) {\n throw new Error('Failed to fetch custom voices');\n }\n\n return res.json();\n}\n\nexport default async function ({ customVoiceHostname, deploymentId, region, subscriptionKey }) {\n const { models } = await fetchCustomVoices({ customVoiceHostname, deploymentId, region, subscriptionKey });\n\n return models\n .map(\n ({ properties: { Gender: gender }, locale: lang, name: voiceURI }) =>\n new SpeechSynthesisVoice({ gender, lang, voiceURI })\n )\n .sort(({ name: x }, { name: y }) => (x > y ? 1 : x < y ? -1 : 0));\n}\n","/* eslint no-magic-numbers: [\"error\", { \"ignore\": [0, 1, -1] }] */\n\nimport SpeechSynthesisVoice from './SpeechSynthesisVoice';\n\nexport default async function fetchVoices({ authorizationToken, region, speechSynthesisHostname, subscriptionKey }) {\n // Although encodeURI on a hostname doesn't work as expected for hostname, at least, it will fail peacefully.\n const hostname = speechSynthesisHostname || `${encodeURI(region)}.tts.speech.microsoft.com`;\n const res = await fetch(`https://${hostname}/cognitiveservices/voices/list`, {\n headers: {\n 'content-type': 'application/json',\n ...(authorizationToken\n ? {\n authorization: `Bearer ${authorizationToken}`\n }\n : {\n 'Ocp-Apim-Subscription-Key': subscriptionKey\n })\n }\n });\n\n if (!res.ok) {\n throw new Error('Failed to fetch voices');\n }\n\n const voices = await res.json();\n\n return voices\n .map(({ Gender: gender, Locale: lang, Name: voiceURI }) => new SpeechSynthesisVoice({ gender, lang, voiceURI }))\n .sort(({ name: x }, { name: y }) => (x > y ? 1 : x < y ? -1 : 0));\n}\n","import { Event } from 'event-target-shim';\n\nexport default class SpeechSynthesisEvent extends Event {\n constructor(type) {\n super(type);\n }\n}\n","/* eslint no-empty: [\"error\", { \"allowEmptyCatch\": true }] */\n\nimport { EventTarget, getEventAttributeValue, setEventAttributeValue } from 'event-target-shim';\nimport EventAsPromise from 'event-as-promise';\n\nimport fetchSpeechData from './fetchSpeechData';\nimport SpeechSynthesisEvent from './SpeechSynthesisEvent';\nimport subscribeEvent from './subscribeEvent';\n\nfunction asyncDecodeAudioData(audioContext, arrayBuffer) {\n return new Promise((resolve, reject) => {\n const promise = audioContext.decodeAudioData(arrayBuffer, resolve, reject);\n\n // Newer implementation of \"decodeAudioData\" will return a Promise\n promise && typeof promise.then === 'function' && resolve(promise);\n });\n}\n\nfunction playDecoded(audioContext, audioBuffer, source) {\n return new Promise((resolve, reject) => {\n const audioContextClosed = new EventAsPromise();\n const sourceEnded = new EventAsPromise();\n const unsubscribe = subscribeEvent(\n audioContext,\n 'statechange',\n ({ target: { state } }) => state === 'closed' && audioContextClosed.eventListener()\n );\n\n try {\n source.buffer = audioBuffer;\n // \"ended\" may not fire if the underlying AudioContext is closed prematurely\n source.onended = sourceEnded.eventListener;\n\n source.connect(audioContext.destination);\n source.start(0);\n\n Promise.race([audioContextClosed.upcoming(), sourceEnded.upcoming()]).then(resolve);\n } catch (err) {\n reject(err);\n } finally {\n unsubscribe();\n }\n });\n}\n\nclass SpeechSynthesisUtterance extends EventTarget {\n constructor(text) {\n super();\n\n this._lang = null;\n this._pitch = 1;\n this._rate = 1;\n this._voice = null;\n this._volume = 1;\n\n this.text = text;\n\n this.onboundary = null;\n this.onend = null;\n this.onerror = null;\n this.onmark = null;\n this.onpause = null;\n this.onresume = null;\n this.onstart = null;\n }\n\n get lang() {\n return this._lang;\n }\n\n set lang(value) {\n this._lang = value;\n }\n\n get onboundary() {\n return getEventAttributeValue(this, 'boundary');\n }\n\n set onboundary(value) {\n setEventAttributeValue(this, 'boundary', value);\n }\n\n get onend() {\n return getEventAttributeValue(this, 'end');\n }\n\n set onend(value) {\n setEventAttributeValue(this, 'end', value);\n }\n\n get onerror() {\n return getEventAttributeValue(this, 'error');\n }\n\n set onerror(value) {\n setEventAttributeValue(this, 'error', value);\n }\n\n get onmark() {\n return getEventAttributeValue(this, 'mark');\n }\n\n set onmark(value) {\n setEventAttributeValue(this, 'mark', value);\n }\n\n get onpause() {\n return getEventAttributeValue(this, 'pause');\n }\n\n set onpause(value) {\n setEventAttributeValue(this, 'pause', value);\n }\n\n get onresume() {\n return getEventAttributeValue(this, 'resume');\n }\n\n set onresume(value) {\n setEventAttributeValue(this, 'resume', value);\n }\n\n get onstart() {\n return getEventAttributeValue(this, 'start');\n }\n\n set onstart(value) {\n setEventAttributeValue(this, 'start', value);\n }\n\n get pitch() {\n return this._pitch;\n }\n\n set pitch(value) {\n this._pitch = value;\n }\n\n get rate() {\n return this._rate;\n }\n\n set rate(value) {\n this._rate = value;\n }\n\n get voice() {\n return this._voice;\n }\n\n set voice(value) {\n this._voice = value;\n }\n\n get volume() {\n return this._volume;\n }\n\n set volume(value) {\n this._volume = value;\n }\n\n preload({ deploymentId, fetchCredentials, outputFormat }) {\n this.arrayBufferPromise = fetchSpeechData({\n fetchCredentials,\n deploymentId,\n lang: this.lang || window.navigator.language,\n outputFormat,\n pitch: this.pitch,\n rate: this.rate,\n text: this.text,\n voice: this.voice && this.voice.voiceURI,\n volume: this.volume\n });\n\n // We need to call \"catch\" to make sure the Promise is running.\n // We will ignore the reject result and handled in play() later.\n this.arrayBufferPromise.catch();\n }\n\n async play(audioContext) {\n try {\n // We should emit \"start\" event even if preload() failed.\n this.dispatchEvent(new SpeechSynthesisEvent('start'));\n\n // HACK: iOS requires bufferSourceNode to be constructed before decoding data.\n const source = audioContext.createBufferSource();\n const audioBuffer = await asyncDecodeAudioData(audioContext, await this.arrayBufferPromise);\n\n this._playingSource = source;\n\n await playDecoded(audioContext, audioBuffer, source);\n\n this._playingSource = null;\n this.dispatchEvent(new SpeechSynthesisEvent('end'));\n } catch (error) {\n // \"message\" is not in spec but to provide a friendly message.\n this.dispatchEvent(new ErrorEvent('error', { error: 'synthesis-failed', message: error.stack }));\n }\n }\n\n stop() {\n this._playingSource && this._playingSource.stop();\n }\n}\n\nexport default SpeechSynthesisUtterance;\n","const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\n// Use a lookup table to find the index.\nconst lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);\nfor (let i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n}\n\nexport const encode = (arraybuffer: ArrayBuffer): string => {\n let bytes = new Uint8Array(arraybuffer),\n i,\n len = bytes.length,\n base64 = '';\n\n for (i = 0; i < len; i += 3) {\n base64 += chars[bytes[i] >> 2];\n base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];\n base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];\n base64 += chars[bytes[i + 2] & 63];\n }\n\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + '=';\n } else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + '==';\n }\n\n return base64;\n};\n\nexport const decode = (base64: string): ArrayBuffer => {\n let bufferLength = base64.length * 0.75,\n len = base64.length,\n i,\n p = 0,\n encoded1,\n encoded2,\n encoded3,\n encoded4;\n\n if (base64[base64.length - 1] === '=') {\n bufferLength--;\n if (base64[base64.length - 2] === '=') {\n bufferLength--;\n }\n }\n\n const arraybuffer = new ArrayBuffer(bufferLength),\n bytes = new Uint8Array(arraybuffer);\n\n for (i = 0; i < len; i += 4) {\n encoded1 = lookup[base64.charCodeAt(i)];\n encoded2 = lookup[base64.charCodeAt(i + 1)];\n encoded3 = lookup[base64.charCodeAt(i + 2)];\n encoded4 = lookup[base64.charCodeAt(i + 3)];\n\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\n }\n\n return arraybuffer;\n};\n","/* eslint no-magic-numbers: [\"error\", { \"ignore\": [0, 1, 100] }] */\n\n// Cognitive Services does not support unsigned percentage\n// It must be converted into +/- first.\nfunction relativePercentage(value) {\n let relative = Math.round((value - 1) * 100);\n\n if (relative >= 0) {\n relative = '+' + relative;\n }\n\n return relative + '%';\n}\n\nexport default function buildSSML({ lang, pitch = 1, rate = 1, text, voice, volume }) {\n return `<speak version=\"1.0\" xml:lang=\"${lang}\">\n <voice xml:lang=\"${lang}\" name=\"${voice}\">\n <prosody pitch=\"${relativePercentage(pitch)}\" rate=\"${relativePercentage(rate)}\" volume=\"${relativePercentage(\n volume\n )}\">\n ${text}\n </prosody>\n </voice>\n</speak>`;\n}\n","const SPEAK_TAG_PATTERN = /^\\s*<speak(\\s|\\/?>)/u;\nconst XML_PROLOG_PATTERN = /^\\s*<\\?xml\\s/u;\n\nexport default function isSSML(text) {\n return SPEAK_TAG_PATTERN.test(text) || XML_PROLOG_PATTERN.test(text);\n}\n","import { decode } from 'base64-arraybuffer';\nimport buildSSML from './buildSSML';\nimport isSSML from './isSSML';\n\nconst DEFAULT_LANGUAGE = 'en-US';\nconst DEFAULT_OUTPUT_FORMAT = 'riff-16khz-16bit-mono-pcm';\nconst DEFAULT_VOICE = 'Microsoft Server Speech Text to Speech Voice (en-US, AriaNeural)';\nconst EMPTY_MP3_BASE64 =\n 'SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU3LjU2LjEwMQAAAAAAAAAAAAAA//tAwAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAACAAABhgC7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7//////////////////////////////////////////////////////////////////8AAAAATGF2YzU3LjY0AAAAAAAAAAAAAAAAJAUHAAAAAAAAAYYoRBqpAAAAAAD/+xDEAAPAAAGkAAAAIAAANIAAAARMQU1FMy45OS41VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7EMQpg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV';\n\nexport default async function ({\n deploymentId,\n fetchCredentials,\n lang = DEFAULT_LANGUAGE,\n outputFormat = DEFAULT_OUTPUT_FORMAT,\n pitch,\n rate,\n text,\n voice = DEFAULT_VOICE,\n volume\n}) {\n if (!text) {\n // If text is empty, play a short audio clip. This allows developers to easily prime the AudioContext object by playing an empty string.\n return decode(EMPTY_MP3_BASE64);\n }\n\n const { authorizationToken, region, speechSynthesisHostname, subscriptionKey } = await fetchCredentials();\n\n if ((authorizationToken && subscriptionKey) || (!authorizationToken && !subscriptionKey)) {\n throw new Error('Only \"authorizationToken\" or \"subscriptionKey\" should be set.');\n } else if ((region && speechSynthesisHostname) || (!region && !speechSynthesisHostname)) {\n throw new Error('Only \"region\" or \"speechSynthesisHostnamename\" should be set.');\n }\n\n const ssml = isSSML(text) ? text : buildSSML({ lang, pitch, rate, text, voice, volume });\n\n // Although calling encodeURI on hostname does not actually works, it fails faster and safer.\n const hostname =\n speechSynthesisHostname ||\n (deploymentId\n ? `${encodeURI(region)}.voice.speech.microsoft.com`\n : `${encodeURI(region)}.tts.speech.microsoft.com`);\n const search = deploymentId ? `?deploymentId=${encodeURI(deploymentId)}` : '';\n const url = `https://${hostname}/cognitiveservices/v1${search}`;\n\n const res = await fetch(url, {\n headers: {\n 'Content-Type': 'application/ssml+xml',\n 'X-Microsoft-OutputFormat': outputFormat,\n ...(authorizationToken\n ? {\n Authorization: `Bearer ${authorizationToken}`\n }\n : {\n 'Ocp-Apim-Subscription-Key': subscriptionKey\n })\n },\n method: 'POST',\n body: ssml\n });\n\n if (!res.ok) {\n throw new Error(`web-speech-cognitive-services: Failed to syntheis speech, server returned ${res.status}`);\n }\n\n return res.arrayBuffer();\n}\n","export default function subscribeEvent(target, name, handler) {\n target.addEventListener(name, handler);\n\n return () => target.removeEventListener(name, handler);\n}\n","import createSpeechSynthesisPonyfill from './TextToSpeech/createSpeechSynthesisPonyfill';\n\nexport default createSpeechSynthesisPonyfill;\n","/* global process */\n\nimport createSpeechRecognitionPonyfill, {\n createSpeechRecognitionPonyfillFromRecognizer\n} from './SpeechServices/SpeechToText';\nimport createSpeechSynthesisPonyfill from './SpeechServices/TextToSpeech';\nimport fetchAuthorizationToken from './SpeechServices/fetchAuthorizationToken';\n\nexport default function createSpeechServicesPonyfill(options = {}, ...args) {\n return {\n ...createSpeechRecognitionPonyfill(options, ...args),\n ...createSpeechSynthesisPonyfill(options, ...args)\n };\n}\n\nexport {\n createSpeechRecognitionPonyfill,\n createSpeechRecognitionPonyfillFromRecognizer,\n createSpeechSynthesisPonyfill,\n fetchAuthorizationToken\n};\n\nconst meta = document.createElement('meta');\n\nmeta.setAttribute('name', 'web-speech-cognitive-services');\n// @ts-ignore\nmeta.setAttribute('content', `version=${process.env.npm_package_version}`);\n\ndocument.head.appendChild(meta);\n","import { createSpeechRecognitionPonyfillFromRecognizer, createSpeechServicesPonyfill } from './index';\n\nglobalThis.WebSpeechCognitiveServices = {\n create: createSpeechServicesPonyfill,\n createSpeechRecognitionPonyfillFromRecognizer\n};\n"],"mappings":"4iBAAA,IAAAA,GAAAC,EAAAC,IAAA,cAEA,OAAO,eAAeA,GAAS,aAAc,CAC3C,MAAO,EACT,CAAC,EACDA,GAAQ,QAAUC,GAIlB,IAAIC,GACEC,GAAQ,IAAI,WAAW,EAAE,EAE/B,SAASF,IAAM,CAEb,GAAI,CAACC,KAEHA,GAAkB,OAAO,OAAW,KAAe,OAAO,iBAAmB,OAAO,gBAAgB,KAAK,MAAM,EAE3G,CAACA,IACH,MAAM,IAAI,MAAM,0GAA0G,EAI9H,OAAOA,GAAgBC,EAAK,CAC9B,ICxBA,IAAAC,GAAAC,EAAAC,IAAA,cAEA,OAAO,eAAeA,GAAS,aAAc,CAC3C,MAAO,EACT,CAAC,EACDA,GAAQ,QAAU,OAClB,IAAIC,GAAW,sHACfD,GAAQ,QAAUC,KCPlB,IAAAC,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EACAA,EACA,EAAK,EACb,IAAK,kCACD,OAAO,IAAIX,EACPF,EAAA,eAAe,IACf,EACA,KACA,KACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,kCACD,OAAO,IAAIX,EACPF,EAAA,eAAe,IACf,EACA,KACA,KACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,kCACD,OAAO,IAAIX,EACPF,EAAA,eAAe,IACf,EACA,KACA,MACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,mCACD,OAAO,IAAIX,EACPF,EAAA,eAAe,IACf,EACA,KACA,MACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,gCACD,OAAO,IAAIX,EACPF,EAAA,eAAe,UACf,EACA,KACA,KACA,EACA,GACAa,EACAA,EACA,EAAK,EAEb,IAAK,2BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,IACf,EACA,IACA,KACA,EACA,GACAa,EACA,0BACA,EAAI,EACZ,IAAK,4BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,IACf,EACA,KACA,KACA,EACA,GACAa,EACA,2BACA,EAAI,EACZ,IAAK,4BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,MACf,EACA,IACA,IACA,EACA,EACAa,EACA,2BACA,EAAI,EACZ,IAAK,2BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,IACf,EACA,KACA,KACA,EACA,GACAa,EACA,2BACA,EAAK,EACb,IAAK,2BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,IACf,EACA,KACA,KACA,EACA,GACAa,EACA,2BACA,EAAK,EACb,IAAK,0BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,IACf,EACA,IACA,KACA,EACA,GACAa,EACA,0BACA,EAAK,EACb,IAAK,4BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,SACf,EACA,KACA,KACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,4BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,SACf,EACA,KACA,KACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,2BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,IACf,EACA,KACA,KACA,EACA,GACAa,EACA,2BACA,EAAK,EACb,IAAK,4BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,IACf,EACA,KACA,KACA,EACA,GACAa,EACA,2BACA,EAAI,EACZ,IAAK,kCACD,OAAO,IAAIX,EACPF,EAAA,eAAe,IACf,EACA,KACA,MACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,mCACD,OAAO,IAAIX,EACPF,EAAA,eAAe,IACf,EACA,KACA,MACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,4BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,SACf,EACA,KACA,KACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,6BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,UACf,EACA,KACA,IACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,6BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,UACf,EACA,KACA,IACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,oCACD,OAAO,IAAIX,EACPF,EAAA,eAAe,UACf,EACA,KACA,IACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,qCACD,OAAO,IAAIX,EACPF,EAAA,eAAe,KACf,EACA,KACA,IACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,qCACD,OAAO,IAAIX,EACPF,EAAA,eAAe,KACf,EACA,KACA,IACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,qCACD,OAAO,IAAIX,EACPF,EAAA,eAAe,KACf,EACA,KACA,IACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,8BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,KACf,EACA,KACA,KACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,8BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,KACf,EACA,KACA,IACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,gCACD,OAAO,IAAIX,EACPF,EAAA,eAAe,UACf,EACA,KACA,KACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,0BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,KACf,EACA,IACA,IACA,EACA,EACAa,EACAA,EACA,EAAK,EACb,IAAK,2BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,KACf,EACA,IACA,IACA,EACA,EACAa,EACA,0BACA,EAAI,EACZ,IAAK,6BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,IACf,EACA,MACA,MACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,8BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,IACf,EACA,MACA,MACA,EACA,GACAa,EACA,6BACA,EAAI,EACZ,IAAK,6BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,IACf,EACA,MACA,MACA,EACA,GACAa,EACAA,EACA,EAAK,EACb,IAAK,8BACD,OAAO,IAAIX,EACPF,EAAA,eAAe,IACf,EACA,MACA,MACA,EACA,GACAa,EACA,6BACA,EAAI,EACZ,IAAK,4BACL,QACI,OAAO,IAAIX,EACPF,EAAA,eAAe,IACf,EACA,KACA,KACA,EACA,GACA,4BACA,2BACA,EAAI,EAEpB,CAEO,OAAO,wBAAsB,CAChC,OAAOE,EAAsB,sCACxB,OAAO,OAAW,IAAe,kCAAoC,2BAA2B,CACzG,CAgBA,IAAW,WAAS,CAChB,OAAO,KAAK,YAChB,CAQA,IAAW,QAAM,CACb,GAAI,KAAK,UACL,OAAO,KAAK,UAGpB,CASO,aAAaY,EAAmB,CACnC,GAAI,KAAK,aAAc,CACnB,IAAMC,EAAO,IAAI,SAAS,KAAK,UAAU,EACzCA,EAAK,UAAU,EAAGD,EAAc,KAAK,WAAW,WAAa,EAAG,EAAI,EACpEC,EAAK,UAAU,GAAID,EAAa,EAAI,EAE5C,CAQA,IAAW,0BAAwB,CAC/B,OAAO,KAAK,2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AAO,SAAS,cAAc,MAAM,EAE1CA,GAAK,aAAa,OAAQ,+BAA+B,EAEzDA,GAAK,aAAa,UAAW,4BAA4C,EAEzE,SAAS,KAAK,YAAYA,EAAI,EC1B9B,WAAW,2BAA6B,CACtC,OAAQC,GACR,8CAAAC,EACF","names":["require_rng","__commonJSMin","exports","rng","getRandomValues","rnds8","require_regex","__commonJSMin","exports","_default","require_validate","__commonJSMin","exports","_regex","_interopRequireDefault","obj","validate","uuid","_default","require_stringify","__commonJSMin","exports","unsafeStringify","_validate","_interopRequireDefault","obj","byteToHex","arr","offset","stringify","uuid","_default","require_v1","__commonJSMin","exports","_rng","_interopRequireDefault","_stringify","obj","_nodeId","_clockseq","_lastMSecs","_lastNSecs","v1","options","buf","offset","i","b","node","clockseq","seedBytes","msecs","nsecs","dt","tl","tmh","n","_default","require_parse","__commonJSMin","exports","_validate","_interopRequireDefault","obj","parse","uuid","v","arr","_default","require_v35","__commonJSMin","exports","v35","_stringify","_parse","_interopRequireDefault","obj","stringToBytes","str","bytes","i","DNS","URL","name","version","hashfunc","generateUUID","value","namespace","buf","offset","_namespace","require_md5","__commonJSMin","exports","md5","bytes","msg","i","md5ToHexEncodedArray","wordsToMd5","bytesToWords","input","output","length32","hexTab","x","hex","getOutputLength","inputLength8","len","a","b","c","d","olda","oldb","oldc","oldd","md5ff","md5gg","md5hh","md5ii","safeAdd","length8","y","lsw","bitRotateLeft","num","cnt","md5cmn","q","s","t","_default","require_v3","__commonJSMin","exports","_v","_interopRequireDefault","_md","obj","v3","_default","require_native","__commonJSMin","exports","randomUUID","_default","require_v4","__commonJSMin","exports","_native","_interopRequireDefault","_rng","_stringify","obj","v4","options","buf","offset","rnds","i","_default","require_sha1","__commonJSMin","exports","f","s","x","y","z","ROTL","n","sha1","bytes","K","H","msg","i","l","N","M","arr","j","W","t","a","b","c","e","T","_default","require_v5","__commonJSMin","exports","_v","_interopRequireDefault","_sha","obj","v5","_default","require_nil","__commonJSMin","exports","_default","require_version","__commonJSMin","exports","_validate","_interopRequireDefault","obj","version","uuid","_default","require_commonjs_browser","__commonJSMin","exports","_nil","_parse","_stringify","_v","_v2","_v3","_v4","_validate","_version","_interopRequireDefault","obj","uuid_1","createGuid","exports","createNoDashGuid","Guid_js_1","EventType","exports","PlatformEvent","eventName","eventType","PlatformEvent_js_1","AudioSourceEvent","eventName","audioSourceId","eventType","exports","AudioSourceInitializingEvent","AudioSourceReadyEvent","AudioSourceOffEvent","AudioSourceErrorEvent","error","AudioStreamNodeEvent","audioNodeId","AudioStreamNodeAttachingEvent","AudioStreamNodeAttachedEvent","AudioStreamNodeDetachedEvent","AudioStreamNodeErrorEvent","PlatformEvent_js_1","ServiceEvent","eventName","jsonstring","eventType","exports","ConnectionEvent","connectionId","ConnectionStartEvent","uri","headers","ConnectionEstablishedEvent","ConnectionClosedEvent","statusCode","reason","ConnectionErrorEvent","message","type","ConnectionEstablishErrorEvent","statuscode","ConnectionMessageReceivedEvent","networkReceivedTimeISO","ConnectionMessageSentEvent","networkSentTimeISO","ArgumentNullError","argumentName","exports","InvalidOperationError","error","ObjectDisposedError","objectName","Error_js_1","Guid_js_1","MessageType","exports","ConnectionMessage","messageType","body","headers","id","ConnectionOpenResponse","statusCode","reason","exports","DeferralMap","id","deferral","result","error","exports","PlatformEvent_js_1","DialogEvent","eventName","eventType","exports","SendingAgentContextMessageEvent","agentConfig","Error_js_1","Guid_js_1","EventSource","metadata","event","paramName","eventId","onEventCallback","id","listener","e","exports","Error_js_1","EventSource_js_1","Events","_Events","eventSource","exports","ConnectionState","exports","require_IErrorMessages","__commonJSMin","exports","Error_js_1","List","_List","list","item","itemIndex","index","count","removedElements","addedCallback","subscriptionId","removedCallback","disposedCallback","seperator","cloneCopy","val","callback","i","selectList","filteredList","compareFn","orderedArray","a","b","array","reason","subscriptions","exports","PromiseState","exports","PromiseResult","promiseResultEventSource","result","error","PromiseResultEventSource","onSetResult","onSetError","Deferred","resolve","reject","Sink","i","errorHandler","successCallback","errorCallback","e","marshalPromiseToCallbacks","promise","cb","err","val","typedError","Error_js_1","List_js_1","Promise_js_1","SubscriberType","Queue","list","item","resolve","promise","val","deferredSubscriber","pendingItemProcessor","reason","subs","detachable","promiseArray","wrapper","lists","subscriber","dequeuedItem","exports","ConnectionMessage_js_1","Error_js_1","Guid_js_1","RawWebsocketMessage","messageType","payload","id","exports","RiffPcmEncoder","actualSampleRate","desiredSampleRate","actualAudioFrame","audioFrame","audioLength","buffer","view","offset","str","i","input","srcFrame","srcRate","dstRate","ratio","dstLength","dstFrame","srcOffset","dstOffset","nextSrcOffset","accum","count","exports","Error_js_1","Guid_js_1","Queue_js_1","Stream","streamId","streamChunk","exports","TranslationStatus","exports","Exports_js_1","ChunkedArrayBufferStream","targetChunkSize","streamId","chunk","bytesCopiedFromBuffer","bytesToCopy","targetView","sourceView","exports","Timeout","_Timeout","scheduledTimeoutFunctions","unhandledRequests","workerUrl","worker","data","timerId","idOrFunc","unhandledTimerId","id","message","func","delay","exports","PlatformEvent_js_1","OCSPEvent","eventName","eventType","signature","exports","OCSPMemoryCacheHitEvent","OCSPCacheMissEvent","OCSPDiskCacheHitEvent","OCSPCacheUpdateNeededEvent","OCSPMemoryCacheStoreEvent","OCSPDiskCacheStoreEvent","OCSPCacheUpdateCompleteEvent","OCSPStapleReceivedEvent","OCSPWSUpgradeStartedEvent","serialNumber","OCSPCacheEntryExpiredEvent","expireTime","OCSPCacheEntryNeedsRefreshEvent","startTime","OCSPCacheHitEvent","OCSPVerificationFailedEvent","error","OCSPCacheFetchErrorEvent","OCSPResponseRetrievedEvent","OCSPCacheUpdateErrorEvent","Exports_js_1","BackgroundEvent","error","exports","__exportStar","exports","TranslationStatus_js_1","HeaderNames","exports","AuthInfo","headerName","token","exports","Exports_js_1","HeaderNames_js_1","IAuthentication_js_1","CognitiveSubscriptionKeyAuthentication","subscriptionKey","authFetchEventId","exports","Exports_js_1","IAuthentication_js_1","HeaderNames_js_1","CognitiveTokenAuthentication","_CognitiveTokenAuthentication","fetchCallback","fetchOnExpiryCallback","authFetchEventId","token","exports","Exports_js_1","exports","Contracts","_Contracts","param","name","maxLength","minLength","isDisposed","array","item","exports","fs","__importStar","LogLevel_js_1","Contracts_js_1","ConsoleLoggingListener","logLevelFilter","path","enableOutput","event","log","logFragments","e","prop","value","valueToLog","exports","AudioFormatTag","exports","AudioStreamFormat","AudioStreamFormatImpl","samplesPerSecond","bitsPerSample","channels","format","_AudioStreamFormatImpl","samplesPerSec","isWavFormat","view","sampleRate","AudioContext","offset","str","i","Exports_js_1","Exports_js_2","AudioStreamFormat_js_1","exports","MicAudioSource","_MicAudioSource","privRecorder","deviceId","audioSourceId","mediaStream","error","typedError","nav","getUserMedia","constraints","successCallback","errorCallback","next","errorMsg","reason","audioNodeId","stream","streamId","label","name","value","defaultMicrophoneName","microphoneDeviceId","deferred","devices","device","event","hasClose","Exports_js_1","Exports_js_2","AudioStreamFormat_js_1","FileAudioSource","file","filename","audioSourceId","errorMsg","audioNodeId","stream","streamId","result","header","headerResult","processHeader","view","getWord","index","formatSize","channelCount","sampleRate","bitsPerSample","pos","reader","event","h","onerror","error","format","chunk","processFile","buff","ev","fileBuffer","c","e","exports","Exports_1","PcmRecorder","stopInputOnRelease","context","mediaStream","outputStream","waveStreamEncoder","micInput","attachScriptProcessor","scriptNode","bufferSize","audioSampleRate","event","inputFrame","waveFrame","skipAudioWorklet","workletScript","blob","workletNode","ev","err","track","url","exports","net","__importStar","tls","agent_base_1","__importDefault","https_proxy_agent_1","ws_1","HeaderNames_js_1","Exports_js_1","WebsocketMessageAdapter","_WebsocketMessageAdapter","uri","connectionId","messageFormatter","proxyInfo","headers","enableCompression","options","protocol","reason","error","networkReceivedTime","deferred","rawMessage","connectionMessage","message","messageSendStatusDeferral","messageSendDeferral","sendItem","e","code","closeReason","pendingSendItem","sendError","event","agent","httpProxyOptions","request","socketPromise","baseAgent","resolve","reject","socket","exports","Exports_js_1","WebsocketMessageAdapter_js_1","WebsocketConnection","uri","queryParameters","headers","messageFormatter","proxyInfo","enableCompression","connectionId","queryParams","i","paramName","key","val","headerName","message","exports","ReplayableAudioNode","audioSource","bytesPerSecond","offsetToSeek","bytesToSeek","i","retVal","result","BufferEntry","offset","value","startOffset","endOffset","exports","chunk","serial","byteOffset","fs","__importStar","Contracts_js_1","AudioFileWriter","filename","format","headerOffset","buffer","exports","Exports_js_1","Exports_js_2","Guid_js_1","Exports_js_3","AudioStreamFormat_js_1","AudioInputStream","format","PushAudioInputStream","callback","PullAudioInputStream","exports","PushAudioInputStreamImpl","dataBuffer","audioNodeId","stream","event","arrayBuffer","buf","view","i","PullAudioInputStreamImpl","totalBytes","transmitBuff","readBuff","pulledBytes","SpeechSynthesisOutputFormat","exports","SpeechSynthesisOutputFormat_js_1","AudioStreamFormat_js_1","AudioOutputFormatImpl","_AudioOutputFormatImpl","formatTag","channels","samplesPerSec","avgBytesPerSec","blockAlign","bitsPerSample","audioFormatString","requestAudioFormatString","hasHeader","speechSynthesisOutputFormat","speechSynthesisOutputFormatString","audioLength","view","audio","tmp","exports","Exports_js_1","Contracts_js_1","AudioOutputFormat_js_1","AudioOutputStream","PullAudioOutputStream","exports","PullAudioOutputStreamImpl","format","dataBuffer","intView","totalBytes","chunk","tmpBuffer","PushAudioOutputStream","callback","PushAudioOutputStreamImpl","buffer","Exports_js_1","Contracts_js_1","Exports_js_2","AudioFileWriter_js_1","AudioInputStream_js_1","AudioOutputStream_js_1","AudioConfig","_AudioConfig","pcmRecorder","AudioConfigImpl","deviceId","file","name","audioStream","AudioOutputConfigImpl","player","filename","exports","source","cb","err","error","audioNodeId","value","def","destination","format","buffer","CancellationReason","exports","PullAudioInputStreamCallback","exports","PushAudioOutputStreamCallback","exports","Contracts_js_1","KeywordRecognitionModel","fileName","file","exports","SessionEventArgs","sessionId","exports","Exports_js_1","RecognitionEventArgs","offset","sessionId","exports","OutputFormat","exports","Exports_js_1","IntentRecognitionEventArgs","result","offset","sessionId","exports","RecognitionResult","resultId","reason","text","duration","offset","language","languageDetectionConfidence","errorDetails","json","properties","exports","Exports_js_1","SpeechRecognitionResult","resultId","reason","text","duration","offset","language","languageDetectionConfidence","speakerId","errorDetails","json","properties","exports","Exports_js_1","IntentRecognitionResult","intentId","resultId","reason","text","duration","offset","language","languageDetectionConfidence","errorDetails","json","properties","exports","Contracts_js_1","LanguageUnderstandingModel","uri","langModelImp","LanguageUnderstandingModelImpl","firstDot","lastSegment","appId","subscriptionKey","region","exports","Exports_js_1","SpeechRecognitionEventArgs","result","offset","sessionId","exports","ConversationTranscriptionEventArgs","MeetingTranscriptionEventArgs","Exports_js_1","CancellationEventArgsBase","reason","errorDetails","errorCode","offset","sessionId","exports","CancellationEventArgsBase_js_1","SpeechRecognitionCanceledEventArgs","exports","Exports_js_1","TranslationRecognitionEventArgs","result","offset","sessionId","exports","Exports_js_1","TranslationSynthesisEventArgs","result","sessionId","exports","Exports_js_1","TranslationRecognitionResult","_TranslationRecognitionResult","translations","resultId","reason","text","duration","offset","language","languageDetectionConfidence","errorDetails","json","properties","result","exports","TranslationSynthesisResult","reason","audio","exports","ResultReason","exports","Exports_js_1","Contracts_js_1","Exports_js_2","SpeechConfig","subscriptionKey","region","speechImpl","SpeechConfigImpl","endpoint","hostName","authorizationToken","exports","_SpeechConfigImpl","value","name","def","proxyHostName","proxyPort","proxyUserName","proxyPassword","currentProperties","profanity","ret","language","voice","format","Exports_js_1","Contracts_js_1","Exports_js_2","SpeechTranslationConfig","subscriptionKey","region","ret","SpeechTranslationConfigImpl","authorizationToken","hostName","speechImpl","endpoint","exports","value","languages","proxyHostName","proxyPort","proxyUserName","proxyPassword","name","def","currentProperties","profanity","language","voice","format","Exports_js_1","PropertyCollection","_PropertyCollection","key","def","keyToUse","value","clonedMap","n","destinationCollection","exports","PropertyId","exports","Exports_js_1","Exports_js_2","Contracts_js_1","Exports_js_3","Recognizer","_Recognizer","audioConfig","properties","connectionFactory","cb","errorCb","disposing","enabled","osPlatform","osName","osVersion","recognizerConfig","recognitionMode","ret","result","subscriptionKey","authorizationToken","exports","Exports_js_1","Exports_js_2","Contracts_js_1","Exports_js_3","SpeechRecognizer","_SpeechRecognizer","speechConfig","audioConfig","speechConfigImpl","autoDetectSourceLanguageConfig","token","cb","err","model","errorCb","disposing","authentication","connectionFactory","recognizerConfig","configImpl","exports","Exports_js_1","Exports_js_2","Contracts_js_1","Exports_js_3","IntentRecognizer","speechConfig","audioConfig","configImpl","value","cb","err","context","model","e","simplePhrase","intentId","intentName","modelImpl","errorCb","authentication","connectionFactory","recognizerConfig","audioImpl","disposing","appId","region","subscriptionKey","refGrammers","addedLmIntent","grammer","exports","VoiceProfileType","exports","HeaderNames_js_1","Exports_js_1","PropertyCollection_js_1","PropertyId_js_1","ConnectionMessage","exports","ConnectionMessageImpl","message","header","key","Exports_js_1","Exports_js_2","ConnectionMessage_js_1","Contracts_js_1","Exports_js_3","Connection","_Connection","recognizer","recoBase","ret","synthesizer","synthBase","cb","err","path","propertyName","propertyValue","payload","success","error","connectionEvent","exports","Exports_js_1","Exports_js_2","Connection_js_1","Contracts_js_1","Exports_js_3","TranslationRecognizer","_TranslationRecognizer","speechConfig","audioConfig","connectionFactory","configImpl","speechTranslationConfig","autoDetectSourceLanguageConfig","speechTranslationConfigImpl","value","cb","err","lang","languages","index","errorCb","disposing","authentication","recognizerConfig","conn","exports","Exports_js_1","Translations","key","def","value","exports","NoMatchReason","exports","Exports_js_1","Exports_js_2","NoMatchDetails","_NoMatchDetails","reason","result","simpleSpeech","exports","TranslationRecognitionCanceledEventArgs","sessionid","cancellationReason","errorDetails","errorCode","result","exports","Exports_js_1","IntentRecognitionCanceledEventArgs","reason","errorDetails","errorCode","result","offset","sessionId","exports","CancellationDetailsBase","reason","errorDetails","errorCode","exports","Exports_js_1","CancellationDetailsBase_js_1","Exports_js_2","CancellationDetails","_CancellationDetails","reason","errorDetails","errorCode","result","simpleSpeech","exports","CancellationErrorCode","exports","Exports_js_1","ConnectionEventArgs","exports","Exports_js_1","ServiceEventArgs","json","name","sessionId","exports","PhraseListGrammar","_PhraseListGrammar","recogBase","recognizer","recoBase","phrase","phrases","exports","Contracts_js_1","Exports_js_1","DialogServiceConfig","value","exports","DialogServiceConfigImpl","name","def","proxyHostName","proxyPort","proxyUserName","proxyPassword","channel","Contracts_js_1","DialogServiceConfig_js_1","Exports_js_1","BotFrameworkConfig","subscription","region","botId","botFrameworkConfig","authorizationToken","host","subscriptionKey","resolvedHost","endpoint","exports","Contracts_js_1","DialogServiceConfig_js_1","Exports_js_1","CustomCommandsConfig","applicationId","subscription","region","customCommandsConfig","authorizationToken","value","exports","QueryParameterNames","exports","Exports_js_1","Exports_js_2","QueryParameterNames_js_1","ConnectionFactoryBase","region","config","queryParams","endpoint","parameterName","propertyId","serviceProperties","value","propId","exports","Exports_js_1","Exports_js_2","Exports_js_3","ConnectionFactoryBase_js_1","Exports_js_4","HeaderNames_js_1","QueryParameterNames_js_1","DialogConnectionFactory","_DialogConnectionFactory","config","authInfo","connectionId","applicationId","dialogType","region","language","requestTurnStatus","queryParams","resourceInfix","version","headers","endpoint","hostSuffix","host","enableCompression","exports","DialogConnectorFactory_js_1","Exports_js_1","Exports_js_2","Contracts_js_1","Exports_js_3","PropertyId_js_1","DialogServiceConnector","dialogConfig","audioConfig","dialogServiceConfigImpl","agentConfig","cb","err","token","speechActivityTemplate","retPromise","ret","e","activity","errCb","disposing","speechConfig","authentication","connectionFactory","recognizerConfig","audioSource","exports","ActivityReceivedEventArgs","activity","audioStream","exports","TurnStatusResponsePayload","_TurnStatusResponsePayload","json","exports","TurnStatusPayload_js_1","TurnStatusReceivedEventArgs","turnStatus","exports","ServicePropertyChannel","exports","ProfanityOption","exports","Error_js_1","Exports_js_1","AudioStreamFormat_js_1","BaseAudioPlayer","audioFormat","newAudioData","cb","err","audioData","newSamplesData","e","error","timerPeriod","maxValue","float32Data","i","channelCount","bufferSource","frameCount","audioBuffer","channel","channelOffset","source","destination","newBuffer","exports","ConnectionMessageEventArgs","message","exports","VoiceProfile","profileId","profileType","exports","Exports_js_1","Exports_js_2","VoiceProfileEnrollmentResult","_VoiceProfileEnrollmentResult","reason","json","statusText","results","item","result","exports","VoiceProfileEnrollmentCancellationDetails","_VoiceProfileEnrollmentCancellationDetails","errorDetails","errorCode","Exports_js_1","Contracts_js_1","Exports_js_2","VoiceProfileResult","reason","statusText","exports","VoiceProfileCancellationDetails","_VoiceProfileCancellationDetails","errorDetails","errorCode","result","Contracts_js_1","Exports_js_1","VoiceProfilePhraseResult","reason","statusText","type","phraseArray","exports","Exports_js_1","AudioConfig_js_1","Contracts_js_1","Exports_js_2","VoiceProfileClient","speechConfig","speechConfigImpl","token","profileType","lang","profileIds","profile","audioConfig","configImpl","authentication","connectionFactory","recognizerConfig","audioImpl","disposing","result","successReason","exports","Exports_js_1","Contracts_js_1","Exports_js_2","SpeakerRecognizer","speechConfig","audioConfig","configImpl","token","model","result","authentication","connectionFactory","recognizerConfig","audioImpl","disposing","exports","Contracts_js_1","Exports_js_1","SpeakerIdentificationModel","_SpeakerIdentificationModel","profiles","profile","exports","Contracts_js_1","Exports_js_1","SpeakerVerificationModel","_SpeakerVerificationModel","profile","exports","LanguageIdMode","exports","Exports_js_1","Contracts_js_1","Exports_js_2","LanguageIdMode_js_1","AutoDetectSourceLanguageConfig","_AutoDetectSourceLanguageConfig","config","languages","configs","autoConfig","langs","customProperty","mode","exports","Contracts_js_1","AutoDetectSourceLanguageResult","_AutoDetectSourceLanguageResult","language","languageDetectionConfidence","result","exports","Contracts_js_1","SourceLanguageConfig","_SourceLanguageConfig","language","endpointId","exports","Exports_js_1","Exports_js_2","SpeakerRecognitionResultType","exports","SpeakerRecognitionResult","response","resultReason","cancellationErrorCode","errorDetails","resultType","SpeakerRecognitionCancellationDetails","_SpeakerRecognitionCancellationDetails","reason","errorCode","result","Exports_js_1","Exports_js_2","Contracts_js_1","Exports_js_3","Conversation","speechConfig","arg2","arg3","arg4","conversationImpl","cb","err","ConversationImpl","error","exports","id","e","r","updatedParticipant","p","newParticipant","ejectedParticipant","nickname","hostNickname","configImpl","convId","part","props","key","val","value","conversationTranslator","token","room","participant","conversationId","lang","userId","participantId","message","languages","recognizer","conversationInfo","dispose","typedError","includeHost","participants","isMuted","isLocked","ConversationCommon","audioConfig","cb","err","e","error","typedError","exports","Exports_js_1","ConversationExpirationEventArgs","expirationTime","sessionId","exports","Exports_js_1","ConversationParticipantsChangedEventArgs","reason","participants","sessionId","exports","CancellationEventArgsBase_js_1","ConversationTranslationCanceledEventArgs","exports","Exports_js_1","ConversationTranslationEventArgs","result","offset","sessionId","exports","TranslationRecognitionResult_js_1","ConversationTranslationResult","participantId","translations","originalLanguage","resultId","reason","text","duration","offset","errorDetails","json","properties","exports","StringUtils","format","replacements","formatted","key","appendToFormatted","str","appendToKey","appendFunc","i","c","next","exports","Exports_js_1","StringUtils_js_1","Contracts_js_1","Exports_js_2","HeaderNames_js_1","QueryParameterNames_js_1","ConnectionFactoryBase_js_1","Exports_js_3","ConversationTranslatorConnectionFactory","_ConversationTranslatorConnectionFactory","convGetter","config","authInfo","connectionId","isVirtMicArrayEndpoint","convInfo","region","replacementValues","endpointUrl","queryParams","headers","parsedUrl","val","key","connFactory","enableCompression","exports","Exports_js_1","ConversationTranslatorConnectionFactory_js_1","Exports_js_2","Contracts_js_1","Exports_js_3","Conversation_js_1","Exports_js_4","SpeechState","exports","ConversationTranslationRecognizer","speechConfig","audioConfig","translator","convGetter","tr","e","newState","token","error","cancelEvent","ConversationTranslator","name","value","currentProperties","conversation","nickname","param1","param2","param3","lang","propertyIdsToCopy","prop","key","result","cb","err","message","resolve","reject","reason","success","Exports_js_1","Exports_js_2","Contracts_js_1","Exports_js_3","ConversationTranscriber","_ConversationTranscriber","speechConfig","audioConfig","speechConfigImpl","autoDetectSourceLanguageConfig","token","cb","err","errorCb","disposing","authentication","connectionFactory","recognizerConfig","configImpl","exports","Exports_js_1","User","userId","exports","Participant","_Participant","id","avatar","displayName","isHost","isMuted","isUsingTts","preferredLanguage","voice","language","ParticipantChangedReason","exports","Exports_js_1","Exports_js_2","Contracts_js_1","Exports_js_3","Meeting","speechConfig","meetingId","arg3","arg4","meetingImpl","MeetingImpl","exports","id","e","r","updatedParticipant","p","newParticipant","ejectedParticipant","nickname","configImpl","convId","part","props","key","val","value","cb","err","room","error","participant","lang","userId","participantId","message","languages","recognizer","meetingInfo","dispose","typedError","includeHost","participants","isMuted","isLocked","CancellationEventArgsBase_js_1","MeetingTranscriptionCanceledEventArgs","exports","Exports_js_1","Exports_js_2","Contracts_js_1","Exports_js_3","Exports_js_4","MeetingTranscriber","audioConfig","token","meeting","cb","err","meetingImpl","errorCb","disposing","exports","Exports_js_1","ConversationTranscriptionResult","resultId","reason","text","duration","offset","language","languageDetectionConfidence","speakerId","errorDetails","json","properties","exports","Conversation_js_1","exports","ConversationCommon_js_1","ConversationExpirationEventArgs_js_1","ConversationParticipantsChangedEventArgs_js_1","ConversationTranslationCanceledEventArgs_js_1","ConversationTranslationEventArgs_js_1","ConversationTranslationResult_js_1","ConversationTranslator_js_1","ConversationTranscriber_js_1","IParticipant_js_1","ParticipantChangedReason_js_1","Meeting_js_1","MeetingTranscriptionCanceledEventArgs_js_1","MeetingTranscriber_js_1","ConversationTranscriptionResult_js_1","Exports_js_1","Exports_js_2","Contracts_js_1","Exports_js_3","Synthesizer","_Synthesizer","speechConfig","speechConfigImpl","token","text","languageToDefaultVoice","language","voice","ssml","disposing","request","osPlatform","osName","osVersion","synthesizerConfig","subscriptionKey","authentication","authorizationToken","exports","SynthesisRequest","requestId","isSSML","cb","err","dataStream","Exports_js_1","Exports_js_2","AudioFileWriter_js_1","AudioOutputFormat_js_1","AudioOutputStream_js_1","Contracts_js_1","Exports_js_3","Synthesizer_js_1","SpeechSynthesizer","_SpeechSynthesizer","speechConfig","audioConfig","autoDetectSourceLanguageConfig","speechConfigImpl","text","cb","err","stream","ssml","locale","authentication","connectionFactory","synthesizerConfig","IsSsml","dataStream","requestId","audioDestination","e","error","typedError","response","json","item","exports","SynthesisResult","resultId","reason","errorDetails","properties","exports","Exports_js_1","SpeechSynthesisResult","resultId","reason","audioData","errorDetails","properties","audioDuration","exports","SpeechSynthesisEventArgs","result","exports","SpeechSynthesisWordBoundaryEventArgs","audioOffset","duration","text","wordLength","textOffset","boundaryType","exports","SpeechSynthesisBookmarkEventArgs","audioOffset","text","exports","SpeechSynthesisVisemeEventArgs","audioOffset","visemeId","animation","exports","SpeechSynthesisBoundaryType","exports","Exports_js_1","SynthesisVoicesResult","requestId","json","errorDetails","item","exports","SynthesisVoiceGender","exports","SynthesisVoiceType","GENDER_LOOKUP","VoiceInfo","json","style","Exports_js_1","AudioOutputStream_js_1","AudioStreamFormat_js_1","MediaDurationPlaceholderSeconds","AudioFormatToMimeType","SpeakerAudioDestination","audioDestinationId","buffer","cb","err","error","receivedAudio","audioBlob","format","mimeType","reason","volume","binary","exports","CancellationEventArgsBase_js_1","ConversationTranscriptionCanceledEventArgs","exports","CancellationEventArgsBase_js_1","MeetingTranscriptionCanceledEventArgs","exports","PronunciationAssessmentGradingSystem","exports","PronunciationAssessmentGranularity","exports","Contracts_js_1","Exports_js_1","PronunciationAssessmentConfig","_PronunciationAssessmentConfig","referenceText","gradingSystem","granularity","enableMiscue","json","config","recognizer","recoBase","phonemeAlphabet","enableMiscueString","nbestPhonemeCount","enableProsodyAssessment","topic","jsonString","paramsJson","exports","Contracts_js_1","Exports_js_1","ContentAssessmentResult","detailResult","exports","PronunciationAssessmentResult","_PronunciationAssessmentResult","jsonString","j","result","json","Contracts_js_1","Exports_js_1","AvatarConfig","character","style","videoFormat","value","exports","AvatarEventTypes","exports","AvatarEventArgs","audioOffset","description","Exports_js_1","Exports_js_2","ConnectionFactoryBase_js_1","Exports_js_3","HeaderNames_js_1","QueryParameterNames_js_1","SpeechSynthesisConnectionFactory","config","authInfo","connectionId","endpoint","region","hostSuffix","endpointId","hostPrefix","host","queryParams","headers","enableCompression","exports","SpeechSynthesisConnectionFactory_js_1","Exports_js_1","Exports_js_2","AudioOutputFormat_js_1","Exports_js_3","Contracts_js_1","Synthesizer_js_1","AvatarSynthesizer","speechConfig","avatarConfig","peerConnection","iceGatheringDone","event","sdp","result","sdpAnswerString","sdpAnswer","text","r","ssml","authentication","connectionFactory","synthesizerConfig","_authentication","_synthesizerConfig","config","isSSML","requestId","deferredResult","e","exports","Coordinate","x","y","exports","AvatarVideoFormat","codec","bitrate","width","height","topLeft","bottomRight","Exports_js_1","AvatarWebRTCConnectionResult","SDPAnswer","resultId","reason","errorDetails","properties","exports","Exports_js_1","Exports_js_2","Diagnostics","logLevel","path","callback","exports","AudioConfig_js_1","exports","AudioStreamFormat_js_1","AudioInputStream_js_1","AudioOutputStream_js_1","CancellationReason_js_1","PullAudioInputStreamCallback_js_1","PushAudioOutputStreamCallback_js_1","KeywordRecognitionModel_js_1","SessionEventArgs_js_1","RecognitionEventArgs_js_1","OutputFormat_js_1","IntentRecognitionEventArgs_js_1","RecognitionResult_js_1","SpeechRecognitionResult_js_1","IntentRecognitionResult_js_1","LanguageUnderstandingModel_js_1","SpeechRecognitionEventArgs_js_1","SpeechRecognitionCanceledEventArgs_js_1","TranslationRecognitionEventArgs_js_1","TranslationSynthesisEventArgs_js_1","TranslationRecognitionResult_js_1","TranslationSynthesisResult_js_1","ResultReason_js_1","SpeechConfig_js_1","SpeechTranslationConfig_js_1","PropertyCollection_js_1","PropertyId_js_1","Recognizer_js_1","SpeechRecognizer_js_1","IntentRecognizer_js_1","VoiceProfileType_js_1","TranslationRecognizer_js_1","Translations_js_1","NoMatchReason_js_1","NoMatchDetails_js_1","TranslationRecognitionCanceledEventArgs_js_1","IntentRecognitionCanceledEventArgs_js_1","CancellationDetailsBase_js_1","CancellationDetails_js_1","CancellationErrorCodes_js_1","ConnectionEventArgs_js_1","ServiceEventArgs_js_1","Connection_js_1","PhraseListGrammar_js_1","DialogServiceConfig_js_1","BotFrameworkConfig_js_1","CustomCommandsConfig_js_1","DialogServiceConnector_js_1","ActivityReceivedEventArgs_js_1","TurnStatusReceivedEventArgs_js_1","ServicePropertyChannel_js_1","ProfanityOption_js_1","BaseAudioPlayer_js_1","ConnectionMessageEventArgs_js_1","ConnectionMessage_js_1","VoiceProfile_js_1","VoiceProfileEnrollmentResult_js_1","VoiceProfileResult_js_1","VoiceProfilePhraseResult_js_1","VoiceProfileClient_js_1","SpeakerRecognizer_js_1","SpeakerIdentificationModel_js_1","SpeakerVerificationModel_js_1","AutoDetectSourceLanguageConfig_js_1","AutoDetectSourceLanguageResult_js_1","SourceLanguageConfig_js_1","SpeakerRecognitionResult_js_1","Exports_js_1","Synthesizer_js_1","SpeechSynthesisOutputFormat_js_1","SpeechSynthesizer_js_1","SynthesisResult_js_1","SpeechSynthesisResult_js_1","SpeechSynthesisEventArgs_js_1","SpeechSynthesisWordBoundaryEventArgs_js_1","SpeechSynthesisBookmarkEventArgs_js_1","SpeechSynthesisVisemeEventArgs_js_1","SpeechSynthesisBoundaryType_js_1","SynthesisVoicesResult_js_1","VoiceInfo_js_1","SpeakerAudioDestination_js_1","ConversationTranscriptionCanceledEventArgs_js_1","MeetingTranscriptionCanceledEventArgs_js_1","PronunciationAssessmentGradingSystem_js_1","PronunciationAssessmentGranularity_js_1","PronunciationAssessmentConfig_js_1","PronunciationAssessmentResult_js_1","LanguageIdMode_js_1","AvatarConfig_js_1","AvatarEventArgs_js_1","AvatarSynthesizer_js_1","AvatarVideoFormat_js_1","AvatarWebRTCConnectionResult_js_1","Diagnostics_js_1","LogLevel_js_1","Exports_js_1","ProxyInfo","_ProxyInfo","proxyHostName","proxyPort","proxyUserName","proxyPassword","parameters","config","exports","require_core","__commonJSMin","exports","module","encodings","mkrequest","args","statusCodes","method","encoding","headers","baseurl","arg","msg","code","require_browser","__commonJSMin","exports","module","core","StatusError","_StatusError","res","params","buffer","key","value","mkrequest","statusCodes","method","encoding","headers","baseurl","_url","body","_headers","parsed","resp","bent_1","__importDefault","Exports_js_1","RestRequestType","exports","RestMessageAdapter","configParams","headerKey","headers","headerValue","arr","headerMap","line","parts","header","value","key","method","uri","queryParams","body","responseReceivedDeferral","requestCommand","handleRestResponse","data","j","send","postData","sendRequest","params","error","k","RestConfigBase","_RestConfigBase","exports","__exportStar","exports","Exports_js_1","Exports_js_2","ConnectionFactoryBase_js_1","Exports_js_3","HeaderNames_js_1","IntentConnectionFactory","config","authInfo","connectionId","endpoint","region","hostSuffix","queryParams","headers","enableCompression","intentRegion","exports","Exports_js_1","Exports_js_2","ConnectionFactoryBase_js_1","Exports_js_3","HeaderNames_js_1","SpeakerRecognitionConnectionFactoryBase","config","authInfo","endpointPath","connectionId","endpoint","region","hostSuffix","host","scenario","queryParams","headers","enableCompression","mode","SpeakerRecognitionConnectionFactory","exports","VoiceProfileConnectionFactory","Exports_js_1","SpeechRecognitionEvent","eventName","requestId","sessionId","eventType","exports","RecognitionTriggeredEvent","audioSourceId","audioNodeId","ListeningStartedEvent","ConnectingToServiceEvent","authFetchEventid","RecognitionStartedEvent","authFetchEventId","RecognitionCompletionStatus","RecognitionEndedEvent","serviceTag","status","error","Exports_js_1","HeaderNames_js_1","SpeechConnectionMessage","_SpeechConnectionMessage","messageType","path","requestId","contentType","body","streamId","additionalHeaders","id","headers","headerName","message","exports","Exports_js_1","Exports_js_2","Exports_js_3","Exports_js_4","SpeechConnectionMessage_Internal_js_1","ServiceRecognizerBase","_ServiceRecognizerBase","authentication","connectionFactory","audioSource","recognizerConfig","recognizer","connectionEvent","connectionClosedEvent","targetLanguages","languages","translationVoice","action","languageToVoiceMap","lang","speechSegmentationTimeout","mode","segmentationSilenceTimeoutMs","phraseDetection","sourceLanguages","speechContextLidMode","customModels","token","type","auth","reason","recoMode","successCallback","errorCallBack","conPromise","audioNode","audioStreamNode","format","deviceInfo","error","sessionStartEventArgs","cb","err","e","message","path","payload","contentType","messagePayload","value","telemetryData","cancellationReason","errorCode","connection","connectionMessage","speechStartDetected","speechStartEventArgs","json","speechStopDetected","speechStopEventArgs","sessionStopEventArgs","audioOffsetMs","generateNewRequestId","speechContextJson","requestSession","SpeechServiceConfigJson","replacement","audioFormat","nextSendTime","fastLaneSizeMs","maxSendUnthrottledBytes","startRecogNumber","readAndUploadCycle","audioStreamChunk","sendDelay","isUnAuthorized","sessionId","lastStatusCode","lastReason","event","response","delayMs","resolve","buffer","out","readView","i","exports","Exports_js_1","Exports_js_2","ConversationServiceRecognizer","authentication","connectionFactory","audioSource","recognizerConfig","recognizer","textBody","connectionMessage","result","offset","sessionId","duration","processed","requestId","cancellationReason","errorCode","error","simple","resultReason","resultProps","simpleOffset","cancelReason","cancellationErrorCode","detailed","totalOffset","offsetCorrectedJson","hypothesis","exports","Exports_js_1","Exports_js_2","RecognitionMode","exports","SpeechResultFormat","RecognizerConfig","speechServiceConfig","parameters","value","models","modelsExist","language","customProperty","modelId","Exports_js_1","CRLF","WebsocketMessageFormatter","message","deferral","textMessage","headers","body","headerBodySplit","binaryMessage","dataView","headerLength","headersString","i","e","payload","content","headerBuffer","headerInt8Array","payloadInt8Array","bodyInt8Array","header","headerMatches","separatorIndex","headerName","headerValue","str","buffer","view","exports","Exports_js_1","Exports_js_2","Exports_js_3","ConnectionFactoryBase_js_1","Exports_js_4","HeaderNames_js_1","QueryParameterNames_js_1","SpeechConnectionFactory","config","authInfo","connectionId","endpoint","region","hostSuffix","host","queryParams","endpointId","language","headers","enableCompression","webSocketConnection","uri","exports","Exports_js_1","Exports_js_2","Exports_js_3","ConnectionFactoryBase_js_1","Exports_js_4","HeaderNames_js_1","QueryParameterNames_js_1","ConversationTranscriberConnectionFactory","config","authInfo","connectionId","endpoint","region","hostSuffix","host","queryParams","endpointId","language","headers","enableCompression","webSocketConnection","uri","parameterName","propertyId","serviceProperties","value","exports","Exports_js_1","Exports_js_2","ConnectionFactoryBase_js_1","Exports_js_3","HeaderNames_js_1","QueryParameterNames_js_1","TranscriberConnectionFactory","config","authInfo","connectionId","endpoint","region","hostSuffix","hostDefault","host","queryParams","headers","enableCompression","endpointUrl","endpointId","language","wordLevelTimings","detailed","exports","Exports_js_1","StringUtils_js_1","Exports_js_2","ConnectionFactoryBase_js_1","Exports_js_3","HeaderNames_js_1","QueryParameterNames_js_1","TranslationConnectionFactory","config","authInfo","connectionId","endpoint","queryParams","headers","enableCompression","returnRegionPlaceholder","region","hostSuffix","endpointUrl","translationVoice","exports","Exports_js_1","Exports_js_2","EnumTranslation","recognitionStatus","expectEndOfDictation","reason","cancellationErrorCode","errorDetails","exports","SynthesisStatus","exports","RecognitionStatus","Exports_js_1","TranslationSynthesisEnd","_TranslationSynthesisEnd","json","exports","Contracts_js_1","TranslationStatus_js_1","TranslationHypothesis","_TranslationHypothesis","hypothesis","json","translationHypothesis","exports","Contracts_js_1","Exports_js_1","TranslationStatus_js_1","TranslationPhrase","_TranslationPhrase","phrase","json","translationResponse","exports","Exports_js_1","Exports_js_2","Exports_js_3","TranslationServiceRecognizer","authentication","connectionFactory","audioSource","recognizerConfig","translationRecognizer","connectionEvent","connectionMessage","resultProps","processed","handleTranslationPhrase","translatedPhrase","result","e","reason","cancelReason","cancellationErrorCode","ev","handleTranslationHypothesis","hypothesis","resultProperties","phrase","synthEnd","retEvent","canceledResult","sessionId","requestId","cancellationReason","errorCode","error","properties","cancelEvent","duration","offset","serviceResult","translations","translation","resultReason","confidence","language","audio","exports","SpeechDetected","_SpeechDetected","json","exports","SpeechHypothesis","_SpeechHypothesis","json","exports","SpeechKeyword","_SpeechKeyword","json","exports","Exports_js_1","Exports_js_2","SpeechServiceRecognizer","authentication","connectionFactory","audioSource","recognizerConfig","speechRecognizer","connectionMessage","result","resultProps","processed","hypothesis","offset","ev","simple","resultReason","cancelReason","cancellationErrorCode","detailed","totalOffset","offsetCorrectedJson","event","e","sessionId","requestId","cancellationReason","errorCode","error","properties","cancelEvent","exports","Exports_js_1","Exports_js_2","ConversationTranscriptionServiceRecognizer","authentication","connectionFactory","audioSource","recognizerConfig","conversationTranscriber","phraseDetection","speakerDiarization","connectionMessage","result","resultProps","processed","hypothesis","offset","ev","simple","resultReason","cancelReason","cancellationErrorCode","detailed","totalOffset","offsetCorrectedJson","event","sessionId","requestId","cancellationReason","errorCode","error","cancelEvent","exports","Exports_js_1","Exports_js_2","Exports_js_3","SpeechConnectionMessage_Internal_js_1","TranscriptionServiceRecognizer","authentication","connectionFactory","audioSource","recognizerConfig","transcriber","connection","info","command","connectionMessage","result","offset","sessionId","event","e","duration","ev","requestId","cancellationReason","errorCode","error","properties","cancelEvent","payload","speechEventJson","eventDict","exports","Exports_js_1","DetailedSpeechPhrase","_DetailedSpeechPhrase","json","baseOffset","firstWordOffset","phrase","offset","details","word","exports","Exports_js_1","SimpleSpeechPhrase","_SimpleSpeechPhrase","json","exports","AddedLmIntent","modelImpl","intentName","exports","Exports_js_1","Exports_js_2","Exports_js_3","IntentServiceRecognizer","authentication","connectionFactory","audioSource","recognizerConfig","recognizer","addedIntents","umbrellaIntent","connectionMessage","result","ev","processed","resultProps","speechHypothesis","simple","sendEvent","e","intentResponse","addedIntent","intentId","reason","properties","defferal","sessionId","requestId","cancellationReason","errorCode","error","cancelEvent","exports","IntentResponse","_IntentResponse","json","exports","Exports_js_1","RecognitionEvents_js_1","ServiceTelemetryListener","requestId","audioSourceId","audioNodeId","audioReceivedTime","metrics","telemetry","json","statusCode","exports","Exports_js_1","RecognitionEvents_js_1","ServiceTelemetryListener_Internal_js_1","RequestSession","audioSourceId","eventSource","audioNode","isError","authFetchEventId","connectionId","statusCode","reason","continuousRecognition","offset","bytesSent","detachable","event","exports","SpeechContext","dynamicGrammar","sectionName","value","params","contentAssessmentTopic","isSpeakerDiarizationEnabled","audioOffsetMs","dgi","exports","DynamicGrammarBuilder","phrase","grammar","retObj","retPhrases","value","exports","ActivityPayloadResponse","_ActivityPayloadResponse","json","exports","MessageDataStreamType","AudioOutputFormat_js_1","AudioOutputStream_js_1","ActivityResponsePayload_js_1","DialogServiceTurnState","manager","requestId","payload","audioFormat","exports","Error_js_1","DialogServiceTurnState_js_1","DialogServiceTurnStateManager","id","turnState","exports","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","DialogServiceAdapter","authentication","connectionFactory","audioSource","recognizerConfig","dialogServiceConnector","recoMode","successCallback","errorCallback","connection","connectionEvent","message","interactionGuid","requestId","agentMessage","agentMessageJson","connectionMessage","resultProps","result","processed","speechPhrase","args","hypothesis","offset","ev","keyword","event","audioRequestId","turn","defferal","sessionId","cancellationReason","errorCode","error","properties","cancelEvent","conPromise","preAudioPromise","node","format","deviceInfo","audioNode","sessionStartEventArgs","communicationCustodian","loop","isDisposed","terminateMessageLoop","turnRequestId","audioSessionReqId","speechStartDetected","speechStartEventArgs","json","speechStopDetected","speechStopEventArgs","turnEndRequestId","sessionStopEventArgs","e","reason","config","agentConfigJson","guid","speechActivityTemplate","agentContextJson","serviceResult","resultReason","responseMessage","responsePayload","responseRequestId","activityPayload","updateAgentConfig","pullAudioOutputStream","activity","keywordPropertyValue","keywordOffsetPropertyValue","keywordDurationPropertyValue","keywords","keywordOffsets","keywordDurations","keywordDefinitionArray","i","definition","exports","AgentConfig","value","exports","RestConfigBase_js_1","ConversationConnectionConfig","_ConversationConnectionConfig","exports","Exports_js_1","Contracts_js_1","Exports_js_2","ConversationConnectionConfig_js_1","ConversationManager","args","conversationCode","cb","err","languageCode","nickname","endpointHost","correlationId","subscriptionKey","subscriptionRegion","authToken","queryParams","headers","config","endpoint","response","requestId","errorMessage","errMessageRaw","conversation","e","error","typedError","sessionToken","resolve","reject","exports","Exports_js_1","ConversationConnectionMessage","messageType","body","headers","id","json","exports","Exports_js_1","ConversationConnectionMessage_js_1","ConversationWebsocketMessageFormatter","message","deferral","incomingMessage","e","payload","exports","Exports_js_1","Exports_js_2","Contracts_js_1","Exports_js_3","ConnectionFactoryBase_js_1","ConversationConnectionConfig_js_1","ConversationWebsocketMessageFormatter_js_1","ConversationConnectionFactory","config","authInfo","connectionId","endpointHost","correlationId","endpoint","token","queryParams","enableCompression","exports","Exports_js_1","ConversationRequestSession","sessionId","authFetchEventId","connectionId","isError","statusCode","continuousRecognition","detachable","exports","Exports_js_1","MuteAllEventArgs","isMuted","sessionId","exports","LockRoomEventArgs","isLocked","ParticipantEventArgs","participant","ParticipantAttributeEventArgs","participantId","key","value","ParticipantsListEventArgs","conversationId","token","translateTo","profanityFilter","roomProfanityFilter","isRoomLocked","isMuteAll","participants","ConversationReceivedTranslationEventArgs","command","payload","InternalParticipants","participants","meId","value","exists","id","p","exports","parseCommandResponse","json","CommandResponsePayload","_CommandResponsePayload","exports","parseListResponse","json","parseParticipantResponse","ParticipantsListPayloadResponse","_ParticipantsListPayloadResponse","exports","ParticipantPayloadResponse","_ParticipantPayloadResponse","parseSpeechResponse","json","parseTextResponse","SpeechResponsePayload","_SpeechResponsePayload","exports","TextResponsePayload","_TextResponsePayload","CommandResponsePayload_js_1","exports","ParticipantResponsePayload_js_1","TranslationResponsePayload_js_1","Exports_js_1","Exports_js_2","Exports_js_3","ConversationConnectionMessage_js_1","ConversationRequestSession_js_1","ConversationTranslatorEventArgs_js_1","ConversationTranslatorInterfaces_js_1","Exports_js_4","ConversationServiceAdapter","authentication","connectionFactory","audioSource","recognizerConfig","conversationServiceConnector","connection","reason","message","sessionId","requestId","cancellationReason","errorCode","error","cancelEvent","communicationCustodian","conversationMessageType","sendFinal","commandPayload","participantsPayload","participantsResult","p","joinParticipantPayload","joiningParticipant","leavingParticipant","disconnectParticipant","token","authorizationToken","speechPayload","conversationResultReason","speechResult","textPayload","textResult","messageRetrievalPromise","serviceResultTranslations","translations","translation","exports","Exports_js_1","Exports_js_2","Contracts_js_1","Exports_js_3","ConversationConnectionFactory_js_1","ConversationServiceAdapter_js_1","ConversationRecognizerFactory","conversation","speechConfig","audioConfig","ConversationTranslatorRecognizer","exports","serviceConfigImpl","conversationImpl","cb","token","err","error","typedError","reason","command","disposing","authentication","connectionFactory","recognizerConfig","audioSource","msg","withAsync","promise","e","Exports_js_1","Contracts_js_1","Exports_js_2","Exports_js_3","TranscriberRecognizer","speechTranslationConfig","audioConfig","speechTranslationConfigImpl","audioConfigImpl","token","c","m","cb","err","conversationInfo","command","reco","meetingInfo","channels","transcriber","s","e","disposing","speechConfig","authentication","connectionFactory","recognizerConfig","configImpl","exports","ConversationManager_js_1","exports","ConversationConnectionConfig_js_1","ConversationTranslatorRecognizer_js_1","TranscriberRecognizer_js_1","ConversationTranslatorEventArgs_js_1","ConversationTranslatorInterfaces_js_1","MetadataType","exports","SynthesisAudioMetadata","_SynthesisAudioMetadata","json","Exports_js_1","SpeechSynthesisEvent","eventName","requestId","eventType","exports","SynthesisTriggeredEvent","sessionAudioDestinationId","turnAudioDestinationId","ConnectingToSynthesisServiceEvent","authFetchEventId","SynthesisStartedEvent","Exports_js_1","AudioOutputStream_js_1","Exports_js_2","SynthesisAudioMetadata_js_1","SynthesisEvents_js_1","SynthesisTurn","_SynthesisTurn","value","format","properties","audio","requestId","rawText","isSSML","audioDestination","authFetchEventId","isError","statusCode","responseJson","response","data","metadata","audioBuffer","animation","event","text","type","idx","exports","Exports_js_1","Exports_js_2","Exports_js_3","SpeechConnectionMessage_Internal_js_1","SynthesisAdapterBase","authentication","connectionFactory","synthesizerConfig","audioDestination","connectionEvent","connectionClosedEvent","messagePayload","format","reason","path","payload","type","contentType","text","isSSML","requestId","successCallback","errorCallBack","ssml","connection","e","_cancellationReason","errorCode","error","properties","result","cancellationReason","_connectionMessage","message","connectionMessage","metadataList","metadata","wordBoundaryEventArgs","bookmarkEventArgs","visemeEventArgs","synthesisContextJson","isUnAuthorized","authPromise","event","response","SpeechServiceConfigJson","_metadata","_requestId","_audio","_result","_wordBoundaryEventArgs","_visemeEventArgs","_bookmarkEventArgs","exports","Exports_js_1","Exports_js_2","AvatarSynthesisAdapter","authentication","connectionFactory","synthesizerConfig","avatarSynthesizer","avatarConfig","metadata","avatarEventArgs","exports","Exports_js_1","Exports_js_2","SpeechSynthesisAdapter","authentication","connectionFactory","synthesizerConfig","speechSynthesizer","audioDestination","requestId","synthesisStartEventArgs","audio","audioWithHeader","ev","result","cancelEvent","wordBoundaryEventArgs","visemeEventArgs","bookmarkEventArgs","exports","Exports_js_1","Exports_js_2","ConnectionFactoryBase_js_1","HeaderNames_js_1","SynthesisRestAdapter","config","authentication","endpoint","region","hostSuffix","options","connectionId","authInfo","exports","Exports_js_1","SynthesisServiceType","exports","SynthesizerConfig","speechServiceConfig","parameters","value","Exports_js_1","SynthesisContext","sectionName","value","format","speechSynthesizer","synthesisSection","exports","Exports_js_1","SpeakerRecognitionConfig","context","parameters","exports","Exports_js_1","Exports_js_2","Exports_js_3","Exports_js_4","SpeechConnectionMessage_Internal_js_1","SpeakerServiceRecognizer","authentication","connectionFactory","audioSource","recognizerConfig","recognizer","model","connectionMessage","processed","resultProps","response","result","defferal","sessionId","requestId","cancellationReason","errorCode","error","conPromise","preAudioPromise","node","format","deviceInfo","audioNode","err","sessionStartEventArgs","context","connection","speakerContextJson","exports","Exports_js_1","Exports_js_2","Exports_js_3","Exports_js_4","SpeechConnectionMessage_Internal_js_1","VoiceServiceRecognizer","authentication","connectionFactory","audioSource","recognizerConfig","recognizer","connectionMessage","processed","resultProps","response","enrollmentResponse","phraseResponse","result","defferal","sessionId","requestId","cancellationReason","errorCode","error","profileType","locale","conPromise","createProfileDeferral","err","profile","lang","getPhrasesDeferral","enrollmentDeferral","preAudioPromise","node","format","deviceInfo","audioNode","sessionStartEventArgs","connection","scenario","profileCreateRequest","operation","deferral","profileRequest","model","reason","profileIds","successReason","profileInfo","iProfiles","profileResults","statusCode","exports","SpeechServiceConfig","context","key","value","replacement","k","exports","Context","os","System","SPEECHSDK_CLIENTSDK_VERSION","OS","platform","name","version","Device","manufacturer","model","connectivity","type","__exportStar","exports","AvatarSynthesisAdapter_js_1","SpeechSynthesisAdapter_js_1","Exports_js_1","__exportStar","exports","require_lib","__commonJSMin","exports","module","onErrorResumeNext","fn","context","result","resolve","require_p_defer","__commonJSMin","exports","module","ret","promise","Promise","resolve","reject","_pDefer","_interopRequireDefault","EventAsPromise","_this","options","_classCallCheck","defers","upcomingDeferred","eventListener","bind","one","upcoming","Symbol","iterator","next","done","value","event","deferred","shift","args","array","slice","call","arguments","resolve","push","promise","assertType","condition","message","args","format","i","anyToString","x","currentErrorHandler","reportError","maybeError","error","anyToString","currentErrorHandler","Global","currentWarnHandler","Warning","code","message","args","currentWarnHandler","stack","_a","InitEventWasCalledWhileDispatching","FalsyWasAssignedToCancelBubble","TruthyWasAssignedToReturnValue","NonCancelableEventWasCanceled","CanceledInPassiveListener","EventListenerWasDuplicated","OptionWasIgnored","InvalidEventListener","InvalidAttributeHandler","Event","NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","type","eventInitDict","opts","internalDataMap","$","currentTarget","value","data","setCancelFlag","bubbles","cancelable","event","name","retv","assertType","keys","Global","createInvalidStateError","DOMException","msg","defineErrorCodeProperties","ErrorCodeMap","obj","i","key","EventWrapper","getWrapperClassOf","defineRedirectDescriptor","original","wrapperClassCache","originalEvent","prototype","wrapper","defineWrapper","BaseEventWrapper","originalPrototype","CustomEventWrapper","d","createListener","callback","capture","passive","once","signal","signalListener","setRemoved","listener","isCapture","isPassive","isOnce","isRemoved","invokeCallback","target","thrownError","reportError","findIndexOfListener","listeners","addListener","list","removeListener","index","removeListenerAt","disableCow","_","createListenerListMap","ensureListenerList","listenerMap","EventTarget","type0","callback0","options0","normalizeAddOptions","warnDuplicate","normalizeOptions","eventData","getEventInternalData","cow","options","assertCallback","format","getEventAttributeValue","_b","getEventTargetInternalData","setEventAttributeValue","upsertEventAttributeListener","removeEventAttributeListener","defineEventAttributeCallback","arrayToMap_default","array","extras","map","value","index","import_microsoft_cognitiveservices_speech","SpeechSDK_default","RecognizingSpeech","RecognizedSpeech","SpeechSDK_default","cognitiveServiceEventResultToWebSpeechRecognitionResultList_default","result","maxAlternatives","textNormalization","resultList","arrayToMap_default","confidence","display","itn","lexical","maskedITN","pDefer","deferred","resolve","reject","createPromiseQueue_default","shiftDeferred","queue","value","resolve","pDefer","isFunction","value","resolveFunctionOrReturnValue","fnOrValue","shouldWarnOnSubscriptionKey","patchOptions","authorizationToken","credentials","looseEvent","looseEvents","region","subscriptionKey","otherOptions","resolveFunctionOrReturnValue","customVoiceHostname","speechRecognitionHostname","speechSynthesisHostname","resolvedCredentials","SpeechGrammarList_default","value","AudioConfig","OutputFormat","ResultReason","SpeechConfig","SpeechRecognizer","SpeechSDK_default","serializeRecognitionResult","duration","errorDetails","json","offset","properties","reason","resultId","text","averageAmplitude","arrayBuffer","array","amplitude","cognitiveServicesAsyncToPromise","fn","args","resolve","reject","SpeechRecognitionEvent","Event","type","data","emma","interpretation","resultIndex","results","prepareAudioConfig","audioConfig","originalAttach","boundOriginalAttach","firstChunk","muted","reader","chunk","createSpeechRecognitionPonyfillFromRecognizer","createRecognizer","enableTelemetry","looseEvents","referenceGrammars","textNormalization","SpeechRecognition","EventTarget","SpeechGrammarList_default","event","value","getEventAttributeValue","setEventAttributeValue","err","recognizer","pause","unprepare","queue","createPromiseQueue_default","soundStarted","speechStarted","stopping","detachAudioConfigEvent","name","_","sessionId","result","phrases","dynamicGrammar","audioStarted","finalEvent","finalizedResults","loop","abort","audioSourceOff","audioSourceReady","canceled","firstAudibleChunk","recognized","recognizing","stop","errorMessage","cognitiveServiceEventResultToWebSpeechRecognitionResultList_default","recognizable","createSpeechRecognitionPonyfill_default","options","fetchCredentials","speechRecognitionEndpointId","patchOptions","lang","authorizationToken","region","speechRecognitionHostname","subscriptionKey","speechConfig","host","SpeechToText_default","createSpeechRecognitionPonyfill_default","import_on_error_resume_next","safeIsNaN","value","isEqual","first","second","areInputsEqual","newInputs","lastInputs","i","memoizeOne","resultFn","cache","memoized","newArgs","_i","lastResult","AudioContextConsumer_default","audioContext","queue","utterance","AudioContextQueue_default","audioContext","ponyfill","memoizeOne","utterance","AudioContextConsumer_default","SpeechSynthesisVoice_default","gender","lang","voiceURI","fetchCustomVoices","customVoiceHostname","deploymentId","region","subscriptionKey","hostname","res","fetchCustomVoices_default","models","gender","lang","voiceURI","SpeechSynthesisVoice_default","x","y","fetchVoices","authorizationToken","region","speechSynthesisHostname","subscriptionKey","hostname","res","gender","lang","voiceURI","SpeechSynthesisVoice_default","x","y","SpeechSynthesisEvent","Event","type","import_event_as_promise","chars","lookup","i","decode","base64","bufferLength","len","i","p","encoded1","encoded2","encoded3","encoded4","arraybuffer","bytes","lookup","relativePercentage","value","relative","buildSSML","lang","pitch","rate","text","voice","volume","SPEAK_TAG_PATTERN","XML_PROLOG_PATTERN","isSSML","text","DEFAULT_LANGUAGE","DEFAULT_OUTPUT_FORMAT","DEFAULT_VOICE","EMPTY_MP3_BASE64","fetchSpeechData_default","deploymentId","fetchCredentials","lang","outputFormat","pitch","rate","text","voice","volume","decode","authorizationToken","region","speechSynthesisHostname","subscriptionKey","ssml","isSSML","buildSSML","hostname","search","url","res","subscribeEvent","target","name","handler","asyncDecodeAudioData","audioContext","arrayBuffer","resolve","reject","promise","playDecoded","audioBuffer","source","audioContextClosed","EventAsPromise","sourceEnded","unsubscribe","subscribeEvent","state","err","SpeechSynthesisUtterance","EventTarget","text","value","getEventAttributeValue","setEventAttributeValue","deploymentId","fetchCredentials","outputFormat","fetchSpeechData_default","SpeechSynthesisEvent","error","SpeechSynthesisUtterance_default","DEFAULT_OUTPUT_FORMAT","EMPTY_ARRAY","createSpeechSynthesisPonyfill_default","options","audioContext","fetchCredentials","ponyfill","speechSynthesisDeploymentId","speechSynthesisOutputFormat","patchOptions","SpeechSynthesis","EventTarget","AudioContextQueue_default","getEventAttributeValue","value","setEventAttributeValue","utterance","SpeechSynthesisUtterance_default","reject","resolve","promise","pDefer","handleError","errorCode","message","error","customVoiceHostname","region","speechSynthesisHostname","subscriptionKey","onErrorResumeNext","voices","fetchCustomVoices_default","fetchVoices","SpeechSynthesisEvent","TextToSpeech_default","createSpeechSynthesisPonyfill_default","createSpeechServicesPonyfill","options","args","SpeechToText_default","TextToSpeech_default","meta","createSpeechServicesPonyfill","createSpeechRecognitionPonyfillFromRecognizer"]}
|