Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
初级会员
注册日期: 2008-05-24
年龄: 41
帖子: 9
声望力: 0 ![]() |
![]()
close all;
clear all; [x,fs,bit]=wavread('a.wav');%读语音数据,数据放入了X,fs代表采样率,bit代表采样位数 framelength=240;%设置帧长,%30ms under 8khz framenumber=fix(length(x)/(framelength));%总的数据帧数 totaltime=length(x)/fs;%该段语音总的时间长度 sp1=x(fix(1.1*fs) ![]() sp2=x(0.8*fs ![]() d=0;%初始化,浊音波峰判断 R1=0;%初始化,浊音一个基音周期内帧数 %计算每帧的能量 for i=1:framenumber; E(i)=0;%短时能量初始化 Z(i)=0;%短时过零率初始化 M(i)=0;%短时平均幅度初始化 K(i)=0;%短时零能比初始化 for j=(framelength*(i-1)+1):framelength*i; E(i)=E(i)+x(j)*x(j); %第i帧短时能量 end for j=(framelength*(i-1)+2):framelength*i; Z(i)=Z(i)+abs(sign(x(j)-0.2)-sign(x(j-1)));%第i帧短时过零率 end for j=(framelength*(i-1)+1):framelength*i; M(i)=M(i)+abs(x(j)); end M(i)=M(i)/framelength;%第i帧短时平均幅度 K(i)=Z(i)/E(i);%第i帧短时零能比 end for i=1:framelength; R(i)=0; for j=1:framelength; R(i)=R(i)+sp1(j)*sp1(i+j);%浊音的短时自相关函数 end if (R(i)>=110.11) R(i)=110.11;%修正最高波峰最大值为110.11 d=d+1;%当波峰为110.11时,自加一 end if (d==1)%以第一个波峰110.11为起始点,下一个波峰110.11为终点 R1=R1+1;%计算一个基音周期内帧数 end end for i=1:framelength; r(i)=0; for j=1:framelength; r(i)=r(i)+sp2(j)*sp2(i+j);%清音的自相关函数 end end %思考为什么取sign(x(j)-0.2) %把数据点转化为时间长度 for i=1:framenumber; anyfrequency(i)=totaltime*i/framenumber; end for i=1:length(x); anytime(i)=i*totaltime/length(x); end figure(1) subplot(2,1,1);plot(anytime,x);title('语音图');%语音图 subplot(2,1,2);plot(anyfrequency,E);title('短时能量');%短时能量 figure(2) subplot(2,1,1);plot(anytime,x);title('语音图');%语音图 subplot(2,1,2);plot(anyfrequency,M);title('短时平均幅度');%短时平均幅度 figure(3) subplot(2,1,1);plot(anytime,x);title('语音图');%语音图 subplot(2,1,2);plot(anyfrequency,Z);title('短时过零率');%短时过零率 figure(4) subplot(4,1,1);plot(anytime,x);title('语音图');%语音图 subplot(4,1,2);plot(anyfrequency,Z);title('短时过零率');%短时过零率 subplot(4,1,3);plot(anyfrequency,E);title('短时能量');%短时能量 subplot(4,1,4);plot(anyfrequency,K);title('短时零能比');%短时零能比 figure(5) subplot(3,1,1);plot(R);title('浊音短时自相关函数');%浊音短时自相关函数 subplot(3,1,2);plot(sp1); subplot(3,1,3);plot(x); figure(6) subplot(3,1,1);plot(r);title('清音短时自相关函数');%清音短时自相关函数 subplot(3,1,2);plot(sp2); subplot(3,1,3);plot(x); T=R1/fs%浊音段语音的基音周期,单位为秒(s) f=fs/R1%浊音段语音的基音频率,单位为赫兹(Hz) 麻烦各位帮忙看看,谢谢。 |
![]() |
![]() |
|
|
![]() |
||||
主题 | 主题作者 | 版面 | 回复 | 最后发表 |
[分享]给大家传一个图像空间变换和直方图变换的数学推导 | johnny8088 | MATLAB论坛 | 0 | 2009-01-31 03:26 |
[求助]求GM(1,N)的代码 | hapenl | MATLAB论坛 | 0 | 2008-09-20 06:10 |
[求助]在SIMULINK里,如何将inegrator上方的箭头移到下面去 | yijianmei | MATLAB论坛 | 1 | 2008-07-24 10:15 |
仪表信息图像采集处理研究 | liuna2008 | MATLAB论坛 | 0 | 2008-04-12 18:53 |
Simplify Instrument Communication: Using Instrument Drivers with the Instrument Contr | TechnicalArticles | MATLAB技术文章 | 0 | 2008-01-06 16:32 |