-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
56 lines (44 loc) · 1.24 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
from bs4 import BeautifulSoup
from utils import *
from recognise import mic
def process_speech(speech,data):
for command in commands:
if command in speech:
return commands[command](speech,command,data)
commands = {
"save":savefile,
"image":add_asset,
"database":db_make,
"add":getitem,
"create":getitem,
"background":bg,
"move":moveitem,
"response":resp
}
def main_loop():
# load file
if data:= loadfile():
data = BeautifulSoup(data,features="html.parser")
else:
with open("templates/base.html","r") as f:
data = BeautifulSoup(f.read(),features="html.parser")
with open("main.css","w") as f:
f.write("")
while True:
# Getting text
for i in range(3):
response = mic.recognize_speech()
if response["success"]:
speech = response["transcription"]
break
else:
print("Too many errors stopping")
print("you said:",speech)
if speech:
if "exit" == speech:
break
data = process_speech(speech,data)
else:
print("retry")
if __name__ == "__main__":
main_loop()