def transform_audio(self, audio_segment):
    'Add background noise audio.\n\n        Note that this is an in-place transformation.\n\n        :param audio_segment: Audio segment to add effects to.\n        :type audio_segment: AudioSegmenet|SpeechSegment\n        '
    noise_json = self._rng.choice(self._noise_manifest, 1, replace=False)[0]
    if (noise_json['duration'] < audio_segment.duration):
        raise RuntimeError('The duration of sampled noise audio is smaller than the audio segment to add effects to.')
    diff_duration = (noise_json['duration'] - audio_segment.duration)
    start = self._rng.uniform(0, diff_duration)
    end = (start + audio_segment.duration)
    noise_segment = AudioSegment.slice_from_file(noise_json['audio_filepath'], start=start, end=end)
    snr_dB = self._rng.uniform(self._min_snr_dB, self._max_snr_dB)
    audio_segment.add_noise(noise_segment, snr_dB, allow_downsampling=True, rng=self._rng)
Add background noise audio.

Note that this is an in-place transformation.

:param audio_segment: Audio segment to add effects to.
:type audio_segment: AudioSegmenet|SpeechSegment
def transform_audio(self, audio_segment):
    'Add background noise audio.\n\n        Note that this is an in-place transformation.\n\n        :param audio_segment: Audio segment to add effects to.\n        :type audio_segment: AudioSegmenet|SpeechSegment\n        '
    noise_json = self._rng.choice(self._noise_manifest, 1, replace=False)[0]
    if (noise_json['duration'] < audio_segment.duration):
        raise RuntimeError('The duration of sampled noise audio is smaller than the audio segment to add effects to.')
    diff_duration = (noise_json['duration'] - audio_segment.duration)
    start = self._rng.uniform(0, diff_duration)
    end = (start + audio_segment.duration)
    noise_segment = AudioSegment.slice_from_file(noise_json['audio_filepath'], start=start, end=end)
    snr_dB = self._rng.uniform(self._min_snr_dB, self._max_snr_dB)
    audio_segment.add_noise(noise_segment, snr_dB, allow_downsampling=True, rng=self._rng)