一、隐马尔可夫模型简介

隐马尔可夫模型(Hidden Markov model, HMM)是一种结构最简单的动态贝叶斯网的生成模型,它也是一种著名的有向图模型。它是典型的自然语言中处理标注问题的统计机器学模型,本文将重点介绍这种经典的机器学习模型。
1 引言
假设有三个不同的骰子(6面、4面、8面),每次先从三个骰子里面选择一个,每个骰子选中的概率为1/3,如下图所示,重复上述过程,得到一串数值[1,6,3,5,2,7]。这些可观测变量组成可观测状态链。同时,在隐马尔可夫模型中还有一条由隐变量组成的隐含状态链,在本例中即骰子的序列。比如得到这串数字骰子的序列可能为[D6, D8, D8, D6, D4, D8]。

隐马尔可夫型示意图如下所示:

图中,箭头表示变量之间的依赖关系。图中各箭头的说明如下:

在任意时刻,观测变量(骰子)仅依赖于状态变量(哪类骰子),同时t时刻的状态qt仅依赖于t-1时刻的状态qt-1。这就是马尔科夫链,即系统的下一时刻仅由当前状态(无记忆),即“齐次马尔可夫性假设”

2 隐马尔可夫模型的定义
根据上面的例子,这里给出隐马尔可夫的定义。隐马尔科夫模型是关于时序的概率模型,描述由一个隐藏的马尔可夫链随机生成不可观测的状态随机序列,再由各个状态生成一个可观测的随机序列的过程,隐藏的马尔可夫链随机生成的状态序列,称为状态序列(也就上面例子中的D6,D8等);每个状态生成一个观测,而由此产生的观测随机序列,称为观测序列(也就上面例子中的1,6等)。序列的每个位置又可以看作是一个时刻。
隐马尔可夫模型由初始的概率分布、状态转移概率分布以及观测概率分布确定。具体的形式如下,这里设Q是所有可能的状态的集合,V是所有可能的观测的集合,即有:



3 前向算法


对于步骤一的初始,是初始时刻的状态i1 = q1和观测o1的联合概率。步骤(2) 是前向概率的递推公式,计算到时刻t+1部分观测序列为o1,o2,…,ot,ot+1 且在时刻t+1处于状态qi的前向概率。如上图所示,既然at(j)是得到时刻t观测到o1,o2,…,ot并在时刻t处于状态的qj前向概率,那么at(j)aji就是到时刻t观测到o1,o2,…,ot并在是时刻t处于qj状态而在时刻t+1到达qi状态的联合概率。对于这个乘积在时刻t的所有可能的N个状态求和,其结果就是到时刻t观测为o1,o2,…,ot,并在时刻t+1处于状态qi的联合概率。最后第三步,计算出P(O|lamda)的结果。

当然这里只是介绍了诸多算法中的一种,类似的还有后向算法(大家可以看相关的书籍进行了解)。对于动态规划的解决隐马尔科夫模型预测问题,应用最多的是维特比算法。

二、部分源代码

