class FreqMasking(SpectrogramAugmenter): def __init__(self, num_masks=1, mask_factor=27, name="FreqMasking", verbose=0): super(FreqMasking, self).__init__( action=Action.SUBSTITUTE, zone=(0.2, 0.8), name=name, device="cpu", verbose=verbose, coverage=1., factor=(40, 80), silence=False, stateless=True) self.flow = Sequential([FreqMaskingAugmenter(mask_factor) for _ in range(num_masks)]) def substitute(self, data): return self.flow.augment(data)
class TimeMasking(SpectrogramAugmenter): def __init__(self, num_masks: int = 1, mask_factor: float = 100, p_upperbound: float = 1, name: str = "TimeMasking", verbose=0): super(TimeMasking, self).__init__(action=Action.SUBSTITUTE, zone=(0.2, 0.8), name=name, device="cpu", verbose=verbose, coverage=1., silence=False, stateless=True) self.flow = Sequential([ TimeMaskingAugmenter(mask_factor, p_upperbound) for _ in range(num_masks) ]) def substitute(self, data): return self.flow.augment(data)