-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
196 lines (174 loc) · 6.19 KB
/
Copy pathscript.py
File metadata and controls
196 lines (174 loc) · 6.19 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
from tkinter import *
import tkinter as tk
import speech_recognition as sr
import pyttsx3
import threading
import time
import mysql.connector
use=[]
pas=[]
def stt():
with sr.Microphone() as source:
txt = "listening..."
T.insert(END,txt+'\n')
engine.say("listening")
engine.runAndWait()
audio = r.listen(source)
try:
text = r.recognize_google(audio)
text=text.lower()
tx = "You said : {}".format(text)
T.insert(END,tx+'\n')
engine.say("You said : {}".format(text))
engine.runAndWait()
if 'roll number' in text:
inp = text.replace('roll number','').strip()
dat_ = int(inp)
dat = []
for elements in inp:
dat.append(int(elements))
cur = mydb.cursor()
if dat[2]==1:
db = cur.execute("SELECT*FROM 12a")
for db in cur:
if db[0] == dat_:
T.insert(END, " " + '\n')
T.insert(END, str(db[2]) +'\n')
T.insert(END, str(db[-1]) + '\n')
T.insert(END, str(db[-2]) + '\n')
T.insert(END, " " + '\n')
engine.say(text+" is "+db[2])
engine.runAndWait()
else:
continue
elif dat[2]==2:
db = cur.execute("SELECT*FROM 12b")
for db in cur:
if db[0] == dat_:
T.insert(END, " " + '\n')
T.insert(END, str(db[2]) +'\n')
T.insert(END, str(db[-1]) + '\n')
T.insert(END, str(db[-2]) + '\n')
T.insert(END, " " + '\n')
engine.say(text+" is "+db[2])
engine.runAndWait()
else:
continue
elif dat[2]==3:
db = cur.execute("SELECT*FROM 12c")
for db in cur:
if db[0] == dat_:
T.insert(END, " " + '\n')
T.insert(END, str(db[2]) +'\n')
T.insert(END, str(db[-1]) + '\n')
T.insert(END, str(db[-2]) + '\n')
T.insert(END, " " + '\n')
engine.say(text+" is "+db[2])
engine.runAndWait()
else:
continue
elif dat[2]==4:
db = cur.execute("SELECT*FROM 12d")
for db in cur:
if db[0] == dat_:
T.insert(END, " " + '\n')
T.insert(END, str(db[2]) +'\n')
T.insert(END, str(db[-1]) + '\n')
T.insert(END, str(db[-2]) + '\n')
T.insert(END, " " + '\n')
engine.say(text+" is "+db[2])
engine.runAndWait()
else:
continue
elif dat[2]==5:
db = cur.execute("SELECT*FROM 12e")
for db in cur:
if db[0] == dat_:
T.insert(END, " " + '\n')
T.insert(END, str(db[2]) +'\n')
T.insert(END, str(db[-1]) + '\n')
T.insert(END, str(db[-2]) + '\n')
T.insert(END, " " + '\n')
engine.say(text+" is "+db[2])
engine.runAndWait()
else:
continue
else:
print("error")
else:
pass
except:
T.insert(END,"No results found"+'\n')
engine.say("No results found")
engine.runAndWait()
def digitalclock():
text_input = time.strftime("%H:%M:%S")
cloak.config(text=text_input)
cloak.after(200, digitalclock)
def thread():
maincal = threading.Thread(target=stt)
maincal.start()
def submit():
use.append(username.get())
pas.append(password.get())
top.destroy()
top = tk.Tk()
top.geometry("300x120")
top.title("Login Page")
top.iconbitmap('./res/proj.ico')
lblfrstrow = tk.Label(top, text ="MySql user -", )
lblfrstrow.place(x = 50, y = 20)
username = tk.Entry(top, width = 35)
username.place(x = 150, y = 20, width = 100)
lblsecrow = tk.Label(top, text ="MySql pass -")
lblsecrow.place(x = 50, y = 50)
password = tk.Entry(top, width = 35)
password.place(x = 150, y = 50, width = 100)
submitbtn = tk.Button(top, text ="Login", command = submit)
submitbtn.place(x = 125, y = 90, width = 55)
top.mainloop()
mydb = mysql.connector.connect(
host = "localhost",
user = use[0],
password = pas[0],
database = "class"
)
r = sr.Recognizer()
engine = pyttsx3.init()
engine.setProperty("rate", 120)
root = tk.Tk()
root.title("Record")
root.iconbitmap('./res/proj.ico')
root.geometry("500x500")
root.resizable(False, False)
Font_tuple = ("family", 15)
img0 = PhotoImage(file='./res/artwork.png')
bg=Label(root, image= img0,relief="flat").place(x=-2,y=-2)
cloak = Label(root,
background="black",
font=("family",8),
fg="white")
cloak.place(x=0,y=0)
digitalclock()
T = Text(root,
height = 28,
width = 30,
background="black",
fg="white",
relief="flat")
T.place(x=0,y=15)
T.configure(font=("Courier", 10, "italic"))
im=PhotoImage(file='./res/mic.png')
start = Button(root,
image=im,
text="START",
font="bold",
command=thread,
relief="flat",
bd=0,
bg="black",
fg="tomato",
activebackground="black",
activeforeground="white")
start.place(x=300,y=375)
root.mainloop()