From 8364750272ec7d10c914f817209c5aaae5af32bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 24 Jul 2023 14:16:58 +0800 Subject: [PATCH] optimize: move slicer2, rmvpe, my_utils to lib --- extract_f0_print.py | 2 +- infer-web.py | 2 +- infer_batch_rvc.py | 2 +- my_utils.py => lib/audio.py | 0 rmvpe.py => lib/rmvpe.py | 5 ++--- slicer2.py => lib/slicer2.py | 0 rvc_for_realtime.py | 2 +- trainset_preprocess_pipeline_print.py | 4 ++-- vc_infer_pipeline.py | 2 +- 9 files changed, 9 insertions(+), 10 deletions(-) rename my_utils.py => lib/audio.py (100%) rename rmvpe.py => lib/rmvpe.py (96%) rename slicer2.py => lib/slicer2.py (100%) diff --git a/extract_f0_print.py b/extract_f0_print.py index 4610d95..f96606c 100644 --- a/extract_f0_print.py +++ b/extract_f0_print.py @@ -2,7 +2,7 @@ import os, traceback, sys, parselmouth now_dir = os.getcwd() sys.path.append(now_dir) -from my_utils import load_audio +from lib.audio import load_audio import pyworld import numpy as np, logging diff --git a/infer-web.py b/infer-web.py index 5b6efc0..b9fc2c6 100644 --- a/infer-web.py +++ b/infer-web.py @@ -33,7 +33,7 @@ from lib.infer_pack.models import ( ) from lib.infer_pack.models_onnx import SynthesizerTrnMsNSFsidM from infer_uvr5 import _audio_pre_, _audio_pre_new -from my_utils import load_audio +from lib.audio import load_audio from lib.train.process_ckpt import change_info, extract_small_model, merge, show_info from vc_infer_pipeline import VC from sklearn.cluster import MiniBatchKMeans diff --git a/infer_batch_rvc.py b/infer_batch_rvc.py index 4ba8e05..604853f 100644 --- a/infer_batch_rvc.py +++ b/infer_batch_rvc.py @@ -116,7 +116,7 @@ from lib.infer_pack.models import ( SynthesizerTrnMs768NSFsid, SynthesizerTrnMs768NSFsid_nono, ) -from my_utils import load_audio +from lib.audio import load_audio from fairseq import checkpoint_utils from scipy.io import wavfile diff --git a/my_utils.py b/lib/audio.py similarity index 100% rename from my_utils.py rename to lib/audio.py diff --git a/rmvpe.py b/lib/rmvpe.py similarity index 96% rename from rmvpe.py rename to lib/rmvpe.py index 17a748a..fc254cf 100644 --- a/rmvpe.py +++ b/lib/rmvpe.py @@ -1,6 +1,5 @@ -import sys, torch, numpy as np, traceback, pdb +import torch, numpy as np import torch.nn as nn -from time import time as ttime import torch.nn.functional as F @@ -247,7 +246,7 @@ class E2E(nn.Module): ) else: self.fc = nn.Sequential( - nn.Linear(3 * N_MELS, N_CLASS), nn.Dropout(0.25), nn.Sigmoid() + nn.Linear(3 * nn.N_MELS, nn.N_CLASS), nn.Dropout(0.25), nn.Sigmoid() ) def forward(self, mel): diff --git a/slicer2.py b/lib/slicer2.py similarity index 100% rename from slicer2.py rename to lib/slicer2.py diff --git a/rvc_for_realtime.py b/rvc_for_realtime.py index 4d62861..132e80c 100644 --- a/rvc_for_realtime.py +++ b/rvc_for_realtime.py @@ -196,7 +196,7 @@ class RVC: def get_f0_rmvpe(self, x, f0_up_key): if hasattr(self, "model_rmvpe") == False: - from rmvpe import RMVPE + from lib.rmvpe import RMVPE print("loading rmvpe model") self.model_rmvpe = RMVPE( diff --git a/trainset_preprocess_pipeline_print.py b/trainset_preprocess_pipeline_print.py index 0b79365..784c0a9 100644 --- a/trainset_preprocess_pipeline_print.py +++ b/trainset_preprocess_pipeline_print.py @@ -10,11 +10,11 @@ n_p = int(sys.argv[3]) exp_dir = sys.argv[4] noparallel = sys.argv[5] == "True" import numpy as np, os, traceback -from slicer2 import Slicer +from lib.slicer2 import Slicer import librosa, traceback from scipy.io import wavfile import multiprocessing -from my_utils import load_audio +from lib.audio import load_audio mutex = multiprocessing.Lock() f = open("%s/preprocess.log" % exp_dir, "a+") diff --git a/vc_infer_pipeline.py b/vc_infer_pipeline.py index 85c35c0..672033b 100644 --- a/vc_infer_pipeline.py +++ b/vc_infer_pipeline.py @@ -129,7 +129,7 @@ class VC(object): f0 = f0[0].cpu().numpy() elif f0_method == "rmvpe": if hasattr(self, "model_rmvpe") == False: - from rmvpe import RMVPE + from lib.rmvpe import RMVPE print("loading rmvpe model") self.model_rmvpe = RMVPE(