Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
NaruseMioShirakana authored Jan 15, 2023
1 parent bb6d418 commit b21dece
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion vdecoder/hifigan/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def remove_weight_norm(self):
remove_weight_norm(l)


def padDiff(x):
return F.pad(F.pad(x, (0,0,-1,1), 'constant', 0) - x, (0,0,0,-1), 'constant', 0)

class SineGen(torch.nn.Module):
""" Definition of sine generator
SineGen(samp_rate, harmonic_num = 0,
Expand Down Expand Up @@ -152,7 +155,7 @@ def _f02sine(self, f0_values):
# Buffer tmp_over_one_idx indicates the time step to add -1.
# This will not change F0 of sine because (x-1) * 2*pi = x * 2*pi
tmp_over_one = torch.cumsum(rad_values, 1) % 1
tmp_over_one_idx = (torch.diff(tmp_over_one, dim=1)) < 0
tmp_over_one_idx = (padDiff(tmp_over_one)) < 0
cumsum_shift = torch.zeros_like(rad_values)
cumsum_shift[:, 1:, :] = tmp_over_one_idx * -1.0

Expand Down

0 comments on commit b21dece

Please sign in to comment.