crowsetta.formats.seq.audseq.AudSeq#
- class crowsetta.formats.seq.audseq.AudSeq(start_times: ndarray, end_times: ndarray, labels: ndarray, annot_path: Path, notated_path=None)[source]#
Bases:
object
Class meant to represent Audacity Labeltrack annotations exported to txt files in the standard format[1]_.
The txt file will have 3 tab-separated columns that represent the start time, end time, and labels of annotated regions.
- start_times#
Vector of integer sample numbers corresponding to beginning of segments, i.e. onsets.
- Type:
- end_times#
Vector of integer sample numbers corresponding to ends of segments, i.e. offsets.
- Type:
- labels#
Vector of string labels for segments; each element is either a single word, or a single phonetic transcription code.
- Type:
- annot_path#
Path to file from which annotations were loaded.
- Type:
- notated_path#
Path to file that
annot_path
annotates. E.g., an audio file, or an array file that contains a spectrogram generated from audio. Optional, default is None.- Type:
References
- __init__(start_times: ndarray, end_times: ndarray, labels: ndarray, annot_path: Path, notated_path=None) None #
Method generated by attrs for class AudSeq.
Methods
__init__
(start_times, end_times, labels, ...)Method generated by attrs for class AudSeq.
from_file
(annot_path[, notated_path])Load annotations from a file.
to_annot
([round_times, decimals])Convert this annotation to a
crowsetta.Annotation
.to_file
(annot_path)Save this 'aud-seq' annotation to a txt file in the standard/default Audacity LabelTrack format.
to_seq
([round_times, decimals])Convert this annotation to a
crowsetta.Sequence
.Attributes
- classmethod from_file(annot_path: str | bytes | PathLike | Path, notated_path: str | bytes | PathLike | Path | None = None) Self [source]#
Load annotations from a file.
- Parameters:
annot_path (str, pathlib.Path) – Path to an annotation file, with ‘.txt’ extension.
notated_path (str, pathlib.Path) – Path to file that
annot_path
annotates. E.g., an audio file, or an array file that contains a spectrogram generated from audio. Optional, default is None.
Examples
>>> example = crowsetta.data.get('aud-seq') >>> audseq = crowsetta.formats.seq.AudSeq.from_file(example.annot_path)
- to_annot(round_times: bool = True, decimals: int = 3) Annotation [source]#
Convert this annotation to a
crowsetta.Annotation
.- Parameters:
- Returns:
annot
- Return type:
Examples
>>> example = crowsetta.data.get('aud-seq') >>> audseq = crowsetta.formats.seq.AudSeq.from_file(example.annot_path) >>> annot = audseq.to_annot()
Notes
The
round_times
anddecimals
arguments are provided to reduce differences across platforms due to floating point error, e.g. when loading annotation files and then sending them to a csv file, the result should be the same on Windows and Linux.
- to_file(annot_path: str | bytes | PathLike | Path) None [source]#
Save this ‘aud-seq’ annotation to a txt file in the standard/default Audacity LabelTrack format.
- Parameters:
annot_path (str, pathlib.Path) – Path with filename of txt file that should be saved.
- to_seq(round_times: bool = True, decimals: int = 3) Sequence [source]#
Convert this annotation to a
crowsetta.Sequence
.- Parameters:
- Returns:
seq
- Return type:
Examples
>>> example = crowsetta.data.get('aud-seq') >>> audseq = crowsetta.formats.seq.AudSeq.from_file(example.annot_path) >>> seq = audseq.to_seq()
Notes
The
round_times
anddecimals
arguments are provided to reduce differences across platforms due to floating point error, e.g. when loading annotation files and then sending them to a csv file, the result should be the same on Windows and Linux.