Skip to content

Commit

Permalink
V3.1.0a (app breaking bug fixes)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frikallo committed Jul 19, 2023
1 parent 7b1e158 commit a053391
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 11 deletions.
4 changes: 4 additions & 0 deletions Build/build-CPU.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
{
"optionDest": "datas",
"value": "F:/Repos/MISST/MISST/Pretrained;Pretrained/"
},
{
"optionDest": "datas",
"value": "F:/Repos/MISST/venv-minimal/Lib/site-packages/demucs;demucs/"
}
],
"nonPyinstallerOptions": {
Expand Down
4 changes: 4 additions & 0 deletions Build/build-CUDA.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
{
"optionDest": "datas",
"value": "F:/Repos/MISST/MISST/Pretrained;Pretrained/"
},
{
"optionDest": "datas",
"value": "F:/Repos/MISST/venv/Lib/site-packages/demucs;demucs/"
}
],
"nonPyinstallerOptions": {
Expand Down
50 changes: 41 additions & 9 deletions MISST/MISSTapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io
import random
import shutil
import signal
import subprocess
import sys
import tempfile
Expand Down Expand Up @@ -167,6 +168,7 @@ def on_closing():

# Terminate the current process
self.logger.info("MISST closed.")
os.kill(current_pid, signal.SIGTERM)
sys.exit()

self.protocol("WM_DELETE_WINDOW", on_closing)
Expand Down Expand Up @@ -1051,7 +1053,7 @@ def sourcePreprocess(self, url:str) -> None:
if self.import_Spotify_var.get() == "on":
self.import_file_button.configure(state=tkinter.DISABLED)
self.import_button.configure(state=tkinter.DISABLED)
if "spotify.com" not in url:
if "https://open.spotify.com/track" not in url:
self.console.endUpdate()
self.console.addLine("\nMISST> Invalid URL.")
self.import_file_button.configure(state=tkinter.NORMAL)
Expand All @@ -1060,10 +1062,16 @@ def sourcePreprocess(self, url:str) -> None:
self.console.endUpdate()
self.console.update("\nMISST> Downloading")
temp_dir = tempfile.mkdtemp()
cmd = f"{os.path.abspath('./Assets/Bin/spotdl.exe')} {url} --output {temp_dir} --ffmpeg ./ffmpeg.exe"
cmd = [os.path.abspath("./Assets/Bin/spotdl.exe"),
url,
"--output",
temp_dir,
"--ffmpeg",
"./ffmpeg.exe"
]
process = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, creationflags=0x08000000)
if process.returncode != 0:
print(process.stderr)
self.logger.error(process.stderr)
self.console.endUpdate()
self.console.addLine("\nMISST> Error downloading file.")
self.import_file_button.configure(state=tkinter.NORMAL)
Expand All @@ -1085,7 +1093,7 @@ def sourcePreprocess(self, url:str) -> None:
elif self.import_Youtube_var.get() == "on":
self.import_file_button.configure(state=tkinter.DISABLED)
self.import_button.configure(state=tkinter.DISABLED)
if "https://music.youtube.com/watch?v=" and "https://www.youtube.com/watch?v=" not in url:
if "https://music.youtube.com/watch?v=" not in url and "https://www.youtube.com/watch?v=" not in url:
self.console.endUpdate()
self.console.addLine("\nMISST> Invalid URL.")
self.import_file_button.configure(state=tkinter.NORMAL)
Expand All @@ -1094,10 +1102,21 @@ def sourcePreprocess(self, url:str) -> None:
self.console.endUpdate()
self.console.update("\nMISST> Downloading")
temp_dir = tempfile.mkdtemp()
cmd = f"{os.path.abspath('./Assets/Bin/music-dl.exe')} -v -x --embed-thumbnail --audio-format flac -o {temp_dir}/%(title)s.%(ext)s {url} --ffmpeg-location ./ffmpeg.exe"
cmd = [os.path.abspath("./Assets/Bin/music-dl.exe"),
"-v",
"-x",
"--embed-thumbnail",
"--audio-format",
"flac",
"-o",
f"{temp_dir}/%(title)s.%(ext)s",
url,
"--ffmpeg-location",
"./ffmpeg.exe"
]
process = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, creationflags=0x08000000)
if process.returncode != 0:
print(process.stderr)
self.logger.error(process.stderr)
self.console.endUpdate()
self.console.addLine("\nMISST> Error downloading file.")
self.import_file_button.configure(state=tkinter.NORMAL)
Expand Down Expand Up @@ -1131,6 +1150,7 @@ def sourcePreprocess(self, url:str) -> None:
try:
MISSThelpers.apple_music(url, temp_dir) # Download
except:
self.logger.error(traceback.format_exc())
self.console.endUpdate()
self.console.addLine("\nMISST> Error downloading file.")
self.import_file_button.configure(state=tkinter.NORMAL)
Expand All @@ -1152,7 +1172,7 @@ def sourcePreprocess(self, url:str) -> None:
elif self.import_Soundcloud_var.get() == "on":
self.import_file_button.configure(state=tkinter.DISABLED)
self.import_button.configure(state=tkinter.DISABLED)
if "soundcloud.com" not in url:
if "https://soundcloud.com" not in url:
self.console.endUpdate()
self.console.addLine("\nMISST> Invalid URL.")
self.import_file_button.configure(state=tkinter.NORMAL)
Expand All @@ -1161,10 +1181,22 @@ def sourcePreprocess(self, url:str) -> None:
self.console.endUpdate()
self.console.update("\nMISST> Downloading")
temp_dir = tempfile.mkdtemp()
cmd = f"{os.path.abspath('./Assets/Bin/music-dl.exe')} -v -x --embed-thumbnail --audio-format flac -o {temp_dir}/%(title)s.%(ext)s {url} --ffmpeg-location ./ffmpeg.exe"
cmd = [
os.path.abspath("./Assets/Bin/music-dl.exe"),
"-v",
"-x",
"--embed-thumbnail",
"--audio-format",
"flac",
"-o",
f"{temp_dir}/%(title)s.%(ext)s",
url,
"--ffmpeg-location",
"./ffmpeg.exe"
]
process = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, creationflags=0x08000000)
if process.returncode != 0:
print(process.stderr)
self.logger.error(process.stderr)
self.console.endUpdate()
self.console.addLine("\nMISST> Error downloading file.")
self.import_file_button.configure(state=tkinter.NORMAL)
Expand Down
2 changes: 1 addition & 1 deletion MISST/MISSTplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pyaudio
import soundfile as sf
from MISSTsettings import MISSTsettings
from scipy.signal import fftconvolve, butter, filtfilt
from scipy.signal import butter, fftconvolve, filtfilt


