Introduction
This article describes how to deploy htk Kit HCopy and HDecode tools to android phone, enabling mobile terminal offline speech recognition function. c is an open source language htk kit in the android NDK to integrate the tool in the package.
NDK build environment can refer Andye the blog in the history of the most straightforward Android jni development environment to build data -NDK. Speak very comprehensive. I will not repeat here
HCopy Kit
View HTK file in MakeFile know HCopy rely on the following documents
HCopy.c esig_asc.c esignal.c esig_edr.c esig_nat.c HAdapt.c HArc.c HAudio.c HDict.c HExactMPE.c HFB.c HFBLat.c HLabel. c HLat.c HLM.c HMap.c HMath.c HMem.c HModel.c HNet.c HParm.c HRec.c HShell.c HSigP.c HTrain.c HUtil.c HVQ.c HWave.c strarr.c
the these files are copied to jni directory. Android.mk and modify files:
1 |
LOCAL_PATH := $(call my-dir) |
Build on what you can compile the source code and generates libTestNdk.so HCopy file in the obj / local / armeabi / directory, add the following code to the need to call the DLL class:
1 |
static { |
Of course HCopy suitable for use in linux terminal environment, in practical engineering, HCopy need to modify the source code. Enabling him to continuously extract features of multiple files and initialization is performed only once.
First HCopy in the initialization part of the main function to move all HCopyInit function, and the like OpenSpeechFile PutTargetFile extraction features and functions to move HCopyWhile function.
Then jni interface functions to call him.
1 |
int argc=5; |
HDecode Kit
By looking at HDecode in the Makefile know HDecode dependent files while compiling HDecode need to carry parameters -DNO_LAT_LM, based on this Android.mk add the following in the file:
. 1 |
include $(CLEAR_VARS) |
And copy the file to the folder jni. Build on what you can compile the source code and generates libTestHDNdk.so HDecode file in the obj / local / armeabi / directory, add the following code to the need to call the DLL class:
1 |
static { |
Also HDecode suitable for use in linux terminal environment, in practical engineering, HDecode need to modify the source code. Referring to complete HCopy modification method.
1 |
int argc=27; |
Recognition results
In practical engineering, to save the audio recording of the phone to /hucd/a.wav in, and in turn call HCopyDoFile and HDecodeDoFile function can be found in the identification results / hucd / out files generated.
Since the environment is not generally exist android gunzip other tools, and therefore do not attempt to use Fillter in hdecode.hlda.cfg, if HLANGMODFILTER = 'gunzip -c $ .gz' Please remove similar configuration, and the language model uncompressed.