Stop Talking to Yourself

It really bugs me that Google Now and Siri don’t have public voice APIs. Speech recognition is capable of so much more than weather reports and egg timers.

I see a lot of potential in voice based interfaces, but I don’t want to reinvent the wheel. Fortunately, once you download Tal Ater’s JavaScript library Annyang (Hello!) you’re ready to roll.

Annyang provides easy access to the Web Speech API, (make sure you’re using Chrome), enabling you to define voice commands for your web app. Need a demo? Try submitting this form entirely hands-free.

Annyang is easy to implement and accessible via CDN:


// define functions up front var alertName = function(name){ alert(“Your name is “ + name); }

var alertLoc = function(loc){ alert(“You live in “ + loc); }

var commands = { // or define voice commands and functions together ‘go home’: function(){ window.location = “”;},

// define voice commands with one word variables ('My name is Neal')
'my name is :name': alertName,

// or multi-world variables (e.g. 'I live in New York City')
'I live in *loc': alertLoc   };   annyang.init(commands);   annyang.start(); } </script> ```

Speech recognition isn’t going to replace your keyboard or mouse tomorrow, but it’s on the horizon. Siri, get excited!

Join the discussion

2017 Neal Shyam