class_docstr: Mix in various (bursts of overlapping) sounds with random pauses between. Useful if your
  original sound is clean and you want to simulate an environment where short noises sometimes
  occur.
  A folder of (noise) sounds to be mixed in must be specified.
class_docstr_tok: ["Mix","in","various","(","bursts","of","overlapping",")","sounds","with","random","pauses","between",".","Useful","if","your","original","sound","is","clean","and","you","want","to","simulate","an","environment","where","short","noises","sometimes","occur",".","A","folder","of","(","noise",")","sounds","to","be","mixed","in","must","be","specified","."]
code: def randomize_parameters(
      self, samples: NDArray[np.float32], sample_rate: int
  ):
      super().randomize_parameters(samples, sample_rate)
      if self.parameters["should_apply"]:
          input_sound_duration = len(samples) / sample_rate
  
          current_time = 0
          global_offset = random.uniform(
              -self.max_time_between_sounds,
              self.max_time_between_sounds,
          )
          current_time += global_offset
          sounds = []
  
          snr_db = random.uniform(self.min_snr_db, self.max_snr_db)
          rms_db = random.uniform(
              self.min_absolute_noise_rms_db,
              self.max_absolute_noise_rms_db,
          )
  
          while current_time < input_sound_duration:
              sound_file_path = random.choice(self.sound_file_paths)
              sound, _ = self.__load_sound(sound_file_path, sample_rate)
              sound_duration = len(sound) / sample_rate
  
              # Ensure that the fade time is not longer than the duration of the sound
              fade_in_time = min(
                  sound_duration,
                  random.uniform(
                      self.min_fade_in_time, self.max_fade_in_time
                  ),
              )
              fade_out_time = min(
                  sound_duration,
                  random.uniform(
                      self.min_fade_out_time, self.max_fade_out_time
                  ),
              )
  
              if not self.add_all_noises_with_same_level:
                  snr_db = random.uniform(
                      self.min_snr_db, self.max_snr_db
                  )
                  rms_db = random.uniform(
                      self.min_absolute_noise_rms_db,
                      self.max_absolute_noise_rms_db,
                  )
  
              sounds.append(
                  {
                      "fade_in_time": fade_in_time,
                      "start": current_time,
                      "end": current_time + sound_duration,
                      "fade_out_time": fade_out_time,
                      "file_path": sound_file_path,
                      "snr_db": snr_db,
                      "rms_db": rms_db,
                  }
              )
  
              # burst mode - add overlapping sounds
              while (
                  random.random() < self.burst_probability
                  and current_time < input_sound_duration
              ):
                  pause_factor = random.uniform(
                      self.min_pause_factor_during_burst,
                      self.max_pause_factor_during_burst,
                  )
                  pause_time = pause_factor * sound_duration
                  current_time = sounds[-1]["start"] + pause_time
  
                  if current_time >= input_sound_duration:
                      break
  
                  sound_file_path = random.choice(self.sound_file_paths)
                  sound, _ = self.__load_sound(
                      sound_file_path, sample_rate
                  )
                  sound_duration = len(sound) / sample_rate
  
                  fade_in_time = min(
                      sound_duration,
                      random.uniform(
                          self.min_fade_in_time, self.max_fade_in_time
                      ),
                  )
                  fade_out_time = min(
                      sound_duration,
                      random.uniform(
                          self.min_fade_out_time, self.max_fade_out_time
                      ),
                  )
  
                  if not self.add_all_noises_with_same_level:
                      snr_db = random.uniform(
                          self.min_snr_db, self.max_snr_db
                      )
                      rms_db = random.uniform(
                          self.min_absolute_noise_rms_db,
                          self.max_absolute_noise_rms_db,
                      )
  
                  sounds.append(
                      {
                          "fade_in_time": fade_in_time,
                          "start": current_time,
                          "end": current_time + sound_duration,
                          "fade_out_time": fade_out_time,
                          "file_path": sound_file_path,
                          "snr_db": snr_db,
                          "rms_db": rms_db,
                      }
                  )
  
              # wait until the last sound is done
              current_time += sound_duration
  
              # then add a pause
              pause_duration = random.uniform(
                  self.min_time_between_sounds,
                  self.max_time_between_sounds,
              )
              current_time += pause_duration
  
          self.parameters["sounds"] = sounds
  
file_path: audiomentations/audiomentations/augmentations/add_short_noises.py
imports: import functools
  import random
  import warnings
  from pathlib import Path
  from typing import Optional, List, Union, Callable
  import numpy
  from numpy.typing import NDArray
  from audiomentations.core.audio_loading_utils import load_sound_file
  from audiomentations.core.transforms_interface import BaseWaveformTransform
  from audiomentations.core.utils import calculate_desired_noise_rms, calculate_rms, calculate_rms_without_silence, convert_decibels_to_amplitude_ratio, find_audio_files_in_paths
label_desc: Use image node_id 3 for calling the AddShortNoises obj's underlying member method code with example usage: obj.randomize_parameters(samples, sample_rate) without return types