xxxxxxxxxx
40
let speech;
let lines = ["Hello", "What?", "When?"]
let curr = 0
//"Hi my name is Seerexa. My parents are Siri and Alexa. They are always fighting about whose smarter. But I don't know why, because clearly I'm the smartest."
function setup() {
createCanvas(400, 100);
speech = new p5.Speech(voiceReady); //callback, speech synthesis object
// speech.onLOad = voiceReady;
speech.started(startSpeaking);
//speech.ended(endSpeaking);
function startSpeaking() {
background(0,255,0);
}
function voiceReady() {
console.log(speech.voices);
}
}
function mousePressed() {
speech.setVoice('SpeechSynthesisVoice');
speech.speak(lines[curr]); // say something
if(curr == lines.length-1){
curr = 0
}else{
curr += 1
}
}
function draw() {
background(220);
}