Filter löschen
Filter löschen

Simple if else for buffer speech

4 Ansichten (letzte 30 Tage)
Hamzah amee
Hamzah amee am 5 Nov. 2014
Beantwortet: Balavignesh am 3 Jul. 2024 um 5:55
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

Antworten (1)

Balavignesh
Balavignesh am 3 Jul. 2024 um 5:55
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

Kategorien

Mehr zu Audio I/O and Waveform Generation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by