-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSong Detection.py
106 lines (76 loc) · 2.34 KB
/
Song Detection.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
94
95
96
97
98
99
100
101
102
103
104
105
106
from tkinter import *
from tkinter import ttk
import tkinter
from PIL import Image, ImageTk
import os
from pygame import mixer
import random
import re
from threading import Thread
import time
choosenSong = 'Animals.mp3'
mixer.init()
mixer.music.load("PlayList/02 Animals.mp3")
root = Tk()
root.title("Genre Detection of Song")
lb = Label(root, text=choosenSong)
lb.pack(side="bottom", fill="x", expand=1)
def startThreads():
global t1
global t2
global b0
b0.config(state=DISABLED)
t1.start()
t2.start()
b0 = Button(root, text='Play & Record', bg="white", fg='black', bd=4, relief='raised', command=startThreads)
def nextSong():
global choosenSong
global lb
songs = os.listdir("PlayList")
size = len(songs)
index = random.randint(0, size-1)
choosenSong = re.sub('\d+', '', songs[index])
choosenSong = choosenSong.replace('.mp', '')
print (str(index), choosenSong)
mixer.music.load("PlayList/" + songs[index])
mixer.music.play()
lb.configure(text=choosenSong)
lb.update()
def play():
time.sleep(3)
mixer.music.play()
def resume():
mixer.music.unpause()
def pause():
mixer.music.pause()
def stop():
mixer.music.stop()
def feedback():
os.system('python Ensemble.py')
t1 = Thread(target=feedback)
t2 = Thread(target=play)
def main():
global root
# img = Image.open("4a.jpg")
# photo = tk.PhotoImage("4a.jpg")
# background_label = Label(root, image=photo)
# background_label.place(x=0, y=0, relwidth=1, relheight=1)
# background_label.image = photo
root.geometry("400x600")
# label = Label(root, text='Genre Detection of Songs')
# label.grid(row=9, column=6, pady=10)
img = ImageTk.PhotoImage(Image.open("play-it-again-720x540.png"))
panel = tkinter.Label(root, image = img,width=500,height=500)
panel.pack(side="bottom",fill="x",expand=1)
b0.pack(side="left",fill="x",expand=1)
b4 = Button(root, text='Feedback', bg="white", fg='black', bd=4, relief='raised', command=stop)
b4.pack(side="right",fill="x",expand=1)
b1 = Button(root,text='Resume', bg="white", fg='black', bd=4, relief='raised', command=resume)
b1.pack(side="left")
b3 = Button(root, text='Pause', bg="white", fg='black', bd=4, relief='raised', command=pause)
b3.pack(side="left")
b2 = Button(root, text='Next Song', bg="white", fg='black', bd=4, relief='raised', command=nextSong)
b2.pack(side="right")
root.mainloop()
if __name__ == '__main__':
main()