peakerDataunction [recogRate, confusionMatrix, speakerSet]=speakerIdentify(speakerSet, gmm) % speakerIdentify: speaker identification using GMM parameters % Usage: [recogRate, confusionMatrix, speakerSet]=speakerIdentify(speakerSet, gmm) % speakerSet: structure array generated by speakerSetRead.m % gmm: GMM parameters % Roger Jang, 20070517 currDir=pwd; cd('c/int') % ====== Speaker identification using GMM parameters speakerNum=length(speakerSet); for i=1:speakerNum fprintf('%d/%d: Recognizing wave files by %s\n', i, speakerNum, speakerSet(i).name); for j=1:length(speakerSet(i).sentence) % fprintf('\t%d/%d: %s\n', j, length(speakerSet(i).sentence), speakerSet(i).sentence(j).path); waveFile=speakerSet(i).sentence(j).path; if exist('output.txt'), delete('output.txt'); end cmd=['speakerIdentifyIntC.exe ', waveFile, ' MFCC gmmList.txt output.txt']; [status, result]=dos(cmd); pause(0.1); % wait for the previous program to write files if ~exist('output.txt') fprintf('cmd=%s\n', cmd); fprintf('result=%s\n', result); keyboard end contents = textread('output.txt','%s','delimiter','\n','whitespace',''); contents(1)=[]; for k=1:length(contents) items=split(contents{k}, 9); cumLogProb(k)=eval(items{2}); end [maxProb, index]=max(cumLogProb); speakerSet(i).sentence(j).predictedSpeaker=index; speakerSet(i).sentence(j).cumLogProb=cumLogProb; end end cd(currDir); % ====== Compute confusion matrix and recognition rate confusionMatrix=zeros(speakerNum); for i=1:speakerNum, predictedSpeaker=[speakerSet(i).sentence.predictedSpeaker]; [index, count]=elementCount(predictedSpeaker); confusionMatrix(i, index)=count; end recogRate=sum(diag(confusionMatrix))/sum(sum(confusionMatrix));