Home > asr > waveDir2fea.m

waveDir2fea

PURPOSE ^

waveDir2fea: Convert a directory of a wave files to a directory of feature files

SYNOPSIS ^

function waveData=waveDir2fea(waveDir, feaDir)

DESCRIPTION ^

 waveDir2fea: Convert a directory of a wave files to a directory of feature files
    Usage: waveDir2fea(waveDir, feaDir)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function waveData=waveDir2fea(waveDir, feaDir)
0002 % waveDir2fea: Convert a directory of a wave files to a directory of feature files
0003 %    Usage: waveDir2fea(waveDir, feaDir)
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'];    % Put fea files according to the path of wav files
0014 %    feaFile=fullfile(parentDir, [main, '.fea']);
0015 %    feaFile=sprintf('%s/%.5d.fea', feaDir, i);                 % Put fea files based on sequential numbering
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 %    fprintf('\tdosCmd=%s\n', dosCmd);
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)    % Check if there is any error
0030         waveData(i).success=0;
0031     else
0032 %{
0033         % HCopy.exe does not recognize some offending file names. Try other methods by copying files to other temp files.
0034         % Unfortunately, these files are not recognized by recog.exe either!
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 % ====== Self demo
0056 function selfdemo
0057 waveDir='D:\dataset\【中科院】keywordSpotting\waveFile';
0058 feaDir='D:\dataset\【中科院】keywordSpotting\feaFile';
0059 waveDir2fea(waveDir, feaDir);

Generated on Tue 01-Jun-2010 09:50:19 by m2html © 2003