def random_overlayed( supervision_manifest: Pathlike, feature_manifest: Pathlike, output_cut_manifest: Pathlike, random_seed: int, snr_range: Tuple[float, float], offset_range: Tuple[float, float] ): """ Create a CutSet stored in OUTPUT_CUT_MANIFEST that contains supervision regions from SUPERVISION_MANIFEST and features supplied by FEATURE_MANIFEST. It first creates a trivial CutSet, splits it into two equal, randomized parts and overlays their features to create a mix. The parameters of the mix are controlled via SNR_RANGE and OFFSET_RANGE. """ fix_random_seed(random_seed) supervision_set = SupervisionSet.from_yaml(supervision_manifest) feature_set = FeatureSet.from_yaml(feature_manifest) source_cut_set = make_cuts_from_supervisions(supervision_set=supervision_set, feature_set=feature_set) left_cuts, right_cuts = split(source_cut_set, num_splits=2, randomize=True) snrs = np.random.uniform(*snr_range, size=len(left_cuts)).tolist() relative_offsets = np.random.uniform(*offset_range, size=len(left_cuts)).tolist() overlayed_cut_set = CutSet.from_cuts( left_cut.overlay( right_cut, offset_other_by=left_cut.duration * relative_offset, snr=snr ) for left_cut, right_cut, snr, relative_offset in zip(left_cuts, right_cuts, snrs, relative_offsets) ) overlayed_cut_set.to_yaml(output_cut_manifest)
def simple( feature_manifest: Pathlike, output_cut_manifest: Pathlike, supervision_manifest: Optional[Pathlike], ): """ Create a CutSet stored in OUTPUT_CUT_MANIFEST that contains the regions and features supplied by FEATURE_MANIFEST. Optionally it can use a SUPERVISION_MANIFEST to select the regions and attach the corresponding supervisions to the cuts. This is the simplest way to create Cuts. """ feature_set = FeatureSet.from_yaml(feature_manifest) if supervision_manifest is None: cut_set = make_cuts_from_features(feature_set) else: supervision_set = SupervisionSet.from_yaml(supervision_manifest) cut_set = make_cuts_from_supervisions(feature_set=feature_set, supervision_set=supervision_set) cut_set.to_yaml(output_cut_manifest)
def make_feats( audio_manifest: Pathlike, output_dir: Pathlike, segmentation_manifest: Optional[Pathlike], # TODO: augmentation manifest should specify a number of transforms and probability of their application # e.g.: # "add_noise", "prob": 0.5, "noise_recordings": ["path1.wav", "path2.wav"] # "reverberate", "prob": 0.2, "rirs": ["rir1.wav", "rir2.wav"] (or however the RIRs are stored like... can be params for simulation) augmentation_manifest: Optional[Pathlike], feature_manifest: Optional[Pathlike], compressed: bool, lilcom_tick_power: int, root_dir: Optional[Pathlike], num_jobs: int): """ Extract features for recordings in a given AUDIO_MANIFEST. The features are stored in OUTPUT_DIR, with one file per recording (or segment). """ audio_set = RecordingSet.from_yaml(audio_manifest) feature_extractor = (FeatureExtractor.from_yaml(feature_manifest) if feature_manifest is not None else FeatureExtractor()) # TODO: to be used (actually, only the segmentation info will be used, and all supervision info will be ignored) supervision_set = (SupervisionSet.from_yaml(segmentation_manifest) if segmentation_manifest is not None else None) output_dir = Path(output_dir) output_dir.mkdir(exist_ok=True, parents=True) feature_set_builder = FeatureSetBuilder( feature_extractor=feature_extractor, output_dir=output_dir, root_dir=root_dir, augmentation_manifest=augmentation_manifest) feature_set_builder.process_and_store_recordings( recordings=audio_set, segmentation=None, # TODO: implement and use compressed=compressed, lilcom_tick_power=lilcom_tick_power, num_jobs=num_jobs)
def load_supervision_set(): return SupervisionSet.from_yaml('test/fixtures/supervision.yml')