botframework - 在 Directline 4.0 网络聊天中集成认知语音
问题描述
以前V3.0
我使用此代码并将其Bot.App
作为参数传递,但我不知道如何在 DirectlineV4.0
中使用Webchat-E5.js
const speechOptions = {
speechRecognizer: new CognitiveServices.SpeechRecognizer({ locale: 'de-DE', subscriptionKey: '1add78901d9d' }),
speechSynthesizer: new CognitiveServices.SpeechSynthesizer({
gender: CognitiveServices.SynthesisGender.Female,
subscriptionKey: '1add78125a901d9d',
voiceName: 'Microsoft Server Speech Text to Speech Voice (de-DE, Stefan, Apollo)'
})
};
提前谢谢了。
文本到语音无法与认知 Bing API 一起使用。
window.fetch('https://sfbotspeech.cognitiveservices.azure.com/sts/v1.0/issuetoken', { method: 'POST', headers: {
'Ocp-Apim-Subscription-Key' : 'f9d649bf33bf2427c', 'Content-type': 'application/x-www-form-urlencoded' , 'Content-Length': '0'} })
.then(function (res) {
return res.text();
})
.then(function (authtok) {
SpeechToken = authtok;
console.log(SpeechToken) ;
const webSpeechPonyfillFactory = WebChat.createCognitiveServicesSpeechServicesPonyfillFactory({
authorizationToken: SpeechToken
});
///
WebChat.renderWebChat(
{
bot: bot,
directLine: WebChat.createDirectLine({token}),
user: user,
//speechOptions: speechOptions,
resize: 'detect',
styleOptions: styleOptions,
selectVoice: (activity) =>
activity.locale === 'de-DE',
webSpeechPonyfillFactory : webSpeechPonyfillFactory
},
document.getElementById('BotChatGoesHere')
);
解决方案
查看位于 BotFramework-WebChat 存储库中的示例06.g.select-voice 。附件index.html
显示了完整的代码。
上面的示例扩展了示例06.c.cognitive-services-speech-services-js。如果您需要其他指导,请考虑查看此指南。
希望有帮助!
推荐阅读
- python - 我怎样才能训练一个模型来接受每边的词向量并预测中间词?
- node.js - 部署nodejs+informixDB到heroku
- datatables - 使用数据表中的过滤列表发送多封电子邮件
- javascript - 对于具有固定数量字段的对象,使用一个 setter 方法还是多个方法更好?
- python - 为什么python中没有设置popitem?
- shell - 在 shell 中执行一个名称中包含空格的 python 文件
- python - 支持故障排除初学者类代码
- r - 插入符号 glm 逻辑回归类型 = “响应?”
- html - 当一个溢出时堆栈div
- mysql - MySQL 使用 BETWEEN 不返回任何内容?