⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zrc.m

📁 matlab实现对声音信号短时能量
💻 M
字号:
%计算短时能量,过零率
clear all;
close all;
clc;
filename ='e:\2.wav';
[y,Fs,bits]=wavread(filename,[40000,120000]);
lefty = y(:,1);
subplot(3,1,1);
plot(lefty,'b');
hold on
set(gca,'FontName','Arial','FontSize',10);
title(['左声道声音波形']);
xlabel(['采样点数']);



subplot(3,1,2);
plot(lefty,'b');
hold on;

wavesize=length(y);
b =[-0.0113    0.0242   -0.0222    0.0066    0.0201   -0.0274    0.0052    0.0346   -0.0475    0.0056...
0.0729   -0.1106    0.0059    0.5481    0.5481    0.0059   -0.1106    0.0729    0.0056   -0.0475...
0.0346    0.0052   -0.0274    0.0201    0.0066   -0.0222    0.0242   -0.0113];
[h,w]= freqz(b,1,882);
 waveoutYuJiaZhong= filter([1  -0.9375],1,lefty);%低通滤波
waveoutspeech = filter(b,1,lefty);
plot(waveoutYuJiaZhong);
title(['滤波非语言前的时域波形']);
xlabel(['采样点数']);
subplot(3,1,3);
plot((waveoutspeech));
title(['滤波非语音后的时域波形']);
xlabel(['采样点数']);
figure;
plot(w,abs(h));
title(['滤波器的放大倍数']);
%帧长N和帧和数目FrameNumber
N=2*Fs/100
between=N/2;
FrameNumber = floor(wavesize/between)-1;
Tlefty=waveoutspeech ;
%短时能量
En=zeros(FrameNumber,1);


for ii=1:FrameNumber
    startPositon=(between)*(ii-1)+1;
    temp =Tlefty(startPositon:startPositon+N-1);
    temp = temp.*hamming(N);
    En(ii) = sum(temp.*temp);
end
%求能量的平均值
   

%================分帧过零率========================%
N=2*Fs/100
between=N/2;
FrameNumber =floor( wavesize/between)-2;
Tlefty=waveoutspeech ;
Zcr=zeros(FrameNumber,1);
delta = 0.0005;
for ii=1:FrameNumber
      startPositon=(between)*(ii-1)+1; 
    temp =Tlefty(startPositon:startPositon+N-1);
    temp = temp.*hamming(N); 
    for jj=2:N
        if(temp(jj)*temp(jj-1)<0 && (temp(jj)-temp(jj-1))>delta) 
%         if(temp(jj)*temp(jj-1)<0) 
           Zcr(ii)= Zcr(ii)+2;
        end
    end
end

figure;
jj=[1:FrameNumber];
subplot(3,1,1);
plot(lefty,'b');
title(['时域波形']);
xlabel(['采样点数']);
subplot(3,1,2);
plot(En);
title(['短时能量']);
xlabel(['帧数']);
subplot(3,1,3);
jj=[1:FrameNumber];
plot(Zcr);
title(['过零率']);
xlabel(['帧数']);



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -