Skip to content

dew.data.audio

Sound records: a media file’s audio over the window video.PickClip drew.

A sound file reads as a video’s track does, so a pure-audio dataset is video.PickClip then DecodeAudio. The reader is imported on use.

NameSummary
DecodeAudioThe sound of the media in field over the window under clip, widened by context seconds on either side, mono float32 in [-1, 1] at sample_rate under to, with {to}_valid marking the samples the track holds.

dataclass source

class DecodeAudio(
sample_rate: int = 16000,
*,
context: float = 0.0,
field: str = 'mp4',
clip: str = 'clip',
to: str = 'audio',
missing: Literal['reject', 'silence'] = 'reject',
rejects: bool = True,
)

The sound of the media in field over the window under clip, widened by context seconds on either side, mono float32 in [-1, 1] at sample_rate under to, with {to}_valid marking the samples the track holds. A file with no sound, or less than the window, is rejected under missing="reject" and filled with silence, marked invalid, under missing="silence"; a file that does not read is rejected under both.

rejects: bool

Whether a file that does not read, or under missing="reject" lacks sound, is dropped (filter_map) rather than an error.

external: bool

A file a record names by path is read from storage (dew.data.pipeline.External).

def declared(facts: Mapping[str, object]) -> Mapping[str, object]

Mono samples at sample_rate over the window and context either side, under to, with their validity: audio_seconds long.

def map(element: Batch) -> Batch | Rejected