segment_calc_script.m 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. % segment_calc_script
  2. tmp=dir;
  3. nfiles=length(tmp);
  4. names=cell(nfiles,1); for j=1:nfiles, names(j)=cellstr(tmp(j).name); end;
  5. wavnames=regexp(names,'.*wav$','match');
  6. ind=~cellfun('isempty',wavnames);
  7. wavnames=wavnames(ind);
  8. segnames=regexp(names,'.*wav.seg.txt$','match');
  9. ind=~cellfun('isempty',segnames);
  10. segnames=segnames(ind);
  11. nwaves=length(wavnames);
  12. movingwin=[0.01 0.005];
  13. params.tapers=[2 3]; params.pad=1; params.Fs=44100; params.fpass=[5000 20000];
  14. F1=[]; F2=[]; F3=[]; F4=[]; F0=[]; C1=[]; C2=[];
  15. for i=1:nwaves,
  16. i
  17. % data=wavread(wavnames{i}{1});
  18. % [Feat S t f]= acoustic_features_MB(data,movingwin,params);
  19. sname=[wavnames{i}{1} '.sp'];
  20. load(char(sname),'-mat');
  21. C=fft(log(S),[],2); cep=real(C); C1=[C1 cep(:,2)']; C2=[C2 cep(:,3)'];
  22. x0=log(mean(S,2))/log(10)*10; x0=x0-max(x0); F0=[F0 x0'];
  23. x=log(Feat(:,1)); w=Feat(:,2)-x; x=x/log(10)*10; x=x-max(x);
  24. F1=[F1 x'];
  25. F2=[F2 w'];
  26. F3=[F3 Feat(:,3)'];
  27. tmp=load(char(segnames{i}(1))); sz=size(tmp);
  28. seg=zeros(length(t),1);
  29. if sz(1)>0,
  30. for j=1:sz(1), ind=find((t>tmp(j,1)) & (t<tmp(j,2))); seg(ind)=1; end
  31. end;
  32. F4=[F4 seg'];
  33. end
  34. tb=find(F4<1); ts=find(F4>0);
  35. F5=zeros(length(F0),1);
  36. F5(find(F0>-20))=1.1;
  37. F6=medfilt1(F5,5);