spec#
- class diffsptk.Spectrum(fft_length: int, *, eps: float = 0, relative_floor: float | None = None, out_format: str | int = '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: Tensor | None = None, a: Tensor | None = None) Tensor [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: Tensor | None = None, a: Tensor | None = None, *, fft_length: int = 512, eps: float = 0, relative_floor: float | None = None, out_format: str = 'power') Tensor [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.
See also