禁用Webchat控件中的文本语音转换

时间:2019-09-05 13:59:15

标签: javascript web-chat

我想在Microsoft Webchat控件中启用“语音转文本”功能,但是我还需要禁用“文本转语音”。

我试图将属性 speechSynthesis SpeechSynthesisUtterance 设置为空,但是它不起作用。更好的是,该漫游器不会将响应回读给用户,但在第一次交互后,麦克风图标会变灰并禁用。

这是我的代码:

var _botConnection = new window.WebChat.createDirectLine({
      token: '{secret}'
});    
const subscriptionKey = 'xxxxxxxxxxxxxx';

async function createPonyfillFactory() {
       const webSpeechPonyfillFactory = await window.WebChat.createCognitiveServicesSpeechServicesPonyfillFactory({
       region: 'westeurope',
       speechRecognitionEndpointId: 'yyyyyyyyyyyyy',
       subscriptionKey
       });

     return options => {
            const webSpeechPonyfill = webSpeechPonyfillFactory(options);
                    return {
                        SpeechGrammarList: webSpeechPonyfill.SpeechGrammarList,
                        SpeechRecognition: webSpeechPonyfill.SpeechRecognition,
                        speechSynthesis: null,
                        SpeechSynthesisUtterance: null
                    }
                };
            };

 window.WebChat.renderWebChat({
       directLine: _botConnection,
       webSpeechPonyfillFactory: await createPonyfillFactory()
       },
       document.getElementById('webchat')
 );

这是控制台输出:

webchat.js:1 TypeError: i is not a constructor
at c (webchat.js:1)
at webchat.js:1
at c (webchat.js:1)
at Generator._invoke (webchat.js:1)
at Generator.e.<computed> [as next] (webchat.js:1)
at n (webchat.js:1)
at s (webchat.js:1)
at webchat.js:1
at new Promise (<anonymous>)
at webchat.js:1

0 个答案:

没有答案