Azure JavaScript TTS-SDK 用于将结果作为内存流错误获取
Azure JavaScript TTS-SDK for getting result as an in-memory stream ERROR
音频数据:未定义,
errorDetails:“无法联系服务器。StatusCode:500,
错误详细信息:"Unable to contact server. StatusCode: 500, undefin…external_ocsp_ocsp.Agent is not a constructor"、
//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 Azure Cognitive Services Speech SDK for JavaScript v1.12, which will be released recently. You can download the compiled js file after the release or you can compile it from the master of the sdk repo 中修复。
音频数据:未定义, errorDetails:“无法联系服务器。StatusCode:500, 错误详细信息:"Unable to contact server. StatusCode: 500, undefin…external_ocsp_ocsp.Agent is not a constructor"、
//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 Azure Cognitive Services Speech SDK for JavaScript v1.12, which will be released recently. You can download the compiled js file after the release or you can compile it from the master of the sdk repo 中修复。