xxxxxxxxxx
let speech;
let input = "...";
let bg;
function setup() {
createCanvas(windowWidth, windowHeight);
background(100);
speech = new p5.SpeechRec('de-DE'); // speech recognition object (will prompt for mic access)
speech.onResult = showResult; // bind callback function to trigger when speech is recognized
speech.continuous = true; // do continuous recognition
speech.interimResults = true;
speech.start(); // start listening
textAlign(CENTER, CENTER);
textSize(200);
bg = color(255);
}
function draw() {
background(bg);
text(input, width/2, height/2);
}
function showResult()
{
input = speech.resultString;
if (input.indexOf("grau") != -1)
bg = color(200);
else if (input.indexOf("rot") != -1)
bg = color(255, 0, 0);
}