Created
April 2, 2024 15:18
-
-
Save bmcfee/6bb3f4381a309024fc3899c7aafcd0d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"id": "8d19f0b6", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import pandas as pd\n", | |
"import jams\n", | |
"from tqdm import tqdm\n", | |
"import mir_eval\n", | |
"from glob import glob\n", | |
"from pathlib import Path\n", | |
"import warnings\n", | |
"import numpy as np\n", | |
"import pickle" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"id": "39d4823b", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"jamses = jams.util.find_with_extension('/home/bmcfee/data/harmonixset/dataset/jams/', 'jams')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"id": "e7215256", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"100%|██████████| 912/912 [00:06<00:00, 141.69it/s]\n" | |
] | |
} | |
], | |
"source": [ | |
"unique_labels = set()\n", | |
"for fn in tqdm(jamses):\n", | |
" j = jams.load(fn, validate=False)\n", | |
" # get the segment annotation\n", | |
" ann = j.annotations['segment', 0]\n", | |
" \n", | |
" # get the intervals and labels\n", | |
" intervals, labels = ann.to_interval_values()\n", | |
" unique_labels |= set(labels)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"id": "acf38c83", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"{'altchorus',\n", | |
" 'bigoutro',\n", | |
" 'bre',\n", | |
" 'break',\n", | |
" 'break1',\n", | |
" 'break2',\n", | |
" 'break3',\n", | |
" 'breakdown',\n", | |
" 'breakdown2',\n", | |
" 'bridge',\n", | |
" 'bridge1',\n", | |
" 'bridge2',\n", | |
" 'bridge3',\n", | |
" 'build',\n", | |
" 'chorus',\n", | |
" 'chorus1',\n", | |
" 'chorus2',\n", | |
" 'chorus3',\n", | |
" 'chorus_instrumental',\n", | |
" 'chorushalf',\n", | |
" 'chorusinst',\n", | |
" 'choruspart',\n", | |
" 'drumroll',\n", | |
" 'end',\n", | |
" 'fadein',\n", | |
" 'fast',\n", | |
" 'gtr',\n", | |
" 'gtr2',\n", | |
" 'gtrbreak',\n", | |
" 'guitar',\n", | |
" 'guitarsolo',\n", | |
" 'inst',\n", | |
" 'inst2',\n", | |
" 'instbridge',\n", | |
" 'instchorus',\n", | |
" 'instintro',\n", | |
" 'instrumental',\n", | |
" 'instrumental2',\n", | |
" 'instrumental3',\n", | |
" 'instrumentalverse',\n", | |
" 'intchorus',\n", | |
" 'intro',\n", | |
" 'intro2',\n", | |
" 'intro3',\n", | |
" 'intro4',\n", | |
" 'intro5',\n", | |
" 'intro6',\n", | |
" 'intro7',\n", | |
" 'intro8',\n", | |
" 'introchorus',\n", | |
" 'intropt2',\n", | |
" 'introverse',\n", | |
" 'mainriff',\n", | |
" 'mainriff2',\n", | |
" 'miniverse',\n", | |
" 'oddriff',\n", | |
" 'opening',\n", | |
" 'outro',\n", | |
" 'outro1',\n", | |
" 'outro2',\n", | |
" 'outro3',\n", | |
" 'outroa',\n", | |
" 'postchorus',\n", | |
" 'postchorus2',\n", | |
" 'postverse',\n", | |
" 'prechorus',\n", | |
" 'prechorus2',\n", | |
" 'prechorus3',\n", | |
" 'prechorus5',\n", | |
" 'preverse',\n", | |
" 'quiet',\n", | |
" 'quietchorus',\n", | |
" 'raps',\n", | |
" 'refrain',\n", | |
" 'rhythmlessintro',\n", | |
" 'saxobeat',\n", | |
" 'section',\n", | |
" 'section1',\n", | |
" 'section10',\n", | |
" 'section11',\n", | |
" 'section12',\n", | |
" 'section13',\n", | |
" 'section14',\n", | |
" 'section15',\n", | |
" 'section16',\n", | |
" 'section17',\n", | |
" 'section2',\n", | |
" 'section3',\n", | |
" 'section4',\n", | |
" 'section5',\n", | |
" 'section6',\n", | |
" 'section7',\n", | |
" 'section8',\n", | |
" 'section9',\n", | |
" 'silence',\n", | |
" 'slow',\n", | |
" 'slow2',\n", | |
" 'slowverse',\n", | |
" 'solo',\n", | |
" 'solo2',\n", | |
" 'solo3',\n", | |
" 'stutter',\n", | |
" 'synth',\n", | |
" 'transition',\n", | |
" 'transition1',\n", | |
" 'transition2',\n", | |
" 'transition2a',\n", | |
" 'transition3',\n", | |
" 'verse',\n", | |
" 'verse1',\n", | |
" 'verse10',\n", | |
" 'verse11',\n", | |
" 'verse1a',\n", | |
" 'verse2',\n", | |
" 'verse3',\n", | |
" 'verse4',\n", | |
" 'verse5',\n", | |
" 'verse6',\n", | |
" 'verse7',\n", | |
" 'verse8',\n", | |
" 'verse9',\n", | |
" 'verse_slow',\n", | |
" 'verseinst',\n", | |
" 'versepart',\n", | |
" 'vocaloutro',\n", | |
" 'worstthingever'}" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"unique_labels" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"id": "93544703", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"MAPPING = {\n", | |
" 'altchorus': 'chorus',\n", | |
" 'bigoutro': 'outro',\n", | |
" r'(.*)\\d+.*': r'\\1',\n", | |
" '(.*)_instrumental': r'\\1',\n", | |
" 'chorus.*': 'chorus',\n", | |
" 'instbridge': 'bridge',\n", | |
" 'instchorus': 'chorus',\n", | |
" 'instintro': 'intro',\n", | |
" 'instrumentalverse': 'verse',\n", | |
" 'intropt2': 'intro',\n", | |
" 'miniverse': 'verse',\n", | |
" 'quietchorus': 'chorus',\n", | |
" 'rhythmlessintro': 'intro',\n", | |
" 'verse_slow': 'verse',\n", | |
" 'verseinst': 'verse',\n", | |
" 'versepart': 'verse',\n", | |
" 'vocaloutro': 'outro'\n", | |
"}\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"id": "f4137ab8", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"with open('../code/labelmapping.pickle', 'wb') as fd:\n", | |
" pickle.dump(MAPPING, fd)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "8d7ad578", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "lrr", | |
"language": "python", | |
"name": "lrr" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.9.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment