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 apply(self, samples: NDArray[np.float32], sample_rate: int):
      num_samples = samples.shape[-1]
      noise_placeholder = np.zeros_like(samples)
  
      signal_mask = None
      gain_signal = self.signal_gain_db_during_noise != 0.0
      if gain_signal:
          signal_mask = np.zeros(shape=(num_samples,), dtype=np.float32)
  
      for sound_params in self.parameters["sounds"]:
          if sound_params["end"] < 0:
              # Skip a sound if it ended before the start of the input sound
              continue
  
          noise_samples, _ = self.__load_sound(
              sound_params["file_path"], sample_rate
          )
  
          if self.noise_transform:
              noise_samples = self.noise_transform(
                  noise_samples, sample_rate
              )
  
          # Apply fade in and fade out
          noise_gain = np.ones_like(noise_samples)
          fade_in_time_in_samples = int(
              sound_params["fade_in_time"] * sample_rate
          )
          fade_in_mask = np.linspace(
              0.0, 1.0, num=fade_in_time_in_samples
          )
          fade_out_time_in_samples = int(
              sound_params["fade_out_time"] * sample_rate
          )
          fade_out_mask = np.linspace(
              1.0, 0.0, num=fade_out_time_in_samples
          )
          noise_gain[: fade_in_mask.shape[0]] = fade_in_mask
          noise_gain[-fade_out_mask.shape[0] :] = np.minimum(
              noise_gain[-fade_out_mask.shape[0] :], fade_out_mask
          )
  
          start_sample_index = int(sound_params["start"] * sample_rate)
          end_sample_index = start_sample_index + len(noise_samples)
  
          if start_sample_index < 0:
              # crop noise_samples: shave off a chunk in the beginning
              num_samples_to_shave_off = abs(start_sample_index)
              noise_samples = noise_samples[num_samples_to_shave_off:]
              noise_gain = noise_gain[num_samples_to_shave_off:]
              start_sample_index = 0
  
          if end_sample_index > num_samples:
              # crop noise_samples: shave off a chunk in the end
              num_samples_to_shave_off = end_sample_index - num_samples
              end_index = len(noise_samples) - num_samples_to_shave_off
              noise_samples = noise_samples[:end_index]
              noise_gain = noise_gain[:end_index]
              end_sample_index = num_samples
  
          # Gain here describes just the gain from the fade in and fade out.
          noise_samples = noise_samples * noise_gain
  
          if self.noise_rms == "relative_to_whole_input":
              clean_rms = calculate_rms(samples)
          else:
              clean_rms = calculate_rms(
                  samples[start_sample_index:end_sample_index]
              )
  
          if self.include_silence_in_noise_rms_estimation:
              noise_rms = calculate_rms(noise_samples)
          else:
              noise_rms = calculate_rms_without_silence(
                  noise_samples, sample_rate
              )
  
          if noise_rms > 0:
              if self.noise_rms in [
                  "relative",
                  "relative_to_whole_input",
              ]:
                  desired_noise_rms = calculate_desired_noise_rms(
                      clean_rms, sound_params["snr_db"]
                  )
  
                  # Adjust the noise to match the desired noise RMS
                  noise_samples = noise_samples * (
                      desired_noise_rms / noise_rms
                  )
              elif self.noise_rms == "absolute":
                  desired_noise_rms_db = sound_params["rms_db"]
                  desired_noise_rms_amp = (
                      convert_decibels_to_amplitude_ratio(
                          desired_noise_rms_db
                      )
                  )
                  gain = desired_noise_rms_amp / noise_rms
                  noise_samples = noise_samples * gain
  
              noise_placeholder[
                  start_sample_index:end_sample_index
              ] += noise_samples
              if gain_signal:
                  signal_mask[
                      start_sample_index:end_sample_index
                  ] = np.maximum(
                      signal_mask[start_sample_index:end_sample_index],
                      noise_gain,
                  )
  
      if gain_signal:
          # Gain the original signal before mixing in the noises
          signal_mask *= self.signal_gain_db_during_noise
          signal_mask = convert_decibels_to_amplitude_ratio(signal_mask)
          return samples * signal_mask + noise_placeholder
      else:
          # Return a mix of the input sound and the added sounds
          return samples + noise_placeholder
  
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 4 for calling the AddShortNoises obj's underlying member method code with example usage: obj.apply(samples, sample_rate) and returns: unknown, unknown