function [ibegin,iend,sambegin,samend]=hearsegm (s,vad,lseg,rseg); % Syntax: [ibegin, iend, sambegin, samend]=hearsegm(s,vad,lseg,rseg); % or: [ibegin, iend, sambegin, samend]=hearsegm(s,vad); % % % Hear the segment of signal, separated by beeps. % s - signal vector % vad - vad variable: two lines - 1st - numbers of frames % 2nd - activity type % lseg - segment length (default 160) % rseg - overlapping (default 0) % ibegin - frames, where the active parts BEGIN % iend - frames, where the active parts END % sambegin - samples, where the active parts BEGIN % samend - samples, where the active parts END if(nargin==2), lseg=160; rseg=0; end wsh=lseg-rseg; [lines,L]=size(vad); if (lines~=2) error ('vad must have 2 lines.'); end % generate short sinus for separate ss=500 * sin( 2*pi*[0:200]*1000 / 8000); ss1=500 * sin( 2*pi*[0:200]*1000*2^(5/12) / 8000); ss2=500 * sin( 2*pi*[0:200]*2000 / 8000); sambegin=[]; samend=[]; ibegin=[]; iend=[]; thisend=0; %disp('press a key after each segment'); % cycle on the segments for i=1:L, thisbegin=thisend+1; thisend=thisbegin+vad(1,i)-1; activity=vad(2,i); if activity==0, write16000('/tmp/rien', ss); % low tone for silence else write16000('/tmp/rien', ss1); % high tone for silence activity end begin=(thisbegin-1) * wsh + 1; eend=(thisend-1) * wsh + lseg; write16000('/tmp/rien', s(begin:eend) ); if activity==1, % output only for active. sambegin=[sambegin begin]; samend=[samend eend]; ibegin=[ibegin thisbegin]; iend=[iend thisend]; end % pause(1); end write16000('/tmp/rien',ss2);