pykanto.utils.custom#

This module contains functions for parsing custom metadata files. Currently: Sonic Visualiser XML files and Chipper .gzip files.

Functions

chipper_units_to_json(directory[, n_fft, ...])

Reads audio unit segmentation metadata from .gzip files output by Chipper and appends them to pykanto .JSON metadata files.

open_gzip(file)

Reads syllable segmentation generated with Chipper.

parse_sonic_visualiser_xml(xml_filepath)

Parses an xml annotation file generated by Sonic Visualiser and returns a SegmentAnnotation.

pykanto.utils.custom.parse_sonic_visualiser_xml(xml_filepath: pathlib.Path) pykanto.utils.types.SegmentAnnotation[source]#

Parses an xml annotation file generated by Sonic Visualiser and returns a SegmentAnnotation.

Note

The individual ID string = folder name + file name + segment index.

Parameters

xml_filepath (Path) – Path to xml file.

Returns

Object with relevant metadata.

Return type

SegmentAnnotation

pykanto.utils.custom.open_gzip(file: pathlib.Path) Tuple[Dict[str, Any], Dict[str, List[int]], float][source]#

Reads syllable segmentation generated with Chipper.

Parameters

file (Path) – Path to the .gzip file.

Returns

Tuple containing two dictionaries (the first contains chipper parameters, the second has two keys [‘Onsets’, ‘Offsets’]) and a parameter ‘timeAxisConversion’.

Return type

Tuple[Dict[str, Any], Dict[str, List[int]], float]

pykanto.utils.custom.chipper_units_to_json(directory: pathlib.Path, n_fft: int = 1024, overlap: int = 1010, pad: int = 150, window_offset: bool = True, overwrite_json: bool = False, pbar: bool = True)[source]#

Reads audio unit segmentation metadata from .gzip files output by Chipper and appends them to pykanto .JSON metadata files.

Parameters
  • directory (Path) – _description_

  • n_fft (int, optional) – _description_. Defaults to 1024.

  • overlap (int, optional) – _description_. Defaults to 1010.

  • pad (int, optional) – _description_. Defaults to 150.

  • window_offset (bool, optional) – _description_. Defaults to True.

  • overwrite_json (bool, optional) – _description_. Defaults to False.

  • pbar (bool, optional) – _description_. Defaults to True.

Raises

FileExistsError – _description_