How to add arrow line and text on graph plot?
조회 수: 48 (최근 30일)
이전 댓글 표시
Hey there, I am newbie to MATLAB and working on speech processing where I have to detect Voice, Unvoiced And Silent Part of the Speech and marked it on the graph as shown in fig. automatically, part of the speech will be decided by the threshold value which is 0-0.1 for Voice part, 0.1-0.3 for voice and 0.3 to 1 for unvoiced part. Also I am attaching my project code for reference.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/169388/image.jpeg)
if true
[data, fs] = audioread('So.wav');
% normalize data
data = data / abs(max(data));
% do framing
f_d = 0.025;
f_size = round(f_d * fs);
n = length(data);
n_f = floor(n/f_size); %no. of frames
temp = 0;
for i = 1 : n_f
frames(i,:) = data(temp + 1 : temp + f_size);
temp = temp + f_size;
end
[r,c] = size(frames);
%ZCR Calculations
for i = 1 : r
x = frames(i, :);
ZCRf1(i) = 0;
for k = 1:length(x) - 1
if ((x(k) < 0) && (x(k + 1) > 0 ))
ZCRf1(i) = ZCRf1(i) + 1;
elseif ((x(k) > 0) && (x(k + 1) < 0))
ZCRf1(i) = ZCRf1(i) + 1;
end
end
end
% calculating rate
ZCRr1 = ZCRf1/length(x);
ZCRr1 = ZCRr1/max(ZCRr1);
f_size = round(f_d * fs);
zcr_wave = 0;
for j = 1 : length(ZCRr1)
l = length(zcr_wave);
zcr_wave(l : l + f_size) = ZCRr1(j);
end
% plot the ZCR with Signal
t = [0 : 1/fs : length(data)/fs]; % time in sec
t = t(1:end - 1);
t1 = [0 : 1/fs : length(zcr_wave)/fs];
t1 = t1(1:end - 1);
figure;
plot(t,data'); hold on;
plot(t1,zcr_wave,'r','LineWidth',1);
%Calculating Energy of the Signal
ste = 0;
for i = 1 : r
ste(i) = sum(frames(i,:).^2);
end
ste = ste./max(ste); %normalize the data
f_size = round(f_d * fs);
ste_wave = 0;
for j = 1 : length(ste)
l = length(ste_wave);
ste_wave(l : l + f_size) = ste(j);
end
% plot the STE with Signal
figure;
t = [0 : 1/fs : length(data)/fs]; % time in sec
t = t(1:end - 1);
t1 = [0 : 1/fs : length(ste_wave)/fs];
t1 = t1(1:end - 1);
plot(t,data'); hold on;
plot(t1,ste_wave,'r','LineWidth',2);
legend('Speech Signal','Short Term Energy (Frame Energy)');
댓글 수: 0
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!