nnAudio.Spectrogram.DFT

class nnAudio.Spectrogram.DFT(n_fft=2048, freq_bins=None, hop_length=512, window='hann', freq_scale='no', center=True, pad_mode='reflect', fmin=50, fmax=6000, sr=22050)

Bases: torch.nn.modules.module.Module

Experimental feature before torch.fft was made avaliable. The inverse function only works for 1 single frame. i.e. input shape = (batch, n_fft, 1)

Methods

__init__

Initializes internal Module state, shared by both nn.Module and ScriptModule.

forward

Convert a batch of waveforms to spectrums.

inverse

Convert a batch of waveforms to CQT spectrograms.

forward(x)

Convert a batch of waveforms to spectrums.

Parameters

x (torch tensor) –

Input signal should be in either of the following shapes.

  1. (len_audio)

  2. (num_audio, len_audio)

3. (num_audio, 1, len_audio) It will be automatically broadcast to the right shape

inverse(x_real, x_imag)

Convert a batch of waveforms to CQT spectrograms.

Parameters
  • x_real (torch tensor) – Real part of the signal.

  • x_imag (torch tensor) – Imaginary part of the signal.