Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions inference/ds_variance.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,15 @@ def preprocess_input(
batch['midi'] = ph_midi

if load_pitch:
# Interpolate unvoiced parts before resampling.
f0 = resample_align_curve(
np.array(param['f0_seq'].split(), np.float32),
interp_f0(np.array(param['f0_seq'].split(), np.float32))[0],
original_timestep=float(param['f0_timestep']),
target_timestep=self.timestep,
align_length=T_s
)
batch['pitch'] = torch.from_numpy(
librosa.hz_to_midi(interp_f0(f0)[0]).astype(np.float32)
librosa.hz_to_midi(f0).astype(np.float32)
).to(self.device)[None]

if self.model.predict_dur:
Expand Down
2 changes: 1 addition & 1 deletion preprocessing/acoustic_binarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def arrange_data_augmentation(self, data_iterator):
aug_list.append(aug_task)
elif aug_type == 1:
aug_task = {
'name': aug_item,
'name': aug_item['name'],
'func': aug_item['func'],
'kwargs': deepcopy(aug_item['kwargs'])
}
Expand Down
15 changes: 11 additions & 4 deletions preprocessing/variance_binarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,21 @@ def process_item(self, item_name, meta_data, binarization_args):
if self.prefer_ds:
f0_seq = self.load_attr_from_ds(ds_id, name, 'f0_seq', idx=ds_seg_idx)
if f0_seq is not None:
f0_timestep = float(self.load_attr_from_ds(ds_id, name, 'f0_timestep', idx=ds_seg_idx))
# Interpolate unvoiced parts before resampling.
f0_points, uv_points = interp_f0(np.array(f0_seq.split(), np.float32))
f0 = resample_align_curve(
np.array(f0_seq.split(), np.float32),
original_timestep=float(self.load_attr_from_ds(ds_id, name, 'f0_timestep', idx=ds_seg_idx)),
f0_points,
original_timestep=f0_timestep,
target_timestep=self.timestep,
align_length=length
)
uv = f0 == 0
f0, _ = interp_f0(f0, uv)
uv = resample_align_curve(
uv_points.astype(np.float32),
original_timestep=f0_timestep,
target_timestep=self.timestep,
align_length=length
) > 0.5
if f0 is None:
f0, uv = pitch_extractor.get_pitch(
waveform, samplerate=hparams['audio_sample_rate'], length=length,
Expand Down
8 changes: 1 addition & 7 deletions utils/infer_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,11 @@ def trans_key(raw_data, key):


def resample_align_curve(points: np.ndarray, original_timestep: float, target_timestep: float, align_length: int):
t_max = (len(points) - 1) * original_timestep
curve_interp = np.interp(
np.arange(0, t_max, target_timestep),
np.arange(align_length) * target_timestep,
original_timestep * np.arange(len(points)),
points
).astype(points.dtype)
delta_l = align_length - len(curve_interp)
if delta_l < 0:
curve_interp = curve_interp[:align_length]
elif delta_l > 0:
curve_interp = np.concatenate((curve_interp, np.full(delta_l, fill_value=curve_interp[-1])), axis=0)
return curve_interp


Expand Down