语音信号处理试验_第1页
语音信号处理试验_第2页
语音信号处理试验_第3页
语音信号处理试验_第4页
语音信号处理试验_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、哈尔滨工程大学实验报告班级:电信二班学号:2013081416姓名:刘世杰操作过程试验才氏告合计综合界面分析总成绩语音信号处理实验一、实验目的1、掌握短时能量的求解方法、短时平均过零率的求解方法,对输入的语音信号 进行端点检测。2、掌握语音信号的Mel倒谱特征(MFCC的求解方法,语音信号的线性预测原理 以及LPCW征的求解方法。3、掌握语音信号基频的概念,加深对基频刻画声调特征作用的理解,掌握语音 信号基频特征的典型求解方法。4、掌握MATLAB应的功能以及使用方法。二、仪器设备HP计算机、MATLAB软件三、实验原理(一)语音信号的短时分析端点检测是语音信号处理过程中非常重要的一步,它的准

2、确性直接影响到语音信号处理的速度和结果。本次实验利用短时过零率和短时能量相结合的语音端点检测算法利用短时过 零率来检测清音,用短时能量来检测浊音,两者相配合便实现了信号信噪比较大情况下的端 点检测。先引入以下三个概念1、短时能量计算定义n时刻某语言信号的短时平均能量 En为:nEn = x(m)w(n - m)2 = x x(m)w(n - m)2二二m =n -(N 4)式中N为窗长,可见短时平均能量为一帧样点值的平方和。特殊地,当窗函数为n矩形窗时,有En = x2(m)m才N)2、短时过零率过零就是指信号通过零值。过零率就是每秒内信号值通过零值的次数。对于离散时间序列,过零则是指序列取样

