phantomJS

phantomJS runs outside the browser but implements enough of the DOM that you can use it for testing, rendering screenshots, running http: requests, etc.,

http://phantomjs.org/index.html

Have installed locally in: tkzic/phantomjs (binary is in the bin/ folder)

Processing, Twitter, OSC, and Max

A variation on the Twitter mood-lamp program.

note 6/2014 – this may not work due to changes in oauth

local files:

  • Processing: /documents/processing/osc_max_testing
  • Max: tkzic/max teaching examples/processing-osc

It grabs a ‘feed’ or any URL which returns a bunch of text. Then it does some analysis on the text, and using the results to send RGB data back to Max using OSC.

Raspberry-Pi FX pedal

Running in Pure Data

(update) Tried this with guitarist John Drew today (2/26/2012). We ran the guitar directly into the iMic (switched to microphone, not line) and the output of iMic into an amplifier. The R-Pi was plugged into to wifi router with an Ethernet cable, so we could use touchOsc to control the delay parameters. It sounded great.

We talked about the possibility of making this into a ‘product’. One idea would be to ditch the Osc controls and build a simple hardware interface – some encoders, switches, and LED’s. You could map everything in PD and download new patches using an ethernet cable or a usb wifi connection – or even some kind of serial/usb link.

Yesterday I programmed a simple variable delay effect in pd to run on Raspberry-Pi. Control was using touchOSC as described in previous posts. I ran the effect in mono at 32k sampling rate – and it sounded great. Also its using the Griffin iMic for sound.

Here’s the command line to set the sample rate and number of channels:

pd-extended -r 32000 -nogui -channels 1 delay-effect-osc.pd

 

Local files:

 

 

 

Parsing Tweets into spoken language

notes

I’ve revised the php program that streams Tweets and sends them to Max, to remove hyperlinks, RT indicators, user mentions, and ascii art. Now it works better with text-to-speech.

things that could be done in a future project:

  • figure out which #hashtags are integral to content, and which are just tagged onto the end of a tweet
  • remove extraneous hyperlinks which don’t get parsed by the API
  • translate symbols like > into “great than” or “better than”
  • translate (or at least flag) foreign languages – this could be aided by geocoding data
  • translate slang acronyms like OMG, LOL
  • natural language parsing (see Stanford open source program) for content and grammatical analysis
  • replace hyperlinks/picture-links with a ‘title’ from the actual target
  • natural language equivalents of things like: RT @zooloo:
things to try
  • Running the output of text-to-speech through musical analysis tools, to detect pitch and rhythm
  • Chaining: Use the content of one tweet to direct a search for the next one. For example say you search for cats and get: “my cat is turning purple” – then you would search for ‘purple’ and get: “I’ve never eaten a purple cow” – then you would search for “cow” and so forth

Twitter streaming API

from https://dev.twitter.com/docs/streaming-apis

This diagram shows the process of handling a stream, using a data store as an intermediary.

The JSON response breaks out various components of the tweet like hashtags and URL’s but it doesn’t provide a clean version of the text – which for example could be converted to speech.

Here’s a sample response which shows all the fields:

{
	"created_at": "Sat Feb 23 01:30:55 +0000 2013",
	"id": 305127564538691584,
	"id_str": "305127564538691584",
	"text": "Window Seat #photo #cats http:\/\/t.co\/sf0fHWEX2S",
	"source": "\u003ca href=\"http:\/\/www.echofon.com\/\" rel=\"nofollow\"\u003eEchofon\u003c\/a\u003e",
	"truncated": false,
	"in_reply_to_status_id": null,
	"in_reply_to_status_id_str": null,
	"in_reply_to_user_id": null,
	"in_reply_to_user_id_str": null,
	"in_reply_to_screen_name": null,
	"user": {
		"id": 19079184,
		"id_str": "19079184",
		"name": "theRobot Vegetable",
		"screen_name": "roveg",
		"location": "",
		"url": "http:\/\/south-fork.org\/",
		"description": "choose art, not life",
		"protected": false,
		"followers_count": 975,
		"friends_count": 454,
		"listed_count": 109,
		"created_at": "Fri Jan 16 18:38:11 +0000 2009",
		"favourites_count": 1018,
		"utc_offset": -39600,
		"time_zone": "International Date Line West",
		"geo_enabled": false,
		"verified": false,
		"statuses_count": 10888,
		"lang": "en",
		"contributors_enabled": false,
		"is_translator": false,
		"profile_background_color": "1A1B1F",
		"profile_background_image_url": "http:\/\/a0.twimg.com\/profile_background_images\/6824826\/BlogisattvasEtc.gif",
		"profile_background_image_url_https": "https:\/\/si0.twimg.com\/profile_background_images\/6824826\/BlogisattvasEtc.gif",
		"profile_background_tile": true,
		"profile_image_url": "http:\/\/a0.twimg.com\/profile_images\/266371487\/1roveggreen_normal.gif",
		"profile_image_url_https": "https:\/\/si0.twimg.com\/profile_images\/266371487\/1roveggreen_normal.gif",
		"profile_link_color": "2FC2EF",
		"profile_sidebar_border_color": "181A1E",
		"profile_sidebar_fill_color": "252429",
		"profile_text_color": "666666",
		"profile_use_background_image": false,
		"default_profile": false,
		"default_profile_image": false,
		"following": null,
		"follow_request_sent": null,
		"notifications": null
	},
	"geo": null,
	"coordinates": null,
	"place": null,
	"contributors": null,
	"retweet_count": 0,
	"entities": {
		"hashtags": [{
			"text": "photo",
			"indices": [12, 18]
		}, {
			"text": "cats",
			"indices": [19, 24]
		}],
		"urls": [{
			"url": "http:\/\/t.co\/sf0fHWEX2S",
			"expanded_url": "http:\/\/middle-fork.org\/?p=186",
			"display_url": "middle-fork.org\/?p=186",
			"indices": [25, 47]
		}],
		"user_mentions": []
	},
	"favorited": false,
	"retweeted": false,
	"possibly_sensitive": false,
	"filter_level": "medium"
}

 

 

Parsing Tweets

A method using regexp and php. Actually what this does is parse Tweets using regexp to reformat the text as html with links. A tutorial here:

http://saturnboy.com/2010/02/parsing-twitter-with-regexp/

This is a php library that breaks out hashtags, usernames, etc., but doesn’t really provide a way to isolate the remaining stuff. I have put it in tkzic/API –  there is an example php program provided.

https://github.com/mzsanford/twitter-text-php

hashtags – using regular expressions

http://stackoverflow.com/questions/11551065/parsing-tweets-to-extract-hashtags-in-r

twitter-text-rb : ruby gem which parses out usernames and hashtags

https://github.com/twitter/twitter-text-rb