azure prononciation assessment time limit

Iheb Jandoubi 5 Reputation points
2024-05-17T11:36:28.55+00:00

i am using azure prononciation assessment to assess an audio , but the problem the assessment happens only for the 1 min of the speech and it doesnt assess the rest of the audio

this is my code

const sdk = require("microsoft-cognitiveservices-speech-sdk");
const { storageConnectionAudio} = require("./blobStorage");
const {streamToBuffer}= require('../utils/streamToBuffer')
const { detectSingleSpeechLanguage } = require("./languageDetection");
async function waitForBlob(blobClient) {
  let exists = await blobClient.exists();
  while (!exists) {
    console.log("wainting for the audio blob")
    await new Promise((resolve) => setTimeout(resolve, 5000));
    exists = await blobClient.exists();
  }
}

/** This is Azure Prononciation Assessment module: in this module we evalute the user audio against his speech  */
function evaluatePronunciation(text, audioBlobName) {
  
  return new Promise(async (resolve, reject) => {
    try {
      console.log('hereeeeeee')
      const language = await detectSingleSpeechLanguage(text)
     

      //Connect to the prononciation assessment ressource
      const speechConfig = sdk.SpeechConfig.fromSubscription(
       =
        );
        speechConfig.setProperty()
      //download the audio of user from the blob storage
      const audioBlobClient = await storageConnectionAudio(audioBlobName);
      await waitForBlob(audioBlobClient);
      if (language === "English") {
        speechConfig.speechRecognitionLanguage = "en-US";
      
      } 
      if (language === "French"){
        speechConfig.speechRecognitionLanguage = "fr-FR";
       
      }
    
      const audio = await audioBlobClient.download();
      const downloadedFile = await streamToBuffer(audio.readableStreamBody);
     
      let audioConfig = sdk.AudioConfig.fromWavFileInput(downloadedFile);
     
      let speechRecognizer = new sdk.SpeechRecognizer(
        speechConfig,
        audioConfig
      );
     
      const pronunciationAssessmentConfig = sdk.PronunciationAssessmentConfig.fromJSON(
        "{\"GradingSystem\": \"HundredMark\", \
        \"Granularity\": \"Phoneme\", \
        \"EnableMiscue\": \"True\", \
        \"EnableProsodyAssessment\": \"True\"}"
    );
    pronunciationAssessmentConfig.referenceText = text;
    
      
      
      pronunciationAssessmentConfig.applyTo(speechRecognizer);
     //Start of the prononciation assessment 
      speechRecognizer.recognizeOnceAsync(async (result) =>
      
      {
        switch (result.reason) {

          case sdk.ResultReason.RecognizedSpeech:
            const pronunciation_result =
              sdk.PronunciationAssessmentResult.fromResult(result);
       
            const jsonInput = pronunciation_result.privPronJson;
Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,464 questions
{count} votes