This week I'm using the p5.speech library to make something fun with web speech recognition.
(Note: requires Chrome or another browser that supports the Web Speech API.)
Open Demolet speech = new p5.SpeechRec('en-US', parseResult)speech.continuous = truespeech.interimResults = falsefunction setup() {createCanvas(window.innerWidth, window.innerHeight)background(255)fill(25)textSize(48)textAlign(CENTER)textStyle(BOLDITALIC)textFont('"Avenir Next", system-ui, sans-serif')text('SAY A COLOR', width / 2, height / 2)speech.start()}function draw() {// Where we’re going we don’t need drawing}const colors = []function parseResult() {if (speech.resultValue) {const color = speech.resultString.split(' ').pop().toUpperCase()colors.push(color)background(color)text(color, width / 2, height / 2)console.log(colors)}}
Voilà! Check out the code on P5.