尝试使用提供的演示中的代码,使用来自https://github.com/watson-developer-cloud/speech-javascript-sdk的最新watson-speech.js .js
document.querySelector('#button').onclick = function () {
fetch('myserverurl/api/token')
.then(function(response) {
return response.text();
}).then(function (token) {
var stream = WatsonSpeech.SpeechToText.recognizeMicrophone({
token: token,
outputElement: '#output' // CSS selector or DOM Element
});
stream.on('error', function(err) {
console.log(err);
});
document.querySelector('#stop').onclick = function() {
stream.stop();
};
}).catch(function(error) {
console.log(error);
});
};在Chrome控制台中尝试启动连接时立即收到此错误: WebSocket已处于关闭或关闭状态。
使用Chrome并在本地测试。
https://stackoverflow.com/questions/51429963
复制相似问题