spec

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

See this page for details.

Parameters
fft_lengthint >= 2 [scalar]

Number of FFT bins, \(L_2\).

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

Output format.

epsfloat >= 0 [scalar]

A small value added to power spectrum.

forward(x)[source]

Convert waveform to spectrum.

Parameters
xTensor [shape=(…, L1)]

Framed waveform.

Returns
yTensor [shape=(…, L2/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