dechoes-Speech

UPDATE: Revised speech project.

I revised my speech project due to some comments which indicated that my project might be wrongly interpreted. I would like to state that this project was meant in no way to be offensive. I apologize to anyone who might have felt like this project was a “punch down.”

Monolothic Prophecies is a piece of software which incites you to ask a question to the large space monolith on the screen. The monolith then samples a noun from your question and responds with a prophecy which alliterates with your used noun.

Code:

//Many thanks to Tatyana Mustakos for her debugging help, way past both of our bedtimes
//and Kabir Mantha for chatting with me about drunk family members at Thanksgiving
//And as always, thank you to Golan Levin and Claire Hentschker
// for their incredible help and support
 
//MONOLITHIC PROPHECIES by dechoes(2018)
 
var r;
var x;
var y;
var z;
var img;
var bg;
var nFrames = 360;
 
//GRAPHICS
// look up the text canvas.
var textCanvas;
 
// make a 2D context for it
var ctx;
 
//-----------------------------------------------------------------
 
// The speech recognizer
var mySentence;
var myRec = new p5.SpeechRec('en-US');
 
// The speech synthesizer
var myVoiceSynthesizer;
 
var img;
 
var myRitaString;
var arr1;
var arr2;
 
var myNouns = [];
var nounCount = 0;
 
var aRandomNoun;
var arrayOfNounAlliterations;
var ithAlliteratingNoun;
var finalIthAlliteratingNoun;
 
var arrayOfVerbAlliterations;
var ithAlliteratingVerb;
var finalIthAlliteratingVerb;
 
var arrayLastVerb;
var verbIAmLookingFor;
var finalWordIAmLookingFor;
 
var arrayOfAdjectiveAlliterations;
var ithAlliteratingAdjective;
var finalIthAlliteratingAdjective;
 
var mode = 1;
var iHaveTheShitINeedToDoTheThing;
 
 
//=========================================
function setup() {
	  createCanvas(1000, 700, WEBGL);
 
	  textCanvas = document.getElementById("text");
	  ctx = textCanvas.getContext("2d");
	//background(0);
	//stroke(255);
	//fill(255);
	//textSize(19);
 
	iHaveTheShitINeedToDoTheThing = false;
 
	var theVersion = RiTa.VERSION;  
	print("theVersion " + theVersion);
 
 
	//Setup speech reconizer
	myRec.continuous = true; //Do continuous recognition
	myRec.interimResults = false; // allow partial recognition
	myRec.onResult = whatToDoWhenIGetNewSpeech;
	myRec.start();
 
	// Make the speech synthesizer
	myVoiceSynthesizer = new p5.Speech();
 
}
 
function draw(){
	//image(img, 0, 0);
	background(0);
 
	monolithGraphics();
 
		 // Clear the 2D canvas
    ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
    ctx.fillStyle = 'white';
    ctx.font="18px Helvetica";
 
	if (iHaveTheShitINeedToDoTheThing){
		finalSentenceBuild();
	}
 
}
 
 
function whatToDoWhenIGetNewSpeech()
	{
		if(myRec.resultValue==true && mode == 1) {
			stroke(255);
			//text(myRec.resultString, width/2, height/2 - 100);
			iHaveTheShitINeedToDoTheThing = true;
			mySentence = String(myRec.resultString);
			console.log(myRec.resultString);
		}
	}
 
 
