Wednesday, August 12, 2015

Remove silent region in audio signal

[ip,fs]=audioread('so1.wav');
%plot(ip);
% step 1 - break the signal into frames of 0.1 seconds
fs = 11000; % sampling frequency
frame_duration = 0.04;
frame_len = frame_duration*fs;
N = length(ip);
num_frames= floor(N/frame_len);

new_sig = zeros(N,1);
count=0;
for k = 1 : num_frames
    % extracting a frame of speech
    frame = ip( (k-1)*frame_len + 1 : frame_len*k );
    % step 2 - identify non silence frames by finding frames with max amplitute more than
    % 0.03
   
    max_val = max(frame);
    if(max_val > 0.03)
        count=count+1;
        new_sig((count-1)*frame_len + 1 : frame_len*count) = frame;
    end
end

new_sig(frame_len*count:end)=[];
 plot(new_sig);

No comments:

Post a Comment