Debug F0 interpolate

This commit is contained in:
ylzz1997 2023-06-08 01:47:42 +08:00
parent 322b082df1
commit b4c8eab5af
3 changed files with 22 additions and 1 deletions

View File

@ -22,6 +22,13 @@ class DioF0Predictor(F0Predictor):
nzindex = nzindex.astype(np.float32)
time_org = self.hop_length / self.sampling_rate * nzindex
time_frame = np.arange(f0.shape[0]) * self.hop_length / self.sampling_rate
if data.shape[0] <= 0:
return np.zeros(f0.shape[0], dtype=np.float32),np.zeros(f0.shape[0], dtype=np.float32)
if data.shape[0] == 1:
return np.ones(f0.shape[0], dtype=np.float32) * f0[0],np.ones(f0.shape[0], dtype=np.float32)
f0 = np.interp(time_frame, time_org, data, left=data[0], right=data[-1])
return f0,vuv_vector

View File

@ -22,10 +22,16 @@ class HarvestF0Predictor(F0Predictor):
nzindex = nzindex.astype(np.float32)
time_org = self.hop_length / self.sampling_rate * nzindex
time_frame = np.arange(f0.shape[0]) * self.hop_length / self.sampling_rate
if data.shape[0] <= 0:
return np.zeros(f0.shape[0], dtype=np.float32),np.zeros(f0.shape[0], dtype=np.float32)
if data.shape[0] == 1:
return np.ones(f0.shape[0], dtype=np.float32) * f0[0],np.ones(f0.shape[0], dtype=np.float32)
f0 = np.interp(time_frame, time_org, data, left=data[0], right=data[-1])
return f0,vuv_vector
def resize_f0(self,x, target_len):
source = np.array(x)
source[source<0.001] = np.nan

View File

@ -23,9 +23,17 @@ class PMF0Predictor(F0Predictor):
nzindex = nzindex.astype(np.float32)
time_org = self.hop_length / self.sampling_rate * nzindex
time_frame = np.arange(f0.shape[0]) * self.hop_length / self.sampling_rate
if data.shape[0] <= 0:
return np.zeros(f0.shape[0], dtype=np.float32),np.zeros(f0.shape[0], dtype=np.float32)
if data.shape[0] == 1:
return np.ones(f0.shape[0], dtype=np.float32) * f0[0],np.ones(f0.shape[0], dtype=np.float32)
f0 = np.interp(time_frame, time_org, data, left=data[0], right=data[-1])
return f0,vuv_vector
def compute_f0(self,wav,p_len=None):
x = wav