diff options
47 files changed, 601 insertions, 1479 deletions
diff --git a/htk_io/Makefile b/htk_io/Makefile index d32d17a..6a5f529 100644 --- a/htk_io/Makefile +++ b/htk_io/Makefile @@ -1,3 +1,7 @@ +ifndef LUA_BINDIR +$(error Please build the package via luarocks: `luarocks make`) +endif + .PHONY: tnet SHELL := /bin/bash BUILD_DIR := $(CURDIR)/build @@ -17,6 +21,7 @@ OBJ_SUBDIR := $(addprefix $(OBJ_DIR)/,$(SUBDIR)) LUA_SUBDIR := $(addprefix $(LUA_DIR)/,$(SUBDIR)) LUA_LIBS := $(addprefix $(LUA_DIR)/,$(LUA_LIBS)) LIB_PATH := $(LUA_BINDIR)/../lib +LUALIB_PATH := $(LUA_BINDIR)/../lib/lua/5.1/ build: $(OBJ_DIR) $(OBJ_SUBDIR) $(OBJS) tnet $(OBJ_DIR)/src/test install: $(LUA_DIR) $(LUA_SUBDIR) $(LUA_LIBS) $(LIBS) @@ -26,7 +31,7 @@ $(OBJ_DIR) $(LUA_DIR) $(OBJ_SUBDIR) $(LUA_SUBDIR): $(LUA_DIR)/%.lua: %.lua cp $< $@ $(LIBS): $(OBJ_DIR)/src/cwrapper.o $(OBJ_DIR)/init.o $(OBJ_DIR)/src/init.o $(OBJ_DIR)/src/libKaldiLib.a - gcc -shared -o $@ $(OBJ_DIR)/src/cwrapper.o $(OBJ_DIR)/init.o $(OBJ_DIR)/src/libKaldiLib.a $(OBJ_DIR)/src/init.o -lstdc++ -Wl,-rpath=$(LIB_PATH) -L$(LIB_PATH) -lnervcore -lluaT + gcc -shared -o $@ $(OBJ_DIR)/src/cwrapper.o $(OBJ_DIR)/init.o $(OBJ_DIR)/src/libKaldiLib.a $(OBJ_DIR)/src/init.o -lstdc++ -Wl,-rpath=$(LIB_PATH) -L$(LIB_PATH) -lnervcore -Wl,-rpath=$(LUALIB_PATH) -L$(LUALIB_PATH) -lnerv -lluaT $(OBJ_DIR)/src/test: $(OBJ_DIR)/src/cwrapper.o $(OBJ_DIR)/src/test.o $(OBJ_DIR)/src/libKaldiLib.a gcc -o $@ $^ -Wl,-rpath=$(LIB_PATH) -L$(LIB_PATH) -lnervcore -Wl,-rpath=$(LUA_LIBDIR) -L$(LUA_LIBDIR) -lluajit-5.1 -lstdc++ -lm $(OBJ_DIR)/src/cwrapper.o: src/cwrapper.cpp @@ -34,7 +39,7 @@ $(OBJ_DIR)/src/cwrapper.o: src/cwrapper.cpp $(OBJ_DIR)/%.o: %.c gcc -o $@ -c $< -g $(INCLUDE) -fPIC clean: - -rm $(OBJ_DIR)/src/*.o + -rm -r $(OBJ_DIR) $(MAKE) -C src/KaldiLib/ clean tnet: $(MAKE) -C src/KaldiLib/ OBJ_DIR=$(OBJ_DIR)/src diff --git a/htk_io/init.c b/htk_io/init.c index edd454f..5b373f9 100644 --- a/htk_io/init.c +++ b/htk_io/init.c @@ -1,4 +1,4 @@ -#include "../nerv/common.h" +#include "nerv/lib/common.h" #include <stdio.h> extern void tnet_io_init(lua_State *L); diff --git a/htk_io/init.lua b/htk_io/init.lua index b360b67..1cdabf1 100644 --- a/htk_io/init.lua +++ b/htk_io/init.lua @@ -6,6 +6,11 @@ function TNetReader:__init(global_conf, reader_conf) self.feat_id = reader_conf.id self.frm_ext = reader_conf.frm_ext self.gconf = global_conf + if self.gconf.use_cpu then + self.mat_type = self.gconf.mmat_type + else + self.mat_type = self.gconf.cumat_type + end self.debug = global_conf.debug if self.debug == nil then self.debug = false @@ -31,12 +36,15 @@ function TNetReader:get_data() end local res = {} -- read HTK feature - local raw = self.gconf.cumat_type.new_from_host(self.feat_repo:cur_utter(self.debug)) + local raw = self.feat_repo:cur_utter(self.debug) + if not self.gconf.use_cpu then + raw = self.gconf.cumat_type.new_from_host(raw) + end local rearranged if self.frm_ext and self.frm_ext > 0 then local step = self.frm_ext * 2 + 1 -- expand the feature - local expanded = self.gconf.cumat_type(raw:nrow(), raw:ncol() * step) + local expanded = self.mat_type(raw:nrow(), raw:ncol() * step) expanded:expand_frm(raw, self.frm_ext) -- rearrange the feature (``transpose'' operation in TNet) if self.gconf.rearrange then @@ -53,8 +61,12 @@ function TNetReader:get_data() feat_utter = self.gconf.mmat_type(rearranged:nrow() - self.gconf.frm_trim * 2, rearranged:ncol()) rearranged:copy_toh(feat_utter, self.gconf.frm_trim, rearranged:nrow() - self.gconf.frm_trim) else - feat_utter = self.gconf.mmat_type(rearranged:nrow(), rearranged:ncol()) - rearranged:copy_toh(feat_utter) + if self.gconf.use_cpu then + feat_utter = rearranged + else + feat_utter = self.gconf.mmat_type(rearranged:nrow(), rearranged:ncol()) + rearranged:copy_toh(feat_utter) + end end res[self.feat_id] = feat_utter -- add corresponding labels diff --git a/htk_io/src/cwrapper.cpp b/htk_io/src/cwrapper.cpp index b7ce2d5..efb5628 100644 --- a/htk_io/src/cwrapper.cpp +++ b/htk_io/src/cwrapper.cpp @@ -8,9 +8,10 @@ extern "C" { #include "cwrapper.h" #include "string.h" -#include "nerv/common.h" +#include "nerv/lib/common.h" +#include "nerv/lib/matrix/mmatrix.h" - extern Matrix *nerv_matrix_host_float_create(long nrow, long ncol, Status *status); + extern Matrix *nerv_matrix_host_float_create(long nrow, long ncol, MContext *context, Status *status); struct TNetFeatureRepo { TNet::FeatureRepository feature_repo; @@ -53,7 +54,8 @@ extern "C" { return repo; } - Matrix *tnet_feature_repo_read_utterance(TNetFeatureRepo *repo, lua_State *L, int debug) { + Matrix *tnet_feature_repo_read_utterance(TNetFeatureRepo *repo, lua_State *L, + int debug, MContext *context) { Matrix *mat; /* nerv implementation */ repo->feature_repo.ReadFullMatrix(repo->feats_host); std::string utter_str = repo->feature_repo.Current().Logical(); @@ -61,7 +63,7 @@ extern "C" { int n = repo->feats_host.Rows(); int m = repo->feats_host.Cols(); Status status; - mat = nerv_matrix_host_float_create(n, m, &status); + mat = nerv_matrix_host_float_create(n, m, context, &status); NERV_LUA_CHECK_STATUS(L, status); size_t stride = mat->stride; if (debug) @@ -119,7 +121,8 @@ extern "C" { size_t sample_rate, const char *tag, lua_State *L, - int debug) { + int debug, + MContext *context) { std::vector<TNet::Matrix<float> > labs_hosts; /* KaldiLib implementation */ Matrix *mat; repo->label_repo.GenDesiredMatrixExt(labs_hosts, frames, @@ -127,7 +130,7 @@ extern "C" { int n = labs_hosts[0].Rows(); int m = labs_hosts[0].Cols(); Status status; - mat = nerv_matrix_host_float_create(n, m, &status); + mat = nerv_matrix_host_float_create(n, m, context, &status); NERV_LUA_CHECK_STATUS(L, status); size_t stride = mat->stride; if (debug) diff --git a/htk_io/src/cwrapper.h b/htk_io/src/cwrapper.h index e1bce6e..0469773 100644 --- a/htk_io/src/cwrapper.h +++ b/htk_io/src/cwrapper.h @@ -1,7 +1,7 @@ #ifndef NERV_TNET_IO_CWRAPPER #define NERV_TNET_IO_CWRAPPER -#include "nerv/matrix/matrix.h" -#include "nerv/common.h" +#include "nerv/lib/matrix/mmatrix.h" +#include "nerv/lib/common.h" #ifdef __cplusplus extern "C" { #endif @@ -10,7 +10,7 @@ extern "C" { TNetFeatureRepo *tnet_feature_repo_new(const char *scp, const char *config, int context); - Matrix *tnet_feature_repo_read_utterance(TNetFeatureRepo *repo, lua_State *L, int debug); + Matrix *tnet_feature_repo_read_utterance(TNetFeatureRepo *repo, lua_State *L, int debug, MContext *context); size_t tnet_feature_repo_current_samplerate(TNetFeatureRepo *repo); const char *tnet_feature_repo_current_tag(TNetFeatureRepo *repo); void tnet_feature_repo_next(TNetFeatureRepo *repo); @@ -28,7 +28,8 @@ extern "C" { size_t sample_rate, const char *tag, lua_State *L, - int debug); + int debug, + MContext *context); void tnet_label_repo_destroy(TNetLabelRepo *repo); #ifdef __cplusplus diff --git a/htk_io/src/init.c b/htk_io/src/init.c index 8a1ec3b..a5132ba 100644 --- a/htk_io/src/init.c +++ b/htk_io/src/init.c @@ -1,4 +1,5 @@ -#include "nerv/common.h" +#include "nerv/lib/common.h" +#include "nerv/matrix/matrix.h" #include "cwrapper.h" #include <stdio.h> @@ -28,12 +29,14 @@ static int feat_repo_current_tag(lua_State *L) { } static int feat_repo_current_utterance(lua_State *L) { + MContext *context; + MMATRIX_GET_CONTEXT(L, 3); TNetFeatureRepo *repo = luaT_checkudata(L, 1, nerv_tnet_feat_repo_tname); int debug; if (!lua_isboolean(L, 2)) nerv_error(L, "debug flag should be a boolean"); debug = lua_toboolean(L, 2); - Matrix *utter = tnet_feature_repo_read_utterance(repo, L, debug); + Matrix *utter = tnet_feature_repo_read_utterance(repo, L, debug, context); luaT_pushudata(L, utter, nerv_matrix_host_float_tname); return 1; } @@ -72,6 +75,8 @@ static int label_repo_new(lua_State *L) { } static int label_repo_read_utterance(lua_State *L) { + MContext *context; + MMATRIX_GET_CONTEXT(L, 5); TNetLabelRepo *repo = luaT_checkudata(L, 1, nerv_tnet_label_repo_tname); TNetFeatureRepo *feat_repo = luaT_checkudata(L, 2, nerv_tnet_feat_repo_tname); size_t frames = luaL_checkinteger(L, 3); @@ -82,7 +87,8 @@ static int label_repo_read_utterance(lua_State *L) { Matrix *utter = tnet_label_repo_read_utterance(repo, frames, tnet_feature_repo_current_samplerate(feat_repo), - tnet_feature_repo_current_tag(feat_repo), L, debug); + tnet_feature_repo_current_tag(feat_repo), + L, debug, context); luaT_pushudata(L, utter, nerv_matrix_host_float_tname); return 1; } diff --git a/htk_io/src/test.c b/htk_io/src/test.c index 6812ef1..1ced108 100644 --- a/htk_io/src/test.c +++ b/htk_io/src/test.c @@ -1,6 +1,9 @@ #include "cwrapper.h" +#include "nerv/lib/matrix/mmatrix.h" #include <stdio.h> +MContext context; + void print_nerv_matrix(Matrix *mat) { int n = mat->nrow; int m = mat->ncol; @@ -22,7 +25,7 @@ int main() { "/slfs1/users/mfy43/swb_ivec/train_bp.scp", "/slfs1/users/mfy43/swb_ivec/plp_0_d_a.conf", 5); Matrix *feat_utter; - feat_utter = tnet_feature_repo_read_utterance(feat_repo, NULL, 1); + feat_utter = tnet_feature_repo_read_utterance(feat_repo, NULL, 1, &context); TNetLabelRepo *lab_repo = tnet_label_repo_new( "/slfs1/users/mfy43/swb_ivec/ref.mlf", @@ -34,7 +37,7 @@ int main() { feat_utter->nrow - 5 * 2, tnet_feature_repo_current_samplerate(feat_repo), tnet_feature_repo_current_tag(feat_repo), NULL, - 1); + 1, &context); print_nerv_matrix(lab_utter); return 0; } diff --git a/kaldi_decode/Makefile b/kaldi_decode/Makefile new file mode 100644 index 0000000..e3a7c2d --- /dev/null +++ b/kaldi_decode/Makefile @@ -0,0 +1,43 @@ +ifndef LUA_BINDIR +$(error Please build the package via luarocks: `luarocks make`) +endif + +ifndef KALDI_BASE +$(error KALDI_BASE is not set) +endif + +ifndef CUDA_BASE +$(error CUDA_BASE is not set) +endif + +KDIR := $(KALDI_BASE) +BUILD_DIR := $(CURDIR)/build +INC_PATH := $(LUA_BINDIR)/../include/ +OBJS := src/nnet-forward.o nnet-forward + +SUBDIR := src +OBJ_DIR := $(BUILD_DIR)/objs +LUA_DIR = $(INST_LUADIR)/kaldi_decode +KALDIINCLUDE := -I $(KDIR)/tools/ATLAS/include/ -I $(KDIR)/tools/openfst/include/ -I $(KDIR)/src/ + +OBJS := $(addprefix $(OBJ_DIR)/,$(OBJS)) +OBJ_SUBDIR := $(addprefix $(OBJ_DIR)/,$(SUBDIR)) + +KL := $(KDIR)/src/feat/kaldi-feat.a $(KDIR)/src/cudamatrix/kaldi-cudamatrix.a $(KDIR)/src/matrix/kaldi-matrix.a $(KDIR)/src/base/kaldi-base.a $(KDIR)/src/util/kaldi-util.a $(KDIR)/src/hmm/kaldi-hmm.a $(KDIR)/src/tree/kaldi-tree.a $(KDIR)/src/nnet/kaldi-nnet.a $(BLAS_LDFLAGS) + +build: $(OBJ_DIR) $(LUA_DIR) $(OBJ_SUBDIR) $(OBJS) +$(OBJ_DIR)/%.o: %.cc + g++ -c -o $@ $< -Wall $(KALDIINCLUDE) -DHAVE_ATLAS -DKALDI_DOUBLEPRECISION=0 -DHAVE_POSIX_MEMALIGN -DLUA_USE_APICHECK -I $(LUA_INCDIR) -I $(INC_PATH) $(CFLAGS) +$(OBJ_DIR)/nnet-forward: $(OBJ_DIR)/src/nnet-forward.o + g++ -o $@ $< $(KL) -L$(LUA_LIBDIR) -Wl,-rpath=$(LUA_LIBDIR) -lluajit-5.1 -L$(CUDA_BASE)/lib64/ -Wl,-rpath=$(CUDA_BASE)/lib64/ -lcudart -lcublas -ldl +$(OBJ_DIR) $(LUA_DIR) $(OBJ_SUBDIR): + -mkdir -p $@ +install: $(LUA_DIR) + cp $(OBJ_DIR)/nnet-forward $(LUA_BINDIR)/nnet-forward-with-nerv + cp src/asr_propagator.lua $(LUA_DIR)/ + sed 's*nnet_forward=*nnet_forward=$(LUA_BINDIR)/nnet-forward-with-nerv.sh*g;s*asr_propagator=*asr_propagator=$(LUA_BINDIR)/../share/lua/5.1/kaldi_decode/asr_propagator.lua*g' decode_with_nerv.sh > $(LUA_BINDIR)/decode_with_nerv.sh + echo '$(LUA_BINDIR)/nnet-forward-with-nerv "$$@"' | cat nnet-forward-with-nerv.sh - | sed 's*\.\./\.\./install/bin/luarocks*$(LUA_BINDIR)/luarocks*g' > $(LUA_BINDIR)/nnet-forward-with-nerv.sh + chmod +x $(LUA_BINDIR)/nnet-forward-with-nerv.sh + chmod +x $(LUA_BINDIR)/decode_with_nerv.sh +clean: + -rm -r $(OBJ_DIR) diff --git a/kaldi_decode/README b/kaldi_decode/README deleted file mode 100755 index 8d0a95b..0000000 --- a/kaldi_decode/README +++ /dev/null @@ -1,13 +0,0 @@ -source path.sh -source cmd.sh - -acwt=0.1 -dir=/slfs5/users/ymz09/chime/baseline/ASR/exp/nerv_seq/ -graph=/slfs5/users/ymz09/chime/baseline/ASR/exp/tri4a_dnn_tr05_multi_enhanced/graph_tgpr_5k -data=/slfs5/users/ymz09/chime/baseline/ASR/data-fbank/et05_real_enhanced -config=/slfs6/users/ymz09/nerv-project/nerv/nerv/examples/mpe_chime3.lua - -decode.sh --nj 4 --cmd "$decode_cmd" --config conf/decode_dnn.config --acwt $acwt \ - $graph $data $config \ - $dir/decode_tgpr_5k_et05_real_enhanced_nerv - diff --git a/kaldi_decode/README.timit b/kaldi_decode/README.timit new file mode 100755 index 0000000..7fac918 --- /dev/null +++ b/kaldi_decode/README.timit @@ -0,0 +1,15 @@ +#!/bin/bash +source path.sh +source cmd.sh + +gmmdir=/speechlab/users/mfy43/timit/s5/exp/tri3/ +data_fmllr=/speechlab/users/mfy43/timit/s5/data-fmllr-tri3/ +dir=/speechlab/users/mfy43/timit/s5/exp/dnn4_nerv_prepare/ +nerv_config=/speechlab/users/mfy43/nerv/nerv/examples/timit_baseline2.lua +decode=/speechlab/users/mfy43/nerv/install/bin/decode_with_nerv.sh + +# Decode (reuse HCLG graph) +$decode --nj 20 --cmd "$decode_cmd" --acwt 0.2 \ + $gmmdir/graph $data_fmllr/test $nerv_config $dir/decode_test || exit 1; +$decode --nj 20 --cmd "$decode_cmd" --acwt 0.2 \ + $gmmdir/graph $data_fmllr/dev $nerv_config $dir/decode_dev || exit 1; diff --git a/kaldi_decode/cmd.sh b/kaldi_decode/cmd.sh deleted file mode 100755 index e2e54e8..0000000 --- a/kaldi_decode/cmd.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# "queue.pl" uses qsub. The options to it are -# options to qsub. If you have GridEngine installed, -# change this to a queue you have access to. -# Otherwise, use "run.pl", which will run jobs locally -# (make sure your --num-jobs options are no more than -# the number of cpus on your machine. - -#a) JHU cluster options -#export train_cmd="queue.pl -l arch=*64" -#export decode_cmd="queue.pl -l arch=*64,mem_free=2G,ram_free=2G" -#export mkgraph_cmd="queue.pl -l arch=*64,ram_free=4G,mem_free=4G" - -#export cuda_cmd="..." - - -#b) BUT cluster options -#export train_cmd="queue.pl -q all.q@@blade -l ram_free=1200M,mem_free=1200M" -#export decode_cmd="queue.pl -q all.q@@blade -l ram_free=1700M,mem_free=1700M" -#export decodebig_cmd="queue.pl -q all.q@@blade -l ram_free=4G,mem_free=4G" - -#export cuda_cmd="queue.pl -q long.q@@pco203 -l gpu=1" -#export cuda_cmd="queue.pl -q long.q@pcspeech-gpu" -#export mkgraph_cmd="queue.pl -q all.q@@servers -l ram_free=4G,mem_free=4G" - -#c) run it locally... -export train_cmd=run.pl -export decode_cmd=run.pl -export cuda_cmd=run.pl -export mkgraph_cmd=run.pl - -#export train_cmd='queue.pl' -#export decode_cmd='queue.pl' -#export cuda_cmd='queue.pl -l gpu=1 -l hostname="markov|date|hamming"' -#export mkgraph_cmd='queue.pl"' - diff --git a/kaldi_decode/conf/decode_dnn.config b/kaldi_decode/conf/decode_dnn.config deleted file mode 100644 index 89dd992..0000000 --- a/kaldi_decode/conf/decode_dnn.config +++ /dev/null @@ -1,2 +0,0 @@ -beam=18.0 # beam for decoding. Was 13.0 in the scripts. -lattice_beam=10.0 # this has most effect on size of the lattices. diff --git a/kaldi_decode/decode.sh b/kaldi_decode/decode_with_nerv.sh index aa7e089..5554b2e 100755 --- a/kaldi_decode/decode.sh +++ b/kaldi_decode/decode_with_nerv.sh @@ -1,5 +1,4 @@ #!/bin/bash - # Copyright 2012-2013 Karel Vesely, Daniel Povey # Apache 2.0 @@ -20,7 +19,7 @@ lattice_beam=8.0 min_active=200 max_active=7000 # limit of active tokens max_mem=50000000 # approx. limit to memory consumption during minimization in bytes -nnet_forward_opts="--prior-scale=1.0" +nnet_forward_opts="--apply-log=true" # IMPORTANT, to apply log before to substract log-prior, and to know the modified 'nnet-forward' removed '--no-softmax' option skip_scoring=false scoring_opts="--min-lmwt 4 --max-lmwt 15" @@ -28,6 +27,13 @@ scoring_opts="--min-lmwt 4 --max-lmwt 15" num_threads=1 # if >1, will use latgen-faster-parallel parallel_opts= # Ignored now. use_gpu="no" # yes|no|optionaly + +cmvn_opts= +splice_opts= +delta_opts= + +asr_propagator= +nnet_forward= # End configuration section. echo "$0 $@" # Print the command line for logging @@ -36,7 +42,7 @@ echo "$0 $@" # Print the command line for logging . parse_options.sh || exit 1; if [ $# != 4 ]; then - echo "Usage: $0 [options] <graph-dir> <data-dir> <nerv-config> <decode-dir>" + echo "Usage: $0 [options] <graph-dir> <data-dir> <nerv-model-config> <decode-dir>" echo "... where <decode-dir> is assumed to be a sub-directory of the directory" echo " where the DNN and transition model is." echo "e.g.: $0 exp/dnn1/graph_tgpr data/test config.lua exp/dnn1/decode_tgpr" @@ -62,8 +68,9 @@ fi graphdir=$1 data=$2 -config=$3 +model_conf=$3 dir=$4 + [ -z $srcdir ] && srcdir=`dirname $dir`; # Default model directory one level up from decoding directory. sdata=$data/split$nj; @@ -90,11 +97,10 @@ thread_string= # PREPARE FEATURE EXTRACTION PIPELINE # import config, -cmvn_opts= -delta_opts= D=$srcdir [ -e $D/norm_vars ] && cmvn_opts="--norm-means=true --norm-vars=$(cat $D/norm_vars)" # Bwd-compatibility, [ -e $D/cmvn_opts ] && cmvn_opts=$(cat $D/cmvn_opts) +[ -e $D/splice_opts ] && splice_opts=$(cat $D/splice_opts) [ -e $D/delta_order ] && delta_opts="--delta-order=$(cat $D/delta_order)" # Bwd-compatibility, [ -e $D/delta_opts ] && delta_opts=$(cat $D/delta_opts) # @@ -103,13 +109,17 @@ feats="ark,s,cs:copy-feats scp:$sdata/JOB/feats.scp ark:- |" # apply-cmvn (optional), [ ! -z "$cmvn_opts" -a ! -f $sdata/1/cmvn.scp ] && echo "$0: Missing $sdata/1/cmvn.scp" && exit 1 [ ! -z "$cmvn_opts" ] && feats="$feats apply-cmvn $cmvn_opts --utt2spk=ark:$sdata/JOB/utt2spk scp:$sdata/JOB/cmvn.scp ark:- ark:- |" +# splice-opts (optional), +[ ! -z "$splice_opts" ] && feats="$feats splice-feats $splice_opts ark:- ark:- |" # add-deltas (optional), [ ! -z "$delta_opts" ] && feats="$feats add-deltas $delta_opts ark:- ark:- |" # # Run the decoding in the queue, if [ $stage -le 0 ]; then - $cmd --num-threads $((num_threads+1)) JOB=1:$nj $dir/log/decode.JOB.log \ - ./src/nnet-forward $nnet_forward_opts --class-frame-counts=$class_frame_counts --use-gpu=$use_gpu $config "$feats" ark:- \| \ +# $cmd --num-threads $((num_threads+1)) JOB=1:$nj $dir/log/decode.JOB.log \ +# remove multi-threads to avoid smp requirement + $cmd --num-threads $((num_threads)) JOB=1:$nj $dir/log/decode.JOB.log \ + $nnet_forward $nnet_forward_opts --class-frame-counts=$class_frame_counts --use-gpu=$use_gpu $model_conf "$feats" ark:- $asr_propagator \| \ latgen-faster-mapped$thread_string --min-active=$min_active --max-active=$max_active --max-mem=$max_mem --beam=$beam \ --lattice-beam=$lattice_beam --acoustic-scale=$acwt --allow-partial=true --word-symbol-table=$graphdir/words.txt \ $model $graphdir/HCLG.fst ark:- "ark:|gzip -c > $dir/lat.JOB.gz" || exit 1; diff --git a/kaldi_decode/kaldi_decode-scm-1.rockspec b/kaldi_decode/kaldi_decode-scm-1.rockspec new file mode 100644 index 0000000..cc533ae --- /dev/null +++ b/kaldi_decode/kaldi_decode-scm-1.rockspec @@ -0,0 +1,36 @@ +package = "kaldi_decode" +version = "scm-1" +source = { + url = "https://github.com/Nerv-SJTU/nerv-speech.git" +} +description = { + summary = "Kaldi decode support for NERV", + detailed = [[ + ]], + homepage = "https://github.com/Determinant/nerv-speech", + license = "BSD" +} +dependencies = { + "nerv >= scm-1", + "lua >= 5.1" +} +build = { + type = "make", + build_variables = { + CFLAGS="$(CFLAGS) -Wall -Wextra -g -O2", + --CFLAGS="$(CFLAGS) -Wall -Wextra -g", + LIBFLAG="$(LIBFLAG)", + LUA_LIBDIR="$(LUA_LIBDIR)", + LUA_BINDIR="$(LUA_BINDIR)", + LUA_INCDIR="$(LUA_INCDIR)", + LUA="$(LUA)", + }, + install_variables = { + LUA_BINDIR="$(LUA_BINDIR)", + INST_PREFIX="$(PREFIX)", + INST_BINDIR="$(BINDIR)", + INST_LIBDIR="$(LIBDIR)", + INST_LUADIR="$(LUADIR)", + INST_CONFDIR="$(CONFDIR)", + }, +} diff --git a/kaldi_decode/local/score.sh b/kaldi_decode/local/score.sh deleted file mode 100755 index b18f350..0000000 --- a/kaldi_decode/local/score.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -# Copyright 2012 Johns Hopkins University (Author: Daniel Povey) -# Apache 2.0 - -[ -f ./path.sh ] && . ./path.sh - -# begin configuration section. -cmd=run.pl -stage=0 -decode_mbr=true -reverse=false -word_ins_penalty=0.0 -min_lmwt=5 -max_lmwt=20 -#end configuration section. - -[ -f ./path.sh ] && . ./path.sh -. parse_options.sh || exit 1; - -if [ $# -ne 3 ]; then - echo "Usage: local/score.sh [--cmd (run.pl|queue.pl...)] <data-dir> <lang-dir|graph-dir> <decode-dir>" - echo " Options:" - echo " --cmd (run.pl|queue.pl...) # specify how to run the sub-processes." - e |