function i=boy_or_girl(s)
limit=360;
fs=16000;
OMG=4000*pi;
k=1000;
omg=linspace(0,OMG-OMG/k,k);
l=length(s);
piece=500;
r=5;
t=linspace(0,r*(piece-1)/fs,r*piece);
W=1/fs*exp(-1i*kron(omg',t));
F=zeros(k,1);
for i=1:l/piece
sample=s((i-1)*piece+1:i*piece);
F=F+abs(W*repmat(sample,r,1))/l*piece;
end
[~,f]=max(F);
justify=f*OMG/k/2/pi;
if justify<limit
display 'boy'
i=0;
else
display 'girl'
i=1;
end
end
为啥是360啊?
limit=360;
fs=16000;
OMG=4000*pi;
k=1000;
omg=linspace(0,OMG-OMG/k,k);
l=length(s);
piece=500;
r=5;
t=linspace(0,r*(piece-1)/fs,r*piece);
W=1/fs*exp(-1i*kron(omg',t));
F=zeros(k,1);
for i=1:l/piece
sample=s((i-1)*piece+1:i*piece);
F=F+abs(W*repmat(sample,r,1))/l*piece;
end
[~,f]=max(F);
justify=f*OMG/k/2/pi;
if justify<limit
display 'boy'
i=0;
else
display 'girl'
i=1;
end
end
为啥是360啊?