Speech Recognition for the Web

annyang!

A tiny JavaScript library that adds voice commands to any project — websites, home automation, accessibility tools, VR, drones, and more.

2kb · Zero dependencies · MIT license

Go ahead, try it…

Say "Hello!"

annyang!

That's cool, but in the real world it's not all kittens and hello world.

No problem, say "Show TPS report"

TPS Report cover

How did you do that?

Simple. Here's all the code.

import annyang from 'annyang';

const commands = {
  'hello': () => alert('Hello!'),
  'show tps report': () => document.getElementById('tpsreport').show()
};

annyang.addCommands(commands);
annyang.start();

What about more complicated commands?

annyang understands commands with named variables, splats, and optional words.

const commands = {
  // Splats (*) capture multi-word text at the end of a command.
  // "Show me Batman and Robin" calls showFlickr('Batman and Robin')
  'show me *query': showFlickr,

  // Named variables (:name) capture a single word anywhere.
  // "calculate October stats" calls calculateStats('October')
  'calculate :month stats': calculateStats,

  // Optional words are wrapped in parentheses.
  // Matches both "say hello friend" and "say hello to my little friend"
  'say hello (to my little) friend': greeting
};

annyang.addCommands(commands);
annyang.start();

It looks like your browser doesn't support speech recognition.

annyang works with all browsers, progressively enhancing those that support the SpeechRecognition standard.

annyang commands can even be triggered manually in unsupported browsers (e.g., “Show me snowboarding”)

Please visit talater.com/annyang in a supported browser like Chrome.