neuralset.events.transforms.chunking.ChunkEvents¶
- class neuralset.events.transforms.chunking.ChunkEvents(*, infra: Backend | None = None, event_type_to_chunk: Literal['Audio', 'Video'], event_type_to_use: str | None = None, min_duration: float | None = None, max_duration: float = inf)[source][source]¶
This functions chunks long events (audio or video) into shorter events. It supports two modes:
Duration-based chunking (if event_type_to_use is None):
Each event of type event_type_to_chunk is split into consecutive chunks with duration between min_duration and max_duration.
Ensures that no chunk exceeds max_duration.
This avoids OOM errors when feeding long events into a deep learning model (e.g. Wav2Vec).
Example:
input: min_duration: 2 max_duration: 3 events: sound: [.......] out: events: sound1: [...] sound2: [....]
Split-based chunking (if
event_type_to_useis notNone):Events of type
event_type_to_chunkare split according to the train/val/test splits ofevent_type_to_use.Ensures each chunk respects
min_durationandmax_duration.Prevents data leakage when processing long events with a deep learning model (e.g. Wav2Vec.
Requires that the splits for
event_type_to_useare already assigned.
Example:
input: max_duration: 2 event_type_to_use: Word events: sound: [.......] word : [1112233] out: events: sound1: [..] sound2: [.] sound3: [..] sound4: [..]