|
Davy Mitchell's Meandering Weblog Home - Angus - Christian - Energy - Fun - General - Internet - IronPython - MoodNews - NintendoDS - Personal - Photos - Podcast - Politics - Python - Scotland - Software Blog Statistics Tag Cloud RSS More Feeds Archives2007-02-102007-02-03 2006-12-16 2006-12-09 2006-12-02 2006-11-25 2006-11-18 2006-11-11 2006-10-14 2006-10-07 |
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. 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. 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. 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
Posted by Davy Mitchell on
2007-02-18 20:13:42. Proof Of God (Link) Permalink A PRACTICAL MAN'S PROOF OF GOD
Posted by Davy Mitchell on
2007-02-18 19:43:54. |
|