我使用Microsoft QnA Maker服务和Azure上托管的Azure Web App bot创建了一个Web Chat bot。我在Azure上为我的机器人启用了Web Chat和Direct Line通道。它工作正常。现在我正在尝试将Bing Speech API集成到语音识别中。以下是代码 -
库:
<script src="https://cdn.botframework.com/botframework-webchat/latest/botchat.js"></script>
<script src="https://cdn.botframework.com/botframework-webchat/latest/CognitiveServices.js"></script>
使用JavaScript创建Web应用程序机器人:
const speechOptions = {
speechRecognizer: new CognitiveServices.SpeechRecognizer({ subscriptionKey: <key> }),
speechSynthesizer: new CognitiveServices.SpeechSynthesizer({
gender: CognitiveServices.SynthesisGender.Female,
subscriptionKey: <key>,
voiceName: 'Microsoft Server Speech Text to Speech Voice (en-US, JessaRUS)'
})
};
BotChat.App({
bot: bot,
locale: params['locale'],
resize: 'detect',
// sendTyping: true, // defaults to false. set to true to send 'typing' activities to bot (and other users) when user is typing
speechOptions: speechOptions,
user: user,
directLine: {
domain: params['domain'],
secret: params['s'],
token: params['t'],
webSocket: params['webSocket'] && params['webSocket'] === 'true' // defaults to true
}
}, document.getElementById('chatBot'));
当我在Chrome或Edge上运行时,我可以点击麦克风并说些什么,然后我得到一个回复(基于QnA制造商中的Key-Answer映射)作为文本和语音。问题是,如果答案太长(如600个字符),我只会将文本作为回复但没有声音。
对此有何帮助?如果我能提供更多详细信息,请通知我。