mirror of
https://github.com/xiph/opus.git
synced 2025-05-18 09:28:30 +00:00
added LPCNet torch implementation
Signed-off-by: Jan Buethe <jbuethe@amazon.de>
This commit is contained in:
parent
90a171c1c2
commit
35ee397e06
38 changed files with 3200 additions and 0 deletions
15
dnn/torch/lpcnet/utils/sample.py
Normal file
15
dnn/torch/lpcnet/utils/sample.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
import torch
|
||||
|
||||
|
||||
def sample_excitation(probs, pitch_corr):
|
||||
|
||||
norm = lambda x : x / (x.sum() + 1e-18)
|
||||
|
||||
# lowering the temperature
|
||||
probs = norm(probs ** (1 + max(0, 1.5 * pitch_corr - 0.5)))
|
||||
# cut-off tails
|
||||
probs = norm(torch.maximum(probs - 0.002 , torch.FloatTensor([0])))
|
||||
# sample
|
||||
exc = torch.multinomial(probs.squeeze(), 1)
|
||||
|
||||
return exc
|
Loading…
Add table
Add a link
Reference in a new issue