1

I'm currently attempting to accept voice input from the user, feed it into the Bing Speech API to get text, and pass that text as a user response. I've gotten as far as receiving the text back from Bing, but I'm not sure how to send that text as a user response. I've been scouring GitHub, so any feedback is appreciated. Relevant code is below:

function(session){
    var bing = new client.BingSpeechClient('mykey');
    var results = '';
    var wave = fs.readFileSync('./new.wav');

    const text = bing.recognize(wave).then(result => {
      console.log('Speech To Text completed');
      console.log(result.header.lexical)
      console.log('\n');
      results.response = result.header.lexical;
    });
    }]
Ezequiel Jadib
  • 14,767
  • 2
  • 38
  • 43
Gavination
  • 78
  • 1
  • 5
  • Update: Figured it out (sorta). In order to take advantage of sending this user input back, I had to use another card. Within the context of the card, I'm able to use the `imBack` function. – Gavination Mar 30 '17 at 19:57
  • 1
    if you've solved your own question, please post it as an answer and accept it: so the community can learn from your experience. Thanks. – Eric Dahlvang Mar 30 '17 at 21:43

2 Answers2

2

You should use session.send.

I recommend you to take a look to the intelligence-SpeechToText sample, where a similar scenario is being shown.

Ezequiel Jadib
  • 14,767
  • 2
  • 38
  • 43
  • Thanks for the reply! I've taken a look at that sample and started working from it. The issue with `session.send` is that it allows the bot to respond to the user. I'm looking to go the other way around. Also, thanks for the edit. – Gavination Mar 30 '17 at 18:02
  • Haha yep! I've got a hunch that it has something to do with the `Message`, but I haven't found something jump out yet. – Gavination Mar 30 '17 at 18:42
  • I haven't seen that being done... I'm not even sure if it's doable..To be honest the scenario that you are thinking it's really strange. Where you read about that scenario or where you got the info about doing it with Message? if what you want to do is to send the text message again to the bot so it can do something with the text, you should just extract the text and handle everything in the callback of the bing.recognize, without trying to emulate sending the message on the user's behalf. – Ezequiel Jadib Mar 30 '17 at 18:55
  • So we can definitely handle the text once we get it from Bing (which is great), but we were really looking to enhance the user experience. What we were trying to avoid was a scenario where we'd have to have the bot respond with "What I heard was x". After chatting with the team, I think it's definitely something we can forego. We just didn't know it'd prove to be so difficult! – Gavination Mar 30 '17 at 19:25
0

Update: Figured it out (sorta). In order to take advantage of sending this user input back, I had to use another card. Within the context of the card, I'm able to use the imBack function

Gavination
  • 78
  • 1
  • 5