It uses oauth to authenticate with twitter before opening a twitter user stream, the program then waits for data to appear, when it does, it uses google translate to create an mp3 file which is then stream by mplayer and hey presto, the Pi talks the tweet!
Its not really a finished program, more, a proof of concept, but I thought it might be useful for other people who want to use twitter in their projects and need a starting point. There is also a great tutorial about consuming twitter streams using python, where I got some of the code for this program
There are a few pre-requisites to getting this to work.
Create a twitter app
You need to create a twitter app using your twitter id, you can do this by visiting dev.twitter.com, signing on, and clicking create app; if you are having problems see a previous blog post of mine, automatically posting updates to twitter, which has some in-depth instructions.
I used leah's python oauth module to authenticate with twitter.
If you have never installed python modules before you are going to need to install the python setup tools, module, distribute, see blog post, python - installing modules, for info on how to do this.
In order to get the code from github you need to install git-core tools.
Get the code from git
Install the module
pycurl is used to connect to the twitter streams.
mplayer is used to output the audio stream.
Create talking twitter client program
Cut and paste the program into it and save.
Press CTRL C to exit and wait a few moments, this is for pycurl to give up the connection.
Limitations (found so far!)
Google translate seems to have a maximum length of string it will create an mp3 for, I found in testing that some tweets weren't output and it was because google didn't return an mp3 because it was too long.
There is no mechanism for recovering from errors, such as a the stream going down, it just falls over!