Skip to content

Instantly share code, notes, and snippets.

@janecakemaster
Forked from melissaosullivan/gist:9032933
Created February 16, 2014 12:03
Show Gist options
  • Save janecakemaster/9033189 to your computer and use it in GitHub Desktop.
Save janecakemaster/9033189 to your computer and use it in GitHub Desktop.
var hue = require("node-hue-api"), HueApi = hue.HueApi, lightState = hue.lightState;
var host = "192.168.1.129",
username = "newdeveloper",
api,
state;
api = new HueApi(host, username);
// lymbix.tonalizeDetailed(phrase, function (object) {
// $("#phrase").html(object['article']);
// $("#text").html(object['dominant_emotion'].replace("_"," & "));
// var rgb = evalColor(object['article_sentiment']['score']);
// console.log("hi");
// $("#colors").css('color', "rgb("+rgb[0]+", "+rgb[1]+", "+rgb[2]+")");
// console.log(object['article_sentiment']['score']);
// console.log(rgb[2]);
// });
// }
var dom_emo, intensity;
lymbix.tonalize(text, function (obj) {
dom_emo = obj['dominant_emotion'];
console.log("h");
intensity = obj['intense_sentence']['intensity'];
});
colorEmotion = { "enjoyment_elation":145,
"affection_friendliness":340,
"amusement_excitement":128,
"contentment_gratitude":80,
"fear_uneasiness":247,
"sadness_grief":257,
"humiliation_shame":38,
"anger_loathing":0 };
if(dom_emo!="Neutral") {
console.log(dom_emo);
var huenum = colorEmotion.dom_emo;
console.log(huenum);
state = lightState.create().on().hsl(100, 100, 100);
}
else state = lightState.create().off();
api.setLightState(1, state, function(err, lights) {
if(err) throw err;
displayResult(lights);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment