Skip to content

Commit

Permalink
Merge pull request #74 from sp-nitech/update
Browse files Browse the repository at this point in the history
Minor update
  • Loading branch information
takenori-y committed May 21, 2024
2 parents db7b6fa + 0b4ba9a commit d80de27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions diffsptk/misc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ def replicate1(x, left=True, right=True):
return y


def remove_gain(a, return_gain=False):
def remove_gain(a, return_gain=False, value=1):
K, a1 = torch.split(a, [1, a.size(-1) - 1], dim=-1)
a = F.pad(a1, (1, 0), value=1)
a = F.pad(a1, (1, 0), value=value)
if return_gain:
ret = (K, a)
else:
Expand Down
8 changes: 6 additions & 2 deletions diffsptk/modules/mglsadf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from ..misc.utils import Lambda
from ..misc.utils import check_size
from ..misc.utils import get_gamma
from ..misc.utils import remove_gain
from .b2mc import MLSADigitalFilterCoefficientsToMelCepstrum
from .gnorm import GeneralizedCepstrumGainNormalization
from .istft import InverseShortTimeFourierTransform
Expand Down Expand Up @@ -221,6 +222,9 @@ def __init__(
self.phase = phase
self.taylor_order = taylor_order

if alpha == 0 and gamma == 0:
cep_order = filter_order

if self.phase == "minimum":
self.pad = nn.ConstantPad1d((cep_order, 0), 0)
elif self.phase == "maximum":
Expand All @@ -241,7 +245,7 @@ def __init__(
def forward(self, x, mc):
c = self.mgc2c(mc)
if self.ignore_gain:
c[..., 0] = 0
c = remove_gain(c, value=0)

if self.phase == "minimum":
c = c.flip(-1)
Expand Down Expand Up @@ -320,7 +324,7 @@ def forward(self, x, mc):
c = self.mgc2c(mc)
c[..., 1:] *= 0.5
if self.ignore_gain:
c[..., 0] = 0
c = remove_gain(c, value=0)
h = self.c2ir(c)
else:
h = self.mgc2ir(mc)
Expand Down

0 comments on commit d80de27

Please sign in to comment.