class MISSTplayer:
Expand Down
8 changes: 7 additions & 1 deletion MISST/MISSTpreprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import logging
import os
import pathlib
import time
import traceback
import wave

import julius
Expand All @@ -12,7 +14,6 @@
from demucs.apply import BagOfModels, apply_model
from demucs.pretrained import get_model
from MISSThelpers import MISSTconsole
from MISSThelpers import MISSThelpers

# Modified functions from https://github.com/facebookresearch/demucs,
# https://pytorch.org/audio/main/tutorials/hybrid_demucs_tutorial.html
Expand Down Expand Up @@ -208,6 +209,8 @@ def process(
logger (logging.Logger): Logger
console (MISSTConsole): Console
"""
# Start the timer
start_time = time.time()
split = int(split * sample_rate)
overlap = int(overlap * split)
logger.info("Loading file")
Expand Down Expand Up @@ -252,6 +255,8 @@ def separation(i):
self.write_wav(torch.from_numpy(stem.transpose()), str(outpath / f"{stems[i]}.wav"), sample_rate)
self.compress_wav_to_flac(str(outpath / f"{stems[i]}.wav"), str(outpath / f"{stems[i]}.flac"))
self.apply_fade_in_out(str(outpath / f"{stems[i]}.flac"), str(outpath / f"{stems[i]}.flac"), 3.5)
logger.info("Wrote to %s" % str(outpath))
logger.info("Done in %.2f seconds" % (time.time() - start_time))
console.endUpdate()
else:
pass
Expand Down Expand Up @@ -280,6 +285,7 @@ def preprocess(self, file:str, outDir:str, chosen_model:str, device:str = "cuda"
del model # Free up memory
except Exception as e:
self.logger.error(e)
self.logger.error(traceback.format_exc())
console.addLine("\nMISST> Error.")
pass
console.addLine("\nMISST> Done.")
Expand Down

0 comments on commit a053391

Please sign in to comment.