function finalSentenceBuild(){
 
	if (mySentence !== undefined){
 
	myRitaString = new RiString(mySentence);
	arr1 = myRitaString.words(); 
	arr2 = RiTa.tokenize(mySentence);
 
 
	print(mySentence);
 
	// Extract just the nouns from mySentence
	for (var i=0; i<arr2.length; i++){ var ithWord = arr2[i]; if (RiTa.isNoun(ithWord)){ myNouns[nounCount] = ithWord; nounCount++; } } // Select a random noun from the extracted array of nouns. if(myNouns.length>0){
		aRandomNoun = myNouns[ floor(random(myNouns.length)) ];
	}else{
		print(myNouns);
		aRandomNoun = "run";
	}
 
 
	print ("My random noun was " + aRandomNoun);
	//text("My random noun was" + " " + aRandomNoun , 150, 150);
 
	// Fetch an array of alliterations for the random noun
	arrayOfNounAlliterations = RiTa.alliterations(aRandomNoun);
	// Check em to see which alliterations are ALSO nouns
	for (var i=0; i<arrayOfNounAlliterations.length; i++){
		ithAlliteratingNoun = arrayOfNounAlliterations[i];
		if (RiTa.isNoun(ithAlliteratingNoun)){
			//print("Yay " + ithAlliteratingNoun + "alliterates and IS A NOUN TOO");
			finalIthAlliteratingNoun = ithAlliteratingNoun;
		}
	}
 
	arrayOfVerbAlliterations = RiTa.alliterations(aRandomNoun);
	// Check em to see which alliterations are ALSO verbs
	for (var i=0; i<arrayOfVerbAlliterations.length; i++){
		ithAlliteratingVerb = arrayOfVerbAlliterations[i];
		if (RiTa.isVerb(ithAlliteratingVerb)){
		//print("Yay " + ithAlliteratingVerb + " " + "alliterates and IS A VERB TOO");
		finalIthAlliteratingVerb = ithAlliteratingVerb;
		}
	}
 
	arrayLastVerb = RiTa.alliterations(aRandomNoun);
	//Check for second verb count
	for (var j = 0; j<arrayLastVerb.length; j++){
		verbIAmLookingFor = arrayLastVerb[j];
		if (RiTa.isVerb(verbIAmLookingFor)){
			//print("Yay" + " " + verbIAmLookingFor + " " + "alliterates and IS A VERB TOO");
			finalWordIAmLookingFor = verbIAmLookingFor;
		}
	}
 
 
	arrayOfAdjectiveAlliterations = RiTa.alliterations(aRandomNoun);
	// Check em to see which alliterations are ALSO verbs
	for (var i=0; i<arrayOfAdjectiveAlliterations.length; i++){
		ithAlliteratingAdjective = arrayOfAdjectiveAlliterations[i];
		if (RiTa.isAdjective(ithAlliteratingAdjective)){
		//print("Yay " + ithAlliteratingAdjective + " " + "alliterates and IS AN ADJECTIVE TOO");
		finalIthAlliteratingAdjective = ithAlliteratingAdjective;
		}
	}
 
	//print (arrayOfNounAlliterations); 
	//text ("you:" + " " + " " + " " + mySentence + " " + "?", 50, 600);
	print ("you:" + " " + " " + " " + mySentence + " " + "?", 50, 600);
	ctx.fillText(" " + " " + " " +"you:" + " " + " " + " " + mySentence + " " + "?", 10, 50);
 
	//FINAL ALLITERATION
	var finalSentence = ("the" + " " + aRandomNoun + " " + "and" + " " + finalIthAlliteratingNoun + " " + finalIthAlliteratingVerb 
		+ " " + finalIthAlliteratingAdjective + " " + "for everyone to" + " " + finalWordIAmLookingFor);
 
	//myVoiceSynthesizer.setVoice('Daniel'); // british voice
	myVoiceSynthesizer.setVoice('Deranged'); 
	myVoiceSynthesizer.setPitch(0.6);
	myVoiceSynthesizer.setRate(0.6);
	myVoiceSynthesizer.speak(finalSentence);
 
	//text("prophetic drunk monolith:" + " " + " " + " " + finalSentence, 50, 650);
	print("prophetic drunk monolith:" + " " + " " + " " + finalSentence, 50, 650);
	ctx.fillText(" " + " " + " " +"prophetic monolith:" + " " + " " + " " + finalSentence, 10, 80);
 
}
noLoop();
}
 
