Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed python package gTTs to festival #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions convert.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ echo "Paste the full list of names (one name per line), then press Enter and Ctr

names=$(</dev/stdin)


comma_separated=$(echo "$names" | tr '\n' ',' | sed 's/,$/\n/')

output_file="student_names.txt"
Expand Down
75 changes: 37 additions & 38 deletions take_attendance.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,57 @@
students_file="student_names.txt"

if [ ! -f "$students_file" ]; then
echo "Error: $students_file not found!"
exit 1
echo "Error: $students_file not found!"
exit 1
fi

# Create attendance directory if it doesn't exist
mkdir -p attendance

current_date=$(date +%Y-%m-%d)
present_file="attendance/${current_date}_present.txt"
absent_file="attendance/${current_date}_absent.txt"

# Read students from the file into an array
IFS=',' read -r -a students <"$students_file"

# Function to speak the student's name using Festival
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
student_name="$1"
echo "$student_name" | festival --tts # Use Festival for TTS
}

# Loop through each student
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 ""
speak_student "$student" # Speak the student's name

echo "Mark attendance for $student: (a for absent, p for present, r to repeat)"
while true; do
read -n 1 -s choice # Read a single character for attendance input
case "$choice" in
a)
echo "$student" >>"$absent_file" # Mark as absent
echo "Marked $student as absent"
break
;;
p)
echo "$student" >>"$present_file" # Mark as present
echo "Marked $student as present"
break
;;
r)
echo "Repeating $student's name"
speak_student "$student" # Repeat the student's name
;;
*)
echo "Invalid option. Use 'a' for absent, 'p' for present, 'r' to repeat."
;;
esac
done
echo ""
done

# Display attendance summary
echo "Attendance completed!"
echo -e "Present students: \n$(cat $present_file)\n"
echo "--------------------------"
Expand Down