speechRecognizer.recognized is not working

Rakesh Indla 5 Reputation points
2023-11-06T08:52:05.3233333+00:00

Hello,

I have used .wav file to convert audio to text, It's working in my local environment, but after we deployed the same code in dev, it's get stuck at speechRecognizer.recognized (this line is not executing), After some time, it is ending up with "Timeout error" Could you please help me.

Code:

const azureRegion = 'westus';
const speechConfig = await SpeechConfig.fromSubscription(this.azureSubscriptionKey,  azureRegion);
speechConfig.speechRecognitionLanguage = "en-IN";
const audioConfig = await AudioConfig.fromWavFileInput(fs.readFileSync('conversationRecord.wav'));
let speechRecognizer = await new SpeechRecognizer(speechConfig, audioConfig);
let completeData = "";
       
speechRecognizer.startContinuousRecognitionAsync(
    () => { console.log("Recognition started.", speechRecognizer.recognized); 
    speechRecognizer.recognized = (sender, event) => {
    if (event.result.reason === ResultReason.RecognizedSpeech) {
        completeData += event.result.text + " ";
        console.log("Converted text:", completeData);
    }
    }, (err) => {
         console.log('Error', err)
         console.error("Error converting text:", err);
     };
    },
    (err) => {
         console.error("Error starting recognition:", err);
    }
 );
Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,476 questions
Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
745 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,520 questions
{count} votes

1 answer

Sort by: Most helpful
  1. romungi-MSFT 43,366 Reputation points Microsoft Employee
    2023-11-06T10:20:39.1566667+00:00

    @Rakesh Indla If the recognition works in your local with the same code and not in your environment then the most likely cause could be the file cannot be read in your environment since it cannot fire an event for recognized. I would suggest providing the complete path of your file to be read or ensure the file is present with the required permissions for the speechrecognizer to read the file. Also, ensure the required libraries are installed to read a wav format file in your environment, usually the libraries that are installed for SDK should take of this dependency while installing the SDK.

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    0 comments No comments