Пример #1
0
    def test_full_shift_no_shorter_cuts(self, feature_set):
        cut_set = make_windowed_cuts_from_features(feature_set=feature_set,
                                                   cut_duration=5.0)

        assert len(cut_set) == 191
        assert len([c for c in cut_set if c.recording_id == 'rec-1']) == 120
        assert len([c for c in cut_set if c.recording_id == 'rec-2']) == 71

        assert all(c.duration == 5.0 for c in cut_set)
Пример #2
0
    def test_full_shift_with_shorter_cuts(self, feature_set):
        cut_set = make_windowed_cuts_from_features(feature_set=feature_set,
                                                   cut_duration=5.0,
                                                   keep_shorter_windows=True)

        assert len(cut_set) == 192
        assert len([c for c in cut_set if c.recording_id == 'rec-1']) == 120
        assert len([c for c in cut_set if c.recording_id == 'rec-2']) == 72

        assert not all(c.duration == 5.0 for c in cut_set)
Пример #3
0
    def test_half_shift_no_shorter_cuts(self, feature_set):
        cut_set = make_windowed_cuts_from_features(feature_set=feature_set,
                                                   cut_duration=5.0,
                                                   cut_shift=2.5)

        assert len(cut_set) == 380
        # below, the last window is only 2.5s duration
        assert len([c for c in cut_set if c.recording_id == 'rec-1']) == 239
        # below, the last two windows are 2.0s and 4.5s duration
        assert len([c for c in cut_set if c.recording_id == 'rec-2']) == 141

        assert all(c.duration == 5.0 for c in cut_set)
Пример #4
0
    def test_half_shift_with_shorter_cuts(self, feature_set):
        cut_set = make_windowed_cuts_from_features(
            feature_set=feature_set,
            cut_duration=5.0,
            cut_shift=2.5,
            keep_shorter_windows=True,
        )

        assert len(cut_set) == 383
        assert len([c for c in cut_set if c.recording_id == "rec-1"]) == 240
        assert len([c for c in cut_set if c.recording_id == "rec-2"]) == 143

        assert not all(c.duration == 5.0 for c in cut_set)
Пример #5
0
def windowed(feature_manifest: Pathlike, output_cut_manifest: Pathlike,
             cut_duration: float, cut_shift: Optional[float],
             keep_shorter_windows: bool):
    """
    Create a CutSet stored in OUTPUT_CUT_MANIFEST from feature regions in FEATURE_MANIFEST.
    The feature matrices are traversed in windows with CUT_SHIFT increments, creating cuts of constant CUT_DURATION.
    """
    feature_set = FeatureSet.from_json(feature_manifest)
    cut_set = make_windowed_cuts_from_features(
        feature_set=feature_set,
        cut_duration=cut_duration,
        cut_shift=cut_shift,
        keep_shorter_windows=keep_shorter_windows)
    cut_set.to_json(output_cut_manifest)