@hahnpro/ms-speech-sdk
Version:
Microsoft Cognitive Services Speech SDK for JavaScript
1 lines • 9.15 kB
Source Map (JSON)
{"version":3,"sources":["src/sdk/VoiceProfileEnrollmentResult.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,uBAAuB,EAGvB,kBAAkB,EAClB,YAAY,EACf,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,uBAAuB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,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,MAAM,WAAW,oBAAoB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,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;IACzB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED;;;GAGG;AACH,qBAAa,4BAA4B;IACrC,OAAO,CAAC,UAAU,CAAe;IACjC,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,gBAAgB,CAAS;gBAEd,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAgBzE,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,uBAAuB,IAAI,uBAAuB,CAE5D;IAED,IAAW,YAAY,IAAI,MAAM,CAEhC;WAEa,6BAA6B,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,oBAAoB,EAAE,CAAA;KAAE,GAAG,4BAA4B,EAAE;WAatG,2BAA2B,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,oBAAoB,EAAE,CAAA;KAAE,GAAG,4BAA4B,EAAE;IAalH,OAAO,CAAC,MAAM,CAAC,wBAAwB;IAavC,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAaxC;AAED;;GAEG;AACH,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\n/* eslint-disable max-classes-per-file */\nimport { CancellationErrorCodePropertyName } from \"../common.speech/Exports.js\";\nimport {\n CancellationDetailsBase,\n CancellationErrorCode,\n CancellationReason,\n PropertyCollection,\n ResultReason\n} from \"./Exports.js\";\n\nexport interface EnrollmentResultDetails {\n profileId: string;\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\nexport interface EnrollmentResultJSON {\n profileId: string;\n enrollmentsCount: number;\n enrollmentsLength: string;\n enrollmentsSpeechLength: string;\n remainingEnrollmentsCount: number;\n remainingEnrollmentsSpeechLength: string;\n audioLength: string;\n audioSpeechLength: string;\n enrollmentStatus: string;\n remainingEnrollments?: number;\n identificationProfileId?: string;\n verificationProfileId?: string;\n}\n\n/**\n * Output format\n * @class VoiceProfileEnrollmentResult\n */\nexport class VoiceProfileEnrollmentResult {\n private privReason: ResultReason;\n private privDetails: EnrollmentResultDetails;\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 if (!!json) {\n this.privDetails = JSON.parse(json) as EnrollmentResultDetails;\n if (this.privDetails.enrollmentStatus.toLowerCase() === \"enrolling\") {\n this.privReason = ResultReason.EnrollingVoiceProfile;\n }\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 enrollmentResultDetails(): EnrollmentResultDetails {\n return this.privDetails;\n }\n\n public get errorDetails(): string {\n return this.privErrorDetails;\n }\n\n public static FromIdentificationProfileList(json: { value: EnrollmentResultJSON[] }): VoiceProfileEnrollmentResult[] {\n const results: VoiceProfileEnrollmentResult[] = [];\n for (const item of json.value) {\n const reason: ResultReason = item.enrollmentStatus.toLowerCase() === \"enrolling\" ?\n ResultReason.EnrollingVoiceProfile : item.enrollmentStatus.toLowerCase() === \"enrolled\" ?\n ResultReason.EnrolledVoiceProfile : ResultReason.Canceled;\n const result = new VoiceProfileEnrollmentResult(reason, null, null);\n result.privDetails = this.getIdentificationDetails(item) as EnrollmentResultDetails;\n results.push(result);\n }\n return results;\n }\n\n public static FromVerificationProfileList(json: { value: EnrollmentResultJSON[] }): VoiceProfileEnrollmentResult[] {\n const results: VoiceProfileEnrollmentResult[] = [];\n for (const item of json.value) {\n const reason: ResultReason = item.enrollmentStatus.toLowerCase() === \"enrolling\" ?\n ResultReason.EnrollingVoiceProfile : item.enrollmentStatus.toLowerCase() === \"enrolled\" ?\n ResultReason.EnrolledVoiceProfile : ResultReason.Canceled;\n const result = new VoiceProfileEnrollmentResult(reason, null, null);\n result.privDetails = this.getVerificationDetails(item) as EnrollmentResultDetails;\n results.push(result);\n }\n return results;\n }\n\n private static getIdentificationDetails(json: EnrollmentResultJSON): unknown {\n return {\n audioLength: json.audioLength ? parseFloat(json.audioLength) : 0,\n audioSpeechLength: json.audioSpeechLength ? parseFloat(json.audioSpeechLength) : 0,\n enrollmentStatus: json.enrollmentStatus,\n enrollmentsCount: json.enrollmentsCount || 0,\n enrollmentsLength: json.enrollmentsLength ? parseFloat(json.enrollmentsLength) : 0,\n enrollmentsSpeechLength: json.enrollmentsSpeechLength ? parseFloat(json.enrollmentsSpeechLength) : 0,\n profileId: json.profileId || json.identificationProfileId,\n remainingEnrollmentsSpeechLength: json.remainingEnrollmentsSpeechLength ? parseFloat(json.remainingEnrollmentsSpeechLength) : 0\n };\n }\n\n private static getVerificationDetails(json: EnrollmentResultJSON): unknown {\n return {\n audioLength: json.audioLength ? parseFloat(json.audioLength) : 0,\n audioSpeechLength: json.audioSpeechLength ? parseFloat(json.audioSpeechLength) : 0,\n enrollmentStatus: json.enrollmentStatus,\n enrollmentsCount: json.enrollmentsCount,\n enrollmentsLength: json.enrollmentsLength ? parseFloat(json.enrollmentsLength) : 0,\n enrollmentsSpeechLength: json.enrollmentsSpeechLength ? parseFloat(json.enrollmentsSpeechLength) : 0,\n profileId: json.profileId || json.verificationProfileId,\n remainingEnrollmentsCount: json.remainingEnrollments || json.remainingEnrollmentsCount,\n remainingEnrollmentsSpeechLength: json.remainingEnrollmentsSpeechLength ? parseFloat(json.remainingEnrollmentsSpeechLength) : 0\n };\n }\n}\n\n/**\n * @class VoiceProfileEnrollmentCancellationDetails\n */\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])]; //eslint-disable-line\n }\n\n return new VoiceProfileEnrollmentCancellationDetails(reason, result.errorDetails, errorCode);\n }\n}\n"]}