Skip to content

Commit

Permalink
constraining the pitch
Browse files Browse the repository at this point in the history
  • Loading branch information
jmvalin committed Oct 8, 2023
1 parent 69c9b34 commit 471d002
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions dnn/torch/fargan/fargan.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,17 @@ def forward(self, cond, prev_pred, exc_mem, period, states, gain=None):
#print(cond.shape, prev.shape)


idx = 256-torch.clamp(period[:,None], min=self.subframe_size+2, max=254)
idx = 256-period[:,None]
rng = torch.arange(self.subframe_size+4, device=device)
idx = idx + rng[None,:] - 2
mask = idx >= 256
idx = idx - mask*period[:,None]
pred = torch.gather(exc_mem, 1, idx)
pred = pred/(1e-5+gain)
pred = torch.clamp(pred/(1e-5+gain), min=-1, max=1)

prev = exc_mem[:,-self.subframe_size:]
dump_signal(prev, 'prev_in.f32')
prev = prev/(1e-5+gain)
prev = torch.clamp(prev/(1e-5+gain), min=-1, max=1)
dump_signal(prev, 'pitch_exc.f32')
dump_signal(exc_mem, 'exc_mem.f32')

Expand Down

0 comments on commit 471d002

Please sign in to comment.