cognitive-services-speech-sdk: Pronunciation assessment with topic not returning ContentAssessment

Hi there, im trying to work on speaking feature (pronunciationAssessmentConfig.enableContentAssessmentWithTopic(settings.topic)😉 with js sdk but the ContentAssessment scores (VocabularyScore, GrammarScore, and TopicScore ) are never returned. I only get pronunciation scores. has someone tried and made it work?

i used node.js sdk

import * as sdk from 'microsoft-cognitiveservices-speech-sdk';
import fs from 'fs';
import _ from 'lodash';

// content assessment with audio file
export const main = (settings) => {
    var audioConfig = sdk.AudioConfig.fromWavFileInput(fs.readFileSync(settings.filename));
    var speechConfig = sdk.SpeechConfig.fromSubscription(settings.subscriptionKey, settings.serviceRegion);

    // setting the recognition language to English.
    speechConfig.speechRecognitionLanguage = "en-US";

    const pronunciationAssessmentConfig = new sdk.PronunciationAssessmentConfig(
        "",
        sdk.PronunciationAssessmentGradingSystem.HundredMark,
        sdk.PronunciationAssessmentGranularity.Phoneme,
        false
    );
    pronunciationAssessmentConfig.enableProsodyAssessment = true;
    pronunciationAssessmentConfig.enableContentAssessmentWithTopic(settings.topic);

    // create the speech recognizer.
    var reco = new sdk.SpeechRecognizer(speechConfig, audioConfig);
    // (Optional) get the session ID
    reco.sessionStarted = (_s, e) => {
        console.log(`SESSION ID: ${e.sessionId}`);
    };
    pronunciationAssessmentConfig.applyTo(reco);

    var results = [];
    var recognizedText = "";

    reco.recognized = function (s, e) {
        var jo = JSON.parse(e.result.properties.getProperty(sdk.PropertyId.SpeechServiceResponse_JsonResult));
        if (jo.DisplayText != ".") {
            console.log(`Recognizing: ${jo.DisplayText}`);
            recognizedText += jo.DisplayText + " ";
        }
        results.push(jo);
    }

    function onRecognizedResult() {
        console.log(`Recognized text: ${recognizedText}`);
        var contentResult = results[results.length-1].NBest[0].ContentAssessment;

        console.log("Content assessment result: \n",
            "\tvocabulary score: ", Number(contentResult.VocabularyScore.toFixed(1)), '\n',
            "\tgrammar score: ", Number(contentResult.GrammarScore.toFixed(1)), '\n',
            "\ttopic score: ", Number(contentResult.TopicScore.toFixed(1))
        );
    }

    reco.canceled = function (s, e) {
        if (e.reason === sdk.CancellationReason.Error) {
            var str = "(cancel) Reason: " + sdk.CancellationReason[e.reason] + ": " + e.errorDetails;
            console.log(str);
        }
        reco.stopContinuousRecognitionAsync();
    };

    reco.sessionStopped = function (s, e) {
        reco.stopContinuousRecognitionAsync();
        reco.close();
        onRecognizedResult();
    };

    reco.startContinuousRecognitionAsync();
}```

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

We won’t plan new release. You can just use LLM to get content scores.