UNPKG

@voice-ping/cognitive-services-speech

Version:

VoicePing Cognitive Services Speech SDK for JavaScript forked from Microsoft

1 lines 4.61 kB
{"version":3,"sources":["src/sdk/VoiceProfileEnrollmentResult.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,uBAAuB,EAGvB,kBAAkB,EAElB,YAAY,EACf,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,wBAAwB;IACrC,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,uBAAuB,EAAE,MAAM,CAAC;IAChC,yBAAyB,EAAE,MAAM,CAAC;IAClC,gCAAgC,EAAE,MAAM,CAAC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,qBAAa,4BAA4B;IACrC,OAAO,CAAC,UAAU,CAAe;IACjC,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,gBAAgB,CAAS;gBAEd,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAezE,IAAW,MAAM,IAAI,YAAY,CAEhC;IAED,IAAW,gBAAgB,IAAI,MAAM,CAEpC;IAED,IAAW,iBAAiB,IAAI,MAAM,CAErC;IAED,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAED,IAAW,YAAY,IAAI,MAAM,CAEhC;CACJ;AAED;;GAEG;AAEH,qBAAa,yCAA0C,SAAQ,uBAAuB;IAElF,OAAO;IAIP;;;;;;;OAOG;WACW,UAAU,CAAC,MAAM,EAAE,4BAA4B,GAAG,yCAAyC;CAU5G","file":"VoiceProfileEnrollmentResult.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport { CancellationErrorCodePropertyName } from \"../common.speech/Exports\";\nimport { Contracts } from \"./Contracts\";\nimport {\n CancellationDetailsBase,\n CancellationErrorCode,\n CancellationReason,\n PropertyCollection,\n PropertyId,\n ResultReason,\n} from \"./Exports\";\n\nexport interface IEnrollmentResultDetails {\n enrollmentsCount: number;\n enrollmentsLength: number;\n enrollmentsSpeechLength: number;\n remainingEnrollmentsCount: number;\n remainingEnrollmentsSpeechLength: number;\n audioLength: number;\n audioSpeechLength: number;\n enrollmentStatus: string;\n}\n\n/**\n * Output format\n * @class VoiceProfileEnrollmentResult\n */\nexport class VoiceProfileEnrollmentResult {\n private privReason: ResultReason;\n private privDetails: IEnrollmentResultDetails;\n private privProperties: PropertyCollection;\n private privErrorDetails: string;\n\n public constructor(reason: ResultReason, json: string, statusText: string) {\n this.privReason = reason;\n this.privProperties = new PropertyCollection();\n if (this.privReason !== ResultReason.Canceled) {\n this.privDetails = JSON.parse(json);\n Contracts.throwIfNullOrUndefined(json, \"JSON\");\n if (this.privDetails.enrollmentStatus.toLowerCase() === \"enrolling\") {\n this.privReason = ResultReason.EnrollingVoiceProfile;\n }\n } else {\n this.privErrorDetails = statusText;\n this.privProperties.setProperty(CancellationErrorCodePropertyName, CancellationErrorCode[CancellationErrorCode.ServiceError]);\n }\n }\n\n public get reason(): ResultReason {\n return this.privReason;\n }\n\n public get enrollmentsCount(): number {\n return this.privDetails.enrollmentsCount;\n }\n\n public get enrollmentsLength(): number {\n return this.privDetails.enrollmentsLength;\n }\n\n public get properties(): PropertyCollection {\n return this.privProperties;\n }\n\n public get errorDetails(): string {\n return this.privErrorDetails;\n }\n}\n\n/**\n * @class VoiceProfileEnrollmentCancellationDetails\n */\n// tslint:disable-next-line:max-classes-per-file\nexport class VoiceProfileEnrollmentCancellationDetails extends CancellationDetailsBase {\n\n private constructor(reason: CancellationReason, errorDetails: string, errorCode: CancellationErrorCode) {\n super(reason, errorDetails, errorCode);\n }\n\n /**\n * Creates an instance of VoiceProfileEnrollmentCancellationDetails object for the canceled VoiceProfileEnrollmentResult.\n * @member VoiceProfileEnrollmentCancellationDetails.fromResult\n * @function\n * @public\n * @param {VoiceProfileEnrollmentResult} result - The result that was canceled.\n * @returns {VoiceProfileEnrollmentCancellationDetails} The cancellation details object being created.\n */\n public static fromResult(result: VoiceProfileEnrollmentResult): VoiceProfileEnrollmentCancellationDetails {\n const reason = CancellationReason.Error;\n let errorCode: CancellationErrorCode = CancellationErrorCode.NoError;\n\n if (!!result.properties) {\n errorCode = (CancellationErrorCode as any)[result.properties.getProperty(CancellationErrorCodePropertyName, CancellationErrorCode[CancellationErrorCode.NoError])];\n }\n\n return new VoiceProfileEnrollmentCancellationDetails(reason, result.errorDetails, errorCode);\n }\n}\n"]}