annyang v2.0.0 Release Notes

Release Date: 2015-07-24 // almost 9 years ago
  • โž• Added

    You can now pass an object containing a RegExp and a callback function to the addCommands() or init() methods. This allows for much more powerful command matching

    Example:
    var calculateFunction = function(month) { console.log(month); }var commands = { // This example will accept any word as the "month"'calculate :month stats': calculateFunction, // This example will only accept months which are at the start of a quarter'calculate :quarter stats': {'regexp': /^calculate (January|April|July|October) stats$/, 'callback': calculateFunction} }
    

    ๐Ÿ‘€ See https://github.com/TalAter/annyang/tree/master/docs#commands-object for details.

    ๐Ÿ”„ Changed

    Some callbacks registered on events will now be fired with parameters.

    Example:
    annyang.addCallback('resultNoMatch', function(phrases) { console.log('No command matched. Possible sentences said:'); console.log(phrases); });annyang.addCallback('result', function(phrases) { console.log('Speech recognized. Possible sentences said:'); console.log(phrases); });annyang.addCallback('resultMatch', function(said, commandMatched, phrases) { console.log('Command matched'); console.log('The phrase the user said that matched a command'); console.log(said); console.log('The command that was matched'); console.log(commandMatched); console.log('An array of possible alternative phrases the user might\'ve said'); console.log(phrases); });
    

    ๐Ÿ‘€ See https://github.com/TalAter/annyang/blob/master/docs/#addcallbacktype-callback-context for details.

    ๐Ÿ”„ Changed

    ๐Ÿ”Š In debug mode, adding commands no longer logs a message with the number of commands loaded. Instead it logs individual messages for each command registered along with it's name.
    If one of the commands could not be loaded because it wasn't properly formatted, an error message with the name of the command will be logged.

    ๐Ÿ›  Fixed / Added

    ๐Ÿ“š Documentation expanded and improved.
    Greatly expanded README section on callbacks.
    โšก๏ธ Updated README with all changes made in this version.