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,UAAU,CAAC,MAAM,EAAE,iBAAiB,GAAG,6BAA6B;IAOlF;;;;;;OAMG;IACH,IAAW,YAAY,IAAI,YAAY,CAEtC;IAED;;;;;;;OAOG;IACH,IAAW,aAAa,IAAI,MAAM,CAEjC;IAED;;;;;;;OAOG;IACH,IAAW,kBAAkB,IAAI,MAAM,CAEtC;IAED;;;;;;OAMG;IACH,IAAW,iBAAiB,IAAI,MAAM,CAErC;IAED;;;;;;OAMG;IACH,IAAW,YAAY,IAAI,MAAM,CAEhC;IAED;;;;;;OAMG;IACH,IAAW,YAAY,IAAI,MAAM,CAEhC;IAED;;;;;;;OAOG;IACH,IAAW,uBAAuB,IAAI,uBAAuB,CAK5D;CACJ","file":"PronunciationAssessmentResult.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n/* eslint-disable max-classes-per-file */\n\nimport {Contracts} from \"./Contracts.js\";\nimport {\n    PropertyId,\n    RecognitionResult\n} from \"./Exports.js\";\n\ninterface AssessmentResult {\n    NBest: DetailResult[];\n}\n\ninterface DetailResult {\n    Words: WordResult[];\n    PronunciationAssessment: {\n        AccuracyScore: number;\n        CompletenessScore: number;\n        FluencyScore: number;\n        PronScore: number;\n        ProsodyScore: number;\n    };\n    ContentAssessment: {\n        GrammarScore: number;\n        VocabularyScore: number;\n        TopicScore: number;\n    };\n}\n\ninterface WordResult {\n    Word: string;\n    Phonemes: {\n        Phoneme?: string;\n        PronunciationAssessment?: {\n            NBestPhonemes: { Phoneme: string }[];\n        };\n     }[];\n    PronunciationAssessment?: {\n        AccuracyScore: number;\n        ErrorType: string;\n    };\n    Syllables: { Syllable: string }[];\n}\n\nexport class ContentAssessmentResult {\n    private privPronJson: DetailResult;\n\n    /**\n     * @Internal\n     * Do not use externally.\n     */\n    public constructor(detailResult: DetailResult) {\n        this.privPronJson = detailResult;\n    }\n\n    /**\n     * Correctness in using grammar and variety of sentence patterns.\n     * Grammatical errors are jointly evaluated by lexical accuracy,\n     * grammatical accuracy and diversity of sentence structures.\n     * @member ContentAssessmentResult.prototype.grammarScore\n     * @function\n     * @public\n     * @returns {number} Grammar score.\n     */\n    public get grammarScore(): number {\n        return this.privPronJson.ContentAssessment.GrammarScore;\n    }\n\n    /**\n     * Proficiency in lexical usage. It evaluates the speaker's effective usage\n     * of words and their appropriateness within the given context to express\n     * ideas accurately, as well as level of lexical complexity.\n     * @member ContentAssessmentResult.prototype.vocabularyScore\n     * @function\n     * @public\n     * @returns {number} Vocabulary score.\n     */\n    public get vocabularyScore(): number {\n        return this.privPronJson.ContentAssessment.VocabularyScore;\n    }\n\n    /**\n     * Level of understanding and engagement with the topic, which provides\n     * insights into the speaker’s ability to express their thoughts and ideas\n     * effectively and the ability to engage with the topic.\n     * @member ContentAssessmentResult.prototype.topicScore\n     * @function\n     * @public\n     * @returns {number} Topic score.\n     */\n    public get topicScore(): number {\n        return this.privPronJson.ContentAssessment.TopicScore;\n    }\n}\n\n/**\n * Pronunciation assessment results.\n * @class PronunciationAssessmentResult\n * Added in version 1.15.0.\n */\nexport class PronunciationAssessmentResult {\n    private privPronJson: DetailResult;\n\n    private constructor(jsonString: string) {\n        const j = JSON.parse(jsonString) as AssessmentResult;\n        Contracts.throwIfNullOrUndefined(j.NBest[0], \"NBest\");\n        this.privPronJson = j.NBest[0];\n    }\n\n    /**\n     * @member PronunciationAssessmentResult.fromResult\n     * @function\n     * @public\n     * @param {RecognitionResult} result The recognition result.\n     * @return {PronunciationAssessmentConfig} Instance of PronunciationAssessmentConfig\n     * @summary Creates an instance of the PronunciationAssessmentResult from recognition result.\n     */\n    public static fromResult(result: RecognitionResult): PronunciationAssessmentResult {\n        Contracts.throwIfNullOrUndefined(result, \"result\");\n        const json: string = result.properties.getProperty(PropertyId.SpeechServiceResponse_JsonResult);\n        Contracts.throwIfNullOrUndefined(json, \"json\");\n        return new PronunciationAssessmentResult(json);\n    }\n\n    /**\n     * Gets the detail result of pronunciation assessment.\n     * @member PronunciationAssessmentConfig.prototype.detailResult\n     * @function\n     * @public\n     * @returns {DetailResult} detail result.\n     */\n    public get detailResult(): DetailResult {\n        return this.privPronJson;\n    }\n\n    /**\n     * The score indicating the pronunciation accuracy of the given speech, which indicates\n     * how closely the phonemes match a native speaker's pronunciation.\n     * @member PronunciationAssessmentResult.prototype.accuracyScore\n     * @function\n     * @public\n     * @returns {number} Accuracy score.\n     */\n    public get accuracyScore(): number {\n        return this.detailResult.PronunciationAssessment?.AccuracyScore;\n    }\n\n    /**\n     * The overall score indicating the pronunciation quality of the given speech.\n     * This is calculated from AccuracyScore, FluencyScore and CompletenessScore with weight.\n     * @member PronunciationAssessmentResult.prototype.pronunciationScore\n     * @function\n     * @public\n     * @returns {number} Pronunciation score.\n     */\n    public get pronunciationScore(): number {\n        return this.detailResult.PronunciationAssessment?.PronScore;\n    }\n\n    /**\n     * The score indicating the completeness of the given speech by calculating the ratio of pronounced words towards entire input.\n     * @member PronunciationAssessmentResult.prototype.completenessScore\n     * @function\n     * @public\n     * @returns {number} Completeness score.\n     */\n    public get completenessScore(): number {\n        return this.detailResult.PronunciationAssessment?.CompletenessScore;\n    }\n\n    /**\n     * The score indicating the fluency of the given speech.\n     * @member PronunciationAssessmentResult.prototype.fluencyScore\n     * @function\n     * @public\n     * @returns {number} Fluency score.\n     */\n    public get fluencyScore(): number {\n        return this.detailResult.PronunciationAssessment?.FluencyScore;\n    }\n\n    /**\n     * The prosody score, which indicates how nature of the given speech, including stress, intonation, speaking speed and rhythm.\n     * @member PronunciationAssessmentResult.prototype.prosodyScore\n     * @function\n     * @public\n     * @returns {number} Prosody score.\n     */\n    public get prosodyScore(): number {\n        return this.detailResult.PronunciationAssessment?.ProsodyScore;\n    }\n\n    /**\n     * The concent assessment result.\n     * Only available when content assessment is enabled.\n     * @member PronunciationAssessmentResult.prototype.contentAssessmentResult\n     * @function\n     * @public\n     * @returns {ContentAssessmentResult} Content assessment result.\n     */\n    public get contentAssessmentResult(): ContentAssessmentResult {\n        if (this.detailResult.ContentAssessment === undefined) {\n            return undefined;\n        }\n        return new ContentAssessmentResult(this.detailResult);\n    }\n}\n"]}