Add files via upload

This commit is contained in:
Anjok07 2022-07-31 18:49:21 -05:00 committed by GitHub
parent d0a3942f24
commit b6b26ea5dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 118 additions and 29 deletions

32
UVR.py
View File

@ -216,6 +216,7 @@ except:
banner_path = os.path.join(base_path, 'img', 'UVR-banner.png') banner_path = os.path.join(base_path, 'img', 'UVR-banner.png')
credits_path = os.path.join(base_path, 'img', 'credits.png') credits_path = os.path.join(base_path, 'img', 'credits.png')
demucs_opt_path = os.path.join(base_path, 'img', 'demucs_opt.png') demucs_opt_path = os.path.join(base_path, 'img', 'demucs_opt.png')
donate_path = os.path.join(base_path, 'img', 'donate.png')
download_path = os.path.join(base_path, 'img', 'download.png') download_path = os.path.join(base_path, 'img', 'download.png')
efile_path = os.path.join(base_path, 'img', 'file.png') efile_path = os.path.join(base_path, 'img', 'file.png')
ense_opt_path = os.path.join(base_path, 'img', 'ense_opt.png') ense_opt_path = os.path.join(base_path, 'img', 'ense_opt.png')
@ -527,6 +528,8 @@ class MainWindow(TkinterDnD.Tk):
size=(20, 20)) size=(20, 20))
self.download_img = open_image(path=download_path, self.download_img = open_image(path=download_path,
size=(30, 30)) size=(30, 30))
self.donate_img = open_image(path=donate_path,
size=(30, 30))
self.key_img = open_image(path=key_path, self.key_img = open_image(path=key_path,
size=(30, 30)) size=(30, 30))
if GetSystemMetrics(1) >= 900: if GetSystemMetrics(1) >= 900:
@ -4288,7 +4291,7 @@ class MainWindow(TkinterDnD.Tk):
top= Toplevel(self) top= Toplevel(self)
window_height = 750 window_height = 780
window_width = 500 window_width = 500
top.title("Settings Guide") top.title("Settings Guide")
@ -4529,14 +4532,21 @@ class MainWindow(TkinterDnD.Tk):
rlg = KThread(target=check_updates) rlg = KThread(target=check_updates)
rlg.start() rlg.start()
def open_bmac_m():
top.attributes("-topmost", False)
callback("https://www.buymeacoffee.com/uvr5")
l0=ttk.Button(frame0,text=update_button_var.get(), command=start_check_updates) l0=ttk.Button(frame0,text=update_button_var.get(), command=start_check_updates)
l0.grid(row=14,column=0,padx=0,pady=5) l0.grid(row=14,column=0,padx=0,pady=5)
l0=tk.Label(frame0,textvariable=update_var,font=("Century Gothic", "12"), justify="center", relief="ridge", fg="#13a4c9") l0=tk.Label(frame0,textvariable=update_var,font=("Century Gothic", "12"), justify="center", relief="ridge", fg="#13a4c9")
l0.grid(row=15,column=0,padx=0,pady=5) l0.grid(row=15,column=0,padx=0,pady=5)
l0=ttk.Button(frame0, image=self.donate_img, command=open_bmac_m)
l0.grid(row=16,column=0,padx=0,pady=5)
l0=tk.Label(frame0,text=f"{space_small}{space_small}{space_small}{space_small}",font=("Century Gothic", "13"), justify="center", relief="flat", fg="#13a4c9") l0=tk.Label(frame0,text=f"{space_small}{space_small}{space_small}{space_small}",font=("Century Gothic", "13"), justify="center", relief="flat", fg="#13a4c9")
l0.grid(row=16,column=0,padx=0,pady=0) l0.grid(row=17,column=0,padx=0,pady=0)
frame0=Frame(tab2,highlightbackground='red',highlightthicknes=0) frame0=Frame(tab2,highlightbackground='red',highlightthicknes=0)
frame0.grid(row=0,column=0,padx=0,pady=0) frame0.grid(row=0,column=0,padx=0,pady=0)
@ -4590,7 +4600,7 @@ class MainWindow(TkinterDnD.Tk):
top_code= Toplevel() top_code= Toplevel()
window_height = 440 window_height = 480
window_width = 320 window_width = 320
top_code.title("User Download Codes") top_code.title("User Download Codes")
@ -4639,8 +4649,12 @@ class MainWindow(TkinterDnD.Tk):
def open_patreon(): def open_patreon():
top_code.attributes("-topmost", False) top_code.attributes("-topmost", False)
callback("https://www.patreon.com/uvr") callback("https://www.patreon.com/uvr")
def open_bmac():
top_code.attributes("-topmost", False)
callback("https://www.buymeacoffee.com/uvr5")
def quit(): def quit():
top.attributes("-topmost", True) top.attributes("-topmost", True)
top_code.destroy() top_code.destroy()
@ -4670,16 +4684,20 @@ class MainWindow(TkinterDnD.Tk):
l0.grid(row=6,column=0,padx=0,pady=5) l0.grid(row=6,column=0,padx=0,pady=5)
l0=tk.Label(frame0, text=f'UVR Patreon', font=("Century Gothic", "11", "underline"), foreground='#13a4c9') l0=tk.Label(frame0, text=f'Support UVR', font=("Century Gothic", "11", "underline"), foreground='#13a4c9')
l0.grid(row=7,column=0,padx=0,pady=5) l0.grid(row=7,column=0,padx=0,pady=5)
l0=tk.Label(frame0, text=f'Obtain codes by becoming an official Patreon.\nClick the button below to open the UVR Patreon link.', font=("Century Gothic", "8"), foreground='#13a4c9') l0=tk.Label(frame0, text=f'Obtain codes by making a one-time donation\n via \"Buy Me a Coffee\" or by becoming a Patreon.\nClick one of the buttons below to donate or pledge!', font=("Century Gothic", "8"), foreground='#13a4c9')
l0.grid(row=8,column=0,padx=0,pady=5) l0.grid(row=8,column=0,padx=0,pady=5)
l0=ttk.Button(frame0, text='UVR Patreon Link', command=open_patreon) l0=ttk.Button(frame0, text='UVR Patreon Link', command=open_patreon)
l0.grid(row=9,column=0,padx=0,pady=5) l0.grid(row=9,column=0,padx=0,pady=5)
l0=ttk.Button(frame0, text='UVR \"Buy Me a Coffee\" Link', command=open_bmac)
l0.grid(row=10,column=0,padx=0,pady=5)
def download_code(): def download_code():
""" """
Input Download Code Input Download Code

