[tuxdroid-svn] r344 - software/tux_pidgin/trunk
Status: Beta
Brought to you by:
ks156
From: Thomas_C <c2m...@c2...> - 2007-06-04 10:32:41
|
Author: Thomas_C Date: 2007-06-04 12:32:32 +0200 (Mon, 04 Jun 2007) New Revision: 344 Modified: software/tux_pidgin/trunk/tux_pidgin.py Log: Tuxdroid speaks with TTS voices that say the contact on pidgin Modified: software/tux_pidgin/trunk/tux_pidgin.py =================================================================== --- software/tux_pidgin/trunk/tux_pidgin.py 2007-06-03 16:19:41 UTC (rev 343) +++ software/tux_pidgin/trunk/tux_pidgin.py 2007-06-04 10:32:32 UTC (rev 344) @@ -61,8 +61,25 @@ import os import re import time +import sgmllib + +class MessageParser(sgmllib.SGMLParser): + """I found this snippets in this website : http://quickies.seriot.ch/index.php""" + def __init__(self): + sgmllib.SGMLParser.__init__(self) + + def strip(self, some_html): + self.theString = "" + self.feed(some_html) + self.close() + return self.theString + + def handle_data(self, data): + self.theString += data + + # This method is execute when a message is receive def received_im_msg(account, name, message, conversation, flags): buddy = purple.PurpleFindBuddy(account, name) @@ -71,22 +88,22 @@ else: alias = name text = "%s says %s" % (alias, message) - text = re.sub("<.*?>", "", text)#html2text + #text = re.sub("<.*?>", "", text)#html2text + message=text.encode('utf-8') + MessageP = MessageParser() + message = MessageP.strip(message) + tux_speak(message) - - tuxspeak(text) - + # This method is excute when a buddy is sign on def buddy_signed_on(buddyid): alias = purple.PurpleBuddyGetAlias(buddyid) - text = "%s is online" % alias text=text.encode('utf-8') tux_speak(text) # Tux speak the text def tux_speak(text): - print text tux.cmd.mouth_open() tux.tts.select_voice(2,100) tux.tts.speak(text) @@ -101,7 +118,7 @@ purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") except dbus.DBusException: print "Pidgin is not launched" - sys.exit(0) + sys.exit(1) |