TalAter / annyang

:speech_balloon: Speech recognition for your site
https://www.talater.com/annyang/
MIT License
6.57k stars 1.05k forks source link

Splat variable not being passed to function #414

Closed lworx-kevin closed 4 years ago

lworx-kevin commented 4 years ago

I am using the splat functionality for multi word pickup but it doesn't work when pointing to a function var.

Issue

`//This doesn't work var commands = { 'Hey Computer tell *req': Joker }; var Joker = function (req) { alert("I work") $.ajax({ //ajax call }) }

//This works var commands = { 'Hey Computer tell *req': function (req) { alert("I work") $.ajax({ //ajax call }) } };

// Add our commands to annyang SpeechKITT.annyang(); SpeechKITT.setStylesheet('https://cdnjs.cloudflare.com/ajax/libs/SpeechKITT/1.0.0/themes/flat.css'); SpeechKITT.setInstructionsText("Say 'Hey Computer' and a command")

SpeechKITT.vroom();

annyang.addCommands(commands);

// Start listening. You can call this here, or attach this call to an event, button, etc.
annyang.start();
annyang.debug(true);`

Am I adding commands incorrectly? Not sure why the function pointer isn't working.

Your Environment

lworx-kevin commented 4 years ago

defined function before function call and it works.