chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:35:17 +08:00
commit 344816a5d8
136 changed files with 25044 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
import numpy as np
def norm_f0(f0, uv=None):
if uv is None:
uv = f0 == 0
f0 = np.log2(f0 + uv) # avoid arithmetic error
f0[uv] = -np.inf
return f0
def interp_f0(f0, uv=None):
if uv is None:
uv = f0 == 0
f0 = norm_f0(f0, uv)
if uv.any() and not uv.all():
f0[uv] = np.interp(np.where(uv)[0], np.where(~uv)[0], f0[~uv])
return denorm_f0(f0, uv=None), uv
def denorm_f0(f0, uv, pitch_padding=None):
f0 = 2 ** f0
if uv is not None:
f0[uv > 0] = 0
if pitch_padding is not None:
f0[pitch_padding] = 0
return f0