-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
174 lines (145 loc) · 6.96 KB
/
main.py
File metadata and controls
174 lines (145 loc) · 6.96 KB
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import os
try:
import tkinter
except:
os.system("pip install pytk --user")
try:
import spleeter
except:
os.system("pip install spleeter --user")
try:
import PySimpleGUI
except:
os.system("pip install pysimplegui --user")
try:
import tensorflow
except:
os.system("pip install tensorflow --user")
try:
import fleep
except:
os.system("pip install fleep --user")
import PySimpleGUI as sg
import tkinter as tk
from tkinter import filedialog
from tkinter import *
from tkinter import messagebox
import time, shutil, fleep, sys, subprocess, pkg_resources
from datetime import datetime
required = {'pysimplegui', 'spleeter', 'pytk', 'tensorflow', 'fleep'}
layout = [[sg.Text("Welcome to SpleeterGUI.\nSpleeter can separate voice and accompaniments from audio tracks.\nSelect an option to proceed:", key='text')],
[sg.Text("Vocals/ accompaniment separation")],
[sg.Button("Start (2)")],
[sg.Text("\nVocals/ drums/ bass/ other separation")],
[sg.Button("Start (4)")],
[sg.Text("\nVocals/ drums/ bass/ piano/ other separation")],
[sg.Button("Start (5)")],
[sg.Text("")],
[sg.Button("About"), sg.Button("Exit")]]
# Create the window
window = sg.Window("SpleeterGUI", layout) #, margins=(10, 50)
print(''' ████████ ██ ██ ██
███████ ██████ ██ █████ █████ ████████ █████ ██████ ██ ██ ██ ██
██ █ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
█████ ██████ ██ ████ ████ ██ ████ ██████ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ █ ██ ██████ ██ ██ ██
███████ ██ █████ █████ █████ ██ █████ ██ █ ██ ██ ██ ██ ██
█████████ ████████ ██
Close this terminal window if you want to force-terminate the program.
Please note, while processing your files the application may say 'not responding'
but worry not your files are actually being processed.''')
# Create an event loop
while True:
event, values = window.read()
# End program if user closes window or
# presses the OK button
if event == "Start (2)":
#print("openfiledialog")
now = datetime.now() # current date and time
date_time = now.strftime("%m%d%Y")
if not os.path.exists("output" + date_time):
time.sleep(1)
os.makedirs("output" + date_time)
root = tk.Tk()
root.withdraw()
file_path = filedialog.askopenfilename()
# Using embedded configuration.
if file_path:
with open(file_path, "rb") as file:
info = fleep.get(file.read(128))
if info.type[0] == "audio":
nfpath = file_path.replace(" ", "_")
os.rename(file_path, nfpath)
file_path = nfpath
stream = os.popen('spleeter separate -p spleeter:2stems -o output' + date_time + " " + file_path)
output = stream.read()
print(output)
os.startfile("output" + date_time)
else:
print("")
messagebox.showwarning("showwarning", "SpleeterGUI can only process audio files(!)")
if event == "Start (4)":
#print("openfiledialog")
now = datetime.now() # current date and time
date_time = now.strftime("%m%d%Y")
if not os.path.exists("output" + date_time):
time.sleep(1)
os.makedirs("output" + date_time)
root = tk.Tk()
root.withdraw()
file_path = filedialog.askopenfilename()
# Using embedded configuration.
if file_path:
with open(file_path, "rb") as file:
info = fleep.get(file.read(128))
if info.type[0] == "audio":
nfpath = file_path.replace(" ", "_")
os.rename(file_path, nfpath)
file_path = nfpath
stream = os.popen('spleeter separate -p spleeter:4stems -o output' + date_time + " " + file_path)
output = stream.read()
print(output)
os.startfile("output" + date_time)
else:
print("")
messagebox.showwarning("showwarning", "SpleeterGUI can only process audio files(!)")
if event == "Start (5)":
#print("openfiledialog")
now = datetime.now() # current date and time
date_time = now.strftime("%m%d%Y")
if not os.path.exists("output" + date_time):
time.sleep(1)
os.makedirs("output" + date_time)
root = tk.Tk()
root.withdraw()
file_path = filedialog.askopenfilename()
# Using embedded configuration.
if file_path:
with open(file_path, "rb") as file:
info = fleep.get(file.read(128))
if info.type[0] == "audio":
nfpath = file_path.replace(" ", "_")
os.rename(file_path, nfpath)
file_path = nfpath
stream = os.popen('spleeter separate -p spleeter:5stems -o output' + date_time + " " + file_path)
output = stream.read()
print(output)
os.startfile("output" + date_time)
else:
print("")
messagebox.showwarning("showwarning", "SpleeterGUI can only process audio files(!)")
if event == "Exit" or event == sg.WIN_CLOSED:
break
if event == "About":
layout = [[sg.Text('''Spleeter is Deezer source separation library with pretrained models written in Python and uses Tensorflow.
It makes it easy to train source separation model (assuming you have a dataset of isolated sources),
and provides already trained state of the art model for performing various flavour of separation.
SpleeterGUI is a GUI-implementation of Spleeter in Python by @deltaonealpha.
github.com/deltaonealpha''', key="new")], [sg.Button("Close")]]
window = sg.Window("About SpleeterGUI", layout, modal=True)
choice = None
while True:
event, values = window.read()
if event == "Close" or event == sg.WIN_CLOSED:
break
window.close()