### Initialize basic voice commands Source: https://www.talater.com/annyang Define simple command-to-function mappings and start the speech recognition engine. ```javascript import annyang from 'annyang'; const commands = { 'hello': () => alert('Hello!'), 'show tps report': () => document.getElementById('tpsreport').show() }; annyang.addCommands(commands); annyang.start(); ``` -------------------------------- ### Define advanced command patterns Source: https://www.talater.com/annyang Use splats, named variables, and optional words to create flexible voice command triggers. ```javascript 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(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.