-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
69 lines (50 loc) · 1.42 KB
/
Copy pathapp.py
File metadata and controls
69 lines (50 loc) · 1.42 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import time
from tornado import web, ioloop
import threading
# import serial_sender as BOT
# obtain audio from the microphone
# r = sr.Recognizer()
import emotions as EMOTIONS
import SocketManager
import twitter_interface as Twit
import say_something as Speech
import brain as Twitter
FACE_DEBUG_MODE = True
def run_webserver():
app.listen(3110)
ioloop.IOLoop.instance().start()
def send_face_position(face_type):
for client in SocketManager.clients:
client.write_message(face_type)
def keep_alive():
while True:
time.sleep(1)
print("")
if __name__ == '__main__':
# Init
app = web.Application([
(r'/audio/(.*)', web.StaticFileHandler, {'path': 'audio'}),
(r'/', SocketManager.Handler)
])
webserver = threading.Thread(target=run_webserver)
webserver.daemon = True
webserver.start()
twitterServer = threading.Thread(target=Twitter.begin_streaming)
twitterServer.daemon = True
twitterServer.start()
alive = threading.Thread(target=keep_alive())
alive.daemon = True
alive.start()
# Send first face
face_type = EMOTIONS.ANGRY_FACE
send_face_position(face_type)
# Rorys face debug mode
if FACE_DEBUG_MODE:
while (1):
user_input = raw_input('What\'s your face? ')
position = EMOTIONS.input_to_face(user_input)
for client in SocketManager.clients:
client.write_message(position)
while (1):
if Twit.tweet_available():
print("Do something here")