Skip to content

Instantly share code, notes, and snippets.

@possan
Created June 4, 2012 12:04
Show Gist options
  • Save possan/2867948 to your computer and use it in GitHub Desktop.
Save possan/2867948 to your computer and use it in GitHub Desktop.
Colloquy walkie talkie script (python part)
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