Search

A twitter reader #python #raspberryPi

I had the idea to get the Raspberry Pi to be a Twitter radio. Not novel and not very useful for the boat although vocalising NAVTEX messages as they arrive might be handy. Anyway it's fun.

In a previous XQuery version, I had used twitter search and the returned RSS feed, but in view of today's annoucement about Twitter dropping XML support, this may not be around for much longer. So I tried the json feed instead which was in fact easier to handle in Python anyway. e.g.

http://search.twitter.com/search.json?q=from:george_szirtes

The script polls the search results at intervals and parses the json into tweets. The text needs cleaning up to be suitable for TTS.  To avoid repeating tweets, I retain the timestamp of the last tweet spoken and ignore tweets with a earlier timestamp. Tweets are reversed so they come out in chronological order:

The full code is in GitHub

Nothing much to this script and nothing specific to the RPi, except that the RPi makes it feasible to do fun things, like a roomfull of tweet vocalisers with which visitors could interact. I guess some filtering or human mediation would be needed here - my attempts to do this in lectures via SMS and a collaborative browser-based whiteboard elicited mainly shockingly bad language.

I'm looking for twitter streams worth listening to. Tom Sutcliffe on Saturday Review recommended the poet George Szirtes @george_szirtes and he is excellent. I wish I had had this running when Jennifer Egan's story Black Box was being tweeted by the New Yorker. A news channel would generate tweets at a useful rate and might be amusing to have in the background. However the problem is to do a better job of cleaning the text and adding SSML markup to the text so the TTS can make a better job of vocalising. It's a bit challanging to listen to but actually I'm amazed how well espeak does.