-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGUI.py
97 lines (72 loc) · 3.76 KB
/
GUI.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
import tkinter as tk
class LipSynchingDetectiveGUI:
def __init__(self, master):
self.master = master
self.master.title('Lip synching detective')
# Create menu bar
self.menu_bar = tk.Menu(self.master)
self.master.config(menu=self.menu_bar)
# Create file menu
self.file_menu = tk.Menu(self.menu_bar, tearoff=0)
self.menu_bar.add_cascade(label='File', menu=self.file_menu)
self.file_menu.add_command(label='Upload song', command=self.upload_song)
self.file_menu.add_command(label='Upload MIDI', command=self.upload_midi)
self.file_menu.add_separator()
self.file_menu.add_command(label='Exit', command=self.master.quit)
# Create help menu
self.help_menu = tk.Menu(self.menu_bar, tearoff=0)
self.menu_bar.add_cascade(label='Help', menu=self.help_menu)
self.help_menu.add_command(label='Instructions', command=self.display_instructions)
self.help_menu.add_separator()
self.help_menu.add_command(label='About', command=self.display_about)
# Create upload files frame
self.upload_frame = tk.Frame(self.master)
self.upload_frame.pack(side='top', fill='both', expand=True)
# Create song upload button
self.song_button = tk.Button(self.upload_frame, text='Upload song', command=self.upload_song)
self.song_button.pack(side='left')
# Create MIDI upload button
self.midi_button = tk.Button(self.upload_frame, text='Upload MIDI', command=self.upload_midi)
self.midi_button.pack(side='left')
# Create analyze button
self.analyze_button = tk.Button(self.upload_frame, text='Analyze', command=self.analyze)
self.analyze_button.pack(side='left')
# Create result display frame
self.result_frame = tk.Frame(self.master)
self.result_frame.pack(side='top', fill='both', expand=True)
# Create result label
self.result_label = tk.Label(self.result_frame, text='Result:')
self.result_label.pack(side='left')
# Create result display
self.result_display = tk.Label(self.result_frame, text='N/A')
self.result_display.pack(side='left')
# Create status bar
self.status_bar = tk.Label(self.master, text='Ready', bd=1, relief='sunken', anchor='w')
self.status_bar.pack(side='bottom', fill='x')
def upload_song(self):
# Prompt user to select song file
song_file = tk.filedialog.askopenfilename()
self.status_bar.config(text='Song file: ' + song_file)
def upload_midi(self):
# Prompt user to select MIDI file
midi_file = tk.filedialog.askopenfilename()
self.status_bar.config(text='MIDI file: ' + midi_file)
def analyze(self):
# Parse MIDI file
midi_notes = parse_midi.parse(self.midi_file)
# Analyze song
song_frequencies = analyze_song.analyze(self.song_file)
# Compare song and MIDI file
result = compare.compare(song_frequencies, midi_notes)
# Display result
self.result_display.config(text=result)
def display_instructions(self):
tk.messagebox.showinfo('Instructions', '1. Click "Upload song" to select the song file you want to analyze.\n2. Click "Upload MIDI" to select the MIDI file corresponding to the song.\n3. Click "Analyze" to start the analysis.\n4. The result will be displayed in the "Result" area.')
def display_about(self):
tk.messagebox.showinfo('About Lip synching detective', 'Lip synching detective is a tool for detecting lip syncing in songs. It compares the frequencies of a song with those in a MIDI file to determine if the song is lip syncing.')
def main():
root = tk.Tk()
app = LipSynchingDetectiveGUI(root)
root.mainloop()
if __name__ == '__main__':
main()