如何在Bot Framework直线中始终打开麦克风

时间:2018-07-02 14:26:54

标签: c# botframework speech-to-text direct-line-botframework

我正在创建一个机器人,该机器人可以接受文本和语音输入,并且还可以在两种模式下进行应答。 该机器人的工作原理非常好,但我必须始终单击麦克风按钮才能与该机器人对话。您是否知道不单击麦克风按钮就能始终打开麦克风并识别语音吗?

<!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 个答案:

答案 0 :(得分:1)

您不能仅打开这种行为。要拥有这样的东西,您必须自己实现整个过程,编辑web chat control的代码。网络聊天控件正在通过Direct Line API库在后台使用DirectLineJS