def __init__( self, sample_rate=16000, int_values=False, augmentor=None, rpyc_conn=None ): self.augmentor = augmentor if augmentor is not None else AudioAugmentor() self.sample_rate = sample_rate self.int_values = int_values self.remote_path_samples = rpyc_conn.get_path_samples
def _process_augmentations(self, augmentor) -> AudioAugmentor: augmentations = [] for augment_name, augment_kwargs in augmentor.items(): prob = augment_kwargs.get('prob', None) if prob is None: logging.error( f'Augmentation "{augment_name}" will not be applied as ' f'keyword argument "prob" was not defined for this augmentation.' ) else: _ = augment_kwargs.pop('prob') try: augmentation = perturbation_types[augment_name]( **augment_kwargs) augmentations.append([prob, augmentation]) except KeyError: logging.error( f"Invalid perturbation name. Allowed values : {perturbation_types.keys()}" ) augmentor = AudioAugmentor(perturbations=augmentations) return augmentor
def from_config(cls, input_config, perturbation_configs=None): if perturbation_configs is not None: aa = AudioAugmentor.from_config(perturbation_configs) else: aa = None sample_rate = input_config.get("sample_rate", 16000) int_values = input_config.get("int_values", False) return cls(sample_rate=sample_rate, int_values=int_values, augmentor=aa)
def __init__(self, sample_rate=16000, int_values=False, augmentor=None): self.augmentor = augmentor if augmentor is not None else AudioAugmentor( ) self.sample_rate = sample_rate self.int_values = int_values