Effacer les filtres
Effacer les filtres

how to find the number of points in audio?

2 vues (au cours des 30 derniers jours)
john
john le 14 Avr 2019
Commenté : Walter Roberson le 15 Avr 2019
point=200;
%Calculate the number of frames
n=floor(length(x)/point); %n takes the closest largest integer
enframe=zeros(point,n);%Initialize, one frame per column
how to find number of points in audio?

Réponse acceptée

Walter Roberson
Walter Roberson le 14 Avr 2019
Audio files do not inherently have "points".
The code you are using appears to be part of dividing a single channel of audio into a number of fixed-sized windows, and you are asking how to determine the window size. The appropriate size for a window depends upon the sampling frequency and upon what kind of operations you are doing with the windows.
Also, for audio, it is common to use overlapping windows in order to better match phases.
I recommend that you look at https://www.mathworks.com/help/signal/ref/buffer.html buffer() to do the work of creating windows from your signal, once you have figured out how big the window should be.
  2 commentaires
john
john le 15 Avr 2019
%[x,fs]=wavread('D:\speech_signal\pena.wav'); %Read audio file
the whole program is like that
[x,fs]= audioread('pena.wav');
%Normalized processing
c=max(abs(x));
x=x/c;
N=length(x);
t=(0:N-1)/fs;
subplot(211);
plot(t,x,'k');
xlabel('time/s');
ylabel('Amplitude');
title('Signal waveform');
axis([0 max(t) -1 1]);
grid;
point=200;
%Calculate the number of frames
n=floor(length(x)/point); %n takes the closest largest integer
enframe=zeros(point,n);%Initialize, one frame per column
% framing, 400 points per frame
for i=1:n;
for j=1:point;
enframe(j,i)=x(j+(i-1)*point);
end
end
%Calculate the short-term energy of each frame
for i=1:n;
energy_short(i)=sum(enframe(:,i).^2);%Take the ith column of all rows of the matrix
end
%Short-term energy normalization
% a=max(energy_short);
% energy_short=energy_short/a;
% finds the starting point of the voice. If the short-term energy is greater than 0.2, the frame at this time is used as the starting frame.
for i=1:n;
if energy_short(i)>0.2 break;
end
end
frame_begin=i;
begin=(i-1)*point+1%Starting point
%Find the end of speech
for i=n:-1:1;
if energy_short(i)>0.2 break;
end
end
last=i*point
x1=x(begin:last);
N=length(x1);
t=(0:N-1)/fs;
subplot(212);
plot(t,x1,'k');
xlabel('Time/s');
ylabel('Amplitude');
title('Waveform after endpoint detection');
axis([0 max(t) -1 1]);
grid;
Walter Roberson
Walter Roberson le 15 Avr 2019
The 200 (400 in the comments) and 0.2 cutoff are arbitrary, especially since you commented out the normalization. To get something that was not arbitrary you would need to have a calibrated system that you could calculate SPL (sound pressure level) from and you would combine that with information on studies on audibility in humans.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Audio I/O and Waveform Generation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by