INNER CODE UNIT · Python
get_unit_f0
voicepaw/so-vits-svc-fork · src/so_vits_svc_fork/inference/core.py:131
def get_unit_f0(
self,
audio: ndarray[Any, dtype[float32]],
tran: int,
cluster_infer_ratio: float,
speaker: int | str,
f0_method: Literal["crepe", "crepe-tiny", "parselmouth", "dio", "harvest"] = "dio",
):
f0 = so_vits_svc_fork.f0.compute_f0(
audio,
sampling_rate=self.target_sample,
hop_length=self.hop_size,
method=f0_method,
)
f0, uv = so_vits_svc_fork.f0.interpolate_f0(f0)
f0 = torch.as_tensor(f0, dtype=self.dtype, device=self.device)
uv = torch.as_tensor(uv, dtype=self.dtype, device=self.device)
f0 = f0 * 2 ** (tran / 12)