Spaces:
Running
Running
Update src/vc_infer_pipeline.py
Browse files76 unmodified lines777879808081828384857 unmodified lines939495949697989910010149 unmodified lines15115215315415515615715815916016116215 unmodified lines17817918017118118218318418518618759 unmodified lines24724824923725025125225325425576 unmodified lines
def get_optimal_torch_device(self, index: int = 0) -> torch.device: if torch.cuda.is_available(): return torch.device(f"cuda:{index % torch.cuda.device_count()}") return torch.device( f"cuda:{index % torch.cuda.device_count()}" ) elif torch.backends.mps.is_available(): return torch.device("mps") return torch.device("cpu")7 unmodified lines hop_length=160, model="full", ): x = x.astype(np.float32) x = x.astype( np.float32 ) x /= np.quantile(np.abs(x), 0.999) torch_device = self.get_optimal_torch_device() audio = torch.from_numpy(x).to(torch_device, copy=True)49 unmodified lines f0 = f0[0].cpu().numpy() return f0
def get_f0_pyin_computation(self, x, f0_min, f0_max): y, sr = librosa.load("saudio/Sidney.wav", self.sr, mono=True) f0, _, _ = librosa.pyin(y, sr=self.sr, fmin=f0_min, fmax=f0_max) f0 = f0[1:] return f0 def get_f0_hybrid_computation( self, methods_str,15 unmodified lines x /= np.quantile(np.abs(x), 0.999) for method in methods: f0 = None if method == "mangio-crepe": if method == "crepe": f0 = self.get_f0_official_crepe_computation(x, f0_min, f0_max) f0 = f0[1:] elif method == "mangio-crepe": f0 = self.get_f0_crepe_computation( x, f0_min, f0_max, p_len, crepe_hop_length )59 unmodified lines ) pad_size = (p_len - len(f0) + 1) // 2 if pad_size > 0 or p_len - len(f0) - pad_size > 0: f0 = np.pad(f0, [[pad_size, p_len - len(f0) - pad_size]], mode="constant") f0 = np.pad( f0, [[pad_size, p_len - len(f0) - pad_size]], mode="constant" ) elif f0_method == "harvest": input_audio_path2wav[input_audio_path] = x.astype(np.double)src/vc_infer_pipeline.py+19-4