function monolithGraphics(){
 
  var t01  = (frameCount%nFrames) / nFrames;
 
  var locX = width/2;
  var locY = - height/2;
  var locX2 = - width/2;
  var r = 214; 
  var g = 255;
  var b = 250;
 
  pointLight(r, g, b, - width/2, - height/2 + 400, 100);
  pointLight(r, g, b, width/2, - height/2 + 400, 300);
  ambientMaterial(250);
  rotateX(radians(60));
  rotateZ(frameCount * 0.002);
 
  var r = map(sin(t01 * 20.0), -1, 1, 0, 1);  
  var boxX =  3 * map(r, 0, 1, -1, 1);
  var boxZ =  2 * map(r, 0, 1, -1, 1);
  var boxY = 0;
 
  translate(boxX, boxY, boxZ); 
 
  push();
  translate(0, 0, -100);
  box(70, 70, 190);
  pop();
 
  push();
  translate(0, 0, -400);
  box(70, 70, 70);
  pop();
 
  push();
  translate(0, 0, 190);
  box(70, 70, 70);
  pop();
 
}

 

Familial Prophecies 

We all have that one family member, who confuses, irritates or offends everyone during large family reunions, the “offensive uncle” during Thanksgiving per say. Familial prophecies is a piece of software which acts as and replaces your family member who never makes any sense. The “prophetic drunk grandpa” featured in the piece responds to your inquiries in prophetic alliterations which confuse you even more than you already were before.

You may ask any type of question, ranging from practical to existential. The prophetic drunk grandpa, who may be conscious about his behavior or not, takes a noun from your question and answers with a mysterious prophecy composed of alliterations (all words alliterate with the noun from your spoken sentence).

The app uses p5.speech for speech synthesis and riTa.js for voice recognition and alliteration creation. Many thanks to Luke DuBois and Daniel C. Howe for this open source software.

 

Process Sketch

 

Code 

//Many thanks to Tatyana Mustakos for her debugging help, way past both of our bedtimes
//and Kabir Mantha for chatting with me about drunk family members at Thanksgiving
//And as always, thank you to Golan Levin and Claire Hentschker
// for their incredible help and support
 
//FAMILIAL PROPHECIES by dechoes (2018)
 
// The speech recognizer
var mySentence;
var myRec = new p5.SpeechRec('en-US');
 
// The speech synthesizer
var myVoiceSynthesizer;
 
var img;
 
var myRitaString;
var arr1;
var arr2;
 
var myNouns = [];
var nounCount = 0;
 
var aRandomNoun;
var arrayOfNounAlliterations;
var ithAlliteratingNoun;
var finalIthAlliteratingNoun;
 
var arrayOfVerbAlliterations;
var ithAlliteratingVerb;
var finalIthAlliteratingVerb;
 
var arrayLastVerb;
var verbIAmLookingFor;
var finalWordIAmLookingFor;
 
var arrayOfAdjectiveAlliterations;
var ithAlliteratingAdjective;
var finalIthAlliteratingAdjective;
 
var mode = 1;
var iHaveTheShitINeedToDoTheThing;
 
 
//=========================================
function setup() {
	createCanvas(900, 700);
	//background(0);
	img  = loadImage ("data/background_prophetic.jpg");
	stroke(255);
	fill(255);
	textSize(19);
 
	iHaveTheShitINeedToDoTheThing = false;
 
	var theVersion = RiTa.VERSION;  
	print("theVersion " + theVersion);
 
 
	//Setup speech reconizer
	myRec.continuous = true; //Do continuous recognition
	myRec.interimResults = false; // allow partial recognition
	myRec.onResult = whatToDoWhenIGetNewSpeech;
	myRec.start();
 
	// Make the speech synthesizer
	myVoiceSynthesizer = new p5.Speech();
 
}
 
function draw(){
	image(img, 0, 0);
 
	if (iHaveTheShitINeedToDoTheThing){
		finalSentenceBuild();
	}
 
}
 
 
function whatToDoWhenIGetNewSpeech()
	{
		if(myRec.resultValue==true && mode == 1) {
			stroke(255);
			//text(myRec.resultString, width/2, height/2 - 100);
			iHaveTheShitINeedToDoTheThing = true;
			mySentence = String(myRec.resultString);
			console.log(myRec.resultString);
		}
	}
 
 
