class_docstr: SpeedPerturbation
  
  The speed perturbation in kaldi uses sox-speed instead of sox-tempo,
  and sox-speed just to resample the input,
  i.e pitch and tempo are changed both.
  
  "Why use speed option instead of tempo -s in SoX for speed perturbation"
  https://groups.google.com/forum/#!topic/kaldi-help/8OOG7eE4sZ8
  
  Warning:
      This function is very slow because of resampling.
      I recommmend to apply speed-perturb outside the training using sox.
class_docstr_tok: ["SpeedPerturbation","The","speed","perturbation","in","kaldi","uses","sox-speed","instead","of","sox-tempo",",","and","sox-speed","just","to","resample","the","input",",","i.e","pitch","and","tempo","are","changed","both",".","``","Why","use","speed","option","instead","of","tempo","-s","in","SoX","for","speed","perturbation","''","https",":","\/\/groups.google.com\/forum\/","#","!","topic\/kaldi-help\/8OOG7eE4sZ8","Warning",":","This","function","is","very","slow","because","of","resampling",".","I","recommmend","to","apply","speed-perturb","outside","the","training","using","sox","."]
code: def __init__(
      self,
      lower=0.9,
      upper=1.1,
      utt2ratio=None,
      keep_length=True,
      res_type="kaiser_best",
      seed=None,
  ):
      self.res_type = res_type
      self.keep_length = keep_length
      self.state = numpy.random.RandomState(seed)
  
      if utt2ratio is not None:
          self.utt2ratio = {}
          # Use the scheduled ratio for each utterances
          self.utt2ratio_file = utt2ratio
          self.lower = None
          self.upper = None
          self.accept_uttid = True
  
          with open(utt2ratio, "r") as f:
              for line in f:
                  utt, ratio = line.rstrip().split(None, 1)
                  ratio = float(ratio)
                  self.utt2ratio[utt] = ratio
      else:
          self.utt2ratio = None
          # The ratio is given on runtime randomly
          self.lower = lower
          self.upper = upper
  
imports: import librosa
  import numpy
  import scipy
  import soundfile
  from espnet.utils.io_utils import SoundHDF5File
label_desc: Use image node_id 1 to create a new SpeedPerturbation object from inherited base classes: object with example: obj = SpeedPerturbation(lower, upper, utt2ratio, keep_length, res_type, seed)