divided an audio signal into no. of frames (segments) and Compute mean from each frame (segment) and then how to Concatenate each mean of a frame to obtain one feature vector

4 views (last 30 days)
[y, Fs] = audioread('F:\audio samples\car crashes\(resource)car_crash.wav');
N = length(y); % sample length
slength = N/Fs; % total time span of audio signal
t = linspace(0, N/Fs, N);
figure;
subplot(2,2,1);
plot(t, y); % pplots the audio
duration = round(0.04*Fs); %duration selected from 40 ms, how many samples in a frame
n_f=floor(N/Fs)+1; %how many frames are there
display(n_f);
temp=0; %temporary value
for i= 1: n_f
frames(i,:) =y (temp+1: temp+duration);
temp=temp+duration;
M{i} =mean(frames(i,:));%mean of (n_f) frames
display(M{i});
Mconcat = cat(1,M{i});
display(Mconcat);
  1 Comment
Walter Roberson
Walter Roberson on 18 Nov 2019
The title does not ask for 40 ms, it asks for 40 total frames.
The Mconcat you create should be the vector of means. You could eliminate some of the trouble by using
Mconcat = zeros(1,n_f);
for i = 1: n_f
frames(i,:) =y (temp+1: temp+duration);
temp=temp+duration;
Mconcat(i) = mean(frames(i,:));%mean of (n_f) frames
end

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!