Simple if else for buffer speech
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi, how can I display the required answer 'yes' or 'no' for each ZCR calculated on each buffer frame speech?
here is the coding. It only display 1 answer. I suppose to get 23 answers. Please help me.thanks a lot.
X=wavread('speech01_denoised.wav');
N=400;
Y = buffer(X,N);
s=sum(abs(diff(Y>0)))/length(Y);%ZCR
if s<=0
display('yes')
elseif (s>=0)
display('no')
end
0 comentarios
Respuestas (1)
Balavignesh
el 3 de Jul. de 2024
Hi Hamzah,
As per my understanding, you would like to display 'yes' or 'no' for wach Zero Crossing Rate (ZCR) calculated on each buffer frame of the speech signal. I suggest you iterate through each frame and calculate the 'ZCR' for each iteration. The number of frames is determined by the second dimension of the buffered matrix 'Y'. A 'for' loop iterates through each frame. This code will display 'yes' or 'no' for each of the 23 frames (or however many frames you have), based on the calculated ZCR for each frame.
Here's an example code snippet that could help you understand this better:
% Read the speech signal
[X, fs] = audioread('speech01_denoised.wav');
% Define the frame length
N = 400;
% Buffer the signal into frames
Y = buffer(X, N);
% Number of frames
numFrames = size(Y, 2);
% Loop through each frame to calculate ZCR and display 'yes' or 'no'
for i = 1:numFrames
frame = Y(:, i);
zcr = sum(abs(diff(frame > 0))) / length(frame); % Calculate ZCR
if zcr <= 0
disp(['Frame ', num2str(i), ': yes']);
else
disp(['Frame ', num2str(i), ': no']);
end
end
Hope that helps!
Balavignesh
0 comentarios
Ver también
Categorías
Más información sobre Signal Processing Toolbox en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!