matlab语音识别系统(源代码)

合集下载

MATLAB在语音识别中的应用

MATLAB在语音识别中的应用

1.基于GUI的音频采集处理系统注:本实验是对“东、北、大、学、中、荷、学、院”孤立文字的识别!首先是GUI的建立,拖动所需控件,双击控件,修改控件的参数;主要有string Tag(这个是回调函数的依据),其中还有些参数如valuestyle也是需要注意的,这个在实际操作中不能忽视。

这里需要给说明一下:图中所示按钮都是在一个按钮组里面,都属于按钮组的子控件。

所以在添加回调函数时,是在按钮组里面添加的,也就是说右击三个按钮外面的边框,选择View Callback——SelectionChange,则在主函数中显示该按钮的回调函数:function uipanel1_SelectionChangeFcn(hObject,eventdata,handles)以第一个按钮“录音”为例讲解代码;下面是“播放”和“保存”的代码:以上就是语音采集的全部代码。

程序运行后就会出现这样的界面:点击录音按钮,录音结束后就会出现相应波形:点击保存,完成声音的保存,保存格式为.wav。

这就完成了声音的采集。

2.声音的处理与识别2.1打开文件语音处理首先要先打开一个后缀为.wav的文件,这里用到的不是按钮组,而是独立的按钮,按钮“打开”的回调函数如下:function pushbutton1_Callback(hObject,eventdata,handles)其中pushbutton1是“打开”按钮的Tag.在回调函数下添加如下代码:运行结果如图:2.2预处理回调函数如下:function pushbutton2_Callback(hObject,eventdata,handles)运行结果如图:2.3短时能量短时能量下的回调函数:function pushbutton3_Callback(hObject,eventdata,handles)其回调函数下的代码是:2.4端点检测这里要先声明一点,为了避免在以后的函数调用中,不能使用前面的变量,所以其实后面的函数都包含了前面的部分。

基于某matlab地人脸识别源代码

基于某matlab地人脸识别源代码

