audioData: undefined, 错误详细信息:"无法联系服务器。状态代码: 500, 错误详细信息:"无法联系服务器。状态代码:500,未定义...external_ocsp_ocsp。代理不是构造函数",
//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();
}
);
},
此问题已在最近发布的 Azure Cognitive Services Speech SDK for JavaScript v1.12 Microsoft中修复。您可以在发布后下载已编译的 js 文件,也可以从 sdk 存储库的主节点编译它。