spec#

class diffsptk.Spectrum(fft_length, *, eps=0, relative_floor=None, out_format='power')[source]#

See this page for details.

Parameters:
fft_lengthint >= 2

The number of FFT bins, \(L\).

epsfloat >= 0

A small value added to the power spectrum.

relative_floorfloat < 0 or None

The relative floor of the power spectrum in dB.

out_format[‘db’, ‘log-magnitude’, ‘magnitude’, ‘power’]

The output format.

forward(b=None, a=None)[source]#

Compute spectrum.

Parameters:
bTensor [shape=(…, M+1)] or None

The numerator coefficients.

aTensor [shape=(…, N+1)] or None

The denominator coefficients.

Returns:
outTensor [shape=(…, L/2+1)]

The spectrum.

Examples

>>> x = diffsptk.ramp(1, 3)
>>> x
tensor([1., 2., 3.])
>>> spec = diffsptk.Spectrum(8)
>>> y = spec(x)
>>> y
tensor([36.0000, 25.3137,  8.0000,  2.6863,  4.0000])
diffsptk.functional.spec(b=None, a=None, *, fft_length=512, eps=0, relative_floor=None, out_format='power')[source]#

Compute spectrum.

Parameters:
bTensor [shape=(…, M+1)] or None

The numerator coefficients.

aTensor [shape=(…, N+1)] or None

The denominator coefficients.

fft_lengthint >= 2

The number of FFT bins, \(L\).

epsfloat >= 0

A small value added to the power spectrum.

relative_floorfloat < 0 or None

The relative floor of the power spectrum in dB.

out_format[‘db’, ‘log-magnitude’, ‘magnitude’, ‘power’]

The output format.

Returns:
outTensor [shape=(…, L/2+1)]

The spectrum.