📄 stanalysis.txt
字号:
[x]=wavread('3.wav');
figure;
subplot(4,1,1);
plot(x);
axis([1 length(x) -1 1]);
ylabel('Speech');
enhance=filter([1-0.9375],1,x);
FrameLen=240;
FrameInc=80;
yframe=enframe(x,FrameLen,FrameInc);
amp1=sum(abs(yframe),2);
subplot(4,1,2);
plot(amp1);
axis([1 length(amp1) 0 max(amp1)]);
ylabel('Energy');
legend('amp1=∑│x│');
amp2=sum(abs(yframe.*yframe),2);
subplot(4,1,3);
plot(amp2);
axis([1 length(amp2) 0 max(amp2)]);
ylabel('Energy');
legend('amp1=∑│x*x│');
%zcr=zeros(size(yframe,1),1)delta=0.02
%for i=1:size(yframe,1) x=yframe(i,:) for j=1:length(x)-1 if x(j)*x(j+1)<0 & abs(x(j)-x(j+1))>delta
% zcr(i)=zcr(i)+1 end endend
tmp1=enframe(x(1:end-1),FrameLen,FrameInc);
tmp2=enframe(x(2:end),FrameLen,FrameInc);
signs=(tmp1.*tmp2)<0;
diffs=(tmp1-tmp2)>0.02;
zcr=sum(signs.*diffs,2);
subplot(4,1,4);
plot(zcr);
axis([1 length(zcr) 0 max(zcr)]);
ylabel('ZCR');
legend('zcr');
[x]=wavread('3.wav');
figure;
subplot(4,1,1);
plot(x);
axis([1 length(x) -1 1]);
ylabel('Speech');
enhance=filter([1-0.9375],1,x);
FrameLen=240;
FrameInc=80;
yframe=enframe(x,FrameLen,FrameInc);
amp1=sum(abs(yframe),2);
subplot(4,1,2);
plot(amp1);
axis([1 length(amp1) 0 max(amp1)]);
ylabel('Energy');
legend('amp1=∑│x│');
amp2=sum(abs(yframe.*yframe),2);
subplot(4,1,3);
plot(amp2);
axis([1 length(amp2) 0 max(amp2)]);
ylabel('Energy');
legend('amp1=∑│x*x│');
zcr=zeros(size(yframe,1),1);
delta=0.02
for i=1:size(yframe,1);
a=yframe(i,:)
for j=1:length(a)-1
if a(j).*a(j+1)<0 & abs(a(j)-a(j+1))>delta
zcr(i)=zcr(i)+1
end
end
end
%tmp1=enframe(x(1:end-1),FrameLen,FrameInc);
%tmp2=enframe(x(2:end),FrameLen,FrameInc);
%signs=(tmp1.*tmp2)<0;
%diffs=(tmp1-tmp2)>0.02;
%zcr=sum(signs.*diffs,2);
subplot(4,1,4);
plot(zcr);
axis([1 length(zcr) 0 max(zcr)]);
ylabel('ZCR');
legend('zcr');
function f=enframe(x,win,inc)
%ENFRAME split signal up into (overlapping) frames: one per row. F=(X,WIN,INC)
%
% F = ENFRAME(X,LEN) splits the vector X up into
% frames. Each frame is of length LEN and occupies
% one row of the output matrix. The last few frames of X
% will be ignored if its length is not divisible by LEN.
% It is an error if X is shorter than LEN.
%
% F = ENFRAME(X,LEN,INC) has frames beginning at increments of INC
% The centre of frame I is X((I-1)*INC+(LEN+1)/2) for I=1,2,...
% The number of frames is fix((length(X)-LEN+INC)/INC)
%
% F = ENFRAME(X,WINDOW) or ENFRAME(X,WINDOW,INC) multiplies
% each frame by WINDOW(:)
% Copyright (C) Mike Brookes 1997
%
% Last modified Tue May 12 13:42:01 1998
%
% VOICEBOX home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You can obtain a copy of the GNU General Public License from
% ftp://prep.ai.mit.edu/pub/gnu/COPYING-2.0 or by writing to
% Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
nx=length(x);
nwin=length(win);
if (nwin == 1)
len = win;
else
len = nwin;
end
if (nargin < 3)
inc = len;
end
nf = fix((nx-len+inc)/inc);
f=zeros(nf,len);
indf= inc*(0:(nf-1)).';
inds = (1:len);
f(:) = x(indf(:,ones(1,len))+inds(ones(nf,1),:));
if (nwin > 1)
w = win(:)';
f = f .* w(ones(nf,1),:);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -