spec#

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

See this page for details.

Parameters:
fft_lengthint >= 2 [scalar]

Number of FFT bins, \(L\).

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

Output format.

epsfloat >= 0 [scalar]

A small value added to power spectrum.

relative_floorfloat < 0 [scalar]

Relative floor in decibels.

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

Convert waveform to spectrum.

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

Framed waveform or numerator coefficients.

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

Denominator coefficients.

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

Spectrum.

Examples

>>> x = diffsptk.ramp(1, 3)
>>> x
tensor([1., 2., 3.])
>>> spec = diffsptk.Spectrum(fft_length=8)
>>> y = spec(x)
>>> y
tensor([36.0000, 25.3137,  8.0000,  2.6863,  4.0000])

See also

frame window stft phase