View File

@ -366,8 +366,19 @@ class Predictor():
#Main Save Path #Main Save Path
save_path = os.path.dirname(_basename) save_path = os.path.dirname(_basename)
inst_only = data['inst_only']
voc_only = data['voc_only']
#print('stemset_n: ', stemset_n) #print('stemset_n: ', stemset_n)
if stemset_n == '(Instrumental)':
if data['inst_only'] == True:
voc_only = True
inst_only = False
if data['voc_only'] == True:
inst_only = True
voc_only = False
#Vocal Path #Vocal Path
if stemset_n == '(Vocals)': if stemset_n == '(Vocals)':
vocal_name = '(Vocals)' vocal_name = '(Vocals)'
@ -511,7 +522,7 @@ class Predictor():
c += 1 c += 1
if not data['demucsmodel']: if not data['demucsmodel']:
if data['inst_only']: if inst_only:
widget_text.write(base_text + f'Preparing to save {stem_text_b}...') widget_text.write(base_text + f'Preparing to save {stem_text_b}...')
else: else:
widget_text.write(base_text + f'Saving {stem_text_a}... ') widget_text.write(base_text + f'Saving {stem_text_a}... ')
@ -531,7 +542,7 @@ class Predictor():
update_progress(**progress_kwargs, update_progress(**progress_kwargs,
step=(0.95)) step=(0.95))
else: else:
if data['inst_only']: if inst_only:
widget_text.write(base_text + f'Preparing {stem_text_b}...') widget_text.write(base_text + f'Preparing {stem_text_b}...')
else: else:
widget_text.write(base_text + f'Saving {stem_text_a}... ') widget_text.write(base_text + f'Saving {stem_text_a}... ')
@ -562,7 +573,7 @@ class Predictor():
c += 1 c += 1
if not data['demucsmodel']: if not data['demucsmodel']:
if data['inst_only']: if inst_only:
widget_text.write(base_text + f'Preparing {stem_text_b}...') widget_text.write(base_text + f'Preparing {stem_text_b}...')
else: else:
widget_text.write(base_text + f'Saving {stem_text_a}... ') widget_text.write(base_text + f'Saving {stem_text_a}... ')
@ -571,7 +582,7 @@ class Predictor():
step=(0.9)) step=(0.9))
widget_text.write('Done!\n') widget_text.write('Done!\n')
else: else:
if data['inst_only']: if inst_only:
widget_text.write(base_text + f'Preparing {stem_text_b}...') widget_text.write(base_text + f'Preparing {stem_text_b}...')
else: else:
widget_text.write(base_text + f'Saving {stem_text_a}... ') widget_text.write(base_text + f'Saving {stem_text_a}... ')
@ -591,7 +602,7 @@ class Predictor():
step=(0.9)) step=(0.9))
widget_text.write('Done!\n') widget_text.write('Done!\n')
if data['voc_only'] and not data['inst_only']: if voc_only and not inst_only:
pass pass
else: else:
if not data['noisereduc_s'] == 'None': if not data['noisereduc_s'] == 'None':
@ -673,7 +684,7 @@ class Predictor():
else: else:
sf.write(Instrumental_path, normalization_set(spec_utils.cmb_spectrogram_to_wave(-v_spec, mp)), mp.param['sr'], subtype=wav_type_set) sf.write(Instrumental_path, normalization_set(spec_utils.cmb_spectrogram_to_wave(-v_spec, mp)), mp.param['sr'], subtype=wav_type_set)
if data['inst_only']: if inst_only:
if file_exists_v == 'there': if file_exists_v == 'there':
pass pass
else: else:
@ -687,7 +698,7 @@ class Predictor():
if data['saveFormat'] == 'Mp3': if data['saveFormat'] == 'Mp3':
try: try:
if data['inst_only'] == True: if inst_only == True:
if data['non_red'] == True: if data['non_red'] == True:
if not data['nophaseinst']: if not data['nophaseinst']:
pass pass
@ -713,7 +724,7 @@ class Predictor():
if not data['nophaseinst']: if not data['nophaseinst']:
pass pass
else: else:
if data['voc_only'] == True: if voc_only == True:
pass pass
else: else:
musfile = pydub.AudioSegment.from_wav(non_reduced_Instrumental_path) musfile = pydub.AudioSegment.from_wav(non_reduced_Instrumental_path)
@ -725,7 +736,7 @@ class Predictor():
os.remove(non_reduced_Instrumental_path) os.remove(non_reduced_Instrumental_path)
except: except:
pass pass
if data['voc_only'] == True: if voc_only == True:
if data['non_red'] == True: if data['non_red'] == True:
musfile = pydub.AudioSegment.from_wav(non_reduced_vocal_path) musfile = pydub.AudioSegment.from_wav(non_reduced_vocal_path)
musfile.export(non_reduced_vocal_path_mp3, format="mp3", bitrate=mp3_bit_set) musfile.export(non_reduced_vocal_path_mp3, format="mp3", bitrate=mp3_bit_set)
@ -745,7 +756,7 @@ class Predictor():
except: except:
pass pass
if data['non_red'] == True: if data['non_red'] == True:
if data['inst_only'] == True: if inst_only == True:
pass pass
else: else:
musfile = pydub.AudioSegment.from_wav(non_reduced_vocal_path) musfile = pydub.AudioSegment.from_wav(non_reduced_vocal_path)
@ -783,7 +794,7 @@ class Predictor():
if data['saveFormat'] == 'Flac': if data['saveFormat'] == 'Flac':
try: try:
if data['inst_only'] == True: if inst_only == True:
if data['non_red'] == True: if data['non_red'] == True:
if not data['nophaseinst']: if not data['nophaseinst']:
pass pass
@ -809,7 +820,7 @@ class Predictor():
if not data['nophaseinst']: if not data['nophaseinst']:
pass pass
else: else:
if data['voc_only'] == True: if voc_only == True:
pass pass
else: else:
musfile = pydub.AudioSegment.from_wav(non_reduced_Instrumental_path) musfile = pydub.AudioSegment.from_wav(non_reduced_Instrumental_path)
@ -821,7 +832,7 @@ class Predictor():
os.remove(non_reduced_Instrumental_path) os.remove(non_reduced_Instrumental_path)
except: except:
pass pass
if data['voc_only'] == True: if voc_only == True:
if data['non_red'] == True: if data['non_red'] == True:
musfile = pydub.AudioSegment.from_wav(non_reduced_vocal_path) musfile = pydub.AudioSegment.from_wav(non_reduced_vocal_path)
musfile.export(non_reduced_vocal_path_flac, format="flac") musfile.export(non_reduced_vocal_path_flac, format="flac")
@ -841,7 +852,7 @@ class Predictor():
except: except:
pass pass
if data['non_red'] == True: if data['non_red'] == True:
if data['inst_only'] == True: if inst_only == True:
pass pass
else: else:
musfile = pydub.AudioSegment.from_wav(non_reduced_vocal_path) musfile = pydub.AudioSegment.from_wav(non_reduced_vocal_path)
@ -880,7 +891,7 @@ class Predictor():
if data['noisereduc_s'] == 'None': if data['noisereduc_s'] == 'None':
pass pass
elif data['non_red'] == True: elif data['non_red'] == True:
if data['inst_only']: if inst_only:
if file_exists_n == 'there': if file_exists_n == 'there':
pass pass
else: else:
@ -889,7 +900,7 @@ class Predictor():
except: except:
pass pass
pass pass
elif data['inst_only']: elif inst_only:
if file_exists_n == 'there': if file_exists_n == 'there':
pass pass
else: else:
@ -1313,8 +1324,9 @@ def main(window: tk.Wm,
global widget_button global widget_button
global stime global stime
global model_hash global model_hash
global demucs_switch global demucs_switch
global inst_only
global voc_only
# Update default settings # Update default settings
@ -1338,6 +1350,7 @@ def main(window: tk.Wm,
ffmp_err = """audioread\__init__.py", line 116, in audio_open""" ffmp_err = """audioread\__init__.py", line 116, in audio_open"""
sf_write_err = "sf.write" sf_write_err = "sf.write"
model_adv_set_err = "Got invalid dimensions for input" model_adv_set_err = "Got invalid dimensions for input"
demucs_model_missing_err = "is neither a single pre-trained model or a bag of models."
try: try:
with open('errorlog.txt', 'w') as f: with open('errorlog.txt', 'w') as f:
@ -1523,6 +1536,8 @@ def main(window: tk.Wm,
#print(dim_f_set) #print(dim_f_set)
#print(demucs_model_set_name) #print(demucs_model_set_name)
inst_only = data['inst_only']
voc_only = data['voc_only']
stime = time.perf_counter() stime = time.perf_counter()
progress_var.set(0) progress_var.set(0)
@ -1956,6 +1971,28 @@ def main(window: tk.Wm,
button_widget.configure(state=tk.NORMAL) # Enable Button button_widget.configure(state=tk.NORMAL) # Enable Button
return return
if demucs_model_missing_err in message:
text_widget.write("\n" + base_text + f'Separation failed for the following audio file:\n')
text_widget.write(base_text + f'"{os.path.basename(music_file)}"\n')
text_widget.write(f'\nError Received:\n\n')
text_widget.write(f'The selected Demucs model is missing.\n\n')
text_widget.write(f'Please download the model or make sure it is in the correct directory.\n\n')
text_widget.write(f'Time Elapsed: {time.strftime("%H:%M:%S", time.gmtime(int(time.perf_counter() - stime)))}')
try:
with open('errorlog.txt', 'w') as f:
f.write(f'Last Error Received:\n\n' +
f'Error Received while processing "{os.path.basename(music_file)}":\n' +
f'Process Method: MDX-Net\n\n' +
f'The selected Demucs model is missing.\n\n' +
f'Please download the model or make sure it is in the correct directory.\n\n' +
message + f'\nError Time Stamp [{datetime.now().strftime("%Y-%m-%d %H:%M:%S")}]\n')
except:
pass
torch.cuda.empty_cache()
progress_var.set(0)
button_widget.configure(state=tk.NORMAL) # Enable Button
return
print(traceback_text) print(traceback_text)
print(type(e).__name__, e) print(type(e).__name__, e)

View File

@ -363,6 +363,17 @@ class Predictor():
c = -1 c = -1
inst_only = data['inst_only']
voc_only = data['voc_only']
if stemset_n == '(Instrumental)':
if data['inst_only'] == True:
voc_only = True
inst_only = False
if data['voc_only'] == True:
inst_only = True
voc_only = False
#Main Save Path #Main Save Path
save_path = os.path.dirname(base_name) save_path = os.path.dirname(base_name)
@ -437,7 +448,7 @@ class Predictor():
if not data['noisereduc_s'] == 'None': if not data['noisereduc_s'] == 'None':
c += 1 c += 1
if demucs_switch == 'off': if demucs_switch == 'off':
if data['inst_only'] and not data['voc_only']: if inst_only and not voc_only:
widget_text.write(base_text + f'Preparing to save {stem_text_b}...') widget_text.write(base_text + f'Preparing to save {stem_text_b}...')
else: else:
widget_text.write(base_text + f'Saving {stem_text_a}... ') widget_text.write(base_text + f'Saving {stem_text_a}... ')
@ -456,7 +467,7 @@ class Predictor():
update_progress(**progress_kwargs, update_progress(**progress_kwargs,
step=(0.95)) step=(0.95))
else: else:
if data['inst_only'] and not data['voc_only']: if inst_only and not voc_only:
widget_text.write(base_text + f'Preparing to save {stem_text_b}...') widget_text.write(base_text + f'Preparing to save {stem_text_b}...')
else: else:
widget_text.write(base_text + f'Saving {stem_text_a}... ') widget_text.write(base_text + f'Saving {stem_text_a}... ')
@ -507,7 +518,7 @@ class Predictor():
step=(0.9)) step=(0.9))
widget_text.write('Done!\n') widget_text.write('Done!\n')
if data['voc_only'] and not data['inst_only']: if voc_only and not inst_only:
pass pass
else: else:
finalfiles = [ finalfiles = [
@ -554,7 +565,7 @@ class Predictor():
update_progress(**progress_kwargs, update_progress(**progress_kwargs,
step=(0.95)) step=(0.95))
sf.write(Instrumental_path, normalization_set(spec_utils.cmb_spectrogram_to_wave(-v_spec, mp)), mp.param['sr'], subtype=wav_type_set) sf.write(Instrumental_path, normalization_set(spec_utils.cmb_spectrogram_to_wave(-v_spec, mp)), mp.param['sr'], subtype=wav_type_set)
if data['inst_only']: if inst_only:
if file_exists == 'there': if file_exists == 'there':
pass pass
else: else:
@ -567,7 +578,7 @@ class Predictor():
if data['noisereduc_s'] == 'None': if data['noisereduc_s'] == 'None':
pass pass
elif data['inst_only']: elif inst_only:
if file_exists_n == 'there': if file_exists_n == 'there':
pass pass
else: else:
@ -1113,6 +1124,7 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
file_err = "FileNotFoundError" file_err = "FileNotFoundError"
ffmp_err = """audioread\__init__.py", line 116, in audio_open""" ffmp_err = """audioread\__init__.py", line 116, in audio_open"""
sf_write_err = "sf.write" sf_write_err = "sf.write"
demucs_model_missing_err = "is neither a single pre-trained model or a bag of models."
try: try:
with open('errorlog.txt', 'w') as f: with open('errorlog.txt', 'w') as f:
@ -4260,6 +4272,28 @@ def main(window: tk.Wm, text_widget: tk.Text, button_widget: tk.Button, progress
button_widget.configure(state=tk.NORMAL) # Enable Button button_widget.configure(state=tk.NORMAL) # Enable Button
return return
if demucs_model_missing_err in message:
text_widget.write("\n" + base_text + f'Separation failed for the following audio file:\n')
text_widget.write(base_text + f'"{os.path.basename(music_file)}"\n')
text_widget.write(f'\nError Received:\n\n')
text_widget.write(f'The selected Demucs model is missing.\n\n')
text_widget.write(f'Please download the model or make sure it is in the correct directory.\n\n')
text_widget.write(f'Time Elapsed: {time.strftime("%H:%M:%S", time.gmtime(int(time.perf_counter() - stime)))}')
try:
with open('errorlog.txt', 'w') as f:
f.write(f'Last Error Received:\n\n' +
f'Error Received while processing "{os.path.basename(music_file)}":\n' +
f'Process Method: Ensemble Mode\n\n' +
f'The selected Demucs model is missing.\n\n' +
f'Please download the model or make sure it is in the correct directory.\n\n' +
message + f'\nError Time Stamp [{datetime.now().strftime("%Y-%m-%d %H:%M:%S")}]\n')
except:
pass
torch.cuda.empty_cache()
progress_var.set(0)
button_widget.configure(state=tk.NORMAL) # Enable Button
return
print(traceback_text) print(traceback_text)
print(type(e).__name__, e) print(type(e).__name__, e)
print(message) print(message)