def sonify(annotation, sr=<NUM_LIT>, duration=None, **kwargs):
length = None<EOL>if duration is None:<EOL><INDENT>duration = annotation.duration<EOL><DEDENT>if duration is not None:<EOL><INDENT>length = int(duration * sr)<EOL><DEDENT>if annotation.namespace in SONIFY_MAPPING:<EOL><INDENT>ann = coerce_annotation(annotation, annotation.namespace)<EOL>return SONIFY_MAPPING[annotation.namespace](ann,<EOL>sr=sr,<EOL>length=length,<EOL>**kwargs)<EOL><DEDENT>for namespace, func in six.iteritems(SONIFY_MAPPING):<EOL><INDENT>try:<EOL><INDENT>ann = coerce_annotation(annotation, namespace)<EOL>return func(ann, sr=sr, length=length, **kwargs)<EOL><DEDENT>except NamespaceError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>raise NamespaceError('<STR_LIT>'<EOL>.format(annotation.namespace))<EOL>
Sonify a jams annotation through mir_eval

    Parameters
    ----------
    annotation : jams.Annotation
        The annotation to sonify

    sr = : positive number
        The sampling rate of the output waveform

    duration : float (optional)
        Optional length (in seconds) of the output waveform

    kwargs
        Additional keyword arguments to mir_eval.sonify functions

    Returns
    -------
    y_sonified : np.ndarray
        The waveform of the sonified annotation

    Raises
    ------
    NamespaceError
        If the annotation has an un-sonifiable namespace