-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVocab_Boost.py
93 lines (78 loc) · 2.88 KB
/
Vocab_Boost.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
import pyttsx3
from plyer import notification
import time
import pandas as pd
import inflect
from tkinter import *
# Initialize inflect engine
p = inflect.engine()
# Path to the Excel file
file_location = r"C:\Users\USER\PycharmProjects\Vocabulary_tutor\list.xlsx"
try:
df = pd.read_excel(file_location, engine='openpyxl')
print(df.head()) # Debug print to check if the data is loaded correctly
except Exception as e:
print(f"Error opening file: {e}")
exit()
# Notify function
def notify(title, message):
notification.notify(title=title, message=message, app_icon=r"C:\Users\USER\PycharmProjects\Vocabulary_tutor\icon3.ico", timeout=15)
# Text-to-Speech initialization
engine = pyttsx3.init()
voices = engine.getProperty('voices')
# Use a default voice index
engine.setProperty('voice', voices[1].id) # You can change the index if needed
engine.setProperty("rate", 135)
engine.setProperty("volume", 1.0)
# Function to display vocabulary
def values(name, timer):
i = 1
for _, row in df.iterrows():
try:
word = row[0]
meaning = row[1]
msg = f"_WORD: {word}\n\nMEANING_: {meaning}"
text = f"Hello {name}, here is your {p.ordinal(i)} word: {word} - {meaning}"
print(f"Debug Text: {text}") # Debug print statement
print(f"Debug Msg: {msg}") # Debug print statement
engine.say(text)
notify("VOCABULARY", msg)
engine.runAndWait()
i += 1
time.sleep(timer)
except Exception as e:
print(f"Error: {e}")
break
# Tkinter GUI setup
root = Tk()
root.title('Vocabulary Tutor')
root.geometry("700x700")
root.configure(background='gray27')
def submit():
try:
name = my_box1.get()
timer = int(my_box2.get())
if not name or timer <= 0:
raise ValueError("Please provide a valid name and timer.")
values(name, timer)
except ValueError as e:
print(f"Error: {e}")
read = """Welcome to Vocabulary Tutor,
this app allows you to set the timer.
You will be notified with an English
word and its meaning after every
specified time. Please fill the below
requirements to continue..."""
my_label0 = Label(root, text=read, font=("Courier", 18, "bold italic"), fg="light cyan", bg="gray27")
my_label0.pack(pady=20)
my_label1 = Label(root, text="Enter your name", font=("Helvetica", 18), fg="gold", bg="gray27")
my_label1.pack(pady=20)
my_box1 = Entry(root)
my_box1.pack(pady=20)
my_label = Label(root, text="Set the timer (in sec)", font=("Times bold", 18), fg="gold", bg="gray27")
my_label.pack(pady=20)
my_box2 = Entry(root)
my_box2.pack(pady=20)
my_button = Button(root, text="Submit", fg='gray1', bg='PaleVioletRed1', activebackground='lawn green', command=submit)
my_button.pack(pady=50)
root.mainloop()