def get_f0(self, audio, sampling_rate=22050, frame_length=1024, hop_length=256, f0_min=100, f0_max=300, harm_thresh=0.1): f0, harmonic_rates, argmins, times = compute_yin( audio, sampling_rate, frame_length, hop_length, f0_min, f0_max, harm_thresh) pad = int((frame_length / hop_length) / 2) f0 = [0.0] * pad + f0 + [0.0] * pad f0 = np.array(f0, dtype=np.float32) return f0
def get_f0(self, audio, sampling_rate=22050, frame_length=1024, hop_length=256, f0_min=100, f0_max=300, harm_thresh=0.1): f0, harmonic_rates, argmins, times = compute_yin( audio, sampling_rate, frame_length, hop_length, f0_min, f0_max, harm_thresh) pad = int((frame_length / hop_length) / 2) f0 = [0.0] * pad + f0 + [0.0] * pad f0 = np.array(f0, dtype=np.float32) # f0 = f0[:, :melspec.size(1)] # 用零向量替换F0 # f0 = torch.zeros(1, melspec.shape[1], dtype=torch.float) # return melspec, f0 return f0
def transform_f0(wav, hparams): sampling_rate = hparams.sampling_rate frame_length = hparams.filter_length hop_length = hparams.hop_length f0_min = hparams.f0_min f0_max = hparams.f0_max harm_thresh = hparams.harm_thresh f0, harmonic_rates, argmins, times = compute_yin( wav, sampling_rate, frame_length, hop_length, f0_min, f0_max, harm_thresh) pad = int((frame_length / hop_length) / 2) f0 = [0.0] * pad + f0 + [0.0] * pad f0 = np.array(f0, dtype=np.float32) return f0