class_docstr: This class resamples an audio signal using sinc-based interpolation.
  
  It is a modification of the `resample` function from torchaudio
  (https://pytorch.org/audio/stable/tutorials/audio_resampling_tutorial.html)
  
  Arguments
  ---------
  orig_freq : int
      the sampling frequency of the input signal.
  new_freq : int
      the new sampling frequency after this operation is performed.
  lowpass_filter_width : int
      Controls the sharpness of the filter, larger numbers result in a
      sharper filter, but they are less efficient. Values from 4 to 10 are
      allowed.
  
  Example
  -------
  >>> from speechbrain.dataio.dataio import read_audio
  >>> signal = read_audio('tests/samples/single-mic/example1.wav')
  >>> signal = signal.unsqueeze(0) # [batch, time, channels]
  >>> resampler = Resample(orig_freq=16000, new_freq=8000)
  >>> resampled = resampler(signal)
  >>> signal.shape
  torch.Size([1, 52173])
  >>> resampled.shape
  torch.Size([1, 26087])
class_docstr_tok: ["This","class","resamples","an","audio","signal","using","sinc-based","interpolation",".","It","is","a","modification","of","the","`","resample","`","function","from","torchaudio","(","https",":","\/\/pytorch.org\/audio\/stable\/tutorials\/audio_resampling_tutorial.html",")","Arguments","--","--","--","--","-","orig_freq",":","int","the","sampling","frequency","of","the","input","signal",".","new_freq",":","int","the","new","sampling","frequency","after","this","operation","is","performed",".","lowpass_filter_width",":","int","Controls","the","sharpness","of","the","filter",",","larger","numbers","result","in","a","sharper","filter",",","but","they","are","less","efficient",".","Values","from","4","to","10","are","allowed",".","Example","--","--","--","-",">",">",">","from","speechbrain.dataio.dataio","import","read_audio",">",">",">","signal","=","read_audio","(","'tests\/samples\/single-mic\/example1.wav","'",")",">",">",">","signal","=","signal.unsqueeze","(","0",")","#","[","batch",",","time",",","channels","]",">",">",">","resampler","=","Resample","(","orig_freq=16000",",","new_freq=8000",")",">",">",">","resampled","=","resampler","(","signal",")",">",">",">","signal.shape","torch.Size","(","[","1",",","52173","]",")",">",">",">","resampled.shape","torch.Size","(","[","1",",","26087","]",")"]
docstr: Arguments
  ---------
  waveforms : tensor
      Shape should be `[batch, time]` or `[batch, time, channels]`.
  lengths : tensor
      Shape should be a single dimension, `[batch]`.
  
  Returns
  -------
  Tensor of shape `[batch, time]` or `[batch, time, channels]`.
docstr_tok: ["Arguments","--","--","--","--","-","waveforms",":","tensor","Shape","should","be","`","[","batch",",","time","]","`","or","`","[","batch",",","time",",","channels","]","`",".","lengths",":","tensor","Shape","should","be","a","single","dimension",",","`","[","batch","]","`",".","Returns","--","--","--","-","Tensor","of","shape","`","[","batch",",","time","]","`","or","`","[","batch",",","time",",","channels","]","`","."]
code: def forward(self, waveforms):
      """
      Arguments
      ---------
      waveforms : tensor
          Shape should be `[batch, time]` or `[batch, time, channels]`.
      lengths : tensor
          Shape should be a single dimension, `[batch]`.
  
      Returns
      -------
      Tensor of shape `[batch, time]` or `[batch, time, channels]`.
      """
  
      if not hasattr(self, "first_indices"):
          self._indices_and_weights(waveforms)
  
      # Don't do anything if the frequencies are the same
      if self.orig_freq == self.new_freq:
          return waveforms
  
      unsqueezed = False
      if len(waveforms.shape) == 2:
          waveforms = waveforms.unsqueeze(1)
          unsqueezed = True
      elif len(waveforms.shape) == 3:
          waveforms = waveforms.transpose(1, 2)
      else:
          raise ValueError("Input must be 2 or 3 dimensions")
  
      # Do resampling
      resampled_waveform = self._perform_resample(waveforms)
  
      if unsqueezed:
          resampled_waveform = resampled_waveform.squeeze(1)
      else:
          resampled_waveform = resampled_waveform.transpose(1, 2)
  
      return resampled_waveform
  
imports: import math
  import random
  import torch
  import torch.nn.functional
  from speechbrain.dataio.legacy import ExtendedCSVDataset
  from speechbrain.dataio.dataloader import make_dataloader
  from speechbrain.processing.signal_processing import compute_amplitude, dB_to_amplitude, convolve1d, notch_filter, reverberate
label_desc: Use image node_id 3 for calling the Resample obj's underlying member method code with example usage: obj.forward(waveforms) and returns: resampled_waveform, waveforms