From 19619161bed6c794d237338fb57dc741e078980b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 28 Nov 2024 18:07:17 +0900 Subject: [PATCH] chore(format): run black on dev (#98) Co-authored-by: github-actions[bot] --- infer/modules/train/extract_f0_print.py | 6 +++-- infer/modules/vc/pipeline.py | 1 - rvc/f0/gen.py | 34 +++++++++++++++++-------- rvc/onnx/infer.py | 4 ++- web.py | 6 ++++- 5 files changed, 36 insertions(+), 15 deletions(-) diff --git a/infer/modules/train/extract_f0_print.py b/infer/modules/train/extract_f0_print.py index 803790e..24fcb95 100644 --- a/infer/modules/train/extract_f0_print.py +++ b/infer/modules/train/extract_f0_print.py @@ -40,7 +40,7 @@ is_half = sys.argv[5] == "True" class FeatureInput(object): - def __init__(self, is_half: bool, device = "cpu", samplerate=16000, hop_size=160): + def __init__(self, is_half: bool, device="cpu", samplerate=16000, hop_size=160): self.fs = samplerate self.hop = hop_size @@ -75,7 +75,9 @@ class FeatureInput(object): ): continue x = load_audio(inp_path, self.fs) - coarse_pit, feature_pit = self.f0_gen.calculate(x, x.shape[0] // self.hop, 0, f0_method, None) + coarse_pit, feature_pit = self.f0_gen.calculate( + x, x.shape[0] // self.hop, 0, f0_method, None + ) np.save( opt_path2, feature_pit, diff --git a/infer/modules/vc/pipeline.py b/infer/modules/vc/pipeline.py index 8e0cd03..7b1c247 100644 --- a/infer/modules/vc/pipeline.py +++ b/infer/modules/vc/pipeline.py @@ -73,7 +73,6 @@ class Pipeline(object): self.sr, ) - def vc( self, model, diff --git a/rvc/f0/gen.py b/rvc/f0/gen.py index 2afdd0e..33989ed 100644 --- a/rvc/f0/gen.py +++ b/rvc/f0/gen.py @@ -15,7 +15,7 @@ def post_process( manual_x_pad: int, f0_mel_min: float, f0_mel_max: float, - manual_f0: Optional[Union[np.ndarray, list]]=None, + manual_f0: Optional[Union[np.ndarray, list]] = None, ) -> Tuple[np.ndarray, np.ndarray]: f0 = np.multiply(f0, pow(2, f0_up_key / 12)) # with open("test.txt","w")as f:f.write("\n".join([str(i)for i in f0.tolist()])) @@ -28,10 +28,14 @@ def post_process( list(range(delta_t)), manual_f0[:, 0] * 100, manual_f0[:, 1] ) shape = f0[manual_x_pad * tf0 : manual_x_pad * tf0 + len(replace_f0)].shape[0] - f0[manual_x_pad * tf0 : manual_x_pad * tf0 + len(replace_f0)] = replace_f0[:shape] + f0[manual_x_pad * tf0 : manual_x_pad * tf0 + len(replace_f0)] = replace_f0[ + :shape + ] # with open("test_opt.txt","w")as f:f.write("\n".join([str(i)for i in f0.tolist()])) f0_mel = 1127 * np.log(1 + f0 / 700) - f0_mel[f0_mel > 0] = (f0_mel[f0_mel > 0] - f0_mel_min) * 254 / (f0_mel_max - f0_mel_min) + 1 + f0_mel[f0_mel > 0] = (f0_mel[f0_mel > 0] - f0_mel_min) * 254 / ( + f0_mel_max - f0_mel_min + ) + 1 f0_mel[f0_mel <= 1] = 1 f0_mel[f0_mel > 255] = 255 f0_coarse = np.rint(f0_mel).astype(np.int32) @@ -44,9 +48,9 @@ class Generator(object): rmvpe_root: Path, is_half: bool, x_pad: int, - device = "cpu", - window = 160, - sr = 16000 + device="cpu", + window=160, + sr=16000, ): self.rmvpe_root = rmvpe_root self.is_half = is_half @@ -60,30 +64,34 @@ class Generator(object): x: np.ndarray, p_len: int, f0_up_key: int, - f0_method: Literal['pm', 'dio', 'harvest', 'crepe', 'rmvpe', 'fcpe'], + f0_method: Literal["pm", "dio", "harvest", "crepe", "rmvpe", "fcpe"], filter_radius: Optional[Union[int, float]], - manual_f0: Optional[Union[np.ndarray, list]]=None, + manual_f0: Optional[Union[np.ndarray, list]] = None, ) -> Tuple[np.ndarray, np.ndarray]: f0_min = 50 f0_max = 1100 if f0_method == "pm": if not hasattr(self, "pm"): from .pm import PM + self.pm = PM(self.window, f0_min, f0_max, self.sr) f0 = self.pm.compute_f0(x, p_len=p_len) elif f0_method == "dio": if not hasattr(self, "dio"): from .dio import Dio + self.dio = Dio(self.window, f0_min, f0_max, self.sr) f0 = self.dio.compute_f0(x, p_len=p_len) elif f0_method == "harvest": if not hasattr(self, "harvest"): from .harvest import Harvest + self.harvest = Harvest(self.window, f0_min, f0_max, self.sr) f0 = self.harvest.compute_f0(x, p_len=p_len, filter_radius=filter_radius) elif f0_method == "crepe": if not hasattr(self, "crepe"): from .crepe import CRePE + self.crepe = CRePE( self.window, f0_min, @@ -95,8 +103,9 @@ class Generator(object): elif f0_method == "rmvpe": if not hasattr(self, "rmvpe"): from .rmvpe import RMVPE + self.rmvpe = RMVPE( - str(self.rmvpe_root/"rmvpe.pt"), + str(self.rmvpe_root / "rmvpe.pt"), is_half=self.is_half, device=self.device, # use_jit=self.config.use_jit, @@ -108,6 +117,7 @@ class Generator(object): elif f0_method == "fcpe": if not hasattr(self, "fcpe"): from .fcpe import FCPE + self.fcpe = FCPE( self.window, f0_min, @@ -120,7 +130,11 @@ class Generator(object): raise ValueError(f"f0 method {f0_method} has not yet been supported") return post_process( - self.sr, self.window, f0, f0_up_key, self.x_pad, + self.sr, + self.window, + f0, + f0_up_key, + self.x_pad, 1127 * log(1 + f0_min / 700), 1127 * log(1 + f0_max / 700), manual_f0, diff --git a/rvc/onnx/infer.py b/rvc/onnx/infer.py index 639a113..1345da3 100644 --- a/rvc/onnx/infer.py +++ b/rvc/onnx/infer.py @@ -76,7 +76,9 @@ class RVC(Model): hubert = np.repeat(hubert, 2, axis=2).transpose(0, 2, 1).astype(np.float32) hubert_length = hubert.shape[1] - pitch, pitchf = self.f0_gen.calculate(wav, hubert_length, f0_up_key, f0_method, None) + pitch, pitchf = self.f0_gen.calculate( + wav, hubert_length, f0_up_key, f0_method, None + ) pitch = pitch.astype(np.int64) pitchf = pitchf.reshape(1, len(pitchf)).astype(np.float32) diff --git a/web.py b/web.py index 4cbf1d7..40e36a1 100644 --- a/web.py +++ b/web.py @@ -691,7 +691,11 @@ def train1key( [ get_info_str(_) for _ in extract_f0_feature( - np7, f0method8, if_f0_3, exp_dir1, version19, + np7, + f0method8, + if_f0_3, + exp_dir1, + version19, ) ]