Created
April 21, 2016 03:51
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://msdn.microsoft.com/en-us/library/hh924823(v=vs.85).aspx | |
//https://github.com/IDMNYU/p5.js-speech/blob/master/examples/05continuousrecognition.html | |
//marc abbey | |
var myRec = new p5.SpeechRec(); //new p5 speech rec object | |
myRec.continuous = true; //continuous speech recognition | |
myRec.interimResults = true; //allow partial recognition (faster, less accurate) | |
var yodel; | |
var speak; | |
var five; | |
var dollars; | |
var down; | |
var sit; | |
var base; | |
var x; | |
var videos = []; | |
function preload() { | |
base = createVideo('Basesmall.mp4'); | |
five = createVideo('5dollarssmall.mp4'); | |
//dollars = createVideo('fivedollarssmall.mp4'); | |
speak = createVideo('Yodel2small.mp4'); | |
yodel = createVideo('Yodel1Longsmall.mp4'); | |
liedown = createVideo('liedownsmall.mp4'); | |
sit = createVideo('sitsmall.mp4'); | |
} | |
function setup() { | |
createCanvas(700, 900); | |
//videos.push(base, five) | |
myRec.onResult = parseResult; //recognition callback | |
myRec.start(); //start engine | |
} | |
function draw() { | |
// image(base, 0,0); | |
} | |
function parseResult() { | |
var mostrecentword = myRec.resultString.split(' ').pop(); | |
var seconds = 0; | |
var currentSeconds = second(); | |
if (mostrecentword.indexOf("dollars") !== -1 || mostrecentword.indexOf("five") !== -1 || mostrecentword.indexOf("dollar") !== -1) { | |
//added play instead of loop | |
five.show(); | |
five.play(); | |
five._onended = function(){ | |
base.show(); | |
base.loop(); | |
five.hide(); | |
} | |
sit.hide(); | |
liedown.hide(); | |
yodel.hide(); | |
speak.hide(); | |
base.hide(); | |
sit.pause(); | |
liedown.pause(); | |
yodel.pause(); | |
speak.pause(); | |
} else if (mostrecentword.indexOf("sit") !== -1 || mostrecentword.indexOf("set") !== -1) { | |
sit.show(); | |
sit.play(); | |
sit._onended = function(){ | |
base.show(); | |
base.loop(); | |
sit.hide(); | |
} | |
five.hide(); | |
liedown.hide(); | |
yodel.hide(); | |
speak.hide(); | |
base.hide(); | |
five.pause(); | |
liedown.pause(); | |
yodel.pause(); | |
speak.pause(); | |
base.pause(); | |
} else if (mostrecentword.indexOf("yodel") !== -1 || mostrecentword.indexOf("Yoda") !== -1) { | |
yodel.show(); | |
yodel.play(); | |
yodel._onended = function(){ | |
base.show(); | |
base.loop(); | |
yodel.hide(); | |
} | |
five.hide(); | |
sit.hide(); | |
liedown.hide(); | |
speak.hide(); | |
base.hide(); | |
five.pause(); | |
sit.pause(); | |
liedown.pause(); | |
speak.pause(); | |
base.pause(); | |
} else if (mostrecentword.indexOf("down") !== -1) { | |
liedown.show(); | |
liedown.play(); | |
liedown._onended = function(){ | |
base.show(); | |
base.loop(); | |
liedown.hide(); | |
} | |
five.hide(); | |
sit.hide(); | |
yodel.hide(); | |
speak.hide(); | |
base.hide(); | |
five.pause(); | |
sit.pause(); | |
yodel.pause(); | |
speak.pause(); | |
base.pause(); | |
} else if (mostrecentword.indexOf("speak") !== -1) { | |
speak.show(); | |
speak.play(); | |
speak._onended = function(){ | |
base.show(); | |
base.loop(); | |
speak.hide(); | |
} | |
five.hide(); | |
sit.hide(); | |
liedown.hide(); | |
yodel.hide(); | |
base.hide(); | |
five.pause(); | |
sit.pause(); | |
liedown.pause(); | |
yodel.pause(); | |
base.pause(); | |
} else { | |
base.show(); | |
base.loop(); | |
five.hide(); | |
sit.hide(); | |
liedown.hide(); | |
yodel.hide(); | |
speak.hide(); | |
five.pause(); | |
sit.pause(); | |
liedown.pause(); | |
yodel.pause(); | |
speak.pause(); | |
} | |
console.log(mostrecentword); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment