Shortcuts

BarkScale

class torchaudio.prototype.transforms.BarkScale(n_barks: int = 128, sample_rate: int = 16000, f_min: float = 0.0, f_max: Optional[float] = None, n_stft: int = 201, bark_scale: str = 'traunmuller')[source]

Turn a normal STFT into a bark frequency STFT with triangular filter banks.

This feature supports the following devices: CPU, CUDA This API supports the following properties: Autograd, TorchScript
Parameters:
  • 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)

  • n_stft (int, optional) – Number of bins in STFT. See n_fft in Spectrogram. (Default: 201)

  • norm (str or None, optional) – If "slaney", divide the triangular bark weights by the width of the bark band (area normalization). (Default: None)

  • bark_scale (str, optional) – Scale to use: traunmuller, schroeder or wang. (Default: traunmuller)

Example
>>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
>>> spectrogram_transform = transforms.Spectrogram(n_fft=1024)
>>> spectrogram = spectrogram_transform(waveform)
>>> barkscale_transform = transforms.BarkScale(sample_rate=sample_rate, n_stft=1024 // 2 + 1)
>>> barkscale_spectrogram = barkscale_transform(spectrogram)

See also

torchaudio.prototype.functional.barkscale_fbanks() - The function used to generate the filter banks.

forward(specgram: Tensor) Tensor[source]
Parameters:

specgram (torch.Tensor) – A spectrogram STFT of dimension (…, freq, time).

Returns:

Bark frequency spectrogram of size (…, n_barks, time).

Return type:

torch.Tensor

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources