0001 function waveData=waveAssess4dir(wadParam)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 language=wadParam.language;
0018 tcpFile=wadParam.tcpFile;
0019 waveDir=wadParam.waveDir;
0020 labDir=wadParam.labDir;
0021 fileExtName=wadParam.fileExtName;
0022 errorLogFile=wadParam.errorLogFile;
0023
0024 if exist(labDir)~=7
0025 fprintf('You need to create the output directory "%s" first!\n', labDir);
0026 return;
0027 end
0028
0029 [date, time]=getDateTime;
0030 fid=fopen(errorLogFile, 'a'); fprintf(fid, 'date=%s, time=%s\n', date, time); fclose(fid);
0031
0032 fprintf('Reading %s\n', tcpFile);
0033 [textBaseName, text]=textread(tcpFile, '%s %s');
0034
0035 fprintf('Find text for each wave file in %s\n', waveDir);
0036 waveData=recursiveFileList(waveDir, fileExtName);
0037 waveNum=length(waveData);
0038 for i=1:waveNum
0039 [parentDir, waveData(i).baseName, ext, junk]=fileparts(waveData(i).path);
0040 index=find(strcmp(lower(waveData(i).baseName), lower(textBaseName)));
0041 if length(index)==1
0042 waveData(i).text=text{index};
0043 else
0044 waveData(i).text='';
0045 fprintf('Warning: No unique mapping for %s (i=%d)\n', waveData(i).path, i);
0046 end
0047 end
0048
0049 fprintf('Start forced alignment for each wave file in %s\n', waveDir);
0050 for i=1:waveNum
0051 waveFile=waveData(i).path;
0052 text=waveData(i).text;
0053 if isempty(text)
0054 continue;
0055 end
0056 if strcmp(language, 'english')
0057 text=strrep(text, '_', ' ');
0058 text=strrep(text, '%percent', 'percent');
0059 text=strrep(text, '%ampersand', 'ampersand');
0060 text=strrep(text, '.period', 'period');
0061 end
0062 labFile=[labDir, '/', waveData(i).baseName, '.lab'];
0063 if exist(labFile)==2
0064 continue;
0065 end
0066 fprintf('%d/%d: waveFile=%s, text=%s, labFile=%s\n', i, waveNum, waveFile, text, labFile);
0067 [cmObj, dosCmd, time, exeStatus, exeResult]=waveAssess(waveFile, text, language);
0068
0069 if ~isempty(cmObj)
0070 cm2labFile(cmObj, labFile);
0071 else
0072 lines=split(exeResult, 10);
0073 fid=fopen(errorLogFile, 'a'); fprintf(fid, '%s\t%s\n', waveData(i).baseName, lines{end}); fclose(fid);
0074 end
0075 end