xxxxxxxxxx
var thetext, thebigstring
var whichword =0
var thewords = []
var thefont = []
var foo = new p5.Speech()
function preload () {
thetext = loadStrings('imaginedragons.txt')
thefont[0] = loadFont('Maletha Collection ttf.ttf')
thefont[1] = loadFont('Rocqora.ttf')
}
function setup() {
createCanvas(windowWidth, windowHeight);
cleanup(thetext)
}
function draw() {
background(255)
frameRate(3)
textFont(random(thefont));
fill(random(255), random(255), random(200, 255))
stroke(random(255), random(255), random(255))
textSize(60)
var randomwords = random(thewords)
for(let i = 0;i<thetext.length;i++)
{
text(randomwords, width/2, height/2)
}
}
function cleanup(){
for(let i = 0; i <thetext.length; i++){
thebigstring += thetext[i]+' '
}
thebigstring = thebigstring.replace(/[^a-zA-Z0-9’ ]/g, ' ');
thebigstring = thebigstring.replace(/ ’/g, ' ');
thebigstring = thebigstring.replace(/’ /g, ' ');
thebigstring = thebigstring.toLowerCase();
thebigstring = thebigstring.replace(/ +/g, ' ');
thebigstring = thebigstring.trim();
thewords = thebigstring.split(' ')
thewords.splice(0, 1, 'when')
}
function keyPressed(){
noLoop()
foo.speak(randomwords) //how to put the object in it
}
function keyReleased(){
loop()
foo.stop()
}