diff --git a/configs/config.py b/configs/config.py index 50c63f0..75bc145 100644 --- a/configs/config.py +++ b/configs/config.py @@ -32,7 +32,7 @@ version_config_list = [ def singleton_variable(func): def wrapper(*args, **kwargs): - if not wrapper.instance: + if wrapper.instance is None: wrapper.instance = func(*args, **kwargs) return wrapper.instance diff --git a/infer-web.py b/infer-web.py index 034fb92..0a47e07 100644 --- a/infer-web.py +++ b/infer-web.py @@ -6,6 +6,10 @@ now_dir = os.getcwd() sys.path.append(now_dir) load_dotenv() load_dotenv("sha256.env") + +if sys.platform == "darwin": + os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1" + from infer.modules.vc import VC from infer.modules.uvr5.modules import uvr from infer.lib.train.process_ckpt import ( diff --git a/infer/modules/vc/modules.py b/infer/modules/vc/modules.py index b67ae64..06769fc 100644 --- a/infer/modules/vc/modules.py +++ b/infer/modules/vc/modules.py @@ -201,7 +201,7 @@ class VC: self.version, protect, f0_file, - ) + ).astype(np.int16) if self.tgt_sr != resample_sr >= 16000: tgt_sr = resample_sr else: diff --git a/infer/modules/vc/pipeline.py b/infer/modules/vc/pipeline.py index 78a542f..b5baf06 100644 --- a/infer/modules/vc/pipeline.py +++ b/infer/modules/vc/pipeline.py @@ -288,7 +288,7 @@ class Pipeline(object): hasp = pitch is not None and pitchf is not None arg = (feats, p_len, pitch, pitchf, sid) if hasp else (feats, p_len, sid) audio1 = (net_g.infer(*arg)[0][0, 0]).data.cpu().float().numpy() - del hasp, arg + del arg del feats, p_len, padding_mask if torch.cuda.is_available(): torch.cuda.empty_cache() @@ -469,7 +469,7 @@ class Pipeline(object): max_int16 = 32768 if audio_max > 1: max_int16 /= audio_max - audio_opt = (audio_opt * max_int16).astype(np.int16) + np.multiply(audio_opt, max_int16, audio_opt) del pitch, pitchf, sid if torch.cuda.is_available(): torch.cuda.empty_cache()