pykanto.utils.types#

Pykanto typing module: provides a) custom type hints not already covered in other modules and b) classes whose main purpose is data storage and/or type checking.

Functions

f_exists(instance, attribute, f)

File exists validator for attr.s decorator.

is_list_of_int(instance, attribute, f)

Validator for attr.s decorator.

is_list_of_str(instance, attribute, f)

Validator for attr.s decorator.

Classes

Annotation(ID, start_times, durations, ...)

Combines segment annotations and audio metadata.

AttrProto(*args, **kwargs)

Inherit to silence attr related errors in Pyrigh

AudioAnnotation(sample_rate, bit_rate, ...)

Type-checks and stores audio metadata.

Chunkinfo(n_workers, len_iterable, n_chunks, ...)

Stores information about a chunked iterable.

Chunkinfo_

alias of pykanto.utils.types.Chunkinfo

Metadata(sample_rate, bit_rate, length_s, ...)

Type-checks and stores metadata for ONE audio segment (e.g.

SegmentAnnotation(ID, start_times, ...)

Type-checks and stores annotations necessary to segment regions of interest present in an audio file (e.g.

ValidDirs(PROJECT, RAW_DATA, DATASET_ID)

Type check user input before instantiating main ProjDirs class.

pykanto.utils.types.is_list_of_int(instance, attribute, f)[source]#

Validator for attr.s decorator.

pykanto.utils.types.is_list_of_str(instance, attribute, f)[source]#

Validator for attr.s decorator.

pykanto.utils.types.f_exists(instance, attribute, f: pathlib.Path)[source]#

File exists validator for attr.s decorator.

class pykanto.utils.types.AttrProto(*args, **kwargs)[source]#

Inherit to silence attr related errors in Pyrigh

__init__(*args, **kwargs)#
class pykanto.utils.types.ValidDirs(PROJECT: Path, RAW_DATA: Path, DATASET_ID: str)[source]#

Type check user input before instantiating main ProjDirs class.

PROJECT: pathlib.Path#
RAW_DATA: pathlib.Path#
DATASET_ID: str#
__init__(PROJECT: Path, RAW_DATA: Path, DATASET_ID: str) None#
class pykanto.utils.types.SegmentAnnotation(ID: str, start_times: List[int], durations: List[int], end_times: List[int], lower_freq: List[int], upper_freq: List[int], label: List[str], annotation_file: Path)[source]#

Type-checks and stores annotations necessary to segment regions of interest present in an audio file (e.g. songs or song bouts).

ID: str#
start_times: List[int]#
durations: List[int]#
end_times: List[int]#
lower_freq: List[int]#
upper_freq: List[int]#
label: List[str]#
annotation_file: pathlib.Path#
__init__(ID: str, start_times: List[int], durations: List[int], end_times: List[int], lower_freq: List[int], upper_freq: List[int], label: List[str], annotation_file: Path) None#
class pykanto.utils.types.AudioAnnotation(sample_rate: int, bit_rate: int, length_s: float, source_wav: Path)[source]#

Type-checks and stores audio metadata.

sample_rate: int#
bit_rate: int#
length_s: float#
source_wav: pathlib.Path#
__init__(sample_rate: int, bit_rate: int, length_s: float, source_wav: Path) None#
class pykanto.utils.types.Annotation(ID: str, start_times: List[int], durations: List[int], end_times: List[int], lower_freq: List[int], upper_freq: List[int], label: List[str], annotation_file: Path, sample_rate: int, bit_rate: int, length_s: float, source_wav: Path)[source]#

Combines segment annotations and audio metadata.

__init__(ID: str, start_times: List[int], durations: List[int], end_times: List[int], lower_freq: List[int], upper_freq: List[int], label: List[str], annotation_file: Path, sample_rate: int, bit_rate: int, length_s: float, source_wav: Path) None#
ID: str#
start_times: List[int]#
durations: List[int]#
end_times: List[int]#
lower_freq: List[int]#
upper_freq: List[int]#
label: List[str]#
annotation_file: pathlib.Path#
class pykanto.utils.types.Metadata(sample_rate: int, bit_rate: int, length_s: float, ID: str, label: str, start: int, end: int, lower_freq: int, upper_freq: int, max_amplitude: float, min_amplitude: float, source_wav: str, annotation_file: str, wav_file: str)[source]#

Type-checks and stores metadata for ONE audio segment (e.g. a song or song bout). Type checks ensure that instances of this class are JSON-serializable as a dictionary.

ID: str#
label: str#
start: int#
end: int#
lower_freq: int#
upper_freq: int#
max_amplitude: float#
min_amplitude: float#
source_wav: str#
annotation_file: str#
wav_file: str#
__init__(sample_rate: int, bit_rate: int, length_s: float, ID: str, label: str, start: int, end: int, lower_freq: int, upper_freq: int, max_amplitude: float, min_amplitude: float, source_wav: str, annotation_file: str, wav_file: str) None#
pykanto.utils.types.Chunkinfo_#

alias of pykanto.utils.types.Chunkinfo

class pykanto.utils.types.Chunkinfo(n_workers, len_iterable, n_chunks, chunksize, last_chunk)[source]#

Stores information about a chunked iterable.