xxxxxxxxxx
61
var typo
var myRec = new p5.SpeechRec();
myRec.continuous = true;
function preload(){
typo =
loadFont('CirrusCumulus.otf');
}
var counter = 0;
var counter2 = 0;
function setup() {
createCanvas(600, 600);
textFont(typo);
textSize(14);
textAlign(CENTER);
myRec.onResult = showResult;
myRec.start();
noStroke ();
fill (255);
rect (200, 0, 200, 200);
}
function showResult(){
if(myRec.resultValue==true) {
counter2 ++;
var posY = counter2 * 20;
if(posY > height){
counter2 = 0;
background(255);
}
text(myRec.resultString, width/2, posY);
console.log(myRec.resultString);
}
}
function draw (){
counter ++;
fill(0);
noStroke();
if(counter % 100 == 0){
textSize (14);
text("ensemble",random(300),random(300), 250);
}
}
function keyReleased() {
if (key == 's' || key == 'S') {
saveCanvas(year()+month()+day()+'-'+hour()+ minute() + second() +'_speechtext'+ '.jpg');
}
}