function varargout = HMM_VoiceRecognation(varargin)
% HMM_VOICERECOGNATION MATLAB code for HMM_VoiceRecognation.fig
%      HMM_VOICERECOGNATION, by itself, creates a new HMM_VOICERECOGNATION or raises the existing
%      singleton*.
%
%      H = HMM_VOICERECOGNATION returns the handle to a new HMM_VOICERECOGNATION or the handle to
%      the existing singleton*.
%
%      HMM_VOICERECOGNATION('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in HMM_VOICERECOGNATION.M with the given input arguments.
%
%      HMM_VOICERECOGNATION('Property','Value',...) creates a new HMM_VOICERECOGNATION or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before HMM_VoiceRecognation_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to HMM_VoiceRecognation_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools 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 HMM_VoiceRecognation% Last Modified by GUIDE v2.5 07-Jan-2022 20:30:18% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...'gui_Singleton',  gui_Singleton, ...'gui_OpeningFcn', @HMM_VoiceRecognation_OpeningFcn, ...'gui_OutputFcn',  @HMM_VoiceRecognation_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 HMM_VoiceRecognation is made visible.
function HMM_VoiceRecognation_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 HMM_VoiceRecognation (see VARARGIN)% Choose default command line output for HMM_VoiceRecognation
handles.output = hObject;% Update handles structure
guidata(hObject, handles);% UIWAIT makes HMM_VoiceRecognation wait for user response (see UIRESUME)
% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.
function varargout = HMM_VoiceRecognation_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 button_choose.
function button_choose_Callback(hObject, eventdata, handles)
% hObject    handle to button_choose (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% fname: 返回文件名
% panme: 返回文件路径名
% index: 选择的文件类型
global fname
global pname
[fname, pname, index] = uigetfile( { '*.wav', '选择语音文件'} ) ;
set( handles.button_reco, 'Enable', 'on' ) % --- Executes on button press in button_reco.
function button_reco_Callback(hObject, eventdata, handles)
% hObject    handle to button_reco (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global fname
global pname
global strfilename = strcat( pname, '\\', fname ) ;
load('hmm.mat')
% 发音
[ y, fs ] = audioread(filename) ;
sound(y, fs) ;
% 识别
x = wavread(filename);
[x1 x2] = vad(x);
m = mfcc(x);
m = m(x1-2:x2-2,:);
for j=1:10pout(j) = viterbi(hmm{j}, m);
end
[d,result_index] = max(pout);
%在static text里显示结果
if result_index == 10% --- Executes on button press in button_exit.
function button_exit_Callback(hObject, eventdata, handles)
% hObject    handle to button_exit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
clear all
close% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: contents = cellstr(get(hObject,'String')) returns listbox1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox1% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns calledfunction edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (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 edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (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 button_clear.
function button_clear_Callback(hObject, eventdata, handles)
% hObject    handle to button_clear (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
function f=enframe(x,win,inc)
%ENFRAME split signal up into (overlapping) frames: one per row. F=(X,WIN,INC)
%
%   F = ENFRAME(X,LEN) splits the vector X up into
%   frames. Each frame is of length LEN and occupies
%   one row of the output matrix. The last few frames of X
%   will be ignored if its length is not divisible by LEN.
%   It is an error if X is shorter than LEN.
%
%   F = ENFRAME(X,LEN,INC) has frames beginning at increments of INC
%   The centre of frame I is X((I-1)*INC+(LEN+1)/2) for I=1,2,...
%   The number of frames is fix((length(X)-LEN+INC)/INC)
%
%   F = ENFRAME(X,WINDOW) or ENFRAME(X,WINDOW,INC) multiplies
%   each frame by WINDOW(:) %
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% nx=length(x);
nwin=length(win);
if (nwin == 1) len = win;
else len = nwin;
end
if (nargin < 3) inc = len;
end
nf = fix((nx-len+inc)/inc);
f=zeros(nf,len);
indf= inc*(0:(nf-1)).';
inds = (1:len);
f(:) = x(indf(:,ones(1,len))+inds(ones(nf,1),:));
if (nwin > 1) w = win(:)'; f = f .* w(ones(nf,1),:);
end 

三、运行结果














四、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1]韩纪庆,张磊,郑铁然.语音信号处理(第3版)[M].清华大学出版社,2019.
[2]柳若边.深度学习:语音识别技术实践[M].清华大学出版社,2019.

【语音识别】基于matlab GUI HMM 0~9数字和汉字语音识别(带面板)【含Matlab源码 1716期】相关推荐

  1. 【语音识别】基于DTW算法实现0~9数字和汉字语音识别含Matlab源码

    1 简介 在孤立词语音识别中,动态时间规整DTW算法是一种应用较为广泛的算法之一,有着较强的科学性,在立足于当前DTW语音识别算法应用的实际情况下,简略阐述了该课题的研究背景,并从预处理和特征参数提取 ...

  2. 【路径规划】基于matlab GUI蚁群算法机器人栅格地图最短路径规划【含Matlab源码 927期】

    ⛄一.蚁群算法简介 1 引言 在自然界中各种生物群体显现出来的智能近几十年来得到了学者们的广泛关注,学者们通过对简单生物体的群体行为进行模拟,进而提出了群智能算法.其中, 模拟蚁群觅食过程的蚁群优化算 ...

  3. 【图像加密】基于matlab GUI Logistic+Tent+Kent+Henon图像加密与解密【含Matlab源码 1745期】

    ⛄一.混沌系统简介 0 引言 随着通讯技术的飞速发展, 越来越多的领域需要传送数字图像信号, 因此信息的传送安全问题显得越来越重要.通常应用于数字图像通信的两种保护技术为:数字水印技术和图像加密技术. ...

  4. 【路径规划】基于matlab GUI多种蚁群算法栅格地图最短路径规划【含Matlab源码 650期】

    ⛄一.蚁群算法及栅格地图简介 1 蚁群算法 1.1 蚁群算法的提出 蚁群算法(ant colony optimization, ACO),又称蚂蚁算法,是一种用来寻找优化路径的机率型算法.它由Marc ...

  5. 【药材识别】基于matlab GUI SVM色差色温判断药材炮制程度系统【含Matlab源码 2241期】

    ⛄一.SVM色差色温判断药材炮制程度系统简介 本课题来源于"十二五"国家科技支撑计划项目(2012BAI29B11).颜色是中药质量标准中性状评价极为重要的内容,但传统的中药颜色检 ...

  6. matlab svm 语音识别,【情感识别】基于matlab支持向量机(SVM)的语音情感识别【含Matlab源码 543期】...

    一.简介 支持向量机(Support Vector Machine)是Cortes和Vapnik于1995年首先提出的,它在解决小样本.非线性及高维模式识别中表现出许多特有的优势,并能够推广应用到函数 ...

  7. 【图像处理】基于matlab GUI多功能图像处理系统【含Matlab源码 1876期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[图像处理]基于matlab GUI多功能图像处理系统[含Matlab源码 1876期] 点击上面蓝色字体,直接付费下载,即可. 获取代码 ...

  8. 【Matlab验证码识别】遗传算法和最大熵优化+大津法(OTSU)+自定义阈值数字验证码识别【含GUI源码 1694期】

    一.代码运行视频(哔哩哔哩) [Matlab验证码识别]遗传算法和最大熵优化+大津法(OTSU)+自定义阈值数字验证码识别[含GUI源码 1694期] 二.matlab版本及参考文献 1 matlab ...

  9. 【电力预测】基于matlab GUI灰色模型电力负荷预测【含Matlab源码 769期】

    一.获取代码方式 获取代码方式1: 完整代码已上传我的资源: [电力负荷预测]基于matlab GUI灰色模型电力负荷预测[含Matlab源码 769期] 获取代码方式2: 通过订阅紫极神光博客付费专 ...

  10. 【数据分析】基于matlab GUI齿轮箱振动数据分析【含Matlab源码 2122期】

    一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[数据分析]基于matlab GUI齿轮箱振动数据分析[含Matlab源码 2122期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方 ...

最新文章

  1. java创建线程的两种方法区别
  2. Manjaro Linux执行某些命令缺少libtinfo.so.5问题
  3. 我的世界服务器刷怪笼怎么修改,我的世界改造刷怪笼的方法,有三种方法介绍...
  4. 爬虫实战:使用Selenium爬取京东宝贝信息
  5. 腾讯AI Lab联合清华,港中文长文解析图深度学习的历史、最新进展到应用
  6. 工作97:父子组件传值
  7. c语言学习-计算200-300之间的偶数和并将和打印输出
  8. 188. 买卖股票的zui佳时机 IV(JavaScript)
  9. JAVA POI读取Excel中Cell为null的处理
  10. [译] 通过官网 Go 语言学习笔记 | How to Write Go Code
  11. ICPC China Nanchang National Invitational -- D. Match Stick Game(dp)
  12. php简单使用shmop函数创建共享内存减少服务器负载
  13. NodeJS Stream 三:readable
  14. 关于浏览器兼容的问题
  15. HBase开发实例学习
  16. 运行 appimage linux,Linux 设置图标启动 AppImage (Wiznote和Navicat)
  17. 网络通信基础知识总结
  18. npcap关闭_npcap是什么软件
  19. [c++]平均成绩、从尾到头打印链表、整数从大到小排序、二分法查找、斐波那契数列
  20. 【无标题】水泥稳定层施工

热门文章

  1. DNS和活动目录的关系
  2. SVM支持向量分类器原理及OpenCV实现
  3. php实现微信小程序人脸识别登录
  4. 非常吃惊,程序猿在工作中的幸福感居然是?????
  5. 【软考10】计算机网络基础知识拾遗
  6. 错误因为数据库正在使用,所以无法获得对数据库的独占访问权的解决方案(转)...
  7. 20200707每日一句
  8. 20200602每日一句
  9. 190527每日一句,励志| 为了成功,约束自己;有时候“再等等”,就再也等不到了
  10. 21个GIF动图让你了解各种数学概念