function [rap,lab,fnamefromlist]=rap_1_sentence(name1,no,namelab,namelist) %function [rap,lab,fnamefromlist]=rap_1_sentence(name1,no,namelab,namelist) % % selects sentence number no from the rap file. No log, no minus - you % should do it yourself. % if name o flabel file is supplied, returns also the corresponding labels. % if a list file is supplied, returns the name of the file END_OF_SENTENCE =-1; ff1=fopen(name1,'r','b'); % big endian files perframe = fread(ff1,1,'int'); sent=0; frame=0; totframe = 0; % init empty matrices w/ probas X1=[]; while (~feof(ff1)) sentid = fread(ff1,1,'int'); % if end of sentence, plot and wait ! if (sentid == END_OF_SENTENCE) % if this is the sentence we want , quit the cycle and process ... if (sent == no) break end % make other necessary things at the end of a sentence X1=[]; totframe = totframe + frame; frame = 0; sent=sent+1; continue; end % ok, read the data x = fread(ff1,[1 perframe],'float'); X1 = [X1; x]; frame = frame +1; end fclose (ff1); %%%%%% process the sentence here %%%%%%%%%%%%%% rap = X1; %[sent totframe frame] % if we have the label file name, extract the labels ... if (nargin > 2 & ~isempty(namelab)) fflab = fopen(namelab,'r'); dummy = fscanf(fflab,'%d\n',totframe); lab = fscanf(fflab,'%d\n',frame); fclose (fflab); end % if we have the list file, if (nargin > 3 & ~isempty(namelist)) fflist = fopen(namelist,'r'); for ii=0:(sent-1) % this is discarding the previous ss=fscanf(fflist, '%s',[1 1]); end fnamefromlist=fscanf(fflist, '%s',[1 1]); fclose (fflist); end