-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
142 lines (127 loc) · 5.76 KB
/
main.py
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#main.py
#import I
#import pprofile
#import actions
#import ticket
import languageloop
#import audioloop
import causal_model
import ears
import pickle
#import actions
import audiocortex
import actions
#import speechLib
from threading import Thread
import threading
import time
import queue
from datetime import datetime, timedelta
#checks, field all info, push inputs to causal_model, return path, enact target function
#Initializing speech2text generator
class executive_loop:
def __init__(self):
print("< ------- Executive Loop intializing... ------ >")
self.pq = queue.Queue()
self.cm = causal_model.model()
self.flags = {"icloud": False, "gmail": False, "citizen": False}
self.run()
def chores(self):
while(True):
time.sleep(35)
print("< ------- Doing Chores ------ >")
#update some information
#0.01549275362
if(self.flags["icloud"]):
currentlatlong = actions.track_device(0)
currentaddress = actions.latlonglookup(currentlatlong[0], currentlatlong[1])
weather = actions.getPrecipitation(currentaddress[2], currentaddress[1])
collectiontime = datetime.now()
self.pq.put(["Weather Underground", "The forecast at " + collectiontime.strftime("%H:%M:%S") + " on "+ collectiontime.strftime("%d/%m/%Y") + " is " + weather])
temp = actions.getCurrentTemp(currentaddress[2], currentaddress[1])
self.pq.put(["Weather Underground", "The temperature at " + collectiontime.strftime("%H:%M:%S") + " on "+ collectiontime.strftime("%d/%m/%Y") +" is " + temp])
#when, from, contents
#headlines = actions.getHeadlines()
#for x in range(0, len(headlines)):
# self.pq.put(["Reuters", "Today: " + headlines[x]])
if(self.flags['citizen']):
nearbyincidents = actions.get_incidents(currentlatlong[0], currentlatlong[1], 0.01549275362)
for x in range(0, len(nearbyincidents)):
self.pq.put(["Citizen", "At " + str(nearbyincidents[x][1]) + " Citizen reported a code " + str(nearbyincidents[x][5])+ " incident: "+ nearbyincidents[x][0]])
print("< ------- Chores Done ------ >")
time.sleep(18000)
def audio(self):
print("< ------- Loading Audio Loop ------ >")
print("< ------ Initializing Ear ------ >")
ear = ears.listen()
while(next(ear)!=True):
time.sleep(0.01)
print("< ------- Loaded Audio Loop ------ >")
print("< -- Initializing Audio Cortex -- >")
audcortex = audiocortex.audio_cortex()
print("< -------- Audio Cortex Loaded ------- >")
while(True):
#check for audio
#fingerprint, text
current_audio_output = next(ear)
self.pq.put(current_audio_output)
audcortex.passIn(current_audio_output[1], current_audio_output[0])
#next(creng)
#current_voice_val = creng.send(current_audio_output[0])
def texts(self):
while(True):
#check for texts
if(self.flags["gmail"]):
texts = actions.getMail()
if(len(texts)>0):
for x in range(0, len(texts)):
#when, from, contents
self.pq.put([texts[x][1], texts[x][2]])
time.sleep(1)
def run(self):
listen = threading.Thread(target=self.audio,args=())
text = threading.Thread(target=self.texts,args=())
chore = threading.Thread(target=self.chores,args=())
listen.start()
text.start()
chore.start()
print("< ------- Loading Language Loop ------ >")
lang = languageloop.language_loop()
print("< -------- Language Loop Loaded ------ >")
print("< ------- Loading Causal Model ------ >")
#cm = causal_model.model()
print("< -------- Causal Model Loaded ------ >")
print(" ")
print(" ")
print(" ")
print(" ")
#print("#̷̨͕̝͚̬͋~̷͇͔̿͊̅̓̿̈͗͋#̵̬̭̲̞̺͆͆̄̿͛͐̇͋̎~̴̨̘̔́͑̌#̶̧̡̨̰͉̣̣́͘~̴̡͙̒̎̇̌̃͛ͅ#̷̛̱̰̒̇̋̿͠ ̷̨̨͍̠͎̤͉̱͎̦͆͌̄͊͑͘̚Ê̴̘̬͕̰͔n̴̠̲͈̠̺̥̜̹̙̲̓͆͋̆̉̏͂́͆̂t̶͖͓̪̭͖͕̄é̸̢̯̖̼͇r̷̨̙͓̽̾̿̕ͅí̷͇͙̞͍̘̣̰̠̦̒͂̔n̴̢̮͖̮̦͍̈̍̈͋̂̃͌̚g̷͕͖̟͒̆̈͌͊ ̵̡͎̙̻̰̎́͠T̴̞͖͔̮̿̀͒̆̀̒̊̄̋͠h̷̢̨̨̡͉̹̖̖͚̋̆́ͅe̴̢͚̤̫͍̝̤̠͑̓͒̋͒̕͜͜͠ ̵̬̦̍͂̅͐͝L̵̻̫̯̱͕͗̓̇́͊̚͝ợ̴͙̫̩̽̌̐̊̍̆o̶̢̼̭͎͉͇̭̠̼͗̈́̊͋̒̓ͅp̸̪̖̻̼͕͔̭̮͎̱͐͐ ̶͇̫̣̹̥̖̽͒̉̔̅ͅ#̷̢͆̇̋͊͒̊̕̚~̷̤̗̱̯̘̿͐̃̀͊͝#̵͚̘̼̝̱̼͙̻̘̗͛̑͗̓̾͘͠͝~̵̯̱̖͙̣͌̅̿̓̐̿͝#̶̡̼̬̰͇̙͐̾̈́̅͜~̷̭̼͛̍̇̋̎̌̿͂͊͝#̵̲̙͚̠͍̈́̂͛͜")
print(" ")
print(" ")
print(" ")
print(" ")
print("< -------- Entering Executive Loop ------ >")
while(True):
#<-input block->
#<-end input block->
#<-processing block->
#language processing
cur = self.pq.get()
print(cur)
if(cur!=False):
response = lang.feed(cur[0], cur[1])
answer = response[0]
commands = response[1]
print("< -------- Executive Loop Received ------ >")
print(response)
#<-end processing block->
#<-decision block->
#<-end decision block->
#<-action block->
#<-end action block->
listen.join()
text.join()
chore.join()
q = executive_loop()
q.run()
#listen for sensor info