lpc2lsp#

class diffsptk.LinearPredictiveCoefficientsToLineSpectralPairs(lpc_order: int, log_gain: bool = False, sample_rate: int | None = None, out_format: str | int = 'radian')[source]#

See this page for details.

Parameters:
lpc_orderint >= 0

The order of the input LPC, \(M\).

log_gainbool

If True, output the gain in logarithmic scale.

sample_rateint >= 1 or None

The sample rate in Hz.

out_format[‘radian’, ‘cycle’, ‘khz’, ‘hz’]

The output format.

References

[1]

P. Kabal et al., “The computation of line spectral frequencies using Chebyshev polynomials,” IEEE Transactions on Acoustics, Speech, and Signal Processing, vol. 34, no. 6, pp. 1419-1426, 1986.

forward(a: Tensor) Tensor[source]#

Convert LPC to LSP.

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

The LPC coefficients.

Returns:
outTensor [shape=(…, M+1)]

The LSP frequencies.

Examples

>>> x = diffsptk.nrand(4)
>>> x
tensor([-1.5326,  1.0875, -1.5925,  0.6913,  1.6217])
>>> lpc = diffsptk.LPC(3, 5)
>>> a = lpc(x)
>>> a
tensor([ 2.7969,  0.3908,  0.0458, -0.0859])
>>> lpc2lsp = diffsptk.LinearPredictiveCoefficientsToLineSpectralPairs(3)
>>> w = lpc2lsp(a)
>>> w
tensor([2.7969, 0.9037, 1.8114, 2.4514])
diffsptk.functional.lpc2lsp(a: Tensor, log_gain: bool = False, sample_rate: int | None = None, out_format: str = 'radian') Tensor[source]#

Convert LPC to LSP.

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

The LPC coefficients.

log_gainbool

If True, output the gain in logarithmic scale.

sample_rateint >= 1 or None

The sample rate in Hz.

out_format[‘radian’, ‘cycle’, ‘khz’, ‘hz’]

The output format.

Returns:
outTensor [shape=(…, M+1)]

The LSP frequencies.