mglsadf#

diffsptk.MLSA#

alias of PseudoMGLSADigitalFilter

class diffsptk.PseudoMGLSADigitalFilter(filter_order, frame_period, *, alpha=0, gamma=0, c=None, ignore_gain=False, phase='minimum', mode='multi-stage', **kwargs)[source]#

See this page for details.

Parameters:
filter_orderint >= 0

Order of filter coefficients, \(M\).

frame_periodint >= 1

Frame period, \(P\).

alphafloat in (-1, 1)

Frequency warping factor, \(\alpha\).

gammafloat in [-1, 1]

Gamma, \(\gamma\).

cint >= 1 or None

Number of stages.

ignore_gainbool

If True, perform filtering without gain.

phase[‘minimum’, ‘maximum’, ‘zero’]

Filter type.

mode[‘multi-stage’, ‘single-stage’, ‘freq-domain’]

‘multi-stage’ approximates the MLSA filter by cascading FIR filters based on the Taylor series expansion. ‘single-stage’ uses a FIR filter whose coefficients are the impulse response converted from input mel-cepstral coefficients using FFT. ‘freq-domain’ performs filtering in the frequency domain rather than time one.

taylor_orderint >= 0

Order of Taylor series expansion (valid only if mode is ‘multi-stage’).

cep_orderint >= 0

Order of linear cepstrum (valid only if mode is ‘multi-stage’).

ir_lengthint >= 1

Length of impulse response (valid only if mode is ‘single-stage’).

n_fftint >= 1

Number of FFT bins for conversion (valid only if mode is ‘single-stage’).

**kwargsadditional keyword arguments

See ShortTimeFourierTransform() (valid only if mode is ‘freq-domain’).

References

[1]

T. Yoshimura et al., “Embedding a differentiable mel-cepstral synthesis filter to a neural speech synthesis system,” Proceedings of ICASSP, 2023.

forward(x, mc)[source]#

Apply an MGLSA digital filter.

Parameters:
xTensor [shape=(…, T)]

Excitation signal.

mcTensor [shape=(…, T/P, M+1)]

Mel-generalized cepstrum, not MLSA digital filter coefficients.

Returns:
outTensor [shape=(…, T)]

Output signal.

Examples

>>> M = 4
>>> x = diffsptk.step(3)
>>> mc = diffsptk.nrand(2, M)
>>> mc
tensor([[-0.9134, -0.5774, -0.4567,  0.7423, -0.5782],
        [ 0.6904,  0.5175,  0.8765,  0.1677,  2.4624]])
>>> mglsadf = diffsptk.MLSA(M, frame_period=2)
>>> y = mglsadf(x.view(1, -1), mc.view(1, 2, M + 1))
>>> y
tensor([[0.4011, 0.8760, 3.5677, 4.8725]])