Matlab在语音识别中的应用

上传人:新** 文档编号:498131355 上传时间:2023-09-19 格式:DOC 页数:27 大小:332.50KB
返回 下载 相关 举报
Matlab在语音识别中的应用_第1页
第1页 / 共27页
Matlab在语音识别中的应用_第2页
第2页 / 共27页
Matlab在语音识别中的应用_第3页
第3页 / 共27页
Matlab在语音识别中的应用_第4页
第4页 / 共27页
Matlab在语音识别中的应用_第5页
第5页 / 共27页
点击查看更多>>
资源描述

《Matlab在语音识别中的应用》由会员分享,可在线阅读,更多相关《Matlab在语音识别中的应用(27页珍藏版)》请在金锄头文库上搜索。

1、.wd1. 基于GUI的音频采集处理系统注:本实验是对“东、北、大、学、中、荷、学、院孤立文字的识别!首先是GUI的建立,拖动所需控件,双击控件,修改控件的参数;主要有string Tag(这个是回调函数的依据),其中还有些参数如value style 也是需要注意的,这个在实际操作中不能无视。这里需要给说明一下:图中所示按钮都是在一个按钮组里面,都属于按钮组的子控件。所以在添加回调函数时,是在按钮组里面添加的,也就是说右击三个按钮外面的边框,选择View CallbackSelectionChange,那么在主函数中显示该按钮的回调函数:function uipanel1_Selection

2、ChangeFcn(hObject, eventdata, handles)以第一个按钮“录音为例讲解代码;下面是“播放和“保存的代码:以上就是语音采集的全部代码。程序运行后就会出现这样的界面:点击录音按钮,录音完毕后就会出现相应波形:点击保存,完成声音的保存,保存格式为.wav。这就完成了声音的采集。2. 声音的处理与识别2.1 翻开文件语音处理首先要先翻开一个后缀为.wav的文件,这里用到的不是按钮组,而是独立的按钮,按钮“翻开的回调函数如下:function pushbutton1_Callback(hObject, eventdata, handles)其中pushbutton1是“翻

3、开按钮的Tag.在回调函数下添加如下代码:运行结果如图:2.2 预处理回调函数如下:function pushbutton2_Callback(hObject, eventdata, handles)运行结果如图:2.3 短时能量短时能量下的回调函数:function pushbutton3_Callback(hObject, eventdata, handles)其回调函数下的代码是:2.4 端点检测这里要先声明一点,为了防止在以后的函数调用中,不能使用前面的变量,所以其实后面的函数都包含了前面的局部。显而易见这样程序就会显得很冗长,这也是值得以后修改的地方。function pushbut

4、ton4_Callback(hObject, eventdata, handles)2.5 生成模版本功能和上面重复的局部省略掉了,现在只补充添加的代码:2.6 语音识别将翻开的语音与提前录好的语音库进展识别,采用的是DTW算法。识别完后就会在相应的文本框里显示识别的文字。代码如下:程序运行前后的比照图:GUI的整体效果图:总结实验已经实现了对“东、北、大、学、中、荷、学、院文字的识别,前提是用模版的语音作为样本去和语音库测试,这已经可以保证的正确率,这说明算法是正确的,只是需要优化。而现场录音和模版匹配时,那么不能保证较高的正确率,这说明特征参数的提取这方面还不够完善。特征参数提取的原那么是

5、类内距离尽量小,类间距离尽量大的原那么,这是需要以后完善的地方。也需要优化,先生成一个模版库,然后用待测语音和模版库语音识别,让这个模版库孤立出来,不需要每次测试都要重复生成模版库,提高运算速率。以后有时机可以实现连续语音的识别!附件这是全部代码文件mfcc.mat 文件是程序运行过程中生成的;test 文件夹里面存放了录音的模版:这里是6个.M文件,如下:1 WienerScalart96.mfunction output=WienerScalart96(signal,fs,IS)% output=WIENERSCALART96(signal,fs,IS)% Wiener filter ba

6、sed on tracking a priori SNR usingDecision-Directed % method, proposed by Scalart et al 96. In this method it is assumed that% SNRpost=SNRprior +1. based on this the Wiener Filter can be adapted to a% model like Ephraims model in which we have a gain function which is a% function of a priori SNR and

7、 a priori SNR is being tracked using Decision% Directed method. % Author: Esfandiar Zavarehei% Created: MAR-05if (nargin=3 & isstruct(IS)%This option is for compatibility with another programmeW=IS.windowsizeSP=IS.shiftsize/W;%nfft=IS.nfft;wnd=IS.window;if isfield(IS,IS)IS=IS.IS;elseIS=.25;endend% .

8、UP TO HEREpre_emph=0;signal=filter(1 -pre_emph,1,signal);NIS=fix(IS*fs-W)/(SP*W) +1);%number of initial silence segmentsy=segment(signal,W,SP,wnd); % This function chops the signal into framesY=fft(y);YPhase=angle(Y(1:fix(end/2)+1,:); %Noisy Speech PhaseY=abs(Y(1:fix(end/2)+1,:);%SpecrogramnumberOfF

9、rames=size(Y,2);FreqResol=size(Y,1);N=mean(Y(:,1:NIS); %initial Noise Power Spectrum meanLambdaD=mean(Y(:,1:NIS).2);%initial Noise Power Spectrum variancealpha=.99; %used in smoothing xi (For Deciesion Directed method for estimation of A Priori SNR)NoiseCounter=0;NoiseLength=9;%This is a smoothing f

10、actor for the noise updatingG=ones(size(N);%Initial Gain used in calculation of the new xiGamma=G;X=zeros(size(Y); % Initialize X (memory allocation)h=waitbar(0,Wait.);for i=1:numberOfFrames%VAD and Noise Estimation STARTif i=NIS % If initial silence ignore VADSpeechFlag=0;NoiseCounter=100;else% Els

11、e Do VADNoiseFlag, SpeechFlag, NoiseCounter, Dist=vad(Y(:,i),N,NoiseCounter); %Magnitude Spectrum Distance VADendif SpeechFlag=0 % If not Speech Update Noise ParametersN=(NoiseLength*N+Y(:,i)/(NoiseLength+1); %Update and smooth noise meanLambdaD=(NoiseLength*LambdaD+(Y(:,i).2)./(1+NoiseLength); %Upd

12、ate and smooth noise varianceend%VAD and Noise Estimation ENDgammaNew=(Y(:,i).2)./LambdaD; %A postiriori SNRxi=alpha*(G.2).*Gamma+(1-alpha).*max(gammaNew-1,0); %Decision Directed Method for A Priori SNRGamma=gammaNew;G=(xi./(xi+1);X(:,i)=G.*Y(:,i); %Obtain the new Cleaned valuewaitbar(i/numberOfFram

13、es,h,num2str(fix(100*i/numberOfFrames);endclose(h);output=OverlapAdd2(X,YPhase,W,SP*W); %Overlap-add Synthesis of speechoutput=filter(1,1 -pre_emph,output); %Undo the effect of Pre-emphasisfunction ReconstructedSignal=OverlapAdd2(XNEW,yphase,windowLen,ShiftLen);%Y=OverlapAdd(X,A,W,S);%Y is the signa

14、l reconstructed signal from its spectrogram. X is a matrix%with each column being the fft of a segment of signal. A is the phase%angle of the spectrum which should have the same dimension as X. if it is%not given the phase angle of X is used which in the case of real values is%zero (assuming that its the magnitude). W is the window length of time%domain segments if not given the length is assumed to be twice as long as%fft window length. S is the sh

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号