{"version":3,"sources":["src/common.speech/EnumTranslation.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,qBAAqB,EACrB,kBAAkB,EAClB,YAAY,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,qBAAa,eAAe;WACV,8BAA8B,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,oBAAoB,GAAE,OAAe,GAAG,YAAY;WA0BzH,yBAAyB,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,kBAAkB;WAoBnF,4BAA4B,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,qBAAqB;WAwBzF,yBAAyB,CAAC,qBAAqB,EAAE,qBAAqB,GAAG,MAAM;CAkBhG","file":"EnumTranslation.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport {\n    CancellationErrorCode,\n    CancellationReason,\n    ResultReason\n} from \"../sdk/Exports.js\";\nimport { RecognitionStatus } from \"./Exports.js\";\n\nexport class EnumTranslation {\n    public static implTranslateRecognitionResult(recognitionStatus: RecognitionStatus, expectEndOfDictation: boolean = false): ResultReason {\n        let reason = ResultReason.Canceled;\n        switch (recognitionStatus) {\n            case RecognitionStatus.Success:\n                reason = ResultReason.RecognizedSpeech;\n                break;\n            case RecognitionStatus.EndOfDictation:\n                // If we need the result in EndOfDictation (typically some session level result),\n                // translate into RecognizedSpeech, otherwise NoMatch\n                reason = expectEndOfDictation ? ResultReason.RecognizedSpeech : ResultReason.NoMatch;\n                break;\n            case RecognitionStatus.NoMatch:\n            case RecognitionStatus.InitialSilenceTimeout:\n            case RecognitionStatus.BabbleTimeout:\n                reason = ResultReason.NoMatch;\n                break;\n            case RecognitionStatus.Error:\n            case RecognitionStatus.BadRequest:\n            case RecognitionStatus.Forbidden:\n            default:\n                reason = ResultReason.Canceled;\n                break;\n        }\n        return reason;\n    }\n\n    public static implTranslateCancelResult(recognitionStatus: RecognitionStatus): CancellationReason {\n        let reason = CancellationReason.EndOfStream;\n        switch (recognitionStatus) {\n            case RecognitionStatus.Success:\n            case RecognitionStatus.EndOfDictation:\n            case RecognitionStatus.NoMatch:\n                reason = CancellationReason.EndOfStream;\n                break;\n            case RecognitionStatus.InitialSilenceTimeout:\n            case RecognitionStatus.BabbleTimeout:\n            case RecognitionStatus.Error:\n            case RecognitionStatus.BadRequest:\n            case RecognitionStatus.Forbidden:\n            default:\n                reason = CancellationReason.Error;\n                break;\n        }\n        return reason;\n    }\n\n    public static implTranslateCancelErrorCode(recognitionStatus: RecognitionStatus): CancellationErrorCode {\n        let reason: CancellationErrorCode = CancellationErrorCode.NoError;\n        switch (recognitionStatus) {\n            case RecognitionStatus.Error:\n                reason = CancellationErrorCode.ServiceError;\n                break;\n            case RecognitionStatus.TooManyRequests:\n                reason = CancellationErrorCode.TooManyRequests;\n                break;\n            case RecognitionStatus.BadRequest:\n                reason = CancellationErrorCode.BadRequestParameters;\n                break;\n            case RecognitionStatus.Forbidden:\n                reason = CancellationErrorCode.Forbidden;\n                break;\n            default:\n                reason = CancellationErrorCode.NoError;\n                break;\n        }\n\n        return reason;\n\n    }\n\n    public static implTranslateErrorDetails(cancellationErrorCode: CancellationErrorCode): string {\n        let errorDetails: string = \"The speech service encountered an internal error and could not continue.\";\n        switch (cancellationErrorCode) {\n            case CancellationErrorCode.Forbidden:\n                errorDetails = \"The recognizer is using a free subscription that ran out of quota.\";\n                break;\n            case CancellationErrorCode.BadRequestParameters:\n                errorDetails = \"Invalid parameter or unsupported audio format in the request.\";\n                break;\n            case CancellationErrorCode.TooManyRequests:\n                errorDetails = \"The number of parallel requests exceeded the number of allowed concurrent transcriptions.\";\n                break;\n            default:\n                break;\n        }\n        return errorDetails;\n    }\n\n}\n"]}