jams.nsconvert.convert
- jams.nsconvert.convert(annotation, target_namespace)[source]
Convert a given annotation to the target namespace.
- Parameters:
- annotationjams.Annotation
An annotation object
- target_namespacestr
The target namespace
- Returns:
- mapped_annotationjams.Annotation
if annotation already belongs to target_namespace, then it is returned directly.
otherwise, annotation is copied and automatically converted to the target namespace.
- Raises:
- SchemaError
if the input annotation fails to validate
- NamespaceError
if no conversion is possible
Examples
Convert frequency measurements in Hz to MIDI
>>> ann_midi = jams.convert(ann_hz, 'note_midi')
And back to Hz
>>> ann_hz2 = jams.convert(ann_midi, 'note_hz')