Using voice to text library

Very new to Processing...

This is a simplified version of what I'm actually trying to do, but this should provide enough info. I'm using the text-to-speech library I found here(http://stt.getflourish.com/), which leverages Google/Chrome to transcribe text. Once the word is spoken/recognized, Processing finds that word in a csv file, get's a numeric value from an adjacent column, then changes the background color based on that value.

The two issues I'm experiencing:

1.I can print the value from the spreadsheet, but I can't seem to use the value. I'm guessing that I need to convert it from a string, to an integer somehow? This is where I was trying to do that:

String T = ("Total"); int i = int(T); 

2.I'm only able to get a single value to return before I need to restart the sketch, and reload the localhost file. For instance, if I say "hello", I get the printed word "hello", and the corresponding values from the csv, but if I say a second word, the word is printed, but I don't get any values(and no color change).

Any help is appreciated! Thanks!

import muthesius.net.*; import org.webbitserver.*; int myColorBackground = color(250, 20, 250); Table table; WebSocketP5 socket; void setup() { size(640, 480); socket = new WebSocketP5(this, 8080); table = loadTable("word_database.csv", "header"); println("Loaded Database"); } void draw() { background(myColorBackground); } void websocketOnMessage(WebSocketConnection con, String msg) { println(msg); TableRow result = table.findRow((msg), "SynsetTerms"); println(result.getString("PosScore"), "Pos Score"); println(result.getString("NegScore"), "Neg Score"); println(result.getString("Total"), "Total"); String T = ("Total"); int i = int(T); println(i, "i"); println(T, "T"); if (i>0) { myColorBackground = color(0, 0, 255); } else { myColorBackground = color(255, 255, 0); }; } void websocketOnOpen(WebSocketConnection con) { println("A client joined"); } void websocketOnClosed(WebSocketConnection con) { println("A client left"); } 
submitted by /u/Boomdone
[link] [comments]

How can I detect when these bouncy balls need to respawn / Have I done this upside down?

I'm rather new to Processing, but the Bacteria sketch which featured those variables with underscores spurred me on to try something new. Nothing terribly clever here - I make an array of balls with random starting attributes, then apply gravity and decay to them. They bounce off the edges.

Eventually they should run out of energy and stop moving, but I can't figure out how I can detect this. I've tried checking if n < ySpeed < m but the values seem to change, presumably according to the values of gravity and so on. I'm reaching the conclusion that I've perhaps done this all the wrong way round, and would be better off flipping the screen rather than having the origin be in the top-left.

Any comments are welcomed; hope I've formatted everything correctly - it all looks okay in my preview. :)

Ball[] ball; int numBall = 64; int ballSize = 12; float gravity = 0.15; float decay = 0.8; void setup() { size(800, 600); colorMode(HSB, 1); noStroke(); ball = new Ball[numBall]; // Initialise it for (int i = 0; i < ball.length; i++) { ball[i] = new Ball(i*(width/numBall), random(0, ballSize), random(-1, 1), random(-5, 5), i); } } void draw() { background(1); for (int i = 0; i < ball.length; i++) { ball[i].move(); ball[i].check(); ball[i].draw(); } } class Ball { float xPos, yPos, xSpeed, ySpeed, numColor; Ball(float xPos_, float yPos_, float xSpeed_, float ySpeed_, float numColor_) { xPos = xPos_; yPos = yPos_; xSpeed = xSpeed_; ySpeed = ySpeed_; numColor = numColor_; } void move() { xPos += xSpeed; yPos += ySpeed; ySpeed = ySpeed + gravity; } void draw() { fill(numColor/numBall, 1, 1); ellipse(xPos, yPos, ballSize, ballSize); } void check() { if (xPos >= width || xPos <= 0) { xPos -= xSpeed; xSpeed = -xSpeed*decay; } if (yPos >= height || yPos <= 0) { yPos -= ySpeed; ySpeed = -ySpeed*decay; } } } 
submitted by /u/MandyBrigwell
[link] [comments]

The artist with a super-computing mind

widener8
Sunday’s Crash, 2005

george-widener-friday
George Widener, Friday Disasters

widener5titanic5b
George Widener, Titanic, 2007. Image Henry Boxer Gallery

The Art et Marges museum in Brussels has spent the past 25 years showing the work of “outsider” artists. The ones who are self-taught, or work either in isolation, or in workshops for mentally disabled and psychologically fragile people. Do have a look when you’re in the Belgian capital. It’s a cheerful and friendly place and right now their exhibition is called Save the World. That’s where i rediscovered the work of George Widener.

Like most outsider artists, Widener’s life receives as much scrutiny as his work. He has savant syndrome, a condition in which a person diagnosed as autistic demonstrates prodigious capacities or abilities that surpass by far what is considered normal.

Widener’s super talent is numerical computation. He processes complex arithmetical calculations at great speed and has a prodigious proficiency in calculating dates. He can memorize dates, days and events dating back to 180 A.D. and he can do the same for the upcoming 80.000 years.

His super-calculator power drives him to obsessively compute complex sequences of numbers, extract patterns from dates and scrutinize historical events (he is particularly keen on catastrophes). He turns them into large-scale calendars, mazes and date grids that visualize his idea of how the world is organized.

George Widener. Ricco Maresca Gallery

Doomsday Device, 2013,)
George Widener, Doomsday Device, 2013. Image Outsider Art Fair

Out of his analysis of patterns and dates, Widener also attempts to extract informed prophecies about future events. Could patterns of dates of events or phenomena make it possible to predict future plane crashes and other disasters?

This might sound a bit batty but it seems that Widener also applies his arithmetical genius to gambling. I’m going to quote an article from The Guardian: He has learned how to count cards, a system of winning at blackjack by memorising cards and calculating their values. He describes himself as a semi-professional gambler. “I have taken the casinos for thousands of dollars.”

0aaarenewwwabl90
George Widener, Renewable, 2016. Ricco/Maresca Gallery

kingGW3076
George Widener, King of the World, 2010. Image Outsider Art Fair

Furthermore, Widener’s super computing mind leads him to use his own algorithms to elaborate numerical puzzles and games that only intelligent and independently-thinking machines of the Singularity age will be able to fully enjoy and understand.

GeorgeWidener_RobotPuzzle.lo_
George Widener, Robot Puzzle, 2011

george-widener-2014-7
Untitled (Games for Robots No. 1), 2014

widener7
George Widener, Megalopolis, 2005

_no_rain_five_days_1024
George Widener, No Rain Five Days, 2012

00ageoeorgeoewidern98
George Widener, Untitled (Calendrical Geometry 007), 2015. Image artsy

_magic_circle_1024x768
George Widener, Magic Circle 12-21-2012, 2012

4birdthdayweeeeekdn
George Widener, Birthday ma (Weekends), 2012. Image Galerie Zander

iwasbornGW017
George Widener, I Was Born, 2012. Image Galerie Zander

The exhibition Save the World remains open at Art et Marges in Brussels until 29 January 2017.

How do I make a slide show from image urls being imported from a JSON file?

Hey, slightly convulted title but let me explain. I have a "photoDB.json" file which contains url links (and other information on photos such as authors)

I'm trying to load the images from this into a slideshow. Currently my code looks like this : (phone formatting and a noob so prepare yourself)

JSONObject json;

PImage display;

String lnk;

void setup() -[

Size(1200,800);

json = loadJSONObject("photoDB.json");

JSONARRAY photoData = json.getJSONArray("photos");

for (int I = 0; I < photoData.size(); i++;) -[

JSONObject json = photoData.getJSONObject(i);

String author = json.getString("author");

String caption = json.getString("caption");

String thumbURL = json.getString("thumbURL");

thumbURL = thumbURL.replaceAll("-sm" , "-lg");

lnk = (thumbURL);

println(lnk);

String url = lnk;

display = loadImage(url, ".jpg");

println(author + ", " + caption);

]-

]-

void draw() -[ image(display, 0, 0); ]-

Currently it loads only the last image (and author name and title of the image) but it doesn't go through each image in the .json file. If anyone can point me right it'd be greatly appreciated!

submitted by /u/physc65
[link] [comments]

How to make a rect clickable and play a sound when clicked

Hey guys,

I don't know how hard or easy this is but I have the base of a sketch set up to look like a guitar with 6 strings. What I want the sketch to do is whenever a string (rectangle) is clicked it plays a sound. Would anyone be able to have a mess with this code and see if it can be done? Thanks so much!

void setup() 

{ size(400,400); background (255, 253,208); }

void draw() {

fill(0,0,0); ellipse(200, 200, 250, 250); fill(128,128,128); noStroke(); rect (0,95,400,5); //E rect (0,135,400,5); //A rect (0,175,400,5); //D rect (0,215,400,5); //G rect (0,255,400,5); //B rect (0,295,400,5); //e

}

submitted by /u/hyrys
[link] [comments]