简体   繁体   中英

Azure SpeechSynthesizer Error HTTP: not supported. Expected HTTPS: NPM `microsoft-cognitiveservices-speech-sdk`

I am using the microsoft-congnitiveservices-speech-sdk npm package and things have been working fine. But randomly I am getting an error now. Either broke with browser update or minor package update(?)

'Unable to contact server. StatusCode: 500, undefined Reason: TypeError [ERR_INVALID_PROTOCOL]: Protocol "http:" not supported. Expected "https:"'

I have tried from both a local dev HTTP server, as well as a production site that is secure with HTTPS. Any thoughts or solutions to solve what is being the microsoft-congnitiveservices-speech-sdk issue?

import * as Azure from "microsoft-cognitiveservices-speech-sdk";

const speechConfig = Azure.SpeechConfig.fromSubscription(SPEECH_KEY, SPEECH_REGION);
      speechConfig.speechSynthesisOutputFormat = Azure.SpeechSynthesisOutputFormat.Audio48Khz192KBitRateMonoMp3;

const synthesizer = new Azure.SpeechSynthesizer(speechConfig);

const ssml = `
  <speak version="1.0" xmlns="https://www.w3.org/2001/10/synthesis" xml:lang="en-US">
    <voice name="en-US-JennyNeural">
      <prosody volume="85" pitch="medium" rate="1">
        <break time="1.5s" /> ${text}
      </prosody>
    </voice>
  </speak>
`

try {
  synthesizer.speakSsmlAsync(
    ssml,
    result => {
        synthesizer.close();
        console.log('RESULT', result)
        resolve(result);
    },
    error => {
        synthesizer.close();
        console.log('ERROR', error)
        if(error) throw Error(error)
    });
}
catch(err) {
  console.log(err)
  throw(err)
}

For me, the issue was related to Sentry integration. More info here: https://github.com/microsoft/cognitive-services-speech-sdk-js/issues/458

So far seems like issue is not resolved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM