xxxxxxxxxx
55
let speechDetect = false
var serial
var portName = "/dev/tty.usbmodem141401"
var inData
var outByte = 0
function setup() {
noCanvas();
//this is part for detecting speech
let lang=navigator.language||'en-US';
let speechRec=new p5.SpeechRec(lang,gotSpeech);
let continuous=true;
let interim=false;
speechRec.start(continuous,interim);
//This is part is for initiate serial communication to Arduino
serial = new p5.SerialPort()
serial.on('data',serialEvent);
serial.on('error',serialError);
// serial.open(portName);
function gotSpeech(){
if(speechRec.resultValue){
createP(speechRec.resultString);
speechDetect = true;
outByte =1
Serial.write (outByte)
}
console.log(speechDetect);
}
}
function serialEvent(){
}
function serialError(){
console.log("Something is wrong with the port!")
}