Javascript 将Bot与Azure语音服务集成问题
尝试通过浏览器在bot上使用Azure语音服务时出现语音服务异常 使用IE、Chrome和Firefox在我的机器人上触发语音识别时出现以下异常: SCRIPT12008:SCRIPT12008:WebSocket错误:HTTP响应不正确。状态代码401,未经授权 对于键入的消息,bot可以正常工作,但在用户单击麦克风图标时失败。 我正在使用Directline与机器人通信。 你能提出建议吗? 提前ThxJavascript 将Bot与Azure语音服务集成问题,javascript,frameworks,bots,Javascript,Frameworks,Bots,尝试通过浏览器在bot上使用Azure语音服务时出现语音服务异常 使用IE、Chrome和Firefox在我的机器人上触发语音识别时出现以下异常: SCRIPT12008:SCRIPT12008:WebSocket错误:HTTP响应不正确。状态代码401,未经授权 对于键入的消息,bot可以正常工作,但在用户单击麦克风图标时失败。 我正在使用Directline与机器人通信。 你能提出建议吗? 提前Thx <!DOCTYPE html> <html> <head
<!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>
html,正文{高度:100%}
艾拉
变量用户={
id:'用户',
姓名:你
};
var botConnection=new BotChat.DirectLine({
令牌:“XXXXXXXXXX”,
用户:用户
});
var语音选项={
语音识别器:新的认知服务。语音识别器({subscriptionKey:'xxxxxxxxxxx'}),
speechSynthesizer:新的认知服务。speechSynthesizer(
{
订阅密钥:“XXXXXXXXXX”,
性别:认知服务。综合性别。女性,
voiceName:“Microsoft服务器语音文本到语音语音(美国英语,JessaRUS)”
})
};
BotChat.App({
用户:用户,,
botConnection:botConnection,
语音提示:语音提示,
机器人:{id:'xxxxxxxxxxx',名称:'Bella'},
调整大小:“检测”
},document.getElementById(“bot”);
僵尸连接
1.后期活动({
发件人:用户:,
名称:'requestWelcomeDialog',
键入:“事件”,
值:“”
})
.订阅(功能(id){
log('trigger requestWelcomeDialog'sent');
});
函数closeChat(){
var chatWin=document.getElementById('bot-container');
var closeIcon=document.getElementById('bot-minimize');
chatWin.classList.add('hide');
closeIcon.classList.remove('hide');
}
函数startChat(){
var chatWin=document.getElementById('bot-container');
var closeIcon=document.getElementById('bot-minimize');
chatWin.classList.remove('hide');
closeIcon.classList.add('hide');
}
onload=函数(){
//closeChat();
}
必应搜索已经过时。
Azure搜索使用是推荐的方法,但botchat.js不支持这种方法。
因此,迁移到webchat.cs是必要的。
更多信息请访问