Twitter voice notifier with Python and Twython

This script (thanks to Raspberry Pi Projects book and Raspberry Pi Twitter monitor) is the first step of interactive led video art project I have in mind. The goal is allow people to change the configuration of led installation via Twitter and see results via real-time video streaming.

But it is the final goal, now, first step is connect Twitter with Python. To try that, I made this simple script that speaks to you every time you are mentioned on Twitter. You must also register your app on to get keys and tokens.

import time
from twython import TwythonStreamer
import subprocess

def say(words):
	devnull = open("/dev/null","w")["espeak","-v", "en-rp",words],stderr=devnull)

# Search terms
TERMS = '@YourId'

# Twitter application authentication
APP_KEY = '-------------------'
APP_SECRET = '-----------------'
OAUTH_TOKEN = '----------------'
OAUTH_TOKEN_SECRET = '--------------------'

# Setup callbacks from Twython Streamer
class TalkingTwitter(TwythonStreamer):
        def on_success(self, data):
                if 'text' in data:
                        print data['text'].encode('utf-8')
			say(data['text'].encode('utf-8')) # reads the mention
			say("You have been mentioned in Twitter") # only informs you

# Create streamer
except KeyboardInterrupt:
	print "Bye Bye!"

You can download the code from github

Posted in In progress, Linux, Programming, Python, Raspberry Pi, Social Tagged with: , , , , ,
0 comments on “Twitter voice notifier with Python and Twython
1 Pings/Trackbacks for "Twitter voice notifier with Python and Twython"
  1. […] idea is to reuse the Talking Twitter script and the driver for the 32×32 RGB LED […]

Leave a Reply

Your email address will not be published. Required fields are marked *