xxxxxxxxxx
var foo = new p5.Speech(); // this is a speech synthesizer object
foo.onLoad = speechLoaded; // callback function
var box; // input box
var s = '';
function setup() {
createCanvas(windowWidth, windowHeight);
background(255);
textSize(80);
var box = createInput('');
box.position(width/2, height/2);
box.size(100);
box.input(boxtyped);
}
function draw() {
}
function mousePressed()
{
background(255);
text(s, mouseX, mouseY);
foo.setVolume(mouseY/height);
foo.setRate(random(0.5,2));
var p = map(mouseX, 0, width, 0.5, 2);
foo.setPitch(p);
foo.speak(s);
}
function boxtyped()
{
s = this.value();
}
function speechLoaded() {
foo.listVoices();
// foo.setVoice("Google español de Estados Unidos");
foo.setVoice("Google UK English Female");
foo.interrupt = true;
}