InverseBarkScale¶
- class torchaudio.prototype.transforms.InverseBarkScale(n_stft: int, n_barks: int = 128, sample_rate: int = 16000, f_min: float = 0.0, f_max: Optional[float] = None, max_iter: int = 100000, tolerance_loss: float = 1e-05, tolerance_change: float = 1e-08, sgdargs: Optional[dict] = None, bark_scale: str = 'traunmuller')[source]¶
Estimate a STFT in normal frequency domain from bark frequency domain.
It minimizes the euclidian norm between the input bark-spectrogram and the product between the estimated spectrogram and the filter banks using SGD.
- Parameters:
n_stft (int) – Number of bins in STFT. See
n_fft
inSpectrogram
.n_barks (int, optional) – Number of bark filterbanks. (Default:
128
)sample_rate (int, optional) – Sample rate of audio signal. (Default:
16000
)f_min (float, optional) – Minimum frequency. (Default:
0.
)f_max (float or None, optional) – Maximum frequency. (Default:
sample_rate // 2
)max_iter (int, optional) – Maximum number of optimization iterations. (Default:
100000
)tolerance_loss (float, optional) – Value of loss to stop optimization at. (Default:
1e-5
)tolerance_change (float, optional) – Difference in losses to stop optimization at. (Default:
1e-8
)sgdargs (dict or None, optional) – Arguments for the SGD optimizer. (Default:
None
)bark_scale (str, optional) – Scale to use:
traunmuller
,schroeder
orwang
. (Default:traunmuller
)
- Example
>>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True) >>> mel_spectrogram_transform = transforms.BarkSpectrogram(sample_rate, n_fft=1024) >>> mel_spectrogram = bark_spectrogram_transform(waveform) >>> inverse_barkscale_transform = transforms.InverseBarkScale(n_stft=1024 // 2 + 1) >>> spectrogram = inverse_barkscale_transform(mel_spectrogram)
- forward(barkspec: Tensor) Tensor [source]¶
- Parameters:
barkspec (torch.Tensor) – A Bark frequency spectrogram of dimension (…,
n_barks
, time)- Returns:
Linear scale spectrogram of size (…, freq, time)
- Return type: