profile
viewpoint

Ask questionsUnable to contact server. StatusCode: 1006, undefined Reason: Unexpected server response: 200

Hi,

I'm trying to use the sdk as described here, but I'm getting this weird error: Unable to contact server. StatusCode: 1006, undefined Reason: Unexpected server response: 200

I followed this guide to connect existing Bot with existing Cognitive Service.

code:

const sdk = require('microsoft-cognitiveservices-speech-sdk');
const fs = require('fs');
const Throttle = require('throttle');

async function main() {
  console.log('start')
  const fileName = 'test-message-16k.wav'
  const audioStream = fs.createReadStream(fileName);
  const pushStream = sdk.AudioInputStream.createPushStream();
  const handleData = (buf) => {
    pushStream.write(buf.slice());
    console.log('data')
  };

  audioStream.pipe(new Throttle(16384))
    .on('data', handleData)
    .once('close', () => {
      console.log('close')
      pushStream.close();
      audioStream.removeListener('data', handleData);
    });
  const audioConfig = sdk.AudioConfig.fromStreamInput(pushStream)
  const botConfig = sdk.BotFrameworkConfig.fromSubscription('subscription-key', 'region')
  const reco = new sdk.DialogServiceConnector(botConfig, audioConfig)
  reco.recognizing = (_s, event) => {
    console.log('hypothesis', {
      text: event.result.text
    });
  };

  reco.recognized = (_s, event) => {
    ... <some code here>
    }
  };

  reco.canceled = (_s, event) => {
    ... <some code here>
  };

  // Signals that a new session has started with the speech service
  reco.sessionStarted = (_s, event) => {
    ... <some code here>
  };

  // Signals the end of a session with the speech service.
  reco.sessionStopped = (_s, event) => {
    ... <some code here>
  };

  // Signals that the speech service has started to detect speech.
  reco.speechStartDetected = (_s, event) => {
    ... <some code here>
  };

  // Signals that the speech service has detected that speech has stopped.
  reco.speechEndDetected = (_s, event) => {
    ... <some code here>
  };
  console.log('connect')
  reco.connect()
  reco.listenOnceAsync(undefined,
    (e) => {
      console.error('error')
      console.error(e)
    }
  );
  console.log('end')
}
main().catch((r) => console.error(r))

output is somthing like:

data
data
...
reco
connect
end
data
data
....
error
Unable to contact server. StatusCode: 1006, undefined Reason:  Unexpected server response: 200
data
data

This 'subscription-key', 'region' are in used in other parts of our code to connect azure speech sdk and direct line and it works as expected.

Please advise.

Thanks

cc: @orgads

microsoft/cognitive-services-speech-sdk-js

Answer questions nisheetjain

Thanks orgads for the sharing the issue with us.

To make sure the setup is right, can you confirm if you have enabled the channel correctly in Azure bot service following this page?

useful!

Related questions

Continuous recognition doesn't work well when throttling the input stream hot 1
source:https://uonfu.com/
Github User Rank List