-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic.py
61 lines (51 loc) · 1.54 KB
/
basic.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
import time, threading, platform, os
from nlp import mostSimilar, vectorized_commands
from speechrecog import text_stream, start_listen
from state_track import state, start_state_checking
from shortcut_control import shortcut
from commands import KEYWORD, commands, macros
from functions import *
from language_helpers import *
from boot import bootZoom
from preferences import commandLineControlMac
curr_system = platform.system()
def main():
commandLineControlMac()
bootZoom()
global text_stream
start_state_checking(1)
start_listen()
while True:
while KEYWORD not in text_stream[0]:
time.sleep(.25)
raw_text = text_stream[0]
text_stream[0] = ''
print(raw_text)
print(state)
if curr_system == 'Darwin':
os.system('''/usr/bin/osascript -e 'tell app "Finder" to set frontmost of process "zoom.us" to true' ''')
else:
shortcut('focus')
time.sleep(.1)
raw_text = sliceAfterSubstr(raw_text, KEYWORD)
if " and " in raw_text:
texts = [sliceUpToSubstr(raw_text, " and "), sliceAfterSubstr(raw_text, " and ")]
else:
texts = [raw_text]
for text in texts:
if not text.strip(): continue
compared = mostSimilar(text, [x for x in vectorized_commands])[0]
if 'send this message' not in compared:
text = compared
for command, callback in commands.items():
if command in text:
if 'send' in command:
if 'message' in command:
callback(sliceAfterSubstr(text, command + ' ') + '\n')
else:
callback(macros[command])
else:
callback()
break
if __name__ == '__main__':
main()