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
下面的內容有不詳細的地方,可以參考這個鏈接。
- 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 rebuild
everything : $(TARGET)
all : $(TARGET)
objs : $(OBJS)
rebuild: veryclean everything
clean :
rm -fr src/*.so
rm -fr src/*.o
veryclean : clean
rm -fr $(TARGET)
$(TARGET) : $(OBJS)
$(CC) $(CXXFLAGS) -o $@ $(OBJS) $(LDFLAGS) $(LIBS)
把這些都準備好後,就可以單獨編譯和調試HVTIE,學習解碼過程了。