-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand_main.py
32 lines (31 loc) · 1.1 KB
/
command_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
from fuzzywuzzy import process
from playsound import playsound
#DEMO
'''
1:{"commands":[],"func":""},
'''
command_dict={
0:{"commands":["hai","hello","how are you"], "func":"greet"},
1:{"commands":["search for website","search for site"],"func":"searchforwebsite"},
2:{"commands":["take screenshot","screenshot"], "func":"take_screenshot"},
3:{"commands":["whats the time","time like"],"func":"get_time"},
4:{"commands":["lock my pc","lock computer","lock pc"],"func":"lock_my_pc"}
}
special_commands = ["searchforwebsite"]
def getcommand(txt):
match_percent = 0
for key in command_dict:
details,percent = process.extractOne(txt, command_dict[key]["commands"])
print(details,percent)
if percent > match_percent:
match_percent = percent
command = command_dict[key]["func"]
finaldetail = details
if match_percent > 85:
if command in special_commands:
command = command+"(\"{tx}\")".format(tx=txt)
else:
command = command+"()"
return command, finaldetail
else:
return None