Make Twitter Talk With Python Permalink

You will need elementtree, pyTTS and a Twitter login. Check their API page for a list of XML's - the sample script reads the public timeline.

import urllib2
import os
from pyTTS import *
from time import sleep
from elementtree import ElementTree

auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password('realm', 'host', 'username', 'password')
opener = urllib2.build_opener(auth_handler)
urllib2.install_opener(opener)
f = urllib2.urlopen('http://twitter.com/statuses/public_timeline.xml')

timeline = f.read()
tree = ElementTree.fromstring(timeline)
tts = pyTTS()
tts.SetRate(-3)
tts.SetVoiceByName('MSMary')

all = "Twitter.com <SILENCE MSEC = \"1000\"/>"
for statusNode in tree.findall('.//status'):
    name = statusNode.findall('.//user//screen_name')[0].text
    status = statusNode.findall('.//text')[0].text
    all = all + "<pitch middle = '-10'/>" + name + "<pitch middle = '+10'/><SILENCE MSEC = \"300\"/>" + status + "<SILENCE MSEC = \"800\"/>"
all = all + "<SILENCE MSEC = \"2000\"/>Thanks for listening!"
tts.SpeakToWave("twitter.wav", all, tts_is_xml)
os.system("twitter.wav")

Posted by Davy Mitchell on 2007-02-22 20:49:54.
Categories: Python, Internet, Fun Tags :    
Like this post? Digg it or Del.icio.us it. |



Twitter, IronPython Beta 1.1 and TayLayout Permalink

I am now on Twitter - didn't like the sound of it at first but now I am having fun now. There's a simple API too which I have played with a little. May post my little Python hack tonight...

CodePlex - IronPython(Link) ''This release primarily focuses on adding the remaining new functionality for the 1.1 release (array module, importing pre-compiled modules) along with many new bug fixes.''

TayLayout has now had over 100 downloads (WinForms and wxPython combined). Not bad for the early state of the project.

Posted by Davy Mitchell on 2007-02-22 12:23:07.
Categories: Python, IronPython, Internet
Like this post? Digg it or Del.icio.us it. |



Dog and Ball Permalink

Blue skies this weekend and, of course, Dandy and I hit the beach.

Posted by Davy Mitchell on 2007-02-18 21:19:07.
Categories: Angus, Fun, Photos
Like this post? Digg it or Del.icio.us it. |



Review Of Movable Python Megapack 2.0.0 Permalink

Read my review here. This is the longest document I have written yet with Google's word processor. A fairly pleasent experience Wink

Posted by Davy Mitchell on 2007-02-18 20:13:42.
Categories: Python, IronPython, Software
Like this post? Digg it or Del.icio.us it. |



Proof Of God (Link) Permalink

A PRACTICAL MAN'S PROOF OF GOD

Posted by Davy Mitchell on 2007-02-18 19:43:54.
Categories: General, Christian
Like this post? Digg it or Del.icio.us it. |




Locations of visitors to this page