xxxxxxxxxx
39
// https://github.com/IDMNYU/p5.js-speech/blob/master/examples/04simplerecognition.html
// https://idmnyu.github.io/p5.js-speech/#reference
// https://idmnyu.github.io/p5.js-speech/#download
/*
not run with firefox but test with CHROME from Win 10 OK
pls note:
add file: p5.speech.js
mod file: index.html <script src="p5.speech.js"></script> <!-- add -->
*/
var myRec = new p5.SpeechRec(); // new P5.SpeechRec object
function setup() {
// graphics stuff:
createCanvas(800, 400);
background(255, 255, 255);
fill(0, 0, 0, 255);
// instructions:
textSize(32);
textAlign(CENTER);
text("say something", width / 2, height / 2);
myRec.onResult = showResult;
myRec.start();
}
function draw() {
// why draw when you can talk?
}
function showResult() {
if (myRec.resultValue == true) {
background(192, 255, 192);
text(myRec.resultString, width / 2, height / 2);
console.log(myRec.resultString);
// myRec.stop();
// Uncaught TypeError: myRec.stop is not a function (sketch: line 35)
}
}