3、值改变符号,过零率则是每个样本的改变符号的次数。对于语音信号,则是指在一帧语音中语音信号波形穿过横轴(零电平)的 次数。可以用相邻两个取样改变符号的次数来计算。如果窗的起点是n=0,短时过零率Z为波形穿过横轴(零电平)的次数1 N 1Z0|Sgn(Sw(n) -Sgn(Sw(n -1) |2n卫;1 x _0sgn(x) = -I”短时过零可以看作信号频率的简单度量浊音的短时平均幅度最大,无声的短时平均幅度最小,清音的短时过零率最大,无 声居中,浊音的短时过零率最小。3、短时自相关函数N A JRw(k) =sw(n)sw(n k)n z0是偶函数;s(n)是周期的,那么 R (k)也是周期的

4、;可用于基音周期估计和线性预测分析4、判断语音信号的起点和终点利用过零率检测清音,用短时能量检测浊音,两者配合。首先为短时能量和过零率分别确定两个门限,一个是较低的门限数值较小,对信号的变化比较敏感,很容易超过;另一个是比较高的门限,数值较大。低门限被超过未必是语音的开始,有可能是很短的噪声引起的,高门限被超过并且接下来的自定义时间段内的语音超过低门限,意味着信号开始。此时整个端点检测可分为四段:静音段、过渡段、语音段、结束。实验时使用一个变量表示当前状态。静音段,如果能量或过零率超过低门限,就开始标记起始点,进入过渡段。过渡段当两个参数值都回落到低门限以下,就将当前状态恢复到静音状态。而如果

5、过渡段中两个参数中的任一个超过高门限,即被认为进入语音段。处于语音段时,如果两参数降低到门限以下,而且总的计时长度小于最短时间门限,则认为是一段噪音, 继续扫描以后的语音数据,否则标一记结束端点。(二)语音信号的特征提取由于频率响应H(ejw)反映声道的频率响应和被分析信号的谱包络,因此用10gH (ejw)|做反傅里叶变换求出的 LPC倒谱系数。p通过线性预测分析得到的合成滤波器的系统函数为H(z) = 1/(1- az),其冲激响i 1AA7:”应为h(n)。h(n)的倒谱为h(n) , H (z) = h(n)z就是说H (z)的逆变换h(n)是存在的。n =1AAJ设 h(0)=0 ,

6、 将式 H(z)= h(n)z两边同时对 z,求导,得n 4P.一二 A.: aq iaiz1三logp= 三工h(n)z得到工nh(n)z*= p ,于是有 TOC o 1-5 h z -z1;-z n 4n 1i一 aiz1-x az1i 1p二二 a(1-Z az) nh(n)z= iaiz,卡令其左右两边z的各次哥前系数分别相等,得 i z1n =1n =1到h(n)和a间的递推关系,Ah(1) =a1An 1; Ah(n)=an+Z (1-)ai h(n-k),1 n p、i, n这个倒谱是根据线性预测模型得到的,又称为LPC倒谱。LPC倒谱由于利用线性预测中声道系统函数H (z)的

7、最小相位特性,因此避免了一般同态处理中求复对数的麻烦。(三)语音信号的基频提取浊音信号的自相关函数在基因周期的整数倍位置上出现峰值,而清音的自相关函数没有明显的峰值出现。因此检测自相关函数是否有峰值就可以判断是清音还是浊音,而峰-峰值之间对应的就是基音周期。影响从自相关函数中正确提取基音周期的最主要原因是声道响应。当基音的周期性和共振峰的周期性混在一起时,被检测出来的峰值可能会偏离原来峰值的真实位置。另外,在某些浊音中,第一共振频率可能会等于或低于基音频率。此时,如果其幅度很高,它就可能在自相关函数中产生一个峰值,而该峰值又可以同基音频率的峰值相比拟。1、自相关函数对于离散的语音信号 x(n)

8、,它的自相关函数定义为:R(k)= 2 x(n)x(n-k),如果信号x(n)具有周期性,那么它的自相关函数也具有周期性,而且周期与信号x(n)在周期信号周期的整数倍的周期性相同。自相关函数提供了一种获取周期信号周期的方法。上,它的自相关函数可以达到最大值,因此可以不考虑起始时间,而从自相关函数的第一个最大值的位置估计出信号的基音周期,这使自相关函数成为信号基音周期估计的一种工具。2、短时自相关函数语音信号是非平稳的信号, 所以对信号的处理都使用短时自相关函数。短时自相关函数是在信号的第N个样本点附近用短时窗截取一段信号,做自相关计算所得的结果Rm(k)= E x(n)x(n-k)式中,n表示

9、窗函数是从第 n点开始加入。3、算法 通过对自相关基音检测原理的分析 ,考虑到检测准确度和检测速率 2方面的因素,提出了算法实现方案,并对算法进行了 MATLAB编程实现。四、实验内容利用MATLAB画出信号分析界面,实现语音信号文件的提取,分析并画图,再进行 LPC 和MFCC分析,并画图,经过相应的计算和分析,最终能够识别男或女的声音。画出的界面如下图所示:程序文本:function varargout = voice(varargin)% VOICE MATLAB code for voice.fig% VOICE, by itself, creates a new VOICE or r

10、aises the existing% singleton*.% H = VOICE returns the handle to a new VOICE or the handle to% the existing singleton*.% VOICE(CALLBACK,hObject,eventData,handles,)calls the local% functionnamed CALLBACK in VOICE.M with the given input arguments.% VOICE(Property,Value,.) creates a new VOICE or raises

11、 thepairs% existing singleton*. Startingfrom the left, property valueare% applied to the GUI before voice_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to voice_OpeningFcn via varargin.% *See GUI Options on GUIDEs Tool

12、s menu. Choose GUI allows only one% instance to run (singleton).% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help voice% Last Modified by GUIDE v2.5 22-Apr-2017 19:01:57% Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct(gui_Namegu

13、i_Singleton gui_OpeningFcn gui_OutputFcn gui_LayoutFcn gui_Callbackmfilename, gui_Singleton, , voice_OpeningFcn, voice_OutputFcn, 口,.口);if nargin & ischar(varargin1)gui_State.gui_Callback = str2func(varargin1);end if nargoutvarargout1:nargout = gui_mainfcn(gui_State, varargin:); elsegui_mainfcn(gui_

14、State, varargin:);end% End initialization code - DO NOT EDIT% Executes just before voice is made visible.function voice_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future versio

15、n of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to voice (see VARARGIN)% Choose default command line output for voice handles.output = hObject;% Update handles structure guidata(hObject, handles);% UIWAIT makes voice wait for user response (se

16、e UIRESUME)% uiwait(handles.figure1);set(handles.read_path,String , myspeech.wav );addpath( F:voicebox );% - Outputs from this function are returned to the command line. function varargout = voice_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT)

17、;% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structure varargout1 = handles.output;% - Executes on button press in LPC.function LPC_Callback(hObj

18、ect, eventdata, handles)% hObject handle to LPC (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,Value) returns toggle state of LPC% - Executes on button press in MFCC.function MFCC_Callback(hO

19、bject, eventdata, handles) % hObject handle to MFCC (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,Value) returns toggle state of MFCC% - Executes on button press in pushbutton2.function pus

20、hbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) function read_path_Callback(hObject, eventdata, handles)% hObject handle to read_path

