` where filename is `run.sh`, `configure.sh`, `clearall.sh` *(Avoid < >)*.
64 | - Whenever your name gets called or attendence is being recorded, it'll prompted and all the settings will set to default.
65 | Run `./run.sh` again to start over.
66 |
67 |
68 | [](https://forthebadge.com)
69 | [](https://forthebadge.com)
70 | [](https://forthebadge.com)
71 |
72 | **Star Developer:** **[manasd28 (Manas Dalakoti)](https://github.com/manasd28)**
73 | Developer Student Clubs JIIT 128
74 |
75 | PLEASE NOTE:
76 | For legal reasons,
77 | This bot was purely made for educational purposes only and is meant as a fun way to learn and implement the libraries/packages mentioned above.
78 | This bot is not meant to be used in any malicious way and we are not responsible for anyone actually using this bot to wrongfully attend online classes on his/her/their behalf.
79 |
--------------------------------------------------------------------------------
/background/bgrun1.py:
--------------------------------------------------------------------------------
1 | import speech_recognition as sr
2 | import os
3 | import time
4 |
5 | r1 = sr.Recognizer()
6 |
7 | names = []
8 |
9 | while True:
10 | f = open("./temp/tempfile1.txt",'+a')
11 | flag = 0
12 | with sr.Microphone() as source :
13 | #print('\nSPEAK NOW\n')
14 | r1.adjust_for_ambient_noise(source, duration=0.2)
15 | audio = r1.listen(source, phrase_time_limit = 3)
16 | text = r1.recognize_google(audio, language="en-IN", show_all=True)
17 | try:
18 | dict = text['alternative']
19 | for i in dict:
20 | s = i["transcript"].lower()
21 | k = s.split(" ")
22 | for j in k:
23 | j = str(j)
24 | f.write(j+'\n')
25 | except Exception as e:
26 | continue
27 | f.close()
28 |
--------------------------------------------------------------------------------
/background/bgrun2.py:
--------------------------------------------------------------------------------
1 | import speech_recognition as sr
2 | import os
3 | import time
4 |
5 | time.sleep(1)
6 |
7 | r1 = sr.Recognizer()
8 |
9 | names = []
10 |
11 | while True:
12 | f = open("./temp/tempfile2.txt",'+a')
13 | flag = 0
14 | with sr.Microphone() as source :
15 | #print('\nSPEAK NOW\n')
16 | r1.adjust_for_ambient_noise(source, duration=0.2)
17 | audio = r1.listen(source, phrase_time_limit = 3)
18 | text = r1.recognize_google(audio, language="en-IN", show_all=True)
19 | try:
20 | dict = text['alternative']
21 | for i in dict:
22 | s = i["transcript"].lower()
23 | k = s.split(" ")
24 | for j in k:
25 | j = str(j)
26 | f.write(j+'\n')
27 | except Exception as e:
28 | continue
29 | f.close()
30 |
--------------------------------------------------------------------------------
/background/bgrun3.py:
--------------------------------------------------------------------------------
1 | import speech_recognition as sr
2 | import os
3 | import time
4 |
5 | time.sleep(2)
6 |
7 | r1 = sr.Recognizer()
8 |
9 | names = []
10 |
11 | while True:
12 | f = open("./temp/tempfile3.txt",'+a')
13 | flag = 0
14 | with sr.Microphone() as source :
15 | #print('\nSPEAK NOW\n')
16 | r1.adjust_for_ambient_noise(source, duration=0.2)
17 | audio = r1.listen(source, phrase_time_limit = 3)
18 | text = r1.recognize_google(audio, language="en-IN", show_all=True)
19 | try:
20 | dict = text['alternative']
21 | for i in dict:
22 | s = i["transcript"].lower()
23 | k = s.split(" ")
24 | for j in k:
25 | j = str(j)
26 | f.write(j+'\n')
27 | except Exception as e:
28 | continue
29 | f.close()
30 |
--------------------------------------------------------------------------------
/clearall.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ps -A | grep python | awk -F' ' '{print $1}' | while read x;do kill $x; done
4 | mod1=`pacmd list-modules | grep null-sink -B 1 | awk -F" " '{print $2}' | head -n 1`
5 | pacmd unload-module $mod1
6 | rm -rf nohup.out
7 | notify-send "RUN THE BOT AGAIN IF YOU WANT TO CONTINUE" "Run ./run.sh"; aplay ./require/alert.wav;
8 |
9 |
--------------------------------------------------------------------------------
/configure.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | python ./setup/initialize.py;
4 |
--------------------------------------------------------------------------------
/images/1.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dsc-jiit-128/class_bot/f2ed095cb76d3ce35f9600ca3a8f52e226aa443e/images/1.jpeg
--------------------------------------------------------------------------------
/images/2.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dsc-jiit-128/class_bot/f2ed095cb76d3ce35f9600ca3a8f52e226aa443e/images/2.jpeg
--------------------------------------------------------------------------------
/images/3.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dsc-jiit-128/class_bot/f2ed095cb76d3ce35f9600ca3a8f52e226aa443e/images/3.jpeg
--------------------------------------------------------------------------------
/images/jiit128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dsc-jiit-128/class_bot/f2ed095cb76d3ce35f9600ca3a8f52e226aa443e/images/jiit128.png
--------------------------------------------------------------------------------
/main.py:
--------------------------------------------------------------------------------
1 | import speech_recognition as sr
2 | import os
3 | import webbrowser as wb
4 | import time
5 | from pydub import AudioSegment
6 | from pydub.playback import play
7 |
8 | path = "./require"
9 | roll_call = AudioSegment.from_wav("./require/roll_call.wav")
10 | r1 = sr.Recognizer()
11 |
12 | f = open(path+"/names.txt",'r')
13 | lines = f.readlines()
14 | f.close()
15 |
16 | names = []
17 |
18 | for i in lines:
19 | i = i.rstrip('\n')
20 | names.append(i)
21 |
22 | flag = 0
23 |
24 | #link = input("Please provide the Goole Meet link\n")
25 | #wb.open(link)
26 |
27 | found_names = []
28 | alert_cmd = "notify-send \"YOUR NAME IS BEING CALLED!!!\" \"Return to your meeting ASAP\"; aplay ./require/alert.wav"
29 | at_alert_cmd = "notify-send \"LOOKS LIKE ATTNEDENCE IS GOING ON!!!\" \"Return to your meeting ASAP\"; aplay ./require/alert.wav"
30 | rerun_alert_cmd = "notify-send \"RUN THE BOT AGAIN IF YOU WANT TO CONTINUE\" \"./run.sh\"; aplay ./require/alert.wav"
31 | call_cmd = "./clearall.sh"
32 |
33 | at = 0
34 |
35 | while True:
36 | flag = 0
37 | f1 = open('./temp/tempfile1.txt','+r')
38 | f2 = open('./temp/tempfile2.txt','+r')
39 | f3 = open('./temp/tempfile3.txt','+r')
40 | l1 = f1.readlines()
41 | l2 = f2.readlines()
42 | l3 = f3.readlines()
43 | temp = l1 + l2 + l3
44 | for i in temp:
45 | i = i.rstrip('\n')
46 | found_names.append(i)
47 |
48 | print(found_names,'\n')
49 |
50 | if("attendance" in found_names):
51 | os.system(at_alert_cmd)
52 | flag = 1
53 |
54 | if("present" in found_names):
55 | at+=1
56 | print("\nPresent Found")
57 | flag = 1
58 |
59 | if(at >= 4):
60 | os.system(at_alert_cmd)
61 | at = 0
62 | flag = 1
63 |
64 | for i in names:
65 | if(i in found_names) :
66 | print("\nName Found")
67 | flag = 1
68 | os.system(alert_cmd)
69 | break
70 |
71 | if(flag == 1):
72 | time.sleep(5)
73 | os.system(call_cmd)
74 |
75 | f1.close()
76 | f2.close()
77 | f3.close()
78 |
79 | f1 = open('./temp/tempfile1.txt','w').close()
80 | f2 = open('./temp/tempfile2.txt','w').close()
81 | f3 = open('./temp/tempfile3.txt','w').close()
82 |
83 | del found_names[:]
84 |
85 | if(flag == 1):
86 | time.sleep(5)
87 | os.system(rerun_alert_cmd)
88 | time.sleep(1)
89 | os.system(call_cmd)
90 |
91 | time.sleep(4)
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/require/alert.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dsc-jiit-128/class_bot/f2ed095cb76d3ce35f9600ca3a8f52e226aa443e/require/alert.wav
--------------------------------------------------------------------------------
/require/names.txt:
--------------------------------------------------------------------------------
1 | manas
2 | mansa
3 | maana
4 |
--------------------------------------------------------------------------------
/require/roll_call.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dsc-jiit-128/class_bot/f2ed095cb76d3ce35f9600ca3a8f52e226aa443e/require/roll_call.wav
--------------------------------------------------------------------------------
/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ps -A | grep python | awk -F' ' '{print $1}' | while read x;do kill $x; done
4 |
5 | mod1=`pacmd list-modules | grep null-sink -B 1 | awk -F" " '{print $2}' | head -n 1`
6 | pacmd unload-module $mod1
7 | pacmd load-module module-null-sink sink_name=Temp sink_properties=device.description="Temporary_sink"
8 | str=`pacmd list-sources | grep "stereo.monitor" | sed 's/.*<\(.*\)>/\1/'`
9 | pacmd load-module module-loopback sink=Temp source=${str}
10 |
11 | nohup python ./background/bgrun1.py&
12 | nohup python ./background/bgrun2.py&
13 | nohup python ./background/bgrun3.py&
14 | nohup python ./main.py&
15 |
--------------------------------------------------------------------------------
/setup/__pycache__/recording.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dsc-jiit-128/class_bot/f2ed095cb76d3ce35f9600ca3a8f52e226aa443e/setup/__pycache__/recording.cpython-37.pyc
--------------------------------------------------------------------------------
/setup/__pycache__/recording.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dsc-jiit-128/class_bot/f2ed095cb76d3ce35f9600ca3a8f52e226aa443e/setup/__pycache__/recording.cpython-38.pyc
--------------------------------------------------------------------------------
/setup/initialize.py:
--------------------------------------------------------------------------------
1 | import speech_recognition as sr
2 | import os
3 | import time
4 | import wave
5 |
6 | import recording
7 |
8 | path='./require/'
9 | if(os.path.exists(path+"names.txt")):
10 | os.remove(path+"names.txt")
11 |
12 | r1 = sr.Recognizer()
13 | f = open(path+"names.txt",'w')
14 |
15 | print("This is a demo run that helps you select the names by which the bot will recognize you\n")
16 |
17 | names = []
18 | ind = 0
19 | while(ind<3):
20 | with sr.Microphone() as source:
21 | print("SPEAK YOUR NAME NOW ({})\n".format(ind+1))
22 | r1.adjust_for_ambient_noise(source, duration=0.2)
23 | audio = r1.listen(source, phrase_time_limit=5)
24 | text = r1.recognize_google(audio, language="en-IN", show_all=True)
25 | print(text)
26 | try :
27 | dict = text['alternative']
28 | for j in dict:
29 | if(j['transcript'] not in names):
30 | names.append(j['transcript'])
31 | ind+=1
32 | except TypeError:
33 | print("Please speak again close to microphone!!\n")
34 |
35 | ind=1
36 | for i in names :
37 | print("{}. ".format(ind), i)
38 | ind+=1
39 |
40 | print("PLEASE ENTER THE NUMBER OF THE NAME YOU THINK IS CLOSEST TO YOURS AND IS NOT SOMETHING THAT'LL BE A PART OF THE MEETING\n")
41 | print("MORE NAMES YOU CHOOSE THE BETTER THE RECOGNITION CHANCES ARE!!\n")
42 | print("Enter the number(s) from the list of names (q to QUIT)\n")
43 | temp = []
44 | while(True):
45 | a = input()
46 | if(a == 'q'):
47 | break
48 | a = int(a)
49 | if a not in temp and a>0 and a<=len(names):
50 | temp.append(a)
51 | f.write((names[a-1]+os.linesep).lower())
52 | else:
53 | print("The name already exists or invalid index number entered!!\n")
54 |
55 | #input("PRESS ENTER TO CONTINUE!!\n")
56 | #print("Excellent!!\nNow please be ready to record your audio that will answer your roll call!!\n")
57 |
58 | #recording.start_recording()
59 |
60 | print("WE ARE ALL SET UP NOW!!\n")
61 |
62 | f.close()
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/setup/recording.py:
--------------------------------------------------------------------------------
1 | import pyaudio
2 | import time
3 | import wave
4 |
5 |
6 | def start_recording():
7 | chunk = 1024
8 | sample_format = pyaudio.paInt16
9 | channels = 2
10 | fs = 44100
11 | seconds = 3
12 | filename = "./require/roll_call.wav"
13 |
14 | p = pyaudio.PyAudio()
15 |
16 | print("Recoding : \n")
17 | input("Press ENTER to start 3 second recording\n\n(Please speak closely and loudly!!)\n")
18 |
19 | stream = p.open(format=sample_format,
20 | channels=channels,
21 | rate=fs,
22 | frames_per_buffer=chunk,
23 | input=True)
24 |
25 | frames = []
26 |
27 | for i in range(0, int(fs / chunk * seconds)):
28 | data = stream.read(chunk)
29 | frames.append(data)
30 |
31 | stream.stop_stream()
32 | stream.close()
33 |
34 | p.terminate()
35 |
36 | wf = wave.open(filename, 'wb')
37 | wf.setnchannels(channels)
38 | wf.setsampwidth(p.get_sample_size(sample_format))
39 | wf.setframerate(fs)
40 | wf.writeframes(b''.join(frames))
41 | wf.close()
42 |
43 |
--------------------------------------------------------------------------------
/temp/tempfile1.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dsc-jiit-128/class_bot/f2ed095cb76d3ce35f9600ca3a8f52e226aa443e/temp/tempfile1.txt
--------------------------------------------------------------------------------
/temp/tempfile2.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dsc-jiit-128/class_bot/f2ed095cb76d3ce35f9600ca3a8f52e226aa443e/temp/tempfile2.txt
--------------------------------------------------------------------------------
/temp/tempfile3.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dsc-jiit-128/class_bot/f2ed095cb76d3ce35f9600ca3a8f52e226aa443e/temp/tempfile3.txt
--------------------------------------------------------------------------------