实用标准文档function varargout = FR_Processed_histogram(varargin)%这种算法是基于直方图处理的方法%The histogram of image is calculated and then bin formation is done on the%basis of mean of successive graylevels frequencies. The training is done on odd images of 40 subjects (200 images out of 400 images)%The results of the implemented algorithm is 99.75 (recognition fails on image number 4 of subject 17) gui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ...'gui_Singleton', gui_Singleton, ...'gui_OpeningFcn',@FR_Processed_histogram_OpeningFcn, ...'gui_OutputFcn',@FR_Processed_histogram_OutputFcn, ...'gui_LayoutFcn', [] , ...'gui_Callback', []);if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});elsegui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT%--------------------------------------------------------------------------% --- Executes just before FR_Processed_histogram is made visible.function FR_Processed_histogram_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 version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments toFR_Processed_histogram (see VARARGIN)% Choose default command line output for FR_Processed_histogramhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes FR_Processed_histogram wait for user response (see UIRESUME)% uiwait(handles.figure1);global total_sub train_img sub_img max_hist_level bin_num form_bin_num;total_sub = 40;train_img = 200;sub_img = 10;max_hist_level = 256;bin_num = 9;form_bin_num = 29;%--------------------------------------------------------------------------% --- Outputs from this function are returned to the command line.function varargout = FR_Processed_histogram_OutputFcn(hObject, eventdata, handles)% varargout cell array for returning output args (see VARARGOUT);% 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 varargout{1} = handles.output;%--------------------------------------------------------------------------% --- Executes on button press in train_button.function train_button_Callback(hObject, eventdata, handles)% hObject handle to train_button (see GCBO)% eventdata reserved - to be defined in a future versionof MATLAB% handles structure with handles and user data (see GUIDATA)global train_processed_bin;global total_sub train_img sub_img max_hist_level bin_numform_bin_num;train_processed_bin(form_bin_num,train_img) = 0;K = 1;train_hist_img = zeros(max_hist_level, train_img);for Z=1:1:total_subfor X=1:2:sub_img %%%train on odd number of images ofeach subjectI =imread( strcat('ORL\S',int2str(Z),'\',int2str(X),'.bmp') );[rows cols] = size(I);for i=1:1:rowsfor j=1:1:colsif( I(i,j) == 0 )train_hist_img(max_hist_level, K) =train_hist_img(max_hist_level, K) + 1;elsetrain_hist_img(I(i,j), K) =train_hist_img(I(i,j), K) + 1;endendendK = K + 1;endend[r c] = size(train_hist_img);sum = 0;for i=1:1:cK = 1;for j=1:1:rif( (mod(j,bin_num)) == 0 )sum = sum + train_hist_img(j,i);train_processed_bin(K,i) = sum/bin_num;K = K + 1;sum = 0;elsesum = sum + train_hist_img(j,i);endendtrain_processed_bin(K,i) = sum/bin_num;enddisplay ('Training Done')save 'train'train_processed_bin;%--------------------------------------------------------------------------% --- Executes on button press in Testing_button.function Testing_button_Callback(hObject, eventdata, handles)% hObject handle to Testing_button (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (seeGUIDATA)global train_img max_hist_level bin_num form_bin_num;global train_processed_bin;global filename pathname Iload 'train'test_hist_img(max_hist_level) = 0;test_processed_bin(form_bin_num) = 0;[rows cols] = size(I);for i=1:1:rowsfor j=1:1:colsif( I(i,j) == 0 )test_hist_img(max_hist_level) = test_hist_img(max_hist_level) + 1;elsetest_hist_img(I(i,j)) = test_hist_img(I(i,j)) + 1;endendend[r c] = size(test_hist_img);sum = 0;K = 1;for j=1:1:cif( (mod(j,bin_num)) == 0 )sum = sum + test_hist_img(j); test_processed_bin(K) = sum/bin_num;K = K + 1;sum = 0;elsesum = sum + test_hist_img(j);endendtest_processed_bin(K) = sum/bin_num;sum = 0;K = 1;for y=1:1:train_imgfor z=1:1:form_bin_numsum = sum + abs( test_processed_bin(z) - train_processed_bin(z,y) );endimg_bin_hist_sum(K,1) = sum;sum = 0;K = K + 1;end[temp M] = min(img_bin_hist_sum);M = ceil(M/5);getString_start=strfind(pathname,'S');getString_start=getString_start(end)+1;getString_end=strfind(pathname,'\');getString_end=getString_end(end)-1;subjectindex=str2num(pathname(getString_start:getString_end ));if (subjectindex == M)axes (handles.axes3)%image no: 5 is shown for visualization purposeimshow(imread(STRCAT('ORL\S',num2str(M),'\5.bmp'))) msgbox ( 'Correctly Recognized');elsedisplay ([ 'Error==> Testing Image of Subject >>' num2str(subjectindex) ' matches with the image of subject >> ' num2str(M)])axes (handles.axes3)%image no: 5 is shown for visualization purposeimshow(imread(STRCAT('ORL\S',num2str(M),'\5.bmp'))) msgbox ( 'Incorrectly Recognized');enddisplay('Testing Done')%--------------------------------------------------------------------------function box_Callback(hObject, eventdata, handles)% hObject handle to box (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 box as text% str2double(get(hObject,'String')) returns contents of box as a double%--------------------------------------------------------------------------% --- Executes during object creation, after setting all properties.function box_CreateFcn(hObject, eventdata, handles)% hObject handle to box (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all 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 Input_Image_button.function Input_Image_button_Callback(hObject, eventdata, handles)% hObject handle to Input_Image_button (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global filename pathname I[filename, pathname] = uigetfile('*.bmp', 'Test Image');axes(handles.axes1)imgpath=STRCAT(pathname,filename);I = imread(imgpath);imshow(I)%--------------------------------------------------------------------------% --- Executes during object creation, after setting all properties.function axes3_CreateFcn(hObject, eventdata, handles)% hObject handle to axes3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: place code in OpeningFcn to populate axes3%Programmed by Usman Qayyum。

根据matlab的人脸识别源代码

根据matlab的人脸识别源代码

function varargout = FR_Processed_histogram(varargin)%这种算法是基于直方图处理的方法%The histogram of image is calculated and then bin formation is done on the%basis of mean of successive graylevels frequencies. The training is done on odd images of 40 subjects (200 images out of 400 images)%The results of the implemented algorithm is 99.75 (recognition fails on image number 4 of subject 17)gui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ...'gui_Singleton', gui_Singleton, ...'gui_OpeningFcn',@FR_Processed_histogram_OpeningFcn, ...'gui_OutputFcn',@FR_Processed_histogram_OutputFcn, ...'gui_LayoutFcn', [] , ...'gui_Callback', []);if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});elsegui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT%--------------------------------------------------------------------------% --- Executes just before FR_Processed_histogram is made visible.function FR_Processed_histogram_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 version of MATLAB% handles structure with handles and user data (see GUIDATA) % varargin command line arguments to FR_Processed_histogram (see VARARGIN)% Choose default command line output for FR_Processed_histogramhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes FR_Processed_histogram wait for user response (see UIRESUME)% uiwait(handles.figure1);global total_sub train_img sub_img max_hist_level bin_num form_bin_num;total_sub = 40;train_img = 200;sub_img = 10;max_hist_level = 256;bin_num = 9;form_bin_num = 29;%--------------------------------------------------------------------------% --- Outputs from this function are returned to the command line.function varargout = FR_Processed_histogram_OutputFcn(hObject, eventdata, handles)% varargout cell array for returning output args (see VARARGOUT);% 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 structurevarargout{1} = handles.output;%--------------------------------------------------------------------------% --- Executes on button press in train_button.function train_button_Callback(hObject, eventdata, handles)% hObject handle to train_button (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global train_processed_bin;global total_sub train_img sub_img max_hist_level bin_num form_bin_num;train_processed_bin(form_bin_num,train_img) = 0;K = 1;train_hist_img = zeros(max_hist_level, train_img);for Z=1:1:total_subfor X=1:2:sub_img %%%train on odd number of images of each subjectI = imread( strcat('ORL\S',int2str(Z),'\',int2str(X),'.bmp') );[rows cols] = size(I);for i=1:1:rowsfor j=1:1:colsif( I(i,j) == 0 )train_hist_img(max_hist_level, K) = train_hist_img(max_hist_level, K) + 1;elsetrain_hist_img(I(i,j), K) = train_hist_img(I(i,j), K) + 1;endendendK = K + 1;endend[r c] = size(train_hist_img);sum = 0;for i=1:1:cK = 1;for j=1:1:rif( (mod(j,bin_num)) == 0 )sum = sum + train_hist_img(j,i);train_processed_bin(K,i) = sum/bin_num;K = K + 1;sum = 0;elsesum = sum + train_hist_img(j,i);endendtrain_processed_bin(K,i) = sum/bin_num;enddisplay ('Training Done')save 'train'train_processed_bin;%--------------------------------------------------------------------------% --- Executes on button press in Testing_button.function Testing_button_Callback(hObject, eventdata, handles)% hObject handle to Testing_button (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) global train_img max_hist_level bin_num form_bin_num;global train_processed_bin;global filename pathname Iload 'train'test_hist_img(max_hist_level) = 0;test_processed_bin(form_bin_num) = 0;[rows cols] = size(I);for i=1:1:rowsfor j=1:1:colsif( I(i,j) == 0 )test_hist_img(max_hist_level) =test_hist_img(max_hist_level) + 1;elsetest_hist_img(I(i,j)) = test_hist_img(I(i,j)) + 1;endendend[r c] = size(test_hist_img);sum = 0;K = 1;for j=1:1:cif( (mod(j,bin_num)) == 0 )sum = sum + test_hist_img(j);test_processed_bin(K) = sum/bin_num;K = K + 1;sum = 0;elsesum = sum + test_hist_img(j);endendtest_processed_bin(K) = sum/bin_num;sum = 0;K = 1;for y=1:1:train_imgfor z=1:1:form_bin_numsum = sum + abs( test_processed_bin(z) - train_processed_bin(z,y) );endimg_bin_hist_sum(K,1) = sum;sum = 0;K = K + 1;end[temp M] = min(img_bin_hist_sum);M = ceil(M/5);getString_start=strfind(pathname,'S');getString_start=getString_start(end)+1;getString_end=strfind(pathname,'\');getString_end=getString_end(end)-1;subjectindex=str2num(pathname(getString_start:getString_end));if (subjectindex == M)axes (handles.axes3)%image no: 5 is shown for visualization purposeimshow(imread(STRCAT('ORL\S',num2str(M),'\5.bmp')))msgbox ( 'Correctly Recognized');elsedisplay ([ 'Error==> Testing Image of Subject >>' num2str(subjectindex) ' matches with the image of subject >> ' num2str(M)])axes (handles.axes3)%image no: 5 is shown for visualization purposeimshow(imread(STRCAT('ORL\S',num2str(M),'\5.bmp')))msgbox ( 'Incorrectly Recognized');enddisplay('Testing Done')%--------------------------------------------------------------------------function box_Callback(hObject, eventdata, handles)% hObject handle to box (see GCBO)% eventdata reserved - to be defined in a future version ofMATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of box as text% str2double(get(hObject,'String')) returns contents of box as a double%--------------------------------------------------------------------------% --- Executes during object creation, after setting all properties.function box_CreateFcn(hObject, eventdata, handles)% hObject handle to box (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all 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 Input_Image_button.function Input_Image_button_Callback(hObject, eventdata, handles) % hObject handle to Input_Image_button (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) global filename pathname I[filename, pathname] = uigetfile('*.bmp', 'Test Image');axes(handles.axes1)imgpath=STRCAT(pathname,filename);I = imread(imgpath);imshow(I)%--------------------------------------------------------------------------% --- Executes during object creation, after setting all properties.function axes3_CreateFcn(hObject, eventdata, handles)% hObject handle to axes3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcnscalled% Hint: place code in OpeningFcn to populate axes3 %Programmed by Usman Qayyum。

matlab语音识别系统(源代码)18676

matlab语音识别系统(源代码)18676

(威海)《智能仪器》课程设计题目: MATLAB实现语音识别功能班级:学号:姓名:同组人员:任课教师:完成时间:2012/11/3目录一、设计任务及要求 (1)二、语音识别的简单介绍语者识别的概念 (2)特征参数的提取 (3)用矢量量化聚类法生成码本 (3)的说话人识别 (4)三、算法程序分析函数关系 (4)代码说明 (5)函数mfcc (5)函数disteu (5)函数vqlbg (6)函数test (6)函数testDB (7)函数train (8)函数melfb (8)四、演示分析 (9)五、心得体会 (11)附:GUI程序代码 (12)一、设计任务及要求用MATLAB实现简单的语音识别功能;具体设计要求如下:用MATLAB实现简单的数字1~9的语音识别功能。

二、语音识别的简单介绍基于VQ的说话人识别系统,矢量量化起着双重作用。

在训练阶段,把每一个说话者所提取的特征参数进行分类,产生不同码字所组成的码本。

在识别(匹配)阶段,我们用VQ方法计算平均失真测度(本系统在计算距离d时,采用欧氏距离测度),从而判断说话人是谁。

语音识别系统结构框图如图1所示。

图1 语音识别系统结构框图语者识别的概念语者识别就是根据说话人的语音信号来判别说话人的身份。

语音是人的自然属性之一,由于说话人发音器官的生理差异以及后天形成的行为差异,每个人的语音都带有强烈的个人色彩,这就使得通过分析语音信号来识别说话人成为可能。

用语音来鉴别说话人的身份有着许多独特的优点,如语音是人的固有的特征,不会丢失或遗忘;语音信号的采集方便,系统设备成本低;利用电话网络还可实现远程客户服务等。

因此,近几年来,说话人识别越来越多的受到人们的重视。

与其他生物识别技术如指纹识别、手形识别等相比较,说话人识别不仅使用方便,而且属于非接触性,容易被用户接受,并且在已有的各种生物特征识别技术中,是唯一可以用作远程验证的识别技术。

因此,说话人识别的应用前景非常广泛:今天,说话人识别技术已经关系到多学科的研究领域,不同领域中的进步都对说话人识别的发展做出了贡献。

MATLAB 高级编程与工程应用 语音处理 实验报告+源代码

MATLAB 高级编程与工程应用 语音处理 实验报告+源代码

清华大学电子工程系MATLAB高级编程与工程应用实验二语音处理1.2.1(1)给定e(n) 假设e(n) 是输入信号,s(n) 是输出信号,上述滤波器的传递函数是什么?如果a1 = 1.3789,a2 = 0.9506 ,上述合成模型的共振峰频率是多少?用zplane ,freqz ,impz 分别绘出零极点图,频率响应和单位样值响应。

用filter 绘出单位样值响应,比较和impz 的是否相同。

分析:上述滤波器的传递函数是:H=11−1.3789z−1+0.9506z−2可以求出传递函数的极点为p = 0.6895 ±0.6894 i由此可以计算出模拟频率为Ω = pi/4,又因为T = 1/8000s,则可以得到共振峰频率f = 1000Hz。

使用zplane函数画出零极点图如下:使用freqz函数画出频率响应如下:使用impz函数画出单位样值响应如下:最后使用filter函数画出其单位样值响应如下:编写文件sounds_2_1.m,画出所有图像如下,可以直接比较filter函数和impz函数画出的单位样值响应几乎是一模一样的:sounds_2_1.m:clear;clc;close all;b = 1;a = [1,-1.3789,0.9506];n = [0:1:50];freqz(b,a); %画出频率响应图figure; %新建画布subplot(3,1,1);zplane(b,a); %画出零极点图subplot(3,1,2);impz(b,a,n); %利用impz函数画出单位样值响应subplot(3,1,3);x = (n == 0);stem(n,filter(b,a,x)); %利用filter函数画出单位样值响应(3)运行该程序到27 帧时停住,用(1)中的方法观察零极点图。

添加代码如下:运行程序得到零极点图如下:(4) 在循环中添加程序:对每帧语音信号s(n) 和预测模型系数fa i g ,用filter 计算激励信号e(n) 。

Matlab在语音识别中地应用

Matlab在语音识别中地应用

1.基于GUI的音频采集处理系统注:本实验是对“东、北、大、学、中、荷、学、院”孤立文字的识别!首先是GUI的建立,拖动所需控件,双击控件,修改控件的参数;主要有string Tag(这个是回调函数的依据),其中还有些参数如value style 也是需要注意的,这个在实际操作中不能忽视。

这里需要给说明一下:图中所示按钮都是在一个按钮组里面,都属于按钮组的子控件。

所以在添加回调函数时,是在按钮组里面添加的,也就是说右击三个按钮外面的边框,选择View Callback——SelectionChange,则在主函数中显示该按钮的回调函数:function uipanel1_SelectionChangeFcn(hObject, eventdata, handles)以第一个按钮“录音”为例讲解代码;下面是“播放”和“保存”的代码:以上就是语音采集的全部代码。

程序运行后就会出现这样的界面:点击录音按钮,录音结束后就会出现相应波形:点击保存,完成声音的保存,保存格式为.wav。

这就完成了声音的采集。

2.声音的处理与识别2.1打开文件语音处理首先要先打开一个后缀为.wav的文件,这里用到的不是按钮组,而是独立的按钮,按钮“打开”的回调函数如下:function pushbutton1_Callback(hObject, eventdata, handles)其中pushbutton1是“打开”按钮的Tag.在回调函数下添加如下代码:运行结果如图:2.2预处理回调函数如下:function pushbutton2_Callback(hObject, eventdata, handles)运行结果如图:2.3短时能量短时能量下的回调函数:function pushbutton3_Callback(hObject, eventdata, handles)其回调函数下的代码是:2.4端点检测这里要先声明一点,为了避免在以后的函数调用中,不能使用前面的变量,所以其实后面的函数都包含了前面的部分。

基于Matlab的语音识别系统的设计

基于Matlab的语音识别系统的设计

摘要语音识别主要是让机器听懂人说的话,即在各种情况下,准确地识别出语音的内容,从而根据其信息执行人的各种意图。

语音识别技术既是国际竞争的一项重要技术,也是每一个国家经济发展不可缺少的重要技术支撑。

本文基于语音信号产生的数学模型,从时域、频域出发对语音信号进行分析,论述了语音识别的基本理论。

在此基础上讨论了语音识别的五种算法:动态时间伸缩算法(Dynamic Time Warping,DTW)、基于规则的人工智能方法、人工神经网络(Artificial Neural Network,ANN)方法、隐马尔可夫(Hidden Markov Model,HMM)方法、HMM和ANN的混合模型。

重点是从理论上研究隐马尔可夫(HMM)模型算法,对经典的HMM模型算法进行改进。

语音识别算法有多种实现方案,本文采取的方法是利用Matlab强大的数学运算能力,实现孤立语音信号的识别。

Matlab 是一款功能强大的数学软件,它附带大量的信号处理工具箱为信号分析研究,特别是文中主要探讨的声波分析研究带来极大便利。

本文应用隐马尔科夫模型(HMM) 为识别算法,采用MFCC(MEL频率倒谱系数)为主要语音特征参数,建立了一个汉语数字语音识别系统,其中包括语音信号的预处理、特征参数的提取、识别模板的训练、识别匹配算法;同时,提出利用Matlab图形用户界面开发环境设计语音识别系统界面,设计简单,使用方便,系统界面友好。

经过统计,识别效果明显达到了预期目标。

关键词:语音识别算法;HMM模型;Matlab;GUIABSTRACTSpeech Recognition is designed to allow machines to understand what people say,and accurately identify the contents of voice to execute the intent of people.Speech recognition technology is not only an important internationally competed technology,but also an indispensable foundational technology for the national economic development.Based on the mathematical model from the speech signal,this paper analyze audio signal from the time domain,frequency domain proceeding,and discussed the basic theory of speech recognition technology.Five algorithm are discussed:Dynamic Time Warping(DTW)、Rule-based Artificial Intelligence,Artificial Neural Network(ANN),Hidden Markov Model(HMM),HMM combined with ANN.The focus is put in the theoretical studies of Hidden Markov(HMM) model algorithm,and the classical HMM algorithm is improved.Speech recognition algorithm is realized in various programs,this article taking the method is to use Matlab powerful mathematical operation ability to realize the recognition of speech signal isolation. Matlab is a powerful mathematic software with a mass of toolboxes dealing with signal processing. It gives a terrific shortcut to the research of signal processing,especially the wave analysis. We can characterize the sound with key parameters such as intensity, frequency etc. In this paper, hidden Markov model (HMM) recognition algorithm using MFCC (MELfrequency cepstral coefficients) as the main voice characteristic parameters, the establishment of a Chinese digital speech recognition system, including the preprocessing of the speech signal,the extraction of characteristic parameters the training of the recognition template,identifying matching algorithm;the same time,the use of Matlab graphical user interface development environment designed speech recognition system interface,is designed to be simple,easy to use,friendly interface. Besides,to have a simple exploration of the voice recognition is another target.After statistics,recognition result obviously is made out as the expected goal.Key words:Speech recognition algorithm;HMM model;Matlab;GUI目录一、前言 (1)1.1语音识别的发展历史 (1)1.2语音识别研究现状 (1)1.3语音识别系统的分类 (2)1.4语音识别系统的基本构成 (3)1.5语音识别技术难点 (3)1.6语音识别发展前景 (4)二、语音信号分析 (4)2.1语音学知识 (4)2.1.1音素和音节 (5)2.1.2汉语的声调 (5)2.1.3语音信号产生模型 (6)2.2语音信号数字化和预处理 (7)2.2.1数字化 (7)2.2.2预加重处理 (7)2.2.3防混叠滤波 (8)2.2.4加窗处理 (8)2.3语音信号的时域分析 (9)2.3.1短时能量分析 (9)2.3.2短时平均过零率 (11)2.3.3短时自相关函数和短时平均幅度差函数 (12)2.3.4语音端点检测 (13)2.4语音信号的频域分析 (14)2.4.1滤波器组法 (14)2.4.2傅立叶频谱分析 (14)2.5特征参数提取 (15)2.5.1 LPCC倒谱系数 (15)2.5.2 Mel频率倒谱系数 (16)三、语音识别主要算法 (17)3.1动态时间伸缩算法 (17)3.2基于规则的人工智能方法 (18)3.3人工神经网络方法 (19)3.4隐马尔可夫方法 (20)3.5 HMM和ANN的混合模型 (21)四、隐含马尔可夫模型算法 (23)4.1 HMM的基本理论和数学描述 (23)4.2 HMM的三个基本问题及解决算法 (24)4.3 HMM算法的改进 (31)4.4 HMM的结构和类型 (33)4.5 HMM算法实现的问题 (34)五、基于Matlab环境下的语音识别算法实现 (35)5.1识别系统平台介绍 (35)5.2在Matlab中HMM算法的实现 (36)5.2.1端点检测 (36)5.2.2特征参数提取 (36)5.2.3训练和识别 (37)5.3实验结论分析 (38)六、结束语 (39)6.1回顾 (39)6.2展望 (39)七、致谢 (40)参考文献 (40)一、前言1.1语音识别的发展历史作为智能计算机研究的主导方向和人机语音通信的关键技术,语音识别技术一直受到各国科学界的广泛关注。

语音识别的matlab实现

语音识别的matlab实现

语音识别的MATLAB实现声控小车结题报告小组成员:关世勇吴庆林一、项目要求:声控小车是科大华为科技制作竞赛命题组的项目,其要求是编写一个语言识别程序并适当改装一个小型机动车,使之在一个预先不知道具体形状的跑道上完全由声控来完成行驶比赛。

跑道上可以有坡面,坑,障碍等多种不利条件,小车既要具有较快的速度,也要同时具有较强的灵活性,能够克服上述条件。

二、项目分析:由于小车只要求完成跑道上的声控行驶,所以我们可以使用简单的单音命令来操作,如“前”、“后”、“左”、“右”等。

由于路面有各种不利条件,而且规则要求小车尽可能不越过边线,这就决定了我们的小车不能以较高的速度进行长时间的快速行驶。

所以我们必须控制小车的速度和行进距离。

由于外界存在噪声干扰,所以我们必须对噪声进行处理以减小其影响。

鉴于上诉各种要求,我们决定对购买的遥控小车进行简单改造,使用PC机已有的硬件条件编写软件来完成语音的输入,采集,处理和识别,以实现对小车的控制。

三、解决思路与模块:整个程序大致可划分为三个模块,其结构框图如下图所示:整个程序我们在Visual C++ 环境下编写。

四、各模块的实现:1 声音的采集:将声音信号送入计算机,我们利用了声卡录音的低层操作技术,即对winmm.lib进行API调用。

具体编程时这一部分被写在一个类中(Soundin类)。

在构造函数中设定包括最大采样率(11025),数据缓存(作为程序一次性读入的数据,2048),声卡本身所带的一些影响采样数据等的各种参数;调用API函数waveInGetNumDevs(返回UNIT,参数为空)检察并打开声音输入设备,即声卡;并进而使用waveInGetDevCaps得到声卡的容量(在waveInCaps中存有该数据,对其进行地址引用,从DWORD dwFormats得到最大采样率、声道数和采样位);创建一个叫WaveInThreadEvent的事件对象,并赋予一个Handle,叫m_WaveInEvent,开始利用线程指针m_WaveInThread调用自定义的线程WaveInThreadProc;对结构WAVEFORMATEX中WaveInOpen开始提供录音设备。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

(威海)《智能仪器》课程设计题目: MATLAB实现语音识别功能班级:学号:姓名:同组人员:任课教师:完成时间:2012/11/3目录一、设计任务及要求 (1)二、语音识别的简单介绍2.1语者识别的概念 (2)2.2特征参数的提取 (3)2.3用矢量量化聚类法生成码本 (3)2.4VQ的说话人识别 (4)三、算法程序分析3.1函数关系 (4)3.2代码说明 (5)3.2.1函数mfcc (5)3.2.2函数disteu (5)3.2.3函数vqlbg (6)3.2.4函数test (6)3.2.5函数testDB (7)3.2.6 函数train (8)3.2.7函数melfb (8)四、演示分析 (9)五、心得体会 (11)附:GUI程序代码 (12)一、设计任务及要求用MATLAB实现简单的语音识别功能;具体设计要求如下:用MATLAB实现简单的数字1~9的语音识别功能。

二、语音识别的简单介绍基于VQ的说话人识别系统,矢量量化起着双重作用。

在训练阶段,把每一个说话者所提取的特征参数进行分类,产生不同码字所组成的码本。

在识别(匹配)阶段,我们用VQ方法计算平均失真测度(本系统在计算距离d时,采用欧氏距离测度),从而判断说话人是谁。

语音识别系统结构框图如图1所示。

图1 语音识别系统结构框图2.1语者识别的概念语者识别就是根据说话人的语音信号来判别说话人的身份。

语音是人的自然属性之一,由于说话人发音器官的生理差异以及后天形成的行为差异,每个人的语音都带有强烈的个人色彩,这就使得通过分析语音信号来识别说话人成为可能。

用语音来鉴别说话人的身份有着许多独特的优点,如语音是人的固有的特征,不会丢失或遗忘;语音信号的采集方便,系统设备成本低;利用网络还可实现远程客户服务等。

因此,近几年来,说话人识别越来越多的受到人们的重视。

与其他生物识别技术如指纹识别、手形识别等相比较,说话人识别不仅使用方便,而且属于非接触性,容易被用户接受,并且在已有的各种生物特征识别技术中,是唯一可以用作远程验证的识别技术。

因此,说话人识别的应用前景非常广泛:今天,说话人识别技术已经关系到多学科的研究领域,不同领域中的进步都对说话人识别的发展做出了贡献。

说话人识别技术是集声学、语言学、计算机、信息处理和人工智能等诸多领域的一项综合技术,应用需求将十分广阔。

在吃力语音信号的时候如何提取信号中关键的成分尤为重要。

语音信号的特征参数的好坏直接导致了辨别的准确性。

2.2特征参数的提取对于特征参数的选取,我们使用mfcc的方法来提取。

MFCC参数是基于人的听觉特性利用人听觉的屏蔽效应,在Mel标度频率域提取出来的倒谱特征参数。

MFCC 参数的提取过程如下:1. 对输入的语音信号进行分帧、加窗,然后作离散傅立叶变换,获得频谱分布信息。

设语音信号的DFT 为:10,)()(112-≤≤=∑-=-N k en x k X N n N nk j a π(1)其中式中x(n)为输入的语音信号,N 表示傅立叶变换的点数。

2. 再求频谱幅度的平方,得到能量谱。

3. 将能量谱通过一组Mel 尺度的三角形滤波器组。

我们定义一个有M 个滤波器的滤波器组(滤波器的个数和临界带的个数相近),采用的滤波器为三角滤波器,中心频率为f(m),m=1,2,3,···,M本系统取M=100。

4. 计算每个滤波器组输出的对数能量。

N 12a m k 1S(m)ln(|(k)|H (k)),0m M 1X -==≤≤-∑ (2)其中m H (k)为三角滤波器的频率响应。

5. 经过离散弦变换(DCT )得到MFCC 系数。

10C(n)()cos((0.5/)),(3)01M m S m n m m n N π-==-≤≤-∑MFCC 系数个数通常取20—30,常常不用0阶倒谱系数,因为它反映的是频谱能量,故在一般识别系统中,将称为能量系数,并不作为倒谱系数,本系统选取20阶倒谱系数。

2.3用矢量量化聚类法生成码本我们将每个待识的说话人看作是一个信源,用一个码本来表征。

码本是从该说话人的训练序列中提取的MFCC 特征矢量聚类而生成。

只要训练的序列足够长,可认为这个码本有效地包含了说话人的个人特征,而与讲话的容无关。

本系统采用基于分裂的LBG 的算法设计VQ 码本,(1,2,,)k X k K =⋅⋅⋅为训练序列,B 为码本。

具体实现过程如下:1. 取提取出来的所有帧的特征矢量的型心(均值)作为第一个码字矢量B1。

2. 将当前的码本Bm 根据以下规则分裂,形成2m 个码字。

)1()1({εε-=+=-+m m m m B B B B (4) 其中m 从1变化到当前的码本的码字数,ε是分裂时的参数,本文ε=0.01。

3. 根据得到的码本把所有的训练序列(特征矢量)进行分类,然后按照下面两个公式计算训练矢量量化失真量的总和[]n D 以及相对失真(n 为迭代次数,初始n=0,[1]D -=∞,B 为当前的码书),若相对失真小于某一阈值ε,迭代结束,当前的码书就是设计好的2m 个码字的码书,转5。

否则,转下一步。

量化失真量和:()1min (,)Kn k k D d X B ==∑ (5)相对失真:(1)||n nn D D D-- (6) 4. 重新计算各个区域的新型心,得到新的码书,转3。

5. 重复2 ,3 和4步,直到形成有M 个码字的码书(M 是所要求的码字数),其中D0=10000。

2.4 VQ 的说话人识别设是未知的说话人的特征矢量1{,,}T X X K ,共有T 帧是训练阶段形成的码书,表示码书第m 个码字,每一个码书有M 个码字。

再计算测试者的平均量化失真D ,并设置一个阈值,若D 小于此阈值,则是原训练者,反之则认为不是原训练者。

∑=≤≤=11]min[/1),(j Mm m j T D B x d (7) 三、 算法程序分析在具体的实现过程当中,采用了matlab 软件来帮助完成这个项目。

在matlab 中主要由采集,分析,特征提取,比对几个重要部分。

以下为在实际的操作中,具体用到得函数关系和作用一一列举在下面。

3.1函数关系主要有两类函数文件Train.m 和Test.m在Train.m 调用Vqlbg.m 获取训练录音的vq 码本,而Vqlbg.m 调用mfcc.m 获取单个录音的mel 倒谱系数,接着mfcc.m 调用Melfb.m---将能量谱通过一组Mel 尺度的三角形滤波器组。

在Test.m 函数文件中调用Disteu.m 计算训练录音(提供vq 码本)与测试录音(提供mfcc )mel 倒谱系数的距离,即判断两声音是否为同一录音者提供。

Disteu.m 调用mfcc.m 获取单个录音的mel 倒谱系数。

mfcc.m 调用Melfb.m---将能量谱通过一组Mel 尺度的三角形滤波器组。

3.2具体代码说明3.2.1函数mffc:function r = mfcc(s, fs)---m = 100;n = 256;l = length(s);nbFrame = floor((l - n) / m) + 1; %沿-∞方向取整for i = 1:nfor j = 1:nbFrameM(i, j) = s(((j - 1) * m) + i); %对矩阵M赋值endendh = hamming(n); %加 hamming 窗,以增加音框左端和右端的连续性M2 = diag(h) * M;for i = 1:nbFrameframe(:,i) = fft(M2(:, i)); %对信号进行快速傅里叶变换FFTendt = n / 2;tmax = l / fs;m = melfb(20, n, fs); %将上述线性频谱通过Mel 频率滤波器组得到Mel 频谱,下面在将其转化成对数频谱n2 = 1 + floor(n / 2);z = m * abs(frame(1:n2, :)).^2;r = dct(log(z)); %将上述对数频谱,经过离散余弦变换(DCT)变换到倒谱域,即可得到Mel 倒谱系数(MFCC参数)3.2.2函数disteu---计算测试者和模板码本的距离function d = disteu(x, y)[M, N] = size(x); %音频x赋值给【M,N】[M2, P] = size(y); %音频y赋值给【M2,P】if (M ~= M2)error('不匹配!') %两个音频时间长度不相等endd = zeros(N, P);if (N < P)%在两个音频时间长度相等的前提下copies = zeros(1,P);for n = 1:Nd(n,:) = sum((x(:, n+copies) - y) .^2, 1);endelsecopies = zeros(1,N);for p = 1:Pd(:,p) = sum((x - y(:, p+copies)) .^2, 1)';end%%成对欧氏距离的两个矩阵的列之间的距离endd = d.^0.5;3.2.3函数vqlbg---该函数利用矢量量化提取了音频的vq码本function r = vqlbg(d,k)e = .01;r = mean(d, 2);dpr = 10000;for i = 1:log2(k)r = [r*(1+e), r*(1-e)];while (1 == 1)z = disteu(d, r);[m,ind] = min(z, [], 2);t = 0;for j = 1:2^ir(:, j) = mean(d(:, find(ind == j)), 2);x = disteu(d(:, find(ind == j)), r(:, j));for q = 1:length(x)t = t + x(q);endendif (((dpr - t)/t) < e)break;elsedpr = t;endendend3.2.4函数testfunction finalmsg = test(testdir, n, code)for k = 1:n % read test sound file of each speaker file = sprintf('%ss%d.wav', testdir, k);[s, fs] = wavread(file);v = mfcc(s, fs); % 得到测试人语音的mel倒谱系数distmin = 4; %阈值设置处% 就判断一次,因为模板里面只有一个文件d = disteu(v, code{1}); %计算得到模板和要判断的声音之间的“距离”dist = sum(min(d,[],2)) / size(d,1); %变换得到一个距离的量%测试阈值数量级msgc = sprintf('与模板语音信号的差值为:%10f ', dist);disp(msgc);%此人匹配if dist <= distmin %一个阈值,小于阈值,则就是这个人。

相关文档
最新文档