def convert_jams(jams_file, output_prefix, csv=False, comment_char='<STR_LIT:#>', namespaces=None):
if namespaces is None:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>jam = jams.load(jams_file)<EOL>counter = collections.Counter()<EOL>annotations = []<EOL>for query in namespaces:<EOL><INDENT>annotations.extend(jam.search(namespace=query))<EOL><DEDENT>if csv:<EOL><INDENT>suffix = '<STR_LIT>'<EOL>sep = '<STR_LIT:U+002C>'<EOL><DEDENT>else:<EOL><INDENT>suffix = '<STR_LIT>'<EOL>sep = '<STR_LIT:\t>'<EOL><DEDENT>for ann in annotations:<EOL><INDENT>index = counter[ann.namespace]<EOL>counter[ann.namespace] += <NUM_LIT:1><EOL>filename = os.path.extsep.join([get_output_name(output_prefix,<EOL>ann.namespace,<EOL>index),<EOL>suffix])<EOL>comment = get_comments(jam, ann)<EOL>lab_dump(ann, comment, filename, sep, comment_char)<EOL><DEDENT>
Convert jams to labs.

    Parameters
    ----------
    jams_file : str
        The path on disk to the jams file in question

    output_prefix : str
        The file path prefix of the outputs

    csv : bool
        Whether to output in csv (True) or lab (False) format

    comment_char : str
        The character used to denote comments

    namespaces : list-like
        The set of namespace patterns to match for output