Azure JavaScript TTS-SDK用于将结果作为内存流错误ERROR

问题描述 投票:0回答:1

audioData:未定义,错误详细信息:“无法联系服务器。状态代码:500,ErrorDetails:“无法联系服务器。状态代码:500,未定义... external_ocsp_ocsp。Agent不是构造函数”,

//code
synthesizeSpeech() {
      let that = this;
      const speechConfig = SpeechConfig.fromSubscription(
        "********",
        "********"
      );
      speechConfig.speechSynthesisLanguage = "zh-CN";
      const synthesizer = new SpeechSynthesizer(speechConfig);
      var soundContext = undefined;
      try {
        var AudioContext = window.AudioContext ||window.webkitAudioContext || false;
        if(AudioContext){
          soundContext = new AudioContext();
        }
      } catch (err) {
        console.log(err)
      }
      synthesizer.speakTextAsync(
        "你好你好你好你好你好你好你好.",
        result => {
          console.log(result)
          if(result.audioData && soundContext){
            var source = soundContext.createBufferSource();
            soundContext.decodeAudioData(result.audioData,function(newBuffer){
              source.buffer = newBuffer;
              source.connect(soundContext.destination);
              source.start(0);
            })
          }
          synthesizer.close();
        },
        error => {
          console.log(error);
          synthesizer.close();
        }
      );
    },
microsoft-cognitive speech
1个回答
0
投票

此问题已在Microsoft Azure Cognitive Services Speech SDK for JavaScript v1.12中修复,将在最近发布。您可以在发行后下载已编译的js文件,也可以从sdk repo的母版进行编译。

© www.soinside.com 2019 - 2024. All rights reserved.