0001 function waveData=waveDir2fea(waveDir, feaDir)
0002
0003
0004
0005 if nargin<1, selfdemo; return; end
0006
0007 waveData=recursiveFileList(waveDir, 'wav');
0008 waveNum=length(waveData);
0009 for i=1:waveNum
0010 wavFile=waveData(i).path;
0011 [parentDir, main, ext, junk]=fileparts(wavFile);
0012 index=findstr(parentDir, '/');
0013 feaFile=[feaDir, '/', waveData(i).path(index(1)+1:end-3), 'fea'];
0014
0015
0016 [parentDir, junk, junk, junk]=fileparts(feaFile); mkdirs(parentDir);
0017 fprintf('%d/%d: wavFile=%s, feaFile=%s', i, waveNum, wavFile, feaFile);
0018 waveData(i).feaFile=feaFile;
0019 waveData(i).success=1;
0020 dosCmd=['d:\users\jang\batch\wav2fea.bat "', wavFile, '" "', feaFile, '"'];
0021
0022 if exist(feaFile)==2
0023 waveData(i).time=0;
0024 fprintf(', time=%.2f sec (fea file exists)\n', waveData(i).time);
0025 continue;
0026 end
0027 tic;
0028 [status, result]=dos(dosCmd);
0029 if ~isempty(result)
0030 waveData(i).success=0;
0031 else
0032
0033
0034
0035 fprintf('\n\tTry other methods for feature extraction...');
0036 mainName=tempname;
0037 wavFile2=[mainName, '.wav'];
0038 feaFile2=[mainName, '.fea'];
0039 copyfile(wavFile, wavFile2);
0040 dosCmd2=['d:\users\jang\batch\wav2fea.bat "', wavFile2, '" "', feaFile2, '"'];
0041 [status2, result2]=dos(dosCmd2);
0042 if isempty(result2)
0043 copyfile(feaFile2, feaFile);
0044 else
0045 waveData(i).success=0;
0046 fprintf('\tdosCmd2=%s\n', dosCmd);
0047 fprintf('\tresult2=%s\n', result);
0048 end
0049
0050 end
0051 waveData(i).time=toc;
0052 fprintf(', time=%.2f sec\n', waveData(i).time);
0053 end
0054
0055
0056 function selfdemo
0057 waveDir='D:\dataset\【中科院】keywordSpotting\waveFile';
0058 feaDir='D:\dataset\【中科院】keywordSpotting\feaFile';
0059 waveDir2fea(waveDir, feaDir);