@euirim/microsoft-cognitiveservices-speech-sdk
Version:
Microsoft Cognitive Services Speech SDK for JavaScript
1 lines • 3.66 kB
Source Map (JSON)
{"version":3,"sources":["src/sdk/CancellationDetails.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEzF;;;GAGG;AACH,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,aAAa,CAAwB;IAE7C;;;;;OAKG;IACH,OAAO;IAMP;;;;;;;OAOG;WACW,UAAU,CAAC,MAAM,EAAE,iBAAiB,GAAG,mBAAmB;IAiBxE;;;;;;OAMG;aACQ,MAAM,EAAI,kBAAkB;IAIvC;;;;;;OAMG;aACQ,YAAY,EAAI,MAAM;IAIjC;;;;OAIG;aACQ,SAAS,EAAI,qBAAqB;CAIhD","file":"CancellationDetails.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport { CancellationErrorCodePropertyName, EnumTranslation, SimpleSpeechPhrase } from \"../common.speech/Exports\";\nimport { CancellationErrorCode, CancellationReason, RecognitionResult } from \"./Exports\";\n\n/**\n * Contains detailed information about why a result was canceled.\n * @class CancellationDetails\n */\nexport class CancellationDetails {\n private privReason: CancellationReason;\n private privErrorDetails: string;\n private privErrorCode: CancellationErrorCode;\n\n /**\n * Creates and initializes an instance of this class.\n * @constructor\n * @param {CancellationReason} reason - The cancellation reason.\n * @param {string} errorDetails - The error details, if provided.\n */\n private constructor(reason: CancellationReason, errorDetails: string, errorCode: CancellationErrorCode) {\n this.privReason = reason;\n this.privErrorDetails = errorDetails;\n this.privErrorCode = errorCode;\n }\n\n /**\n * Creates an instance of CancellationDetails object for the canceled RecognitionResult.\n * @member CancellationDetails.fromResult\n * @function\n * @public\n * @param {RecognitionResult} result - The result that was canceled.\n * @returns {CancellationDetails} The cancellation details object being created.\n */\n public static fromResult(result: RecognitionResult): CancellationDetails {\n let reason = CancellationReason.Error;\n let errorCode: CancellationErrorCode = CancellationErrorCode.NoError;\n\n if (!!result.json) {\n const simpleSpeech: SimpleSpeechPhrase = SimpleSpeechPhrase.fromJSON(result.json);\n reason = EnumTranslation.implTranslateCancelResult(simpleSpeech.RecognitionStatus);\n }\n\n if (!!result.properties) {\n errorCode = (CancellationErrorCode as any)[result.properties.getProperty(CancellationErrorCodePropertyName, CancellationErrorCode[CancellationErrorCode.NoError])];\n }\n\n return new CancellationDetails(reason, result.errorDetails, errorCode);\n\n }\n\n /**\n * The reason the recognition was canceled.\n * @member CancellationDetails.prototype.reason\n * @function\n * @public\n * @returns {CancellationReason} Specifies the reason canceled.\n */\n public get reason(): CancellationReason {\n return this.privReason;\n }\n\n /**\n * In case of an unsuccessful recognition, provides details of the occurred error.\n * @member CancellationDetails.prototype.errorDetails\n * @function\n * @public\n * @returns {string} A String that represents the error details.\n */\n public get errorDetails(): string {\n return this.privErrorDetails;\n }\n\n /**\n * The error code in case of an unsuccessful recognition.\n * Added in version 1.1.0.\n * @return An error code that represents the error reason.\n */\n public get ErrorCode(): CancellationErrorCode {\n return this.privErrorCode;\n }\n\n}\n"]}