cdist#

class diffsptk.CepstralDistance(full: bool = False, reduction: str = 'mean')[source]#

See this page for details.

Parameters:
fullbool

If True, include the constant term in the distance calculation.

reduction[‘none’, ‘mean’, ‘batchmean’, ‘sum’]

The reduction type.

References

[1]

R. F. Kubichek, “Mel-cepstral distance measure for objective speech quality assessment,” Proceedings of IEEE Pacific Rim Conference on Communications Computers and Signal Processing, vol. 1, pp. 125-128, 1993.

forward(c1: Tensor, c2: Tensor) Tensor[source]#

Calculate the cepstral distance between two inputs.

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

The input cepstral coefficients.

c2Tensor [shape=(…, M+1)]

The target cepstral coefficients.

Returns:
outTensor [shape=(…,) or scalar]

The cepstral distance.

Examples

>>> import diffsptk
>>> import torch
>>> cdist = diffsptk.CepstralDistance(reduction="none")
>>> c1 = torch.tensor([[ 0.4296,  1.6517], [-1.0464, -0.6088]])
>>> c2 = torch.tensor([[ 1.6441, -0.6962], [ 0.9344,  0.3965]])
>>> distance = cdist(c1, c2)
>>> distance
tensor([2.3479, 1.0053])
diffsptk.functional.cdist(c1: Tensor, c2: Tensor, full: bool = False, reduction: str = 'mean') Tensor[source]#

Calculate the cepstral distance between two inputs.

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

The input cepstral coefficients.

c2Tensor [shape=(…, M+1)]

The target cepstral coefficients.

fullbool

If True, include the constant term in the distance calculation.

reduction[‘none’, ‘mean’, ‘batchmean’, ‘sum’]

The reduction type.

Returns:
outTensor [shape=(…,) or scalar]

The cepstral distance.

See also

fftcep