speech recognizer is Unable to contact with microsoft azure cognitive speech server
function fromFile(file) {
let audioConfig = sdk.AudioConfig.fromWavFileInput(fs.readFileSync(file), "output.wav");
let speechRecognizer = new sdk.SpeechRecognizer(speechConfig, audioConfig);
speechRecognizer.recognizeOnceAsync(function (result){
switch (result.reason) {
case sdk.ResultReason.RecognizedSpeech:
console.log(`RECOGNIZED: Text=${result.text}`);
break;
case sdk.ResultReason.NoMatch:
console.log("NOMATCH: Speech could not be recognized.");
break;
case sdk.ResultReason.Canceled:
const cancellation = sdk.CancellationDetails.fromResult(result);
console.log(`CANCELED: Reason=${cancellation.reason}`);
if (cancellation.reason == sdk.CancellationReason.Error) {
console.log(`CANCELED: ErrorCode=${cancellation.ErrorCode}`);
console.log(`CANCELED: ErrorDetails=${cancellation.errorDetails}`);
console.log(
"CANCELED: Did you set the speech resource key and region values?"
);
}
break;
}
speechRecognizer.close();
});
}
Output Error:
SpeechRecognitionResult {
privResultId: '6B2CC93A9E674B5686C23121695CC183',
privReason: 1,
privText: undefined,
privDuration: undefined,
privOffset: undefined,
privLanguage: undefined,
privLanguageDetectionConfidence: undefined,
privErrorDetails: 'Unable to contact server. StatusCode: 1006, undefined Reason: getaddrinfo ENOTFOUND centralindia;.stt.speech.microsoft.com', privJson: undefined,
privProperties:
PropertyCollection {
privKeys: [ 'CancellationErrorCode' ],
privValues: [ 'ConnectionFailure' ] },
privSpeakerId: undefined
}
above error is given by speech recognizer result in Node js. even I tried with regenerating keys but still it's not working because in speech recognizer connection URI is missing, my keys giving expected result in normal js but not working for Node js