justify">% voice activity detection, it utilises the algorithm due to Rabiner &
% Sambur (1975)
= 0.1;% Initial silence duration in seconds = 0.01;% Frame width in seconds = 0.005;% Frame shift in seconds = 16000;% Sampling Frequency = 0; = 0; = 0; = 0 ; = 0;% Stores forward count of crossing rate> IZCT = 0;% As above, for backward count = 40;% Zero crossing comparison rate for threshold_sam = fix (Ts * Fs);% No of Samples/window_sam = fix (Tsh * Fs);% No of samples/overlap = length (x); = fix ((lengthX-w_sam)/o_sam) +1;% Number of segments in speech signal = fix ((Ini-Ts)/Tsh) +1;% Number of segments in silent period = hamming (w_sam); = o_sam * (segs-1) +1;% Start index of last segment
= 1: o_sam: Limit;% Vector containing starting index for each segment_Vector = zeros (1, segs);% Vector to hold zero crossing rate for all segments
% Below code computes and returns zero crossing rates for all segments in
% speech samplet = 1: segs = 0; = (t-1) * o_sam +1; r = nextIndex +1: (nextIndex + w_sam-1) (x (r)> = 0) && (x (r-1)> = 0)
(x (r)> = 0) && (x (r-1) <0) = ZCRCounter + 1; (x (r) <0) && ; (x (r-1) <0) (x (r) <0) && (x (r-1)> = 0) = ZCRCounter + 1; _Vector (t) = ZCRCounter;
% Below code computes and returns frame energy for all segments in speech
% sample_Vector = zeros (1, segs); u = 1: segs = (u-1) * o_sam +1; = x (nextIndex: nextIndex + w_sam-1). * win; _Vector (u) = sum (abs (Energy));
= mean (Erg_Vector (1: sil));% Mean silence energy (noise energy) = max (Erg_Vector);% Maximum energy for entire utterance = 0.03 * (IMX-IMN) + IMN; % I1 & I2 are Initial thresholds = 4 * IMN; = min (I1, I2);% Lower energy threshold = 5 * ITL;% Upper energy threshold = mean (ZCR_Vector (1: sil));% mean zero crossing rate for silence region = std (ZCR_Vector (1: sil));% standard deviation of crossing rate for
% silence region = min (ZTh, IZC +2 * stdev);% Zero crossing rate threshold = zeros (1, lengthX);% Four single-row vectors are created = indexi;% in these lines to facilitate computation below = indexi; = indexi;
% Search forward for frame with energy greater than ITUi = 1: length (Erg_Vector) (Erg_Vector (i)> ITU) = counter1 + 1; (counter1) = i; = indexi (1) ;
% Search further forward for frame with energy greater than ITLj = ITUs: -1:1 (Erg_Vector (j)
_Vectorf = fliplr (Erg_Vector);% Flips round the energy vector
% Search forward for frame with energy greater than ITU
% This is equivalent to searching backward from last sample for energy> ITUk = 1: length (Erg_Vectorf) (Erg_Vectorf (k)> ITU) = counter3 + 1; (counter3) = k; = i...