快捷方式

GriffinLim

class torchaudio.transforms.GriffinLim(n_fft: int = 400, n_iter: int = 32, 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>, power: float = 2.0, wkwargs: ~typing.Optional[dict] = None, momentum: float = 0.99, length: ~typing.Optional[int] = None, rand_init: bool = True)[源码]

使用 Griffin-Lim 变换从线性幅度频谱图计算波形。

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

实现移植自 librosa [Brian McFee et al., 2015]A fast Griffin-Lim algorithm [Perraudin et al., 2013]Signal estimation from modified short-time Fourier transform [Griffin and Lim, 1983]

参数
  • n_fft (int, optional) – FFT 的大小,创建 n_fft // 2 + 1 个 bin。 (默认: 400)

  • n_iter (int, optional) – 相位恢复过程的迭代次数。 (默认: 32)

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

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

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

  • power (float, optional) – 幅度谱的指数,(必须大于 0)例如,1 表示幅度,2 表示功率,依此类推。 (默认: 2)

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

  • momentum (float, optional) – 快速 Griffin-Lim 的动量参数。将其设置为 0 可恢复原始的 Griffin-Lim 方法。接近 1 的值可能导致收敛加快,但大于 1 可能无法收敛。 (默认: 0.99)

  • length (int, optional) – 预期输出的数组长度。 (默认: None)

  • rand_init (bool, optional) – 如果为 True,则随机初始化相位;否则初始化为零。 (默认: True)

示例
>>> batch, freq, time = 2, 257, 100
>>> spectrogram = torch.randn(batch, freq, time)
>>> transform = transforms.GriffinLim(n_fft=512)
>>> waveform = transform(spectrogram)
使用 GriffinLim 的教程
Text-to-Speech with Tacotron2

使用 Tacotron2 进行文本到语音转换

使用 Tacotron2 进行文本到语音转换
Audio Feature Extractions

音频特征提取

音频特征提取
forward(specgram: Tensor) Tensor[源码]
参数

specgram (Tensor) – 一个仅包含幅度的 STFT 谱图,维度为 (..., freq, frames),其中 freq 为 n_fft // 2 + 1

返回

波形为 (..., time),其中 time 等于提供的 length 参数(如果给定)。

返回类型

张量

文档

访问全面的 PyTorch 开发者文档

查看文档

教程

为初学者和高级开发者提供深入的教程

查看教程

资源

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

查看资源