Simple if else for buffer speech
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
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
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Signal Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!