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:
objectClass 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_pathannotates. E.g., an audio file, or an array file that contains a spectrogram generated from audio. Optional, default is None.- Type:
Examples
>>> audseq = crowsetta.example('marron1') >>> print(audseq) AudSeq(start_times=array([ 0. , 0.76981817, 1.13127401, 2.21840074, 2.55502374, 3.09030949, 3.69457537, 3.81322118, 4.05603121, 4.86171904, 4.87551507, 5.52392822, 6.55587085, 6.59449972, 7.0883974 , 7.18772877, 7.23463526, 7.94375092, 9.01984083, 9.06950652, 9.18263392, 10.06282028, 10.07661631, 10.9705987 , 10.98715393, 11.80663778, 11.86458109, 12.19016727, 13.24142433, 13.277294 , 14.49686257, 14.60723076, 15.22805186, 15.31082801, 16.22136563, 17.25606747, 18.16660509, 18.20247475, 19.65381653, 19.75590711, 20.71059201, 20.78509054, 20.96719806, 21.02514137, 21.35624596, 21.45005892, 21.66527691, 21.67355452, 22.73860761, 22.82966137, 23.63534921, 24.59831172, 24.60383013, 24.67281025, 24.77214163, 25.68267925, 25.70751209, 26.65943778, 27.7410461 , 27.76036054, 28.34531198]), end_times=array([ 0.76981817, 1.13127401, 2.21840074, 2.55502374, 3.09030949, 3.69457537, 3.81322118, 4.05603121, 4.86171904, 4.87551507, 5.53496504, 6.55587085, 6.59449972, 7.0883974 , 7.18772877, 7.23463526, 7.94375092, 9.01984083, 9.06950652, 9.18263392, 10.06282028, 10.07661631, 10.9705987 , 10.98715393, 11.80663778, 11.86458109, 12.20396329, 13.24142433, 13.277294 , 14.49686257, 14.60723076, 15.22805186, 15.31082801, 16.22136563, 17.25606747, 18.16660509, 18.20247475, 19.65381653, 19.75590711, 20.71059201, 20.78509054, 20.96719806, 21.02514137, 21.35624596, 21.45005892, 21.66527691, 21.67355452, 22.73860761, 22.82966137, 23.63534921, 24.59831172, 24.60383013, 24.67281025, 24.77214163, 25.68267925, 25.70751209, 26.65943778, 27.7410461 , 27.76036054, 28.359108 , 29.10133412]), labels=<StringArray> [ 'SIL', 'call', 'SIL', 'call', 'SIL', 'Z', 'SIL', 'Ci', 'C', 'SIL', 'H', 'E', 'SIL', 'R', 'SIL', 'J1', 'J1', 'J2', 'J2', 'SIL', 'B1', 'SIL', 'B2', 'SIL', 'Q', 'SIL', 'H', 'E', 'SIL', 'R', 'SIL', 'O', 'SIL', 'J1', 'J2', 'L', 'SIL', 'N', 'SIL', 'A', 'SIL', 'O', 'SIL', 'P', 'SIL', 'K', 'SIL', 'V', 'SIL', 'J1', 'J2', 'SIL', 'J2', 'SIL', 'B1', 'SIL', 'B2', 'Q', 'SIL', 'H', 'E'] Length: 61, dtype: string, annot_path=PosixPath('/Users/davidnicholson/Documents/repos/vocalpy/crowsetta/src/crowsetta/examples/405_marron1_June_14_2016_69640887.audacity.txt'), notated_path=None) # noqa: E501
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_pathannotates. E.g., an audio file, or an array file that contains a spectrogram generated from audio. Optional, default is None.
Examples
>>> path = crowsetta.example('marron1', return_path=True) >>> audseq = crowsetta.formats.seq.AudSeq.from_file(path) >>> print(audseq) AudSeq(start_times=array([ 0. , 0.76981817, 1.13127401, 2.21840074, 2.55502374, 3.09030949, 3.69457537, 3.81322118, 4.05603121, 4.86171904, 4.87551507, 5.52392822, 6.55587085, 6.59449972, 7.0883974 , 7.18772877, 7.23463526, 7.94375092, 9.01984083, 9.06950652, 9.18263392, 10.06282028, 10.07661631, 10.9705987 , 10.98715393, 11.80663778, 11.86458109, 12.19016727, 13.24142433, 13.277294 , 14.49686257, 14.60723076, 15.22805186, 15.31082801, 16.22136563, 17.25606747, 18.16660509, 18.20247475, 19.65381653, 19.75590711, 20.71059201, 20.78509054, 20.96719806, 21.02514137, 21.35624596, 21.45005892, 21.66527691, 21.67355452, 22.73860761, 22.82966137, 23.63534921, 24.59831172, 24.60383013, 24.67281025, 24.77214163, 25.68267925, 25.70751209, 26.65943778, 27.7410461 , 27.76036054, 28.34531198]), end_times=array([ 0.76981817, 1.13127401, 2.21840074, 2.55502374, 3.09030949, 3.69457537, 3.81322118, 4.05603121, 4.86171904, 4.87551507, 5.53496504, 6.55587085, 6.59449972, 7.0883974 , 7.18772877, 7.23463526, 7.94375092, 9.01984083, 9.06950652, 9.18263392, 10.06282028, 10.07661631, 10.9705987 , 10.98715393, 11.80663778, 11.86458109, 12.20396329, 13.24142433, 13.277294 , 14.49686257, 14.60723076, 15.22805186, 15.31082801, 16.22136563, 17.25606747, 18.16660509, 18.20247475, 19.65381653, 19.75590711, 20.71059201, 20.78509054, 20.96719806, 21.02514137, 21.35624596, 21.45005892, 21.66527691, 21.67355452, 22.73860761, 22.82966137, 23.63534921, 24.59831172, 24.60383013, 24.67281025, 24.77214163, 25.68267925, 25.70751209, 26.65943778, 27.7410461 , 27.76036054, 28.359108 , 29.10133412]), labels=<StringArray> [ 'SIL', 'call', 'SIL', 'call', 'SIL', 'Z', 'SIL', 'Ci', 'C', 'SIL', 'H', 'E', 'SIL', 'R', 'SIL', 'J1', 'J1', 'J2', 'J2', 'SIL', 'B1', 'SIL', 'B2', 'SIL', 'Q', 'SIL', 'H', 'E', 'SIL', 'R', 'SIL', 'O', 'SIL', 'J1', 'J2', 'L', 'SIL', 'N', 'SIL', 'A', 'SIL', 'O', 'SIL', 'P', 'SIL', 'K', 'SIL', 'V', 'SIL', 'J1', 'J2', 'SIL', 'J2', 'SIL', 'B1', 'SIL', 'B2', 'Q', 'SIL', 'H', 'E'] Length: 61, dtype: string, annot_path=PosixPath('/Users/davidnicholson/Documents/repos/vocalpy/crowsetta/src/crowsetta/examples/405_marron1_June_14_2016_69640887.audacity.txt'), notated_path=None) # noqa: E501
- to_annot(round_times: bool = True, decimals: int = 3) Annotation[source]#
Convert this annotation to a
crowsetta.Annotation.- Parameters:
- Returns:
annot
- Return type:
Examples
>>> path = crowsetta.example('marron1') >>> audseq = crowsetta.formats.seq.AudSeq.from_file(path) >>> annot = audseq.to_annot()
Notes
The
round_timesanddecimalsarguments 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
>>> path = crowsetta.example('marron1') >>> audseq = crowsetta.formats.seq.AudSeq.from_file(path) >>> seq = audseq.to_seq()
Notes
The
round_timesanddecimalsarguments 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.