快捷方式

MFCC

class torchaudio.transforms.MFCC(sample_rate: int = 16000, n_mfcc: int = 40, dct_type: int = 2, norm: str = 'ortho', log_mels: bool = False, melkwargs: Optional[dict] = None)[原始碼]

從音訊訊號建立梅爾頻率倒譜系數。

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

預設情況下,這會在 DB 縮放的梅爾譜圖上計算 MFCC。這並非教科書上的實現,但在此實現是為了與 librosa 保持一致性。

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

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

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

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

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

  • log_mels (bool, 可選) – 是否使用對數梅爾譜圖而不是 db 縮放的譜圖。(預設值: False)

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

示例
>>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
>>> transform = transforms.MFCC(
>>>     sample_rate=sample_rate,
>>>     n_mfcc=13,
>>>     melkwargs={"n_fft": 400, "hop_length": 160, "n_mels": 23, "center": False},
>>> )
>>> mfcc = transform(waveform)

另請參閱

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

使用 MFCC 的教程
Audio Feature Extractions

音訊特徵提取

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

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

返回值:

大小為 (…, n_mfcc, time) 的 specgram_mel_db。

返回型別:

Tensor

文件

訪問 PyTorch 的完整開發者文件

檢視文件

教程

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

檢視教程

資源

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

檢視資源