class_docstr: Resampling from the sample rate `old_sr` to `new_sr`.
class_docstr_tok: ["Resampling","from","the","sample","rate","`","old_sr","`","to","`","new_sr","`","."]
docstr: Args:
      old_sr (int): sample rate of the input signal x.
      new_sr (int): sample rate of the output.
      zeros (int): number of zero crossing to keep in the sinc filter.
      rolloff (float): use a lowpass filter that is `rolloff * new_sr / 2`,
          to ensure sufficient margin due to the imperfection of the FIR filter used.
          Lowering this value will reduce anti-aliasing, but will reduce some of the
          highest frequencies.
  
  Shape:
  
      - Input: `[*, T]`
      - Output: `[*, T']` with `T' = int(new_sr * T / old_sr)
  
  
  .. caution::
      After dividing `old_sr` and `new_sr` by their GCD, both should be small
      for this implementation to be fast.
  
  >>> import torch
  >>> resample = ResampleFrac(4, 5)
  >>> x = torch.randn(1000)
  >>> print(len(resample(x)))
  1250
docstr_tok: ["Args",":","old_sr","(","int",")",":","sample","rate","of","the","input","signal","x.","new_sr","(","int",")",":","sample","rate","of","the","output",".","zeros","(","int",")",":","number","of","zero","crossing","to","keep","in","the","sinc","filter",".","rolloff","(","float",")",":","use","a","lowpass","filter","that","is","`","rolloff","*","new_sr","\/","2","`",",","to","ensure","sufficient","margin","due","to","the","imperfection","of","the","FIR","filter","used",".","Lowering","this","value","will","reduce","anti-aliasing",",","but","will","reduce","some","of","the","highest","frequencies",".","Shape",":","-","Input",":","`","[","*",",","T","]","`","-","Output",":","`","[","*",",","T","'","]","`","with","`","T","'","=","int","(","new_sr","*","T","\/","old_sr",")","..","caution",":",":","After","dividing","`","old_sr","`","and","`","new_sr","`","by","their","GCD",",","both","should","be","small","for","this","implementation","to","be","fast",".",">",">",">","import","torch",">",">",">","resample","=","ResampleFrac","(","4",",","5",")",">",">",">","x","=","torch.randn","(","1000",")",">",">",">","print","(","len","(","resample","(","x",")",")",")","1250"]
code: def __init__(
      self,
      old_sr: int,
      new_sr: int,
      zeros: int = 24,
      rolloff: float = 0.945,
  ):
      """
      Args:
          old_sr (int): sample rate of the input signal x.
          new_sr (int): sample rate of the output.
          zeros (int): number of zero crossing to keep in the sinc filter.
          rolloff (float): use a lowpass filter that is `rolloff * new_sr / 2`,
              to ensure sufficient margin due to the imperfection of the FIR filter used.
              Lowering this value will reduce anti-aliasing, but will reduce some of the
              highest frequencies.
  
      Shape:
  
          - Input: `[*, T]`
          - Output: `[*, T']` with `T' = int(new_sr * T / old_sr)
  
  
      .. caution::
          After dividing `old_sr` and `new_sr` by their GCD, both should be small
          for this implementation to be fast.
  
      >>> import torch
      >>> resample = ResampleFrac(4, 5)
      >>> x = torch.randn(1000)
      >>> print(len(resample(x)))
      1250
      """
      super().__init__()
      if not isinstance(old_sr, int) or not isinstance(new_sr, int):
          raise ValueError("old_sr and new_sr should be integers")
      gcd = math.gcd(old_sr, new_sr)
      self.old_sr = old_sr // gcd
      self.new_sr = new_sr // gcd
      self.zeros = zeros
      self.rolloff = rolloff
  
      self._init_kernels()
  
file_path: julius/julius/resample.py
imports: import math
  from typing import Optional
  import torch
  from torch.nn import functional
  from .core import sinc
  from .utils import simple_repr
label_desc: Use image node_id 1 to create a new ResampleFrac object from inherited base classes: torch.nn with example: obj = ResampleFrac(old_sr, new_sr, zeros, rolloff)