class_docstr: Apply random audio codecs to input waveforms using torchaudio.
  
  This class provides an interface for applying codec augmentation techniques to audio data.
  
  Arguments
  ---------
  sample_rate: int
      The sample rate of the input waveform.
  
  Example
  -------
  >>> waveform = torch.rand(4, 16000)
  >>> if torchaudio.list_audio_backends()[0] == 'ffmpeg':
  ...     augmenter = CodecAugment(16000)
  ...     output_waveform = augmenter(waveform)
docstr: Apply the selected audio codec.
  
  Arguments
  ----------
  waveform: torch.Tensor
      Input waveform of shape `[batch, time]`.
  format: str
      The audio format to use (e.g., "wav", "mp3"). Default is None.
  encoder: str
      The encoder to use for the format (e.g., "opus", "vorbis"). Default is None.
  
  Returns
  ---------
  torch.Tensor:
      Coded version of the input waveform of shape `[batch, time]`.
docstr_tok: ["Apply","the","selected","audio","codec",".","Arguments","--","--","--","--","--","waveform",":","torch.Tensor","Input","waveform","of","shape","`","[","batch",",","time","]","`",".","format",":","str","The","audio","format","to","use","(","e.g.",",","``","wav","''",",","``","mp3","''",")",".","Default","is","None",".","encoder",":","str","The","encoder","to","use","for","the","format","(","e.g.",",","``","opus","''",",","``","vorbis","''",")",".","Default","is","None",".","Returns","--","--","--","--","-","torch.Tensor",":","Coded","version","of","the","input","waveform","of","shape","`","[","batch",",","time","]","`","."]
code: def apply_codec(self, waveform, format=None, encoder=None):
      """
      Apply the selected audio codec.
  
      Arguments
      ----------
      waveform: torch.Tensor
          Input waveform of shape `[batch, time]`.
      format: str
          The audio format to use (e.g., "wav", "mp3"). Default is None.
      encoder: str
          The encoder to use for the format (e.g., "opus", "vorbis"). Default is None.
  
      Returns
      ---------
      torch.Tensor:
          Coded version of the input waveform of shape `[batch, time]`.
      """
      audio_effector = torchaudio.io.AudioEffector(
          format=format, encoder=encoder
      )
      waveform_aug = audio_effector.apply(
          waveform.transpose(0, 1).to("cpu"), self.sample_rate
      )
      return waveform_aug.transpose(0, 1).to(waveform.device)
  
file_path: speechbrain/speechbrain/augment/codec.py
imports: import random
  import torch
  import torchaudio
label_desc: Use image node_id 2 for calling the CodecAugment obj's underlying member method code with example usage: obj.apply_codec(waveform, format, encoder) and returns: waveform_aug