快捷方式

PitchShift

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

将波形的音高移动 n_steps 步。

This feature supports the following devices: CPU, CUDA This API supports the following properties: TorchScript
参数:
  • waveform (Tensor) – 形状为 (…, time) 的输入波形。

  • sample_rate (int) – waveform 的采样率。

  • n_steps (int) – 移动 waveform 的(分数)步数。

  • bins_per_octave (int, optional) – 每个八度的步数(默认值:12)。

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

  • win_length (int or None, optional) – 窗口大小。如果为 None,则使用 n_fft。(默认值:None)。

  • hop_length (int or None, optional) – STFT 窗口之间的跳跃长度。如果为 None,则使用 win_length // 4(默认值:None)。

  • window (Tensor or None, optional) – 应用/乘以每个帧/窗口的窗口张量。如果为 None,则使用 torch.hann_window(win_length)(默认值:None)。

示例
>>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
>>> transform = transforms.PitchShift(sample_rate, 4)
>>> waveform_shift = transform(waveform)  # (channel, time)
initialize_parameters(input)[source]

根据输入批处理属性初始化参数。

这增加了一个接口,用于在执行参数形状推断时将参数初始化与前向传递隔离开来。

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

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

返回:

音高移动后的音频,形状为 (…, time)

返回类型:

Tensor

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

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

查看教程

资源

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

查看资源