crowsetta.formats.seq.generic.GenericSeq#
- class crowsetta.formats.seq.generic.GenericSeq(annots: List[Annotation])[source]#
Bases:
object
Class that represents annotations from a generic format, meant to be an abstraction of any sequence-like format.
Consists of
crowsetta.Annotation`s, each with a :class:`crowsetta.Sequence
made up of :class:`crowsetta.Segment`s.Other formats that convert to :class:`~crowsetta.Annotation`s with :class:`~crowsetta.Sequence`s can be converted to this format.
- annots#
A
list
ofcrowsetta.Annotation
instances.- Type:
- __init__(annots: List[Annotation]) None #
Method generated by attrs for class GenericSeq.
Methods
__init__
(annots)Method generated by attrs for class GenericSeq.
from_file
(annot_path)Load annotations in 'generic-seq' format from a csv file.
to_annot
()Returns this set of
crowsetta.Annotation
instances as alist
.to_df
([abspath, basename])Convert these annotations to a :type:`pandas.DataFrame`.
to_file
(annot_path[, abspath, basename])Write these annotations to a csv file in
'generic-seq'
format.to_seq
()Return a
list
ofcrowsetta.Sequence
instances, one for every annotation.Attributes
- classmethod from_file(annot_path: str | bytes | PathLike | Path) Self [source]#
Load annotations in ‘generic-seq’ format from a csv file.
- Parameters:
annot_path (str, pathlib.Path) – Path to csv file containing annotations saved in the
'generic-seq'
format.
Examples
>>> example = crowsetta.data.get('generic-seq') >>> generic = crowsetta.formats.seq.GenericSeq.from_file(example.annot_path)
- to_annot() List[Annotation] [source]#
Returns this set of
crowsetta.Annotation
instances as alist
.This is the same as accessing the
list
ofcrowsetta.Annotation
instances directly. The method is implemented so that this class conforms with thecrowsetta.interface.seq.SeqLike
interface.Examples
>>> example = crowsetta.data.get('generic-seq') >>> generic = crowsetta.formats.seq.GenericSeq.from_file(example.annot_path) >>> annots = generic.to_annot()
- to_df(abspath: bool = False, basename: bool = False) DataFrame [source]#
Convert these annotations to a :type:`pandas.DataFrame`.
- abspathbool
If True, converts filename for each audio file into absolute path. Default is False.
- basenamebool
If True, discard any information about path and just use file name. Default is False.
- to_file(annot_path: str | bytes | PathLike | Path, abspath: bool = False, basename: bool = False) None [source]#
Write these annotations to a csv file in
'generic-seq'
format.- Parameters:
annot_path (str, pathlib.Path) – Path including filename of csv file to write to, will be created (or overwritten if it exists already)
abspath (bool) – If True, converts filename for each audio file into absolute path. Default is False.
basename (bool) – If True, discard any information about path and just use file name. Default is False.