-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
53 lines (40 loc) · 1.56 KB
/
main.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
from recorder import record_voice
from AcausticFeaturesExtract import extract_features
from XGBmodel import xgb_predict
from tools import modern_window
from customtkinter import *
myfont = ("Elephant", 16)
white = "#FFFFFF"
app = modern_window("gender recognizer", mode="dark")
app.geometry("500x500")
def new_rec():
lbl.configure(text="")
btn.configure(state=DISABLED)
timer.configure(text="Speak!", font=("Elephant", 18))
app.update()
voice = record_voice()
timer.configure(text="Wait!", font=("Elephant", 18))
app.update()
features = extract_features(voice)
prediction = xgb_predict(features)
lbl.configure(text=prediction, font=("Elephant", 18))
btn.configure(state=NORMAL)
def record():
btn.configure(state=DISABLED)
timer.configure(text="Speak!", font=("Elephant", 18))
app.update()
voice = record_voice()
timer.configure(text="Wait!", font=("Elephant", 18))
app.update()
features = extract_features(voice)
prediction = xgb_predict(features)
lbl.configure(text=prediction, font=("Elephant", 18))
btn.configure(state=NORMAL, command=new_rec)
lbl = CTkLabel(app, text="", fg_color="transparent")
lbl.pack(pady=40, padx=10, side=TOP, anchor=CENTER)
btn = CTkButton(app, text="RECORD", text_color=white, fg_color='red', font=myfont)
btn.configure(command=record)
btn.pack(pady=80, padx=10, side=BOTTOM, anchor=CENTER)
timer = CTkLabel(app, text="", fg_color="transparent")
timer.pack(pady=40, padx=10, side=BOTTOM, anchor=CENTER)
app.mainloop()