快捷鍵

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], 一種快速 Griffin-Lim 演算法 [Perraudin et al., 2013]從修改後的短時傅立葉轉換進行訊號估計 [Griffin and Lim, 1983]

參數:
  • n_fft (int, optional) – FFT 大小,產生 n_fft // 2 + 1 個 bins。(預設值:400)

  • n_iter (int, optional) – 相位恢復過程的迭代次數。(預設值:32)

  • win_length (int or None, optional) – 視窗大小。(預設值:n_fft)

  • hop_length (int or None, optional) – STFT 視窗之間的 hop 長度。(預設值:win_length // 2)

  • window_fn (Callable[..., Tensor], optional) – 一個建立視窗 tensor 的函數,該 tensor 將被應用/乘以每個 frame/window。(預設值:torch.hann_window)

  • power (float, optional) – magnitude spectrogram 的指數 (必須 > 0),例如,magnitude 為 1,power 為 2,等等。(預設值:2)

  • wkwargs (dict or None, optional) – 視窗函數的參數。(預設值:None)

  • momentum (float, optional) – 用於快速 Griffin-Lim 的 momentum 參數。將其設定為 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) – 僅包含 magnitude 的 STFT spectrogram,其維度為 (…, freq, frames),其中 freq 為 n_fft // 2 + 1

傳回值:

波形 (…, time),其中 time 等於給定的 length 參數。

傳回類型:

Tensor

文件

存取 PyTorch 的完整開發者文件

檢視文件

教學

取得適合初學者和進階開發者的深入教學課程

檢視教學課程

資源

尋找開發資源並取得您問題的解答

檢視資源