-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.py
131 lines (106 loc) · 4.47 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# import libraries
from appJar import gui
import sys
from shutil import rmtree
import os
import ffmpeg
# import functions
from funcs import beatsReversed
from funcs.grouped import everyEvenBeat
from funcs.grouped import everyOddBeat
from funcs.separated import everyFirstBeat
from funcs.separated import everySecondBeat
from funcs.separated import everyThirdBeat
from funcs.separated import everyFourthBeat
from funcs import youtubeConvert
def function(file):
data = app.getAllInputs(includeEmptyInputs=True)
selection = data['option'] # arbitrary but clean
upload = data['f1']
ytLink = data['link']
output = data['output'] + '/output.wav'
fileType = data['type']
importedFile = None
if upload == '' and ytLink == '':
print('file not present...')
app.warningBox('No file selected...', 'Please insert either an audio file or a YouTube Link to use.', parent=None)
return
if data['output'] == '':
print('output directory not present...')
app.warningBox('No output directory selected...', 'Please choose an output directory for your file.', parent=None)
return
if ytLink != '' and upload != '':
print('two files selected...')
app.warningBox('Two files?', 'You must choose one or the other, you can not use the YouTUbe link and the local file at the same time.', parent=None)
return
if ytLink != '':
youtubeConvert.convert(ytLink)
importedFile = './tmp/vid.mp3'
if upload != '':
importedFile = upload
if selection == "Reverse beats of the audio file.":
beatsReversed.run(importedFile, output)
print('Starting proccess...')
if selection == "Get every 1st and 3rd beat of the audio file.":
everyOddBeat.run(importedFile, output)
print('Starting proccess...')
if selection == "Get every 2nd and 4th beat of the audio file.":
everyEvenBeat.run(importedFile, output)
print('Starting proccess...')
if selection == "Get every 1st beat of the audio file.":
everyFirstBeat.run(importedFile, output)
print('Starting proccess...')
if selection == "Get every 2nd beat of the audio file.":
everySecondBeat.run(importedFile, output)
print('Starting proccess...')
if selection == "Get every 3rd beat of the audio file.":
everyThirdBeat.run(importedFile, output)
print('Starting proccess...')
if selection == "Get every 4th beat of the audio file.":
everyFourthBeat.run(importedFile, output)
print('Starting proccess...')
if os.path.exists('./tmp') and os.path.isdir('./tmp'):
print('Deleting temp directory...')
rmtree('./tmp')
print('Deleted!')
if fileType == '.mp3 (slower, much smaller file size)':
print('MP3 conversion starting...')
{
ffmpeg
.input(output)
.output('output.mp3', acodec='libmp3lame')
.run()
}
print('MP3 conversion complete!')
if os.path.exists(output):
os.remove(output)
print('Deleted .wav file.')
print('Success!')
app.infoBox("Success!", "Proccess complete! Check your output directory.", parent=None)
# create a GUI variable called app
app = gui("Amen Audio Tools", "400x400")
app.setIcon('./resources/icon.gif')
app.setResizable(canResize=False)
app.setFont(size=12)
app.setBg("pink")
# add & configure widgets - widgets get a name, to help referencing them later
app.addLabel("heading", "Amen Audio Tools")
app.addRadioButton("option", "Reverse beats of the audio file.")
app.addRadioButton("option", "Get every 1st and 3rd beat of the audio file.")
app.addRadioButton("option", "Get every 2nd and 4th beat of the audio file.")
app.addRadioButton("option", "Get every 1st beat of the audio file.")
app.addRadioButton("option", "Get every 2nd beat of the audio file.")
app.addRadioButton("option", "Get every 3rd beat of the audio file.")
app.addRadioButton("option", "Get every 4th beat of the audio file.")
app.addLabel("inputLabel", "What audio file?")
app.addFileEntry("f1")
app.addLabel("ytLabel", "OR, insert a YouTube link!")
app.addEntry("link")
app.addLabel("outputLabel", "Where to save the output?")
app.addDirectoryEntry("output")
app.addLabel("whatType", "How about file type?")
app.addRadioButton("type", ".wav (faster, much larger file size)")
app.addRadioButton("type", ".mp3 (slower, much smaller file size)")
app.addButton("Perform Magic", function)
# start the GUI
app.go()