matlab 音频 帧长,请教matlab语音分帧问题,求大神谢谢

完整代码在这里

len=2048;

semilen=len/2;

[filename,path]=uigetfile('*.wav','please select a wave file');  % read a wave file  打开音频文件

tic;

filename=strcat(path,filename);    %得到音乐文件名

[data,fs]=wavread(filename);     %读取音乐b

r=frame(len,semilen,data);

s=size(r,1);

r=r';

for i=1:s

r_fft(:,i)=abs(fft(r(:,i)));

r_window(:,i)=r_fft(:,i).*hamming(len);

end

for i=1:s

if i==1;

delta_r(:,i)=r_fft(:,i);

end

if i==2;

delta_r(:,i)=r_fft(:,i)-2*r_fft(:,i-1);

end

if i>=3;

delta_r(:,i)=r_fft(:,i)-2*r_fft(:,i-1)+r_fft(:,i-2);

end

end

for i=1:s

if i==1;

delta_r_two(:,i)=r_fft(:,i);

end

if i>=2;

delta_r_two(:,i)=r_fft(:,i)-r_fft(:,i-1);

end

end

for i=1:s

Dpd_r(:,i)=mean(abs(delta_r(:,i))+abs(delta_r_two(:,i)));

end

maxDpd_r=max(Dpd_r);

normalDpd_r=Dpd_r/maxDpd_r;

for i=1:s

if i==1;

ThersDpd_r(:,i)=mean(normalDpd_r(i)+normalDpd_r(i+1));

end

if i==s;

ThersDpd_r(:,i)=mean(normalDpd_r(i-1)+normalDpd_r(i));

end

if i>=2&&i<=s-1;

ThersDpd_r(:,i)=(normalDpd_r(i-1)+normalDpd_r(i)+normalDpd_r(i+1))/3;

end

end

for i=1:s

if normalDpd_r(i)-ThersDpd_r(i)>0;

Decide_Dpd_r(i)=Dpd_r(i);

end

if normalDpd_r(i)-ThersDpd_r(i)<=0;

Decide_Dpd_r(i)=0;

end

end

q=imregionalmax(Decide_Dpd_r);

q=double(q);

for i=1:length(q)

onset((i-1)*semilen+1)=q(i);

end

n=min(length(data),length(onset));

for i=1:n

oridata(i)=data(i);

orionset(i)=onset(i);

end

stem(orionset,'r');

hold on;

plot(oridata);

toc

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值