spec#

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

See this page for details.

Parameters:
fft_lengthint >= 2

Number of FFT bins, \(L\).

epsfloat >= 0

A small value added to power spectrum.

relative_floorfloat < 0 or None

Relative floor in decibels.

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

Output format.

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

Compute spectrum.

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

Framed waveform or numerator coefficients.

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

Denominator coefficients.

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

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

Numerator coefficients.

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

Denominator coefficients.

fft_lengthint >= 2

Number of FFT bins, \(L\).

epsfloat >= 0

A small value added to power spectrum.

relative_floorfloat < 0 or None

Relative floor in decibels.

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

Output format.

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

Spectrum.

See also

frame window stft phase