以前在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)'
})
};
非常感谢。
“文字转语音”不适用于认知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')
);
答案 0 :(得分:0)
签出位于BotFramework-WebChat存储库中的示例06.g.select-voice。随附的index.html
显示了完整的代码。
以上示例扩展了示例06.c.cognitive-services-speech-services-js。如果您需要其他指导,请考虑仔细阅读。
希望有帮助!