快捷方式

LFCC

class torchaudio.transforms.LFCC(sample_rate: int = 16000, n_filter: int = 128, f_min: float = 0.0, f_max: Optional[float] = None, n_lfcc: int = 40, dct_type: int = 2, norm: str = 'ortho', log_lf: bool = False, speckwargs: Optional[dict] = None)[source]

從音訊訊號建立線性頻率倒譜系數。

This feature supports the following devices: CPU, CUDA This API supports the following properties: Autograd, TorchScript

預設情況下,此函式在 DB 縮放的線性濾波聲譜圖上計算 LFCC。這並非教科書式的實現,但此處如此實現是為了與 librosa 保持一致。

此輸出取決於輸入聲譜圖中的最大值,因此對於分割成片段的音訊片段和完整的音訊片段可能會返回不同的值。

引數:
  • sample_rate (int, 可選) – 音訊訊號的取樣率。(預設值: 16000)

  • n_filter (int, 可選) – 應用的線性濾波器數量。(預設值: 128)

  • n_lfcc (int, 可選) – 保留的 LFCC 係數數量。(預設值: 40)

  • f_min (float, 可選) – 最小頻率。(預設值: 0.)

  • f_max (floatNone, 可選) – 最大頻率。(預設值: None)

  • dct_type (int, 可選) – 要使用的 DCT(離散餘弦變換)型別。(預設值: 2)

  • norm (str, 可選) – 要使用的範數。(預設值: "ortho")

  • log_lf (bool, 可選) – 是否使用對數-LF 聲譜圖而不是 DB 縮放的聲譜圖。(預設值: False)

  • speckwargs (dictNone, 可選) – Spectrogram 的引數。(預設值: None)

示例
>>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
>>> transform = transforms.LFCC(
>>>     sample_rate=sample_rate,
>>>     n_lfcc=13,
>>>     speckwargs={"n_fft": 400, "hop_length": 160, "center": False},
>>> )
>>> lfcc = transform(waveform)

另請參閱

torchaudio.functional.linear_fbanks() - 用於生成濾波器組的函式。

使用 LFCC 的教程
Audio Feature Extractions

音訊特徵提取

音訊特徵提取
forward(waveform: Tensor) Tensor[source]
引數:

waveform (Tensor) – 維度為 (…, time) 的音訊 Tensor。

返回值:

線性頻率倒譜系數,大小為 (…, n_lfcc, time)。

返回型別:

Tensor

文件

獲取 PyTorch 的完整開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深入教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源