evancohen / sonus

:speech_balloon: /so.nus/ STT (speech to text) for Node with offline hotword detection
MIT License
618 stars 79 forks source link

resultNoMatch : callback #64

Closed sharmmoh1983 closed 6 years ago

sharmmoh1983 commented 6 years ago

Hi I want to have a call back function when there is no match of commands .Is it posiible?

sharmmoh1983 commented 6 years ago

Does Sonus.annyang.addCommands(commands) supports addition of resultNoMatch callback

evancohen commented 6 years ago

You can add a command with just a splat (*) to match all input. https://github.com/TalAter/annyang/blob/master/docs/README.md#examples-7

sharmmoh1983 commented 6 years ago

Based on your input , I am using splat like the following '()': function (command) { console.log('ha-command',command); scope.sendSocketNotification('ha-command', command); } But I am getting folllowing error Invalid regular expression: /^$/: Nothing to repeat

evancohen commented 6 years ago

Without the parentheses:

var command = {
  '*': function (command) {
      console.log('ha-command',command);
      scope.sendSocketNotification('ha-command', command);
}
sharmmoh1983 commented 6 years ago

I have tried this one also but giving same error regarding regular expression

var command = { '*': function (command) { console.log('ha-command',command); scope.sendSocketNotification('ha-command', command); }

sharmmoh1983 commented 6 years ago

Actually, the error that I have shared is because of the pattern you have shared

sharmmoh1983 commented 6 years ago

This seems to be the bug or I am not using it properly I want have a mapping for no match command