HTK3.5支持DNN
HTK3.5支持DNN了,本来想做一个HMM+DNN的模型,作为HMM+GMM的对比。但是HTK不支持实时的HMM+DNN解码。原因有两个。
- HTK不支持实时的计算MFCC_0_D_A_Z的特征,即无法实时计算出特征空间的均值。
- HTK不支持实时的DNN或者HMM+DNN的解码。
所以只能做离线的演示。为了学习HVITE的细节,我决定将HVITE工具单独编译。
HTK的源文件结构
- HTK的源文件分为lib和tool两个层次。lib文件之间可能有相互依赖(dependency),而tool文件之间相互独立。
- HTK主要有HTK和HLM两大类工具,前者做语音识别而后者主要是语言模型。
这次只需要将HTKLib文件夹的所有文件和HTKTools中的HVITE文件提取出来即可。
Visual Studio Code
下面的内容有不详细的地方,可以参考这个链接。
https://code.visualstudio.com/docs/languages/cpp
- Visual studio code是一个轻量化,跨平台的调试工具。安装后,需要安装两个插件,分别是C/C++,C++ intellisense。

- 然后将源文件在workspace中打开

- 编译需要GCC工具,在编译之前需要配置tasks.json,相当于一个脚本。
1)打开 Command Palette (Ctrl+Shift+P).
2)选择 Configure Task command
3)点击 Create tasks.json file from templates
4)选择 Others
5)label是对这个build task的命名,这里为HVITE。
6)command表示编译指令,我因为使用了makefile,这里只需要写make。
{// See https://go.microsoft.com/fwlink/?LinkId=733558// for the documentation about the tasks.json format"version": "2.0.0","tasks": [{"label": "HVITE","type": "shell","command": "make","group": {"kind": "build","isDefault": true}}]
}
- 而调试需要GDB工具,需要选择C++(GDB/LLDB)。选择之后需要配置launch.json.
1)最左侧的标签选择 Debug,点击Configure icon.
2)选择C++ (GDB/LLDB),就会弹出launch.json.
3)需要修改program参数,即为之前设置的名字,这里是"${workspaceFolder}/hvite"。
4)args指的是HVITE函数所需要输入的参数。
5)为了能够在调试这前进行编译任务,需要增加一个参数"preLaunchTask": “HVITE”
{// Use IntelliSense to learn about possible attributes.// Hover to view descriptions of existing attributes.// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{"name": "(gdb) Launch","type": "cppdbg","request": "launch","program": "${workspaceFolder}/hvite","args" :[ "-A", "-D", "-T", "1", "-I", "reco.mlf", "-y", "lab","-H", "hmm2/hmm_nhxr", "-H", "hmm2/hmm_xxxx","-S", "./alldataset.scp", "-w", "net.slf", "dict.txt","hmmlist.txt"],// "args": ["-f", "-o", "W", "-i", "train.align", "-I", "reco.mlf", // "-y", "lab", "-H", "./epoch25/models", "-S", "./alldataset.scp", // "-w", "net.slf", "dict.txt", "hmmlist.txt"],"stopAtEntry": false,"cwd": "${workspaceFolder}","environment": [],"externalConsole": true,"MIMode": "gdb","setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true}],"preLaunchTask": "HVITE"}]
}
- Makefile
编译器CC为gcc,LDFLGAS是需要包含的库文件,需要注明-lpthread -lm -lX11,否则会提示缺少头文件。
######################################
#
######################################
#source file
#源文件,自动找所有.c和.cpp文件,并将目标定义为同名.o文件
SOURCE := $(wildcard src/*.c) $(wildcard src/*.cpp)
OBJS := $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE)))
#target you can change test to what you want
#目标文件名,输入任意你想要的执行文件名
TARGET := hvite
#compile and lib parameter
#编译参数
CC := gcc
LIBS :=
LDFLAGS := -lpthread -lm -lX11
DEFINES :=
INCLUDE := -I. -Isrc/
CFLAGS := $(CFLAGS) -m64 -ansi -std=gnu99 -D_SVID_SOURCE -DOSS_AUDIO -D'ARCH="x86_64"' -Wall -Wno-switch -g -I. -DPHNALG
#CFLAGS := -g -Wall -O3 $(DEFINES) $(INCLUDE)
CXXFLAGS:= $(CFLAGS) -DHAVE_CONFIG_H
#i think you should do anything here
#下面的基本上不需要做任何改动了
.PHONY : everything objs clean veryclean rebuildeverything : $(TARGET)all : $(TARGET)objs : $(OBJS)rebuild: veryclean everythingclean :rm -fr src/*.sorm -fr src/*.overyclean : cleanrm -fr $(TARGET)
$(TARGET) : $(OBJS)$(CC) $(CXXFLAGS) -o $@ $(OBJS) $(LDFLAGS) $(LIBS)
把这些都准备好后,就可以单独编译和调试HVTIE,学习解码过程了。













