Simple if else for buffer speech

2 次查看(过去 30 天)
Hamzah amee
Hamzah amee 2014-11-5
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

回答(1 个)

Balavignesh
Balavignesh 2024-7-3
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

类别

Help CenterFile Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by