快捷方式

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)[source]

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

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

实现移植自 *librosa* [Brian McFee 等人, 2015]、*A fast Griffin-Lim algorithm* [Perraudin 等人, 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[source]
参数:

specgram (Tensor) – 仅幅值的 STFT 谱图,维度为 (…, freq, frames),其中 freq 为 n_fft // 2 + 1

返回:

波形,维度为 (…, time),其中 time 如果给定,则等于 length 参数。

返回类型:

Tensor

文档

访问 PyTorch 的完整开发者文档

查看文档

教程

获取针对初学者和高级开发者的深度教程

查看教程

资源

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

查看资源