function optPath=waveDecode(wObj, vsdOpt, gmmcPrm, transProb, plotOpt, inputName) if nargin<1, wObj='\dataset\childSong4public\MIR-QBSH-corpus\waveFile\year2007/person00001/00011.wav'; end if nargin<2, vsdOpt=vsdOptSet; end if nargin<5, plotOpt=0; end if nargin<6, inputName={'a', 'b'}; end if ischar(wObj), wObj=waveFile2obj(wObj); end % wObj is actual the wave file name [inData, outData, inputName, annotation]=wave2feature(wObj, vsdOpt); %load bestInputIndex.mat %inData=inData(bestInputIndex, :); %inputName=inputName(bestInputIndex); if vsdOpt.useInputNormalize==1 error('This is not implemneted yet!\n'); end [feaDim, frameNum]=size(inData); gmmNum=length(gmmcPrm.gmm); % ====== Create state prob stateProb=zeros(gmmNum, frameNum); for i=1:gmmNum stateProb(i,:)=gmmEval(inData, gmmcPrm.gmm(i).gmmPrm); end % ====== Add initial state prob initStateProb=[0; -inf]; % Initial log prob: SU=0, V=-inf stateProb(:,1)=stateProb(:,1)+initStateProb; % ====== Run DP [maxProb, optPath, hmmTable]=dpOverMap(stateProb, transProb, 0); optPath=optPath(2,:)'; if plotOpt sampleTime=(1:length(wObj.signal))'/wObj.fs; frameTime=frame2sampleIndex(1:frameNum, vsdOpt.frameSize, vsdOpt.overlap)'; subplot(5,1,1); plot(sampleTime, wObj.signal); title(strPurify4label(['Waveform of ', wObj.file])); subplot(5,1,2); plot(frameTime, inData', '.-'); set(gca, 'xlim', [-inf inf]); legend(inputName); title('Features'); subplot(5,1,3); plot(frameTime, stateProb, '.-'); legend('SU', 'V'); set(gca, 'xlim', [-inf inf]); title('State prob'); % pitched=1+(stateProb(:,2)-stateProb(:,1)>0); % subplot(5,1,4); plot(frameTime, outData, 'bo-', frameTime, optPath, 'k.-', frameTime, pitched, 'ro-'); legend('GT', 'Predcited', 'StateProb comp'); set(gca, 'xlim', [-inf inf]); subplot(5,1,4); plot(frameTime, outData, 'bo-', frameTime, optPath, 'k.-'); legend('GT', 'Predcited'); set(gca, 'xlim', [-inf inf]); title('Predicted and ground truth'); % subplot(6,1,5); imagesc(stateProb); axis xy subplot(5,1,5); imagesc(hmmTable); axis xy; title('HMM table'); end