How to turn on always the microphone in bot framework direct line

拈花ヽ惹草 提交于 2019-12-13 05:09:28

问题


I'm creating a bot which accept text and voice input and also can answer in both mode. The bot works really good but i have to click always the button of microphone to speak with the bot. Do you know it is possible to make microphone always on and to recognize the voice without clicking the button of microphone ?

<!DOCTYPE html>
<html>
<head>
<link href="https://cdn.botframework.com/botframework- 
webchat/latest/botchat.css" rel="stylesheet" />
  </head>
   <body>
   <div id="bot" />
   <script src="https://cdn.botframework.com/botframework- 
    webchat/latest/botchat.js"></script>
  <script src="https://cdn.botframework.com/botframework- 
 webchat/latest/CognitiveServices.js"></script>
        <script> var speechOptions = {
          speechRecognizer: new CognitiveServices.SpeechRecognizer(
        { subscriptionKey: 'xxxxxx' }),

            speechSynthesizer: new CognitiveServices.SpeechSynthesizer(
        {
            subscriptionKey: 'xxxxxxxxxxx',
            gender: CognitiveServices.SynthesisGender.Female,
            voiceName: 'Microsoft Server Speech Text to Speech Voice (en-US, 
    JessaRUS)'
        })
  }

    var botConnection = new BotChat.DirectLine({
     secret: "zzzzzzzzzz",
    webSocket: true,
   });


BotChat.App({
        speechOptions: speechOptions,
        botConnection: botConnection,
        user: {
            id: 'userid',
            name: 'User',
        },
        bot: { id: 'botid' },
        resize: 'detect',
        locale: 'en-US'

    },

function postHelp() {
    botConnection
        .postActivity({
            from: { id: 'userid', name: 'User' },
            name: 'postHelp',
            type: 'message',
            text: 'help'
        })
        .subscribe(function(id) {
            console.log('"postHelp" sent');
        });
};

function welcome() {
    botConnection
        .postActivity({
            from: { id: 'userid', name: 'User' },
            name: 'welcome',
            type: 'event',
            value: 'help'
        })
        .subscribe(function (id) {
            console.log('"welcome" sent');
        });
}
</script>


回答1:


You cannot just turn on such a behavior. To have something like this, you have to implement the whole thing yourself, editing the code of the web chat control. The web chat control is using the Direct Line API under the hood through the DirectLineJS library.



来源:https://stackoverflow.com/questions/51138445/how-to-turn-on-always-the-microphone-in-bot-framework-direct-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!