【问题标题】:How to turn on always the microphone in bot framework direct line如何在机器人框架直线中始终打开麦克风
【发布时间】:2018-07-06 16:06:33
【问题描述】:

我正在创建一个接受文本和语音输入并且可以在两种模式下回答的机器人。 该机器人工作得非常好,但我必须始终单击麦克风按钮才能与机器人交谈。您知道无需单击麦克风按钮就可以使麦克风始终打开并识别声音吗?

<!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>

【问题讨论】:

  • 这里不足以重现您所询问的情况。如果可以,请发布最低限度的可重现代码,特别是 RootDialog.cs 中显示您的消息 Activity 的部分。
  • @JJ_Wailes 这里不用加RootDialog,问题出在Webchat组件上

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


【解决方案1】:

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

【讨论】:

  • 我已经实现了 DirectLine 并且正在工作......关键是让麦克风打开......不要在每次用户不得不说什么时点击麦克风按钮。
  • 此时此刻是:点击麦克风按钮,说一句话……等待答案,然后再做同样的事情
  • 是的,我就是这么说的。 Web 聊天控件中没有开箱即用的支持。您必须分叉它的源代码并自己实现功能。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-05-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多