快捷方式

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 的完整開發者文件

檢視文件

教程

獲取針對初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源