crowsetta.interface.seq.SeqLike#

class crowsetta.interface.seq.SeqLike[source]#

Bases: BaseFormat, ABC

An abstract base class defining the interface for any annotation format that can be represented as a sequence of segments, with each segment having an onset time, offset time, and a label.

In terms of code in crowsetta, a sequence-like format is any format that can be represented as a crowsetta.Sequence made up of crowsetta.Segment instances. The code block below shows some of the features of these data types.

>>> from crowsetta import Segment, Sequence
>>> a_segment = Segment(
...     label='a',
...     onset_sample=16000,
...     offset_sample=32000,
...     )
>>> another_segment = Segment(
...     label='b',
...     onset_sample=36000,
...     offset_sample=48000,
...     )
>>> list_of_segments = [a_segment, another_segment]
>>> seq = Sequence.from_segments(segments=list_of_segments)
>>> print(seq)
<Sequence with 2 segments>
>>> for segment in seq.segments: print(segment)
Segment(label='a', onset_s=None, offset_s=None, onset_ind=16000, offset_ind=32000)
Segment(label='b', onset_s=None, offset_s=None, onset_ind=36000, offset_ind=48000)
>>> seq.onset_inds
array([16000, 36000])
__init__()#

Methods

__init__()

from_file()

Loads an annotation from a file in a given format.

to_annot()

Converts the instance representing annotations loaded from a file into a crowsetta.Annotation or a list of Annotation instances, that can be used to convert to other formats.

to_seq()

Converts the annotation to a crowsetta.Sequence instance or a python sequence of ``crowsetta.Sequence``s (e.g., a list or tuple).

abstract classmethod from_file() Self#

Loads an annotation from a file in a given format.

abstract to_annot() crowsetta.Annotation | List[crowsetta.Annotation]#

Converts the instance representing annotations loaded from a file into a crowsetta.Annotation or a list of Annotation instances, that can be used to convert to other formats.

to_seq() crowsetta.Sequence | Sequence[crowsetta.Sequence][source]#

Converts the annotation to a crowsetta.Sequence instance or a python sequence of ``crowsetta.Sequence``s (e.g., a list or tuple).