-
Notifications
You must be signed in to change notification settings - Fork 4
/
take_attendance.bash
executable file
·61 lines (51 loc) · 1.26 KB
/
take_attendance.bash
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
#!/bin/bash
students_file="student_names.txt"
if [ ! -f "$students_file" ]; then
echo "Error: $students_file not found!"
exit 1
fi
current_date=$(date +%Y-%m-%d)
present_file="attendance/${current_date}_present.txt"
absent_file="attendance/${current_date}_absent.txt"
IFS=',' read -r -a students <"$students_file"
speak_student() {
student_name="$1"
python3 - <<END
from gtts import gTTS
import os
tts = gTTS("$student_name", lang='en', tld='co.in')
tts.save("./student_audio/student.mp3")
END
mpg123 -q ./student_audio/student.mp3
}
for student in "${students[@]}"; do
speak_student "$student"
echo "Mark attendance for $student: (a for absent, p for present, r to repeat)"
while true; do
read -n 1 -s choice
case "$choice" in
a)
echo "$student" >>"$absent_file"
echo "Marked $student as absent"
break
;;
p)
echo "$student" >>"$present_file"
echo "Marked $student as present"
break
;;
r)
echo "Repeating $student's name"
speak_student "$student"
;;
*)
echo "Invalid option. Use 'a' for absent, 'p' for present, 'r' to repeat."
;;
esac
done
echo ""
done
echo "Attendance completed!"
echo -e "Present students: \n$(cat $present_file)\n"
echo "--------------------------"
echo -e "Absent students: \n$(cat $absent_file)"