快捷方式

SpectralCentroid

class torchaudio.transforms.SpectralCentroid(sample_rate: int, n_fft: int = 400, win_length: ~typing.Optional[int] = None, hop_length: ~typing.Optional[int] = None, pad: int = 0, window_fn: ~typing.Callable[[...], ~torch.Tensor] = <built-in method hann_window of type object>, wkwargs: ~typing.Optional[dict] = None)[source]

计算每个通道沿时间轴的谱质心。

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

谱质心定义为频率值的加权平均值,权重为其幅度。

参数:
  • sample_rate (int) – 音频信号的采样率。

  • n_fft (int, optional) – FFT 大小,创建 n_fft // 2 + 1 个频 bins。(默认值:400

  • win_length (intNone, optional) – 窗口大小。(默认值:n_fft

  • hop_length (intNone, optional) – STFT 窗口之间的跳跃长度。(默认值:win_length // 2

  • pad (int, optional) – 信号的双边填充。(默认值:0

  • window_fn (Callable[..., Tensor], optional) – 用于创建窗口张量的函数,该张量应用于/乘以每个帧/窗口。(默认值:torch.hann_window

  • wkwargs (dictNone, optional) – 窗口函数的参数。(默认值:None

示例
>>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
>>> transform = transforms.SpectralCentroid(sample_rate)
>>> spectral_centroid = transform(waveform)  # (channel, time)
forward(waveform: Tensor) Tensor[source]
参数:

waveform (Tensor) – 维度为 (…, time) 的音频张量。

返回:

大小为 (…, time) 的谱质心。

返回类型:

Tensor

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

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

查看教程

资源

查找开发资源并获得解答

查看资源