###TeCoed### import sys, subprocess, urllib, time, tweepy # == OAuth Authentication == # # This mode of authentication is the new preferred way # of authenticating with Twitter. # The consumer keys can be found on your application's Details # page located at https://dev.twitter.com/apps (under "OAuth settings") consumer_key= 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' consumer_secret= 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx' # The access tokens can be found on your applications's Details # page located at https://dev.twitter.com/apps (located # under "Your access token") access_token= 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' access_token_secret= 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api = tweepy.API(auth) def getSpeech(phrase): googleAPIurl = "http://translate.google.com/translate_tts?tl=en&" param = {'q': phrase} data = urllib.urlencode(param) googleAPIurl += data # Combine the data from the Google API return googleAPIurl def raspberryTalk(text): # This will call mplayer and will play the sound subprocess.call(["mplayer",getSpeech(text)], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) myTimeline = api.user_timeline() for tweet in myTimeline: print tweet.text raspberryTalk(tweet.text) time.sleep(10)