예제 #1
0
 def __init__(self, ir_path="/tmp/ir", p=0.5):
     """
     :param ir_path: Path to a folder that contains one or more wav files of impulse
     responses. No other files should reside in this folder. Must be str or a Path instance.
     :param p:
     """
     super().__init__(p)
     self.ir_files = read_dir(ir_path)
예제 #2
0
 def __init__(self, ir_path="/tmp/ir", p=0.5):
     """
     :param ir_path: Path to a folder that contains one or more wav files of impulse
     responses. Must be str or a Path instance.
     :param p:
     """
     super().__init__(p)
     self.ir_files = read_dir(ir_path)
     self.ir_files = [
         p
         for p in self.ir_files
         if Path(p).suffix.lower() in {".flac", ".mp3", ".ogg", ".wav"}
     ]
     assert len(self.ir_files) > 0
예제 #3
0
 def __init__(self, sounds_path=None, min_snr_in_db=3, max_snr_in_db=30, p=0.5):
     """
     :param sounds_path: Path to a folder that contains sound files to randomly mix in. These
         files can be flac, mp3, ogg or wav.
     :param min_snr_in_db: Minimum signal-to-noise ratio in dB
     :param max_snr_in_db: Maximum signal-to-noise ratio in dB
     :param p:
     """
     super().__init__(p)
     self.sound_file_paths = read_dir(sounds_path)
     self.sound_file_paths = [
         p
         for p in self.sound_file_paths
         if Path(p).suffix.lower() in {".flac", ".mp3", ".ogg", ".wav"}
     ]
     assert len(self.sound_file_paths) > 0
     self.min_snr_in_db = min_snr_in_db
     self.max_snr_in_db = max_snr_in_db
예제 #4
0
    def __init__(
        self,
        sounds_path=None,
        min_snr_in_db=0,
        max_snr_in_db=24,
        min_time_between_sounds=4.0,
        max_time_between_sounds=16.0,
        burst_probability=0.22,
        min_pause_factor_during_burst=0.1,
        max_pause_factor_during_burst=1.1,
        min_fade_in_time=0.005,
        max_fade_in_time=0.08,
        min_fade_out_time=0.01,
        max_fade_out_time=0.1,
        p=0.5,
    ):
        """
        :param sounds_path: Path to a folder that contains sound files to randomly mix in. These
            files can be flac, mp3, ogg or wav.
        :param min_snr_in_db: Minimum signal-to-noise ratio in dB. A lower value means the added
            sounds/noises will be louder.
        :param max_snr_in_db: Maximum signal-to-noise ratio in dB. A lower value means the added
            sounds/noises will be louder.
        :param min_time_between_sounds: Minimum pause time between the added sounds/noises
        :param max_time_between_sounds: Maximum pause time between the added sounds/noises
        :param burst_probability: The probability of adding an extra sound/noise that overlaps
        :param min_pause_factor_during_burst: Min value of how far into the current sound (as
            fraction) the burst sound should start playing. The value must be greater than 0.
        :param max_pause_factor_during_burst: Max value of how far into the current sound (as
            fraction) the burst sound should start playing. The value must be greater than 0.
        :param min_fade_in_time: Min sound/noise fade in time in seconds. Use a value larger
            than 0 to avoid a "click" at the start of the sound/noise.
        :param max_fade_in_time: Min sound/noise fade out time in seconds. Use a value larger
            than 0 to avoid a "click" at the start of the sound/noise.
        :param min_fade_out_time: Min sound/noise fade out time in seconds. Use a value larger
            than 0 to avoid a "click" at the end of the sound/noise.
        :param max_fade_out_time: Max sound/noise fade out time in seconds. Use a value larger
            than 0 to avoid a "click" at the end of the sound/noise.
        :param p: The probability of applying this transform
        """
        super().__init__(p)
        self.sound_file_paths = read_dir(sounds_path)
        self.sound_file_paths = [
            p
            for p in self.sound_file_paths
            if Path(p).suffix.lower() in {".flac", ".mp3", ".ogg", ".wav"}
        ]
        assert len(self.sound_file_paths) > 0
        assert min_snr_in_db <= max_snr_in_db
        assert min_time_between_sounds <= max_time_between_sounds
        assert 0.0 < burst_probability <= 1.0
        if burst_probability == 1.0:
            assert (
                min_pause_factor_during_burst > 0.0
            )  # or else an infinite loop will occur
        assert 0.0 < min_pause_factor_during_burst <= 1.0
        assert max_pause_factor_during_burst > 0.0
        assert max_pause_factor_during_burst >= min_pause_factor_during_burst
        assert min_fade_in_time >= 0.0
        assert max_fade_in_time >= 0.0
        assert min_fade_in_time <= max_fade_in_time
        assert min_fade_out_time >= 0.0
        assert max_fade_out_time >= 0.0
        assert min_fade_out_time <= max_fade_out_time

        self.min_snr_in_db = min_snr_in_db
        self.max_snr_in_db = max_snr_in_db
        self.min_time_between_sounds = min_time_between_sounds
        self.max_time_between_sounds = max_time_between_sounds
        self.burst_probability = burst_probability
        self.min_pause_factor_during_burst = min_pause_factor_during_burst
        self.max_pause_factor_during_burst = max_pause_factor_during_burst
        self.min_fade_in_time = min_fade_in_time
        self.max_fade_in_time = max_fade_in_time
        self.min_fade_out_time = min_fade_out_time
        self.max_fade_out_time = max_fade_out_time
예제 #5
0
 def __init__(self, ir_path="/tmp/ir", p=0.5):
     super().__init__(p)
     self.ir_files = read_dir(ir_path)