Created
June 4, 2012 12:04
-
-
Save possan/2867948 to your computer and use it in GitHub Desktop.
Colloquy walkie talkie script (python part)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import subprocess | |
import os | |
voices = ['Agnes','Kathy','Princess','Vicki','Victoria','Bruce','Fred','Junior','Ralph'] | |
def voiceFromName(name): | |
x = 0 | |
for c in name: | |
x = x + ord(c) | |
x = voices[x%len(voices)] | |
print x | |
return x | |
print voiceFromName('a') | |
while True: | |
try: | |
r = raw_input() | |
# print "Got: "+r | |
r = re.sub('</?(span|name)[^>]+>','',r) | |
# print "Filtered: "+r | |
m = re.search('<sender[^>]+>([^<]+)<', r) | |
whom = m.group(1) | |
# print "Whom: "+whom | |
m = re.findall('<message[^>]+>([^<]+)</mess', r) | |
for line in m: | |
i = line | |
print "Say: "+i | |
os.system('mpg123 static12.mp3'); | |
os.system('say -v "'+voiceFromName(whom)+'" "'+i+'"') | |
except: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment