def __init__(self, feature_extractor: FeatureExtractor, base_feats: np.ndarray, frame_shift: Seconds, padding_value: float = -1000.0): """ :param feature_extractor: The ``FeatureExtractor`` instance that specifies how to mix the features. :param base_feats: The features used to initialize the ``FeatureMixer`` are a point of reference in terms of energy and offset for all features mixed into them. :param frame_shift: Required to correctly compute offset and padding during the mix. :param padding_value: The value used to pad the shorter features during the mix. This value is adequate only for log space features. For non-log space features, e.g. energies, use either 0 or a small positive value like 1e-5. """ self.feature_extractor = feature_extractor self.tracks = [base_feats] self.gains = [] # Keep a pre-computed energy value of the features that we initialize the Mixer with; # it is required to compute gain ratios that satisfy SNR during the mix. self.frame_shift = frame_shift self.reference_energy = feature_extractor.compute_energy(base_feats) assert self.reference_energy > 0.0, \ f"To perform mix, energy must be non-zero and non-negative (got {self.reference_energy})" self.padding_value = padding_value self.dtype = self.tracks[0].dtype
def __init__(self, feature_extractor: FeatureExtractor, base_feats: np.ndarray, frame_shift: Seconds, log_energy_floor: float = -1000.0): """ :param feature_extractor: The ``FeatureExtractor`` that specifies how to mix the features. :param base_feats: The features used to initialize the ``FeatureMixer`` are a point of reference in terms of energy and offset for all features mixed into them. :param frame_shift: Required to correctly compute offset and padding during the mix. :param log_energy_floor: The value used to pad the shorter features during the mix. """ self.feature_extractor = feature_extractor # The mixing output will be available in self.mixed_feats self.mixed_feats = base_feats # Keep a pre-computed energy value of the features that we initialize the Mixer with; # it is required to compute gain ratios that satisfy SNR during the mix. self.frame_shift = frame_shift self.reference_energy = feature_extractor.compute_energy(base_feats) assert self.reference_energy > 0.0, \ f"To perform mix, energy must be non-zero and non-negative (got {self.reference_energy})" self.log_energy_floor = log_energy_floor