21、 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)contents of read_pathall CreateFcns called% Hints: get(hObject,String) returns contents of read_path as text% str2double(get(hObject,String)returnsas a double% - E

22、xecutes during object creation, after setting all properties. function read_path_CreateFcn(hObject, eventdata, handles) % hObject handle to read_path (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after% Hint: edit controls usu

23、ally have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColorget(0, defaultUicontrolBackgroundColor)set(hObject, BackgroundColor , white );end% - Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles)% hObjec

24、t handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) channel=1;String);temp=wavread(get(handles.read_path, y=temp(:,channel);plot(y);% - Executes on button press in pushbutton4.function pushbu

25、tton4_Callback(hObject, eventdata, handles)% hObject handle to pushbutton4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) channel=1;temp=wavread(get(handles.read_path,string );y=temp(:,channel);f=enframe(y,200,

26、200);y=f(150,:);plot(handles.top, y);% Executes on button press in LPCplot1.function LPCplot1_Callback(hObject, eventdata, handles)% hObject handle to LPCplot1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)if g

27、et(handles.LPC, Value )=1channel=1;temp=wavread(get(handles.read_path,string );speech=temp(:,channel);f_temp=enframe(speech,200,200);d_temp=f_temp(25,:);plot(handles.top,d_temp);p=12;ar=lpcauto(d_temp,p);Y=lpcar2ff(ar,255);est_x=filter(0-ar(2:end),1,d_temp);plot(handles.kk,est_x);end% Executes on bu

28、tton press in zuocha.function zuocha_Callback(hObject, eventdata, handles)% hObject handle to zuocha (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if get(handles.LPC, Value )=1 channel=1; temp=wavread(get(han

29、dles.read_path,string );speech=temp(:,channel);f_temp=enframe(speech,200,200); d_temp=f_temp(25,:);p=12;ar=lpcauto(d_temp,p);Y=lpcar2ff(ar,255);est_x=filter(0-ar(2:end),1,d_temp)-d_temp;plot(handles.qq,est_x); end% - Executes on button press in MFCCplot. function MFCCplot_Callback(hObject, eventdata

30、, handles) % hObject handle to MFCCplot (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)if get(handles.MFCC, Value )=1 channel=1; temp= wavread(get(handles.read_path,string );y=temp(:,channel); fs=8000; c=melceps

31、t(y,fs); n = str2double(get(handles.mfcc_num,string );c = c(:,n); plot(handles.kk,c); end% - Executes on button press in read.function read_Callback(hObject, eventdata, handles)% hObject handle to read (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure wi

32、th handles and user data (see GUIDATA)signal = wavread(get(handles.read_path,string );plot(handles.top, signal);function mfcc_num_Callback(hObject, eventdata, handles)% hObject handle to mfcc_num (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with han

33、dles and user data (see GUIDATA)% Hints: get(hObject,String) returns contents of mfcc_num as text% str2double(get(hObject,String) returns contents of mfcc_num as a double% - Executes during object creation, after setting all properties. function mfcc_num_CreateFcn(hObject, eventdata, handles)% hObje

34、ct handle to mfcc_num (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor ),g

35、et(0, defaultUicontrolBackgroundColor)set(hObject, BackgroundColor , white );end function kmeans_num_Callback(hObject, eventdata, handles)% hObject handle to kmeans_num (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUI

36、DATA)% Hints: get(hObject,String) returns contents of kmeans_num as text % str2double(get(hObject,String) returns contents of kmeans_num as a double% - Executes during object creation, after setting all properties.function kmeans_num_CreateFcn(hObject, eventdata, handles)% hObject handle to kmeans_n

37、um (see GCBO)% eventdata reserved - to be defined in a future version of MATLABcalledcalled% handles empty - handles not created until after all CreateFcns % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor ),get(0,

38、defaultUicontrolBackgroundColor)set(hObject, BackgroundColor , white );end% - Executes on button press in keans.function keans_Callback(hObject, eventdata, handles)% hObject handle to keans (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles a

39、nd user data (see GUIDATA)channel = 1;%道选择temp = wavread(get(handles.read_path,String );%W 入语音信号speech = temp(:,channel);%M 化语音信号fs = 8000;%选择采样频率c = melcepst(speech, fs);%梅尔系数的采集,默认12位n = str2double(get(handles.kmeans_num,String );idx ,C = kmeans(c,n);stem(handles.qq, idx);function result_Callback(

40、hObject, eventdata, handles)% hObject handle to result (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,String) returns contents of result as text% str2double(get(hObject,String)returns conten

41、ts of result asa double% - Executes during object creation, after setting all properties. function result_CreateFcn(hObject, eventdata, handles)% hObject handle to result (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all

42、 CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor ),get(0, defaultUicontrolBackgroundColor)set(hObject, BackgroundColor , white ); end% - Executes on button press in male.function male_Callback(hOb

43、ject, eventdata, handles)% hObject handle to male (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,Value) returns toggle state of male% - Executes on button press in female.function female_Call

44、back(hObject, eventdata, handles)% hObject handle to female (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,Value) returns toggle state of female% - Executes on button press in GMM.function GM

45、M_Callback(hObject, eventdata, handles)% hObject handle to GMM (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)xx,fs = wavread(get(handles.read_path, x=xx/max(abs(xx);N=length(xx);time=(0:N-1)/fs;wlen=200; inc=100;y=enframe(x,wlen,inc);etemp=sum(y.A2);etemp=etemp/max(etemp);fn=size(y,2);T1=0.002;T2=0.01;String );%幅度归一化%取信号长度%计算时间刻度%分帧%求取短时平均能量%能量幅值归一化%帧数%设置阈值%读入语音信号voiceseg,vsl,SF,NF=vad_p

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论