microsoft-cognitiveservices-speech-sdk
Version:
Microsoft Cognitive Services Speech SDK for JavaScript
1 lines • 2.58 kB
Source Map (JSON)
{"version":3,"sources":["src/sdk/CancellationDetails.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAGH,iBAAiB,EACjB,qBAAqB,EACxB,MAAM,cAAc,CAAC;AAEtB;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,uBAAuB;IAE5D,OAAO;IAIP;;;;;;;OAOG;WACW,UAAU,CAAC,MAAM,EAAE,iBAAiB,GAAG,qBAAqB,GAAG,mBAAmB;CAgBnG","file":"CancellationDetails.d.ts","sourcesContent":["// 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, 0); // Offset fixups are already done.\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"]}