-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsnap2speech.py
More file actions
29 lines (26 loc) · 784 Bytes
/
Copy pathsnap2speech.py
File metadata and controls
29 lines (26 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#Snap! extension base by Technoboy10
import SimpleHTTPServer
class CORSHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def send_head(self):
path = self.path
print path
ospath = os.path.abspath('')
if 'say' in path:
regex = re.compile("\/say(.*)")
m = regex.match(urllib2.unquote(path))
engine.say(m.group(1))
engine.runAndWait()
if __name__ == "__main__":
import os
import re
import SocketServer
import pyttsx
import urllib2
PORT = 59591 #T+T+S twice
engine = pyttsx.init()
Handler = CORSHTTPRequestHandler
#Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "serving at port", PORT
print "Go ahead and launch Snap!."
httpd.serve_forever()