-
Notifications
You must be signed in to change notification settings - Fork 0
/
smarty
98 lines (98 loc) · 3.43 KB
/
smarty
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
#!/usr/bin/python
import sys
import speech_recognition as sr
recog=sr.Recognizer()
sys.path.append('/libs/')
sys.path.append('/smarty_lib/')
import os
from libs.ColorPython import Color
import smarty_lib
from smarty_lib.mathy import *
from smarty_lib.mysystem import *
from smarty_lib.dumblib import *
from smarty_lib.dblite import *
try:
clear()
print(Color.bold['green'] + "*" * os.get_terminal_size()[0] + Color.reset)
print("\t\t\t\t " +Color.bold['purple'] + responces[0] + Color.reset)
print(Color.bold['green'] + "*" * os.get_terminal_size()[0] + Color.reset)
print( Color.bold['white'] + responces[1] + Color.reset)
pc=0
print( Color.bold['yellow'] + "enter 1 for help" + Color.reset)
print( Color.bold['cyan'] + "enter 2 for speech mode" + Color.reset )
print( Color.bold['red'] + "enter 3 for text mode" + Color.reset)
print()
print(Color.bold['blue'] + "Enter" + Color.bold['yellow'] + ">" + Color.bold['red'] + ">" + Color.bold['green'] + ">" ,end=' ')
pc=int(input())
if pc>3:
exit()
pl=0
if pc==1:
help()
pc=3
while True:
print()
temp=""
text=""
if pc==2:
with sr.Microphone() as source:
if pl==0:
clear()
print(responces[0])
print(responces[1])
pl=1
print("say something.....")
audio=recog.listen(source)
try:
temp=recog.recognize_google(audio)
except:
print("cant recognize")
else:
print( Color.bold['blue'] + "!" *os.get_terminal_size()[0] + Color.reset)
print(Color.bold['red']+"ENTER "+Color.reset+Color.bold['cyan']+"THE "+Color.reset+Color.bold['green']+"COMMAND:"+Color.reset,end='')
temp=input()
text=[]
insert_into_database(temp)
for i in temp.split(' '):
if i.upper() in required:
text.append(i)
for word in text:
if word.upper() in operations.keys():
try:
l=extract_numbers_from_text(temp)
r=operations[word.upper()](l)
except:
print("Something is wrong, please retry")
finally:
break
elif word.upper() in commands.keys():
commands[word.upper()]()
break
elif word.upper() in commands1.keys():
commands1[word.upper()]()
break
elif word.upper() in db.keys():
db[word.upper()]()
break
elif word.upper() in commands2.keys():
try:
l1=extract_numbers_from_text(temp)
arg=[]
if (len(text)!=1):
for i in text:
if i.upper() in checkpoint:
arg.append(i.upper())
for i in l1:
arg.append(i)
commands2[word.upper()](arg)
except:
print("something is wrong,please retry")
finally:
break
else:
if ('www' in temp) or ('google' in temp) or ('search' in temp):
google(temp)
else:
sorry()
except:
exit()