%% Part-2 Tutorial on Singing Transcription (by ) %% % This is the part-3 tutorial on singing transcription from polyphonic music, for . % This part will focus on evaluation on singing transcription. % You should have read and before reading this part. %% Preprocessing % Before we start, let's add necessary toolboxes to the search path of MATLAB: addpath d:/users/jang/matlab/toolbox/utility addpath d:/users/jang/matlab/toolbox/sap addpath d:/users/jang/matlab/toolbox/machineLearning %% % All the above toolboxes can be downloaded from . % Make sure you are using the latest toolboxes to work with this script. %% % For compatibility, here we list the platform and MATLAB version that we used to run this script: fprintf('Platform: %s\n', computer); fprintf('MATLAB version: %s\n', version); fprintf('Date & time: %s\n', char(datetime)); scriptStartTime=tic; % Timing for the whole script %% ST evaluation of a song % Here we want to focus on the evaluation of singing transcription on a single song. % We have put every component for doing so in a file "goTestOne.m", as follows: type goTestOne.m %% % We can run the above script to see how it goes: goTestOne %% ST evaluation of MIR-ST500 dataset % Then we can perform the evaluation over all songs in MIR-ST500 dataset, as follows: % Get all groundtruth files melody=dir('d:/dataSet/public/MIR-ST500/*/*_groundtruth.txt'); melodyCount=length(melody); fprintf('melodyCount=%d\n', melodyCount); % Get song ID for i=1:melodyCount items=split(melody(i).name, '_'); melody(i).songId=eval(items{1}); end % Ordered by songID songId=[melody.songId]; [sorted, index]=sort(songId); melody=melody(index); % Read each feature file and perform singing transcription myTic=tic; for i=1:melodyCount gtFilePath=fullfile(melody(i).folder, melody(i).name); % Read the groundtruth melody(i).noteGt=noteFileRead(gtFilePath); % Read the feature file feaFilePath=fullfile(melody(i).folder, sprintf('%d_feature.json', melody(i).songId)); fea=jsondecode(fileread(feaFilePath)); pv.pitch=fea.vocal_pitch; pv.time=fea.time; melody(i).notePredicted=pv2note(pv, opt); melody(i).fMeasure=noteVecSim(melody(i).notePredicted, melody(i).noteGt); fprintf('%d/%d: file=%s, f-measure=%g\n', i, melodyCount, gtFilePath, melody(i).fMeasure); end fprintf('Time for pv2note() and noteVecSim(): %g sec\n', toc(myTic)); fprintf('Overall f-measure=%g\n', mean([melody.fMeasure])); %% % Since the above procedure will be invoked many times for iterative % performance optimization, we shall use several function to finish the % above task. First of all, let's read the dataset all at once: dsDir='d:/dataSet/public/MIR-ST500'; [melody, time]=stDsRead(dsDir); % Read the dataset fprintf('Time for reading "%s" = %g sec\n', dsDir, time); %% % Then we can try to do note detection: opt=stDsPredict('defaultOpt'); [melody02, time]=stDsPredict(melody, opt, 1); % Evaluate the performance fprintf('Elapsed time=%g sec.\n', time); %% % Then we can start performance evaluation: opt=stDsPerfEval('defaultOpt'); [perf, time]=stDsPerfEval(melody02, opt, 1); % Evaluate the performance fprintf('Average f-measure=%g, elapsed time=%g sec.\n', perf, time); %% Summary % This is a brief tutorial on singing transcription. % There are several directions for further improvement: % % * Explore other features from the original audio files % * Use other models, such as LSTM, RNN, GRU, etc. % %% Appendix % List of functions, scripts, and datasets used in this script: % % * <../list.asp List of files in this folder> % %% % Date and time when finishing this script: fprintf('Date & time: %s\n', char(datetime)); %% % Overall elapsed time: toc(scriptStartTime) %% % , created on datetime %% % If you are interested in the original MATLAB code for this page, you can % type "grabcode(URL)" under MATLAB, where URL is the web address of this % page.