快捷方式

MelScale

class torchaudio.transforms.MelScale(n_mels: int = 128, sample_rate: int = 16000, f_min: float = 0.0, f_max: Optional[float] = None, n_stft: int = 201, norm: Optional[str] = None, mel_scale: str = 'htk')[source]

将普通 STFT 转换为具有三角形滤波器组的梅尔频率 STFT。

This feature supports the following devices: CPU, CUDA This API supports the following properties: Autograd, TorchScript
参数:
  • n_mels (int, 可选) – 梅尔滤波器组的数量。 (默认: 128)

  • sample_rate (int, 可选) – 音频信号的采样率。 (默认: 16000)

  • f_min (float, 可选) – 最小频率。 (默认: 0.)

  • f_max (floatNone, 可选) – 最大频率。 (默认: sample_rate // 2)

  • n_stft (int, 可选) – STFT 中的 bin 数量。 请参阅 Spectrogram 中的 n_fft。 (默认: 201)

  • norm (strNone, 可选) – 如果为 "slaney",则将三角形梅尔权重除以梅尔频带的宽度(面积归一化)。 (默认: None)

  • mel_scale (str, 可选) – 要使用的比例: htkslaney。 (默认: htk)

示例
>>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
>>> spectrogram_transform = transforms.Spectrogram(n_fft=1024)
>>> spectrogram = spectrogram_transform(waveform)
>>> melscale_transform = transforms.MelScale(sample_rate=sample_rate, n_stft=1024 // 2 + 1)
>>> melscale_spectrogram = melscale_transform(spectrogram)

另请参阅

torchaudio.functional.melscale_fbanks() - 用于生成滤波器组的函数。

forward(specgram: Tensor) Tensor[source]
参数:

specgram (Tensor) – 频谱图 STFT,维度为 (…, freq, time)。

返回:

梅尔频率频谱图,大小为 (…, n_mels, time)。

返回类型:

Tensor

文档

访问 PyTorch 的综合开发者文档

查看文档

教程

获取面向初学者和高级开发者的深入教程

查看教程

资源

查找开发资源并获得问题解答

查看资源