快捷方式

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, 可选) – 每倍频程的步数(默认值:12)。

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

  • win_length (intNone, 可选) – 窗口大小。如果为 None,则使用 n_fft。(默认值:None)。

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

  • window (TensorNone, 可选) – 应用/乘以每个帧/窗口的窗口张量。如果为 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 的综合开发者文档

查看文档

教程

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

查看教程

资源

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

查看资源