Unable to contact server. StatusCode: 1006, undefined Reason
See original GitHub issueI just copied and pasted the node js code and replace the filename, key, and region but it throws the following error:
E:\Upwork\stt\stt-new\controllers>node microsoft.js Now recognizing from: m1561477818826.wav SpeechRecognitionResult { privResultId: ‘1530E7597EE7496E91747B86931F79F9’, privReason: 1, privText: undefined, privDuration: undefined, privOffset: undefined, privErrorDetails: 'Unable to contact server. StatusCode: 1006, undefined Reason: ', privJson: undefined, privProperties: PropertyCollection { privKeys: [ ‘CancellationErrorCode’ ], privValues: [ ‘ConnectionFailure’ ] } } Trace: err - Runtime error: Unable to contact server. StatusCode: 1006, undefined Reason: at E:\Upwork\stt\stt-new\controllers\microsoft.js:56:13 at E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\sdk\SpeechRecognizer.js:157:21 at E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\sdk\Recognizer.js:129:17 at Sink.executeErrorCallback (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:351:21) at Sink.reject (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:318:23) at Deferred.reject (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:281:28) at E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:193:46 at Sink.executeErrorCallback (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:351:21) at Sink.reject (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:318:23) at Deferred.reject (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:281:28) E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:354 throw new Error(“‘Unhandled callback error: " + e + ". InnerError: " + error + "’”); ^
Error: ‘Unhandled callback error: Error: ‘Cannot reject a completed promise’. InnerError: ‘Unhandled callback error: Error: ‘Cannot reject a completed promise’’’ at Sink.executeErrorCallback (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:354:27) at Sink.executeSuccessCallback (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:345:23) at Sink.resolve (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:306:23) at Deferred.resolve (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common\Promise.js:277:28) at WebSocket._this.privWebsocketClient.onclose (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\distrib\lib\src\common.browser\WebsocketMessageAdapter.js:107:59) at WebSocket.onClose (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\node_modules\ws\lib\event-target.js:124:16) at WebSocket.emit (events.js:182:13) at WebSocket.emitClose (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\node_modules\ws\lib\websocket.js:182:12) at ClientRequest.req.on (E:\Upwork\stt\stt-new\node_modules\microsoft-cognitiveservices-speech-sdk\node_modules\ws\lib\websocket.js:569:15) at ClientRequest.emit (events.js:182:13)
Here is my code
var sdk = require("microsoft-cognitiveservices-speech-sdk");
var fs = require("fs");
// replace with your own subscription key,
// service region (e.g., "westus"), and
// the name of the file you want to run
// through the speech recognizer.
var subscriptionKey = "*****************";
var serviceRegion = "westus"; // e.g., "westus"
var filename = "m1561477818826.wav"; // 16000 Hz, Mono
// create the push stream we need for the speech sdk.
var pushStream = sdk.AudioInputStream.createPushStream();
// open the file and push it to the push stream.
fs.createReadStream(filename).on('data', function(arrayBuffer) {
pushStream.write(arrayBuffer.buffer);
}).on('end', function() {
pushStream.close();
});
// we are done with the setup
console.log("Now recognizing from: " + filename);
// now create the audio-config pointing to our stream and
// the speech config specifying the language.
var audioConfig = sdk.AudioConfig.fromStreamInput(pushStream);
var speechConfig = sdk.SpeechConfig.fromSubscription(subscriptionKey, serviceRegion);
// setting the recognition language to English.
speechConfig.speechRecognitionLanguage = "en-US";
// create the speech recognizer.
var recognizer = new sdk.SpeechRecognizer(speechConfig, audioConfig);
// start the recognizer and wait for a result.
recognizer.recognizeOnceAsync(
function (result) {
console.log(result);
recognizer.close();
recognizer = undefined;
},
function (err) {
console.trace("err - " + err);
recognizer.close();
recognizer = undefined;
});
Issue Analytics
- State:
- Created 4 years ago
- Comments:21 (8 by maintainers)
Top GitHub Comments
@therowf - please edit the message remove your subscription key!
Has anybody come to a resolution on this? I am having the same issue. My subscription key and region are correct but still get the “Unable to contact server” message.
Thanks.