在 Directline 4.0 Webchat 中集成认知语音
Integrate Cognitive Speech in Directline 4.0 Webchat
之前在 V3.0
我使用这段代码并将其作为参数传递给 Bot.App
,但我不知道如何在 Directline V4.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)'
})
};
非常感谢。
Text to Speech 不适用于 Cognitive 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 的基础上进行了扩展。如果您需要其他指导,请考虑仔细阅读这一篇。
希望得到帮助!
V3.0
我使用这段代码并将其作为参数传递给 Bot.App
,但我不知道如何在 Directline V4.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)'
})
};
非常感谢。
Text to Speech 不适用于 Cognitive 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 的基础上进行了扩展。如果您需要其他指导,请考虑仔细阅读这一篇。
希望得到帮助!