vak.transforms.frame_labels.functional.to_labels¶
- vak.transforms.frame_labels.functional.to_labels(frame_labels: ndarray[Any, dtype[_ScalarType_co]], labelmap: dict, background_label: str = 'background') str [source]¶
Convert vector of frame labels to a string, one character for each continuous segment.
Allows for converting output of network from a label for each frame to one label for each continuous segment, in order to compute string-based metrics like edit distance.
- Parameters:
frame_labels (numpy.ndarray) – A vector where each element represents a label for a frame, either a single sample in audio or a single time bin from a spectrogram. Typically, the output of a neural network.
labelmap (dict) – That maps string labels to integers. The mapping is inverted to convert back to string labels.
background_label (str, optional) – The string label applied to segments belonging to the background class. Default is
vak.common.constants.DEFAULT_BACKGROUND_LABEL
.
- Returns:
labels – The label at the onset of each continuous segment in
frame_labels
, mapped back to string labels inlabelmap
.- Return type: