Skip to content

Commit 0c325f4

Browse files
committed
Avoid empty input for pc aug
1 parent f59a293 commit 0c325f4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

training/nsf_HiFigan_task.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ def Gforward(self, sample):
268268

269269
def G2forward(self, sample):
270270
f0 = sample['f0']
271-
b = int(np.round(f0.shape[0] * self.pc_aug_prob))
271+
b = np.random.binomial(n=f0.shape[0], p=self.pc_aug_prob)
272+
if b == 0:
273+
return self.Gforward(sample)
272274
key = (2 * torch.rand(b, device=f0.device).unsqueeze(-1) - 1) * self.pc_aug_key
273275
aug_f0 = torch.cat((f0[: b] * 2 ** (key / 12), f0[b :]), dim=0)
274276
wav = self.generator(x=sample['mel'], f0=aug_f0)

0 commit comments

Comments
 (0)