clear variables

doread=1;
if doread
D=dir('*.txt');
nd=length(D);

fbuf=[];
bwbuf=[];
nform=[];
vlabel='';
slabel='';
for idi=1:nd
    myname=D(idi).name;
    disp(myname);
    ss=file2str(myname);
    nr=size(ss,1);
    for iri=1:nr
        sss=ss(iri,:);
        disp(iri);
        fguk='. F1-3:';
        bguk=' BW1-3:';
        ipif=findstr(fguk,sss);
        ipib=findstr(bguk,sss);
        if length(ipif)==1 & length(ipib)==1
            fstr=sss(ipif:(ipib-1));
            bwstr=sss(ipib:end);
            fstr=strrep(fstr,fguk,'');
            bwstr=strrep(bwstr,bguk,'');
            fw=str2num(fstr);
            bw=str2num(bwstr);
            numok=0;
            if length(fw)==3 & length(bw)==3 
                fbuf=[fbuf;fw];
                bwbuf=[bwbuf;bw];
                numok=1;
            end;
            if numok
                vguk='. Vowel: ';
                nfguk='. n_form.:';
                sguk='Speaker: ';
                ipiv=findstr(vguk,sss);
                ipinf=findstr(nfguk,sss);
                ipis=findstr(sguk,sss);
                vowstr=sss(ipiv:(ipinf-1));
                vowstr=strrep(vowstr,vguk,'');
                vowstr=strrep(vowstr,'schwa','@');
                if isempty(vlabel)
                    vlabel=vowstr;
                else
                    vlabel=str2mat(vlabel,vowstr);
                end;
                spkstr=sss(ipis:(ipiv-1));
                spkstr=strrep(spkstr,sguk,'');
                if isempty(slabel)
                    slabel=spkstr;
                else
                    slabel=str2mat(slabel,spkstr);
                end;
            end;
        end;
    end;
end;

save vowelresults_wise1213 fbuf bwbuf vlabel slabel
end;

load vowelresults_wise1213.mat 
plot(fbuf(:,2),fbuf(:,1),'.');
set(gca,'xdir','rev');
set(gca,'ydir','rev');
%keyboard;
vlabel=vlabel(:,1);
ht=text(fbuf(:,2),fbuf(:,1),vlabel,'fontsize',12,'fontweight','bold');

vv=find(vlabel=='i');
set(ht(vv),'color','r');
vv=find(vlabel=='a');
set(ht(vv),'color','g');
vv=find(vlabel=='u');
set(ht(vv),'color','b');
vv=find(vlabel=='y');
set(ht(vv),'color','m');
