Shortcuts

FrequencyMasking

class torchaudio.transforms.FrequencyMasking(freq_mask_param: int, iid_masks: bool = False)[source]

Apply masking to a spectrogram in the frequency domain.

This feature supports the following devices: CPU, CUDA This API supports the following properties: Autograd, TorchScript

Proposed in SpecAugment [Park et al., 2019].

Parameters:
  • freq_mask_param (int) – maximum possible length of the mask. Indices uniformly sampled from [0, freq_mask_param).

  • iid_masks (bool, optional) – whether to apply different masks to each example/channel in the batch. (Default: False) This option is applicable only when the input tensor >= 3D.

Example
>>> spectrogram = torchaudio.transforms.Spectrogram()
>>> masking = torchaudio.transforms.FrequencyMasking(freq_mask_param=80)
>>>
>>> original = spectrogram(waveform)
>>> masked = masking(original)
The original spectrogram The spectrogram masked along frequency axis
Tutorials using FrequencyMasking:
Audio Feature Augmentation

Audio Feature Augmentation

Audio Feature Augmentation

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