How to add arrow line and text on graph plot?

59 次查看(过去 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.
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)');

回答(1 个)

Joseph
Joseph 2017-11-21
编辑:Joseph 2017-11-21
Hi, have a look here. It seems to refer to this which seems to do what you are asking for.
You can also use the annotation function.

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by