具有认知语音的 Azure Bot Framework 不工作
Azure Bot Framework with Cognitive Speech not working
我正在关注 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)'
})
};
除了评论和取消评论,我什么都没做。但是代码仍然只适用于 Option 2
请帮我解决这个问题
经过我同事的深入挖掘,我们发现了这个问题。
原始代码使用 https://cdn.botframework.com/botframework-webchat/latest/CognitiveServices.js
中的 javascript
<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 speech url
Storage.Local.GetOrAdd("Host","wss://speech.platform.bing.com")}
由于 bing 语音被描述 我们必须将此行更新为我们自己的订阅
Storage.Local.GetOrAdd("Host","wss://<region>.stt.speech.microsoft.com")}
我们更新后它现在工作正常
我正在关注 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)'
})
};
除了评论和取消评论,我什么都没做。但是代码仍然只适用于 Option 2
请帮我解决这个问题
经过我同事的深入挖掘,我们发现了这个问题。
原始代码使用 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 speech url
Storage.Local.GetOrAdd("Host","wss://speech.platform.bing.com")}
由于 bing 语音被描述 我们必须将此行更新为我们自己的订阅
Storage.Local.GetOrAdd("Host","wss://<region>.stt.speech.microsoft.com")}
我们更新后它现在工作正常