尝试通过浏览器在机器人上使用Azure语音服务时出现语音服务异常
在使用IE,Chrome和Firefox的机器人上触发语音识别时,遇到以下异常: SCRIPT12008:SCRIPT12008:WebSocket错误:错误的HTTP响应。状态码401,未经授权 该漫游器可以很好地处理键入的消息,但是当用户单击麦克风图标时会失败。 我正在使用Directline与机器人进行通信。 您可以提出建议吗? 提前谢谢
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="https://cdn.botframework.com/botframework-webchat/latest/botchat.css" rel="stylesheet" />
<link href="chat-assets/css/botchat-override.css" rel="stylesheet" />
<style>
html,body{height: 100%}
</style>
</head>
<body style="background-color: #fff; background-image: url('aila-msbot.jpg'); background-repeat: no-repeat; background-position: center center; background-size: 100%; ">
<div id="bot-holder">
<div id="bot-container">
<div class="bot-header">
<div class="icon-holder">
<div class="icon"></div>
</div>
<div class="bot-title">Aila</div>
<a href="javascript:closeChat()">X</a>
</div>
<div id="bot"></div>
</div>
<a id="bot-minimize" class="hide" href="javascript:startChat();">
<div class="comment"></div>
</a>
</div>
<script src="https://cdn.botframework.com/botframework-webchat/latest/botchat.js"></script>
<script src="https://cdn.botframework.com/botframework-webchat/latest/CognitiveServices.js"></script>
<script>
var user = {
id: 'User',
name: 'You'
};
var botConnection = new BotChat.DirectLine({
token: 'XXXXXXXXXXXX',
user: user
});
var speechOptions = {
speechRecognizer: new CognitiveServices.SpeechRecognizer( { subscriptionKey: 'XXXXXXXXXXXX'} ),
speechSynthesizer: new CognitiveServices.SpeechSynthesizer(
{
subscriptionKey: 'XXXXXXXXXXXX',
gender: CognitiveServices.SynthesisGender.Female,
voiceName: 'Microsoft Server Speech Text to Speech Voice (en-US, JessaRUS)'
})
};
BotChat.App({
user: user,
botConnection: botConnection,
speechOptions: speechOptions,
bot: { id: 'XXXXXXXXXXXX', name: 'Bella' },
resize: 'detect'
}, document.getElementById("bot"));
botConnection
.postActivity({
from: user,
name: 'requestWelcomeDialog',
type: 'event',
value: ''
})
.subscribe(function (id) {
console.log('"trigger requestWelcomeDialog" sent');
});
function closeChat(){
var chatWin = document.getElementById('bot-container');
var closeIcon = document.getElementById('bot-minimize');
chatWin.classList.add('hide');
closeIcon.classList.remove('hide');
}
function startChat(){
var chatWin = document.getElementById('bot-container');
var closeIcon = document.getElementById('bot-minimize');
chatWin.classList.remove('hide');
closeIcon.classList.add('hide');
}
onload = function(){
//closeChat();
}
</script>
</body>
</html>
答案 0 :(得分:0)
Bing搜索已过时。 推荐使用Azure搜索用法,但是botchat.js不支持使用Azure搜索。 因此,有必要迁移到webchat.cs。 有关更多信息,请访问https://www.npmjs.com/package/botframework-webchat