-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaincode3.py
785 lines (718 loc) · 29 KB
/
maincode3.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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
import nltk
nltk.download('stopwords')
import csv
import pandas
pandas.set_option('display.max_rows', 100)
nltk.download('punkt')
from nltk.corpus import wordnet
from nltk.corpus import stopwords
import speech_recognition as sr
import time
import tkinter
import sys
import numpy as np
import cv2
import PIL
from PIL import Image
from PIL import ImageTk
import pytesseract
# from tkinter import *
from tkinter import *
from tkinter.ttk import *
import matplotlib
matplotlib.use("TkAgg")
# from matplotlib.figure import Figure
# from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,
from matplotlib.figure import Figure
from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg,NavigationToolbar2Tk)
import random
from collections import Counter
import jdk
# import language_tool_python
# tool = language_tool_python.LanguageTool('en-US')
import pyttsx3
from tkinter import ttk
# import numpy as np
# import cv2
import matplotlib.pyplot as plt
# from deepface import DeepFace
import json
import os
from gtts import gTTS
from playsound import playsound
from functools import reduce
tts = gTTS('Welcome to H R pro')
tts.save('hello.mp3')
playsound('hello.mp3')
import matplotlib.pyplot as plt
from mtcnn.mtcnn import MTCNN
from matplotlib.patches import Rectangle
from matplotlib.patches import Circle
from PIL import Image
from reportlab.pdfgen import canvas
from django.http import HttpResponse
#to automate email
import email, smtplib, ssl
from email import encoders
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import mimetypes
import os
import base64
file1 = open('interview log.txt', 'w')
file1.write('.')
global cussing
from threading import Thread
global imgarray
global beforesummationx
beforesummationx=[]
global beforesummationy
beforesummationy=[]
global summationarrax
summationarrax=[]
global summationarray
summationarray=[]
cussing=0
global breakingpoint
breakingpoint=0
global email_id
tts = gTTS('please enter your email')
tts.save('email.mp3')
playsound('email.mp3')
email_id = input('Enter email: ')
global cap
cap = cv2.VideoCapture(0)
def main():
# gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
global cnt
cnt=0
global ansch
ansch=0
# face_classifier = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
# eye_classifier = cv2.CascadeClassifier('haarcascade_eye.xml')
global x, l, m
x=["Tell me about yourself", "Why should I hire you?"
,"What is your long-range objective?",
"What is your greatest accomplishment?",
"How has your education prepared you for your career?",
"What major problem have you had to deal with recently?",
"Do you handle pressure well?",
"Why did you choose to attend this college?",
"What changes would you make at your college?",
"What were your favorite classes? Why?",
"Do you enjoy doing independent research?",
"Who were your favorite professors? Why?",
"Why is your GPA not higher?",
"Do you have any plans for further education?",
"How much training do you think you'll need to become a productive employee?,"
"Why do you want to work in the IT industry?",
"What do you know about our company?",
"Why are you interested in our company?",
"Do you have any location preferences?",
"How familiar are you with the community that we're located in?",
"Are you willing to relocate? In the future?",
"Are you willing to travel? How much?",
"Is money important to you?",
"How much money do you need to make to be happy?",
"What kind of salary are you seeking?",
"What qualities do you feel a successful manager should have?",
"If you had to live your life over again, what one thing would you change?",
"How would you describe your ideal job?",
"Why did you choose this career?",
"When did you decide on this career?",
"What goals do you have in your career?",
"How do you plan to achieve your career goals?",
"How do you personally define success?",
"Describe a situation in which you were successful.",
"What do you think it takes to be successful in this career?",
"What accomplishments have given you the most satisfaction in your life?",
"Would you rather work with information or with people?",
"What motivates you?",
"Tell me about some of your recent goals and what you did to achieve them.",
"What are your short-term goals?",
"What are your mid-range goals?",
"What would your past manager say about you?",
"Are you a goal-oriented person?",
"Where do you want to be ten years from now?",
"Do you handle conflict well?"
]
l=['further elaborate on your level of expertise at that', 'please elaborate further on that', 'kindly discuss further about that', 'give me a further explanation of the term', 'simplify it for me, please']
m=['machine','AI','block', 'blockchain','big','social','cloud','client', 'neural','NLP']
cuss=['shit', 'piss', 'cunt', 'bitch', 'damn', 'fuck', 'bastard','nigga']
lol=0
global lmao
lmao=0
SCALE_FACTOR = 1.05
BLUE_COLOR = (255, 0, 0)
MIN_NEIGHBORS = 5
global img_counter
img_counter=0
global xex
xex=0
global timesleep
timesleep=0
def startProcess():
# opening file 1 and reading good speeches and extracting token words
file1 = open("1.txt", 'r')
reading = file1.read()
tokens = nltk.word_tokenize(reading)
stop_words = set(stopwords.words('english'))
words = [w for w in tokens if w not in stop_words]
#label = tkinter.Label(frame2, text="File 1 loaded", anchor='w')
#label.pack(fill='both')
print('file1 loaded')
# doing the same thing with file 2(bad speeches)
file2 = open("2.txt", 'r')
reading = file2.read()
tokens = nltk.word_tokenize(reading)
stop_words = set(stopwords.words('english'))
words2 = [w for w in tokens if w not in stop_words]
#label = tkinter.Label(frame2, text="File 2 loaded", anchor='w')
#label.pack(fill='both')
print('file2 loaded')
# algorithm for mapping words and phrases to values depending on how many show up in good vs bad speeches
with open('log1.csv', 'w', newline='') as file:
writer = csv.writer(file)
writer.writerow(["Word", "Points"])
for w in words:
if w != "I" and w != "'ve" and w != "." and w != "," and w != "A" and w != "An" and w.isalpha():
points = 0
for l in words:
if l == w:
points = 1 + points
for x in words2:
if w == x:
points = -1 + points
writer.writerow([w, points])
#label = tkinter.Label(frame2, text="File 1 read", anchor='w')
#label.pack(fill='both')
print('file1 read')
for w in words2:
if w != "I" and w != "'ve" and w != "." and w != "," and w != "A" and w != "An" and w.isalpha():
points = 0
for l in words2:
if l == w:
points = -2 + points
for x in words:
if w == x:
points = +1 + points
writer.writerow([w, points])
writer.writerow([w, points])
#label = tkinter.Label(frame2, text="File 2 read", anchor='w')
#label.pack(fill='both')
print('file2 read')
Load_dataframe()
# BUT2.pack()
get_audio()
# BUT3.pack()
# print("End of Interview. \n transcript: \n\n")
def Evaluation():
# Opening and analysing and scoring the speech given by user
tts = gTTS('You are now being evaluated')
tts.save(f'eval{cnt}.mp3')
playsound(f'eval{cnt}.mp3')
file1 = open("interview log.txt", 'r')
# pylanguagetool>file1.txt
reading = file1.read()
tokens = nltk.word_tokenize(reading)
stop_words = set(stopwords.words('english'))
words = [w for w in tokens if w not in stop_words]
# get_demographic()
score = 0
global y
y = []
global low_point
global score_array
score_array = []
global score_index
score_index = 0
arrayofarrayformistakes = []
#label = tkinter.Label(frame4, text="words around which improvement is needed", font=40)
#label.pack()
for w in words:
for ind in df1.index:
if df1['Word'][ind] == w:
# print('score for '+ w)
# print(df1['Points'][ind])
# T.insert(tkinter.END, "Score for"+ w)
# T.insert(tkinter.END, df1['Points'][ind])
score_array.append(score)
for j in score_array:
arrayformistakes = []
xox = 0
if score_index > 10:
for k in score_array:
if score_array.index(j) + 1 != len(score_array):
if j < score_array[score_array.index(j) - 1]:
# for l in range(score_array.index(k)):
if j < score_array[score_array.index(j) + 1]:
print('...', end='')
for m in range(words.index(w) - 4, words.index(w)):
print(words[m], end=' ')
arrayformistakes.append(words[m] + ' ')
print('...')
xox = 1
break
if xox == 1:
# for br in strn2:
# if br in strn:
arrayofarrayformistakes.append(arrayformistakes)
# strn2=strn
# strn=strn.join(arrayformistakes)
# label= tkinter.Label(frame4, text="..."+strn+"...", anchor='w')
# label.pack(fill='both')
break
score_index = score_index + 1
score = score + df1['Points'][ind]
# label= tkinter.Label(frame2, text='Points for word ')
# label.pack()
# label= tkinter.Label(frame2, text=w)
# label.pack()
# label= tkinter.Label(frame2, text=df1['Points'][ind])
# label.pack()
y.append(score)
# y.append(score)
# if not list(reduce(lambda i, j: i & j, (set(x) for x in arrayofarrayformistakes))):
breaker = 0
for i in arrayofarrayformistakes:
breaker = breaker + 1
i = "".join(i)
#label = tkinter.Label(frame4, text="..." + i + "...", anchor='w')
#label.pack(fill='both')
if breaker > 3:
break
# else:
# res = list(reduce(lambda i, j: i & j, (set(x) for x in arrayofarrayformistakes)))
# res="".join(res)
# label= tkinter.Label(frame4, text="..."+res+"...", anchor='w')
# label.pack(fill='both')
# for i in y:
# label= tkinter.Label(frame2, text=i)
# label.pack()
global a
a = {'anger': 0, 'love': 0, 'surprise': 0, 'fear': 0, 'joy': 0, 'sadness': 0}
for w in words:
for ind in df2.index:
if w in df2['Words'][ind]:
a[df2['Emotion'][ind]] = a[df2['Emotion'][ind]] + 1
print(a)
myList = a.items()
myList = sorted(myList)
global q, r
q, r = zip(*myList)
# global d
# print(score)
# T.insert(tkinter.END, score)
# T.pack()
#label = tkinter.Label(frame2, text="Score is ")
#label.pack()
#label = tkinter.Label(frame2, text=score, font=20)
#label.pack()
print(f'score is {score}')
if score >= 100:
# print('excellent')
#label = tkinter.Label(frame2, text="Excellent", font=40)
#label.pack()
print('Excellent')
# T.pack()
elif score > 0 and score <= 60:
#label = tkinter.Label(frame2, text="Average", font=40)
#label.pack()
print('average')
# T.pack()
else:
#label = tkinter.Label(frame2, text="below Average", font=40)
#label.pack()
print('below average')
#BUT = tkinter.Button(frame1, text="Get Graph", command=lambda: [plot(), BUT.destroy()])
#BUT.pack()
plot()
# T.pack()
def Load_dataframe():
#label = tkinter.Label(frame2, text="loading Dataframe", anchor='w')
#label.pack(fill='both')
global df1
df1 = pandas.read_csv('Log1.csv')
df1.drop_duplicates(subset="Word", keep="first", inplace=True)
df1
#label = tkinter.Label(frame2, text="Dataframe Loaded successfully", anchor='w')
#label.pack(fill='both')
print('dataframe loaded successfully')
global df2
df2 = pandas.read_csv('train.csv')
#label = tkinter.Label(frame2, text="Emotions Loaded successfully", anchor='w')
#label.pack(fill='both')
print('emotions loaded successfully')
def get_audio():
#label = tkinter.Label(frame2, text="Initializing Audio Module", anchor='w')
#label.pack(fill='both')
# Speech recognition module
get_recognizer()
getquestion()
# BUT4.pack()
# print("say something!")
# T.insert(tkinter.END, "Say something")
# T.pack()
# photo = PhotoImage(file = r"C:/Users/KIIT/Desktop/project/v6/mic.png")
# photoimage=photo.sample(3,3)
#BUT5 = tkinter.Button(frame1, text="Give Your answer", command=start_audio_module)
#BUT5.pack()
#BUT = tkinter.Button(frame1, text="Evaluate", command=lambda: [Evaluation(), BUT.destroy()])
#BUT.pack()
def get_recognizer():
global au
au = sr.Recognizer()
#label = tkinter.Label(frame2, text="Recognizer Module Achieved", anchor='w')
#label.pack(fill='both')
global flag
flag = 0
global M
M = 0
def start_audio_module():
# label= tkinter.Label(frame2, text="Say something", anchor='w')
# label.pack(fill='both')
global flag
# label= tkinter.Label(frame2, text="Say Something \n time=30 seconds")
# label.pack()
print("starting")
seconds = time.time()
tts = gTTS('start your answer')
tts.save(f'ans{cnt}.mp3')
playsound(f'ans{cnt}.mp3')
global M
M = []
print("check1")
while seconds - time.time() > -10:
# print("Seconds since epoch =", seconds-time.time())
print("check2")
with sr.Microphone() as source:
# label= tkinter.Label(frame2, text="timer begins")
# label.pack()
audio = au.listen(source)
print("Check3")
try:
L = au.recognize_google(audio)
M.append(len(L))
# print(au.recognize_google(audio))
#label = tkinter.Label(frame2, text=L, anchor='w', wraplength=400)
#label.pack(fill='both')
print(L)
if (flag == 0):
file1 = open('interview log.txt', 'w')
flag = flag + 1
if (flag >= 1):
file1 = open('interview log.txt', 'a')
file1.writelines((L + ('\n')))
file1.close()
except sr.UnknownValueError:
# print("Google could not understand audio")
# label= tkinter.Label(frame2, text="could not get audio")
# label.pack()
# print("couldn't get audio")
break
#checkcuss()
global cussing
if cussing >= 2:
Evaluation()
# T.pack()
# except sr.RequestError as e:
# print("Google error; {0}".format(e))
# label= tkinter.Label(frame2, text="audio error")
# label.pack()
# T.pack()
else:
tts = gTTS('Interesting...')
tts.save(f'check{cnt}.mp3')
playsound(f'check{cnt}.mp3')
cussing = cussing + 1
getquestion()
def getquestion():
# label= tkinter.Label(frame2, text="Your question is",font='20', anchor='w')
# label.pack(fill='both')
file1 = open("interview log.txt", 'r')
# pylanguagetool>file1.txt
reading = file1.read()
tokens = nltk.word_tokenize(reading)
stop_words = set(stopwords.words('english'))
words = [w for w in tokens if w not in stop_words]
global cnt
fl = 1
for w in words:
for n in m:
if w == n:
y = random.choice(l)
if (n == 'machine'):
tts = gTTS('You mentioned something about machine learning')
tts.save(f'ml{cnt}.mp3')
playsound(f'ml{cnt}.mp3')
tts = gTTS(y)
tts.save(f'y{cnt}.mp3')
playsound(f'y{cnt}.mp3')
cnt = cnt + 1
fl = 0
m.remove(n)
return
if (n == 'AI'):
tts = gTTS('You mentioned something about Artificial Intelligence')
tts.save(f'ml{cnt}.mp3')
playsound(f'ml{cnt}.mp3')
tts = gTTS(y)
tts.save(f'y{cnt}.mp3')
playsound(f'y{cnt}.mp3')
cnt = cnt + 1
fl = 0
m.remove(n)
return
if (n == 'block'):
tts = gTTS('You mentioned something about Block Chain')
tts.save(f'ml{cnt}.mp3')
playsound(f'ml{cnt}.mp3')
tts = gTTS(y)
tts.save(f'y{cnt}.mp3')
playsound(f'y{cnt}.mp3')
cnt = cnt + 1
fl = 0
m.remove(n)
return
if (n == 'big'):
tts = gTTS('You mentioned something about Big data')
tts.save(f'ml{cnt}.mp3')
playsound(f'ml{cnt}.mp3')
tts = gTTS(y)
tts.save(f'y{cnt}.mp3')
playsound(f'y{cnt}.mp3')
cnt = cnt + 1
fl = 0
m.remove(n)
return
if (n == 'social'):
tts = gTTS('You mentioned something about social network')
tts.save(f'ml{cnt}.mp3')
playsound(f'ml{cnt}.mp3')
tts = gTTS(y)
tts.save(f'y{cnt}.mp3')
playsound(f'y{cnt}.mp3')
cnt = cnt + 1
m.remove(n)
return
fl = 0
if (n == 'cloud'):
tts = gTTS('You mentioned something about cloud computing')
tts.save(f'ml{cnt}.mp3')
playsound(f'ml{cnt}.mp3')
tts = gTTS(y)
tts.save(f'y{cnt}.mp3')
playsound(f'y{cnt}.mp3')
cnt = cnt + 1
fl = 0
m.remove(n)
return
if (n == 'client'):
tts = gTTS('You mentioned something about client relations')
tts.save(f'ml{cnt}.mp3')
playsound(f'ml{cnt}.mp3')
tts = gTTS(y)
tts.save(f'y{cnt}.mp3')
playsound(f'y{cnt}.mp3')
cnt = cnt + 1
fl = 0
m.remove(n)
return
if (n == 'neural'):
tts = gTTS('You mentioned something about neural networks')
tts.save(f'ml{cnt}.mp3')
playsound(f'ml{cnt}.mp3')
tts = gTTS(y)
tts.save(f'y{cnt}.mp3')
playsound(f'y{cnt}.mp3')
cnt = cnt + 1
fl = 0
m.remove(n)
return
if (n == 'NLP'):
tts = gTTS('You mentioned something about N L P')
tts.save(f'ml{cnt}.mp3')
playsound(f'ml{cnt}.mp3')
tts = gTTS(y)
tts.save(f'y{cnt}.mp3')
playsound(f'y{cnt}.mp3')
cnt = cnt + 1
fl = 0
m.remove(n)
return
if (fl == 1):
y = random.choice(x)
tts = gTTS(y)
tts.save(f'y{cnt}.mp3')
playsound(f'y{cnt}.mp3')
cnt = cnt + 1
x.remove(y)
# if (y=="Tell me about yourself"):
# tts = gTTS(y)
# tts.save(f'y{cnt}.mp3')
# playsound(f'y{cnt}.mp3')
# cnt=cnt+1
# x.remove(y)
# if (y=="Why should I hire you?"):
# tts = gTTS(y)
# tts.save(f'y{cnt}.mp3')
# playsound(f'y{cnt}.mp3')
# cnt=cnt+1
# x.remove(y)
# if (y=="What is your long-range objective?"):
# tts = gTTS(y)
# tts.save(f'y{cnt}.mp3')
# playsound(f'y{cnt}.mp3')
# cnt=cnt+1
# x.remove(y)
# if (y=="What is your greatest accomplishment?"):
# tts = gTTS(y)
# tts.save(f'y{cnt}.mp3')
# playsound(f'y{cnt}.mp3')
# cnt=cnt+1
# x.remove(y)
# if (y=="How has your education prepared you for your career?"):
global ansch
tts = gTTS('get ready to start speaking')
tts.save(f'answer{ansch}.mp3')
playsound(f'answer{ansch}.mp3')
ansch = ansch + 1
start_audio_module()
# label= tkinter.Label(frame2, text=y, anchor='w')
# label.pack(fill='both')
def plot():
plt.bar(q, r)
plt.title('Emotion points')
plt.xlabel('Emotions')
plt.ylabel('Points')
plt.grid(True)
plt.savefig('Emotion points.jpg', bbox_inches='tight', dpi=150)
plt.clf()
plt.plot(y,color='red',marker='o')
plt.title('Interview points')
plt.xlabel('Time')
plt.ylabel('Points')
plt.grid(True)
plt.savefig('Interview points.jpg', bbox_inches='tight', dpi=150)
plt.clf()
def video():
global breakingpoint
global cap
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
writer = cv2.VideoWriter('video.avi', cv2.VideoWriter_fourcc(*'DIVX'), 20, (width, height))
while True:
ret, frame = cap.read()
writer.write(frame)
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == 27:
break
cap.release()
writer.release()
cv2.destroyAllWindows()
def vidprocessing():
#loading=0
i=0
cap = cv2.VideoCapture('video.avi')
#length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
while (cap.isOpened()):
ret, color = cap.read()
gray = color
if gray is None:
break
# ksize = (50, 50)
# font = cv2.FONT_HERSHEY_SIMPLEX
def find_face_MTCNN(gray, result_list):
for result in result_list:
summationx = 0
summationy = 0
x, y, w, h = result['box']
# print(x)
# print(y)
# roi = color[y:y+h, x:x+w]
for key, value in result['keypoints'].items():
# dot creator
color = cv2.circle(gray, value, 1, (0, 0, 255), 2)
summationx = value[0] + summationx
summationy = value[1] + summationy
# detectedFace = cv2.GaussianBlur(roi, ksize, 0)
# color[y:y+h, x:x+w] = detectedFace
summationx = summationx / 5
summationy = summationy / 5
global beforesummationx
global beforesummationy
global summationarrax
global summationarray
beforesummationx.append(x+w/2)
beforesummationy.append(y+h/2)
summationarrax.append(summationx)
summationarray.append(summationy)
#print(f'frame {loading} of {length} processed')
#loading = loading + 1
return gray
detector = MTCNN()
faces = detector.detect_faces(gray)
if faces==0:
continue
else:
detectFaceMTCNN = find_face_MTCNN(gray, faces)
cap.release()
cv2.destroyAllWindows()
def plotfromvid():
x=[]
y=[]
global summationarrax
global summationarray
global beforesummationx
global beforesummationy
for i in range(len(beforesummationx)):
x.append(summationarrax[i]-beforesummationx[i])
y.append(summationarray[i]-beforesummationy[i])
plt.plot(x, label="x",color='red')
plt.plot(y, label="y",color='blue')
plt.title('Face deviation')
plt.xlabel('Time')
plt.ylabel('deviation')
plt.grid(True)
plt.savefig('Orientation points.jpg', bbox_inches='tight', dpi=150)
plt.clf()
def makereport():
global email_id
mail=email_id
print(mail)
# name and create pdf
c = canvas.Canvas('report.pdf')
# set background color (this color is yellow I do not recommend)
c.setFillColorRGB(1, 1, 1)
# Select font and font size
c.setFont('Helvetica', 10)
# add an image determine it's position and width and height
c.drawImage('Orientation points.jpg', 5, 20, 500, 300)
# add an image determine it's position and width and height
c.drawImage('Interview points.jpg', 5, 300, 500, 300)
# add an image determine it's position and width and height
c.drawImage('Emotion points.jpg', 5, 580, 500, 300)
# show page and save it
c.drawString(5,10,mail)
c.showPage()
c.save()
tts = gTTS('Your interview will now begin')
tts.save('hello2.mp3')
playsound('hello2.mp3')
Thread(target=video).start()
startProcess()
breakingpoint=1
tts = gTTS('Your interview is over... your results will be sent to your email shortly')
tts.save('end.mp3')
playsound('end.mp3')
cap.release()
cv2.destroyAllWindows()
vidprocessing()
plotfromvid()
makereport()
tts = gTTS('Video processing over')
tts.save('end2.mp3')
playsound('end2.mp3')
if __name__ == '__main__':
main()