Project 09, AI in the browser
Voice Command Controller
Say “turn on the fan” or “set temperature to 22” and watch the room respond. It answers back out loud, and you can type commands if you prefer.
- Runs on
- Browser speech service
- Model
- Browser speech recognition
- First download
- None
- Your browser
- Checking
Talk to the room
Press the button and speak
Try: “turn on the bedroom light”, “set temperature to 20”, “lock the door”, “play music”, “what is on”, “turn everything off”.
How it works
- ListenSpeechRecognition streams words as you speak, and the final phrase is passed on when you pause.
- UnderstandA small parser finds the action (on, off, set, lock), the device and any number in the phrase.
- Act and replyThe device card updates, the log records the command, and the page speaks a short confirmation.
const SR = window.SpeechRecognition || window.webkitSpeechRecognition;
const rec = new SR();
rec.lang = "en-US";
rec.interimResults = true;
rec.onresult = (e) => {
const r = e.results[e.results.length - 1];
if (r.isFinal) handle(r[0].transcript); // "turn on the fan"
};
rec.start();
// Talk back
speechSynthesis.speak(new SpeechSynthesisUtterance("Fan is on"));