function [overallRr, speakerSet1, time]=sidPerfEval(speakerSet1, speakerSet2, sidOpt, showInfo) % Performance evaluation of speaker identification if nargin<4, showInfo=0; end myTic=tic; switch lower(sidOpt.method) case 'gmm' % ====== Speaker identification when the number of mixtures are varied goFrameRrWrtGaussianNum; goUtterRrWrtGaussianNum; return % ====== Speaker identification when number of mixtures = gaussianNumBest (obtained from goUtterRrWrtGaussianNum.m) %gaussianNumBestIndex=5; % This is specified only when goUtterRrWrtGaussianNum is not run goTrainGmm; goUtterRr; %goUtterRrOutsideTest; %goSegmentRr; % ====== Speaker verification %goSpeakerVerify; case 'dtw' speakerNum1=length(speakerSet1); % ====== Speaker ID by DTW for i=1:speakerNum1 tInit=clock; name=speakerSet1(i).name; if showInfo, fprintf('%d/%d: speaker=%s\n', i, speakerNum1, name); end for j=1:length(speakerSet1(i).sentence) % fprintf('\tsentence=%d ==> ', j); % t0=clock; fea=speakerSet1(i).sentence(j).fea; [speakerSet1(i).sentence(j).minDistance, speakerIndex, sentenceIndex, allDistance]=speakerIdDtw(fea, speakerSet2, sidOpt); computedName=speakerSet2(speakerIndex).name; % fprintf('computedName=%s, time=%.2f sec\n', computedName, etime(clock, t0)); speakerSet1(i).sentence(j).frameNum=size(speakerSet1(i).sentence(j).fea, 2); speakerSet1(i).sentence(j).correct=strcmp(name, computedName); speakerSet1(i).sentence(j).computedSpeakerIndex=speakerIndex; speakerSet1(i).sentence(j).computedSentenceIndex=sentenceIndex; speakerSet1(i).sentence(j).computedSentencePath=speakerSet2(speakerIndex).sentence(sentenceIndex).path; speakerSet1(i).sentence(j).allDistance=allDistance; % Record all distance for speaker verification end speakerSet1(i).correct=[speakerSet1(i).sentence.correct]; speakerSet1(i).rr=sum(speakerSet1(i).correct)/length(speakerSet1(i).correct); if showInfo, fprintf('\tRR for %s = %.2f%%, ave. time = %.2f sec\n', name, 100*speakerSet1(i).rr, etime(clock, tInit)/length(speakerSet1(i).sentence)); end end correct=[speakerSet1.correct]; overallRr=sum(correct)/length(correct); fprintf('Ovderall RR = %.2f%%\n', 100*overallRr); otherwise disp('Unknown method!'); end time=toc(myTic); if showInfo %% ====== Plotting % ====== Display each person's performance [~, index]=sort([speakerSet1.rr]); sortedspeakerSet1=speakerSet1(index); outputFile=sprintf('%s/personRrByDtw_dtwFunc=%s_rr=%f%%.htm', sidOpt.outputDir, sidOpt.dtwFunc, 100*overallRr); structDispInHtml(sortedspeakerSet1, sprintf('Performance of all persons (Overall RR=%.2f%%)', 100*overallRr), {'name', 'rr'}, [], outputFile); % ====== Display misclassified utterances sentenceData=[sortedspeakerSet1.sentence]; sentenceDataMisclassified=sentenceData(~[sentenceData.correct]); outputFile=sprintf('%s/sentenceMisclassifiedByDtw_dtwFunc=%s_rr=%f%%.htm', sidOpt.outputDir, sidOpt.dtwFunc, 100*overallRr); structDispInHtml(sentenceDataMisclassified, sprintf('Misclassified Sentences (Overall RR=%.2f%%)', 100*overallRr), {'path', 'computedSentencePath'}, {'path', 'computedSentencePath'}, outputFile); end