function finalSentenceBuild(){
 
	if (mySentence !== undefined){
 
	myRitaString = new RiString(mySentence);
	arr1 = myRitaString.words(); 
	arr2 = RiTa.tokenize(mySentence);
 
 
	print(mySentence);
 
	// Extract just the nouns from mySentence
	for (var i=0; i<arr2.length; i++){ var ithWord = arr2[i]; if (RiTa.isNoun(ithWord)){ myNouns[nounCount] = ithWord; nounCount++; } } // Select a random noun from the extracted array of nouns. if(myNouns.length>0){
		aRandomNoun = myNouns[ floor(random(myNouns.length)) ];
	}else{
		print(myNouns);
		aRandomNoun = "run";
	}
 
 
	print ("My random noun was " + aRandomNoun);
	//text("My random noun was" + " " + aRandomNoun , 150, 150);
 
	// Fetch an array of alliterations for the random noun
	arrayOfNounAlliterations = RiTa.alliterations(aRandomNoun);
	// Check em to see which alliterations are ALSO nouns
	for (var i=0; i<arrayOfNounAlliterations.length; i++){
		ithAlliteratingNoun = arrayOfNounAlliterations[i];
		if (RiTa.isNoun(ithAlliteratingNoun)){
			//print("Yay " + ithAlliteratingNoun + "alliterates and IS A NOUN TOO");
			finalIthAlliteratingNoun = ithAlliteratingNoun;
		}
	}
 
	arrayOfVerbAlliterations = RiTa.alliterations(aRandomNoun);
	// Check em to see which alliterations are ALSO verbs
	for (var i=0; i<arrayOfVerbAlliterations.length; i++){
		ithAlliteratingVerb = arrayOfVerbAlliterations[i];
		if (RiTa.isVerb(ithAlliteratingVerb)){
		//print("Yay " + ithAlliteratingVerb + " " + "alliterates and IS A VERB TOO");
		finalIthAlliteratingVerb = ithAlliteratingVerb;
		}
	}
 
	arrayLastVerb = RiTa.alliterations(aRandomNoun);
	//Check for second verb count
	for (var j = 0; j<arrayLastVerb.length; j++){
		verbIAmLookingFor = arrayLastVerb[j];
		if (RiTa.isVerb(verbIAmLookingFor)){
			//print("Yay" + " " + verbIAmLookingFor + " " + "alliterates and IS A VERB TOO");
			finalWordIAmLookingFor = verbIAmLookingFor;
		}
	}
 
 
	arrayOfAdjectiveAlliterations = RiTa.alliterations(aRandomNoun);
	// Check em to see which alliterations are ALSO verbs
	for (var i=0; i<arrayOfAdjectiveAlliterations.length; i++){
		ithAlliteratingAdjective = arrayOfAdjectiveAlliterations[i];
		if (RiTa.isAdjective(ithAlliteratingAdjective)){
		//print("Yay " + ithAlliteratingAdjective + " " + "alliterates and IS AN ADJECTIVE TOO");
		finalIthAlliteratingAdjective = ithAlliteratingAdjective;
		}
	}
 
	//print (arrayOfNounAlliterations); 
	text ("you:" + " " + " " + " " + mySentence + " " + "?", 50, 600);
 
	//FINAL ALLITERATION
	var finalSentence = ("the" + " " + aRandomNoun + " " + "and" + " " + finalIthAlliteratingNoun + " " + finalIthAlliteratingVerb 
		+ " " + finalIthAlliteratingAdjective + " " + "for everyone to" + " " + finalWordIAmLookingFor);
 
	//myVoiceSynthesizer.listVoices();
	//myVoiceSynthesizer.setVoice('Amelie'); // french voice hohoho
	//myVoiceSynthesizer.setVoice('Anna'); //german voice
	//myVoiceSynthesizer.setVoice('Bad News'); // bad news music !!!!
	//myVoiceSynthesizer.setVoice('Daniel'); // british voice
	myVoiceSynthesizer.setVoice('Deranged'); // grandpa on life machine?
	//myVoiceSynthesizer.setVoice('Hysterical'); // crazy grandpa
	//myVoiceSynthesizer.setVoice('Thomas'); //french man
	//myVoiceSynthesizer.setVoice('Ralph');
	myVoiceSynthesizer.setPitch(0.6);
	myVoiceSynthesizer.setRate(0.6);
	myVoiceSynthesizer.speak(finalSentence);
 
	text ("prophetic drunk grandpa:" + " " + " " + " " + finalSentence, 50, 650);
 
}
noLoop();
}