我正在关注this link,在这里我们可以在bot框架中使用语音识别。
默认代码与选项2 ,
一起使用 // // Option 2: Native browser speech (not supported by all browsers, no speech recognition priming support)
//
// Note that Chrome automatically blocks speech if the HTML file is loaded from disk. You can run a server locally
// or launch Chrome (close all the existing Chrome browsers) with the following option:
// chrome.exe --allow-file-access-from-files <sampleHtmlFile>
//
const speechOptions = {
speechRecognizer: new BotChat.Speech.BrowserSpeechRecognizer(),
speechSynthesizer: new BotChat.Speech.BrowserSpeechSynthesizer()
};
但是当我尝试使用认知服务时,它不起作用,这意味着麦克风不会进入聆听模式。
这是我所做的更改,
// // Option 3: Cognitive Services speech recognition using API key (cross browser, speech priming support)
const speechOptions = {
speechRecognizer: new CognitiveServices.SpeechRecognizer({ subscriptionKey: 'YOUR_COGNITIVE_SPEECH_API_KEY' }),
speechSynthesizer: new CognitiveServices.SpeechSynthesizer({
gender: CognitiveServices.SynthesisGender.Female,
subscriptionKey: 'YOUR_COGNITIVE_SPEECH_API_KEY',
voiceName: 'Microsoft Server Speech Text to Speech Voice (en-US, JessaRUS)'
})
};
除了评论和取消评论外,我什么也没做。但是代码仍然仅与选项2
一起使用请帮我解决这个问题
答案 0 :(得分:0)
经过我同事的深入研究,我们发现了问题。
原始代码使用的是https://cdn.botframework.com/botframework-webchat/latest/CognitiveServices.js
<div id="BotChatGoesHere"></div>
<!-- If you do not want to use Cognitive Services library, comment out the following line -->
<script src="https://cdn.botframework.com/botframework-webchat/latest/CognitiveServices.js"></script>
如果我们打开该JS文件,则可以在下面使用bing语音网址找到一行
Storage.Local.GetOrAdd("Host","wss://speech.platform.bing.com")}
由于描述了 bing语音,我们必须将此行更新为我们自己的订阅
Storage.Local.GetOrAdd("Host","wss://<region>.stt.speech.microsoft.com")}
一旦我们更新,它现在就可以正常工作