% Main program for speaker identification by DTW % Roger Jang, 20090202 clear all; close all; more off; pack; addMyPath; timeInit=clock; sidOpt=sidOptSet; if exist(sidOpt.outputDir)~=7, mkdirs(sidOpt.outputDir); end % ====== Feature extration %delete([sidOpt.outputDir, '/speakerSet.mat']); % Delete old data goFeaExtract; % ====== Speaker ID by DTW for i=1:length(speakerSet1) name=speakerSet1(i).name; fprintf('%d/%d: speaker=%s\n', i, length(speakerSet1), name); for j=1:length(speakerSet1(i).sentence) fprintf('\tsentence=%d ==> ', j); fea=speakerSet1(i).sentence(j).fea; speakerNum=length(speakerSet2); speakerDist=inf*ones(1, speakerNum); for p=1:speakerNum sentenceNum=length(speakerSet2(p).sentence); sentenceDist=inf*ones(1, sentenceNum); for q=1:sentenceNum sentenceDist(q)=feval(sidOpt.dtwFunc, fea, speakerSet2(p).sentence(q).fea, 1, 1); end [speakerDist(p), sentenceIndex]=min(sentenceDist); end [minDist, speakerIndex]=min(speakerDist); computedName=speakerSet2(speakerIndex).name; fprintf('computedName=%s\n', computedName); 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; end speakerSet1(i).correct=[speakerSet1(i).sentence.correct]; speakerSet1(i).rr=sum(speakerSet1(i).correct)/length(speakerSet1(i).correct); fprintf('\tRR for %s = %.2f%%\n', name, 100*speakerSet1(i).rr); end correct=[speakerSet1.correct]; overallRr=sum(correct)/length(correct) fprintf('Ovderall RR = %.2f%%\n', 100*overallRr); % ====== Display each person's performance [junk, index]=sort([speakerSet1.rr]); sortedspeakerSet1=speakerSet1(index); outputFile=sprintf('%s/personRrByDtw_dtwFunc=%s_rr=%f%%.htm', sidOpt.outputDir, sidOpt.dtwFunc, 100*overallRr); structDispInHtml(sortedspeakerSet1, 'Performance of all persons', {'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, 'Misclassified Sentences', {'path', 'computedSentencePath'}, {'path', 'computedSentencePath'}, outputFile); fprintf('%s ===> %g seconds\n', mfilename, etime(clock, timeInit));