summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2016-02-29 22:02:32 +0800
committerDeterminant <[email protected]>2016-02-29 22:02:32 +0800
commite7c9175e1059a15720025a99ccdb35d5bf6dc30f (patch)
tree27f10d1f95116c9faf7b62a6524c235dd811aeb5
parentd9e03b7d2c14549ab480d5e3b31518be4cdc8eed (diff)
parent24d56605428467e604afded423ba2ff49f2644e3 (diff)
Merge branch 'master' of https://github.com/sxkachilles/nerv-speech into sxkachilles-master
Conflicts: kaldi_decode/src/Makefile kaldi_io/src/cwrapper_kaldi.cpp
-rw-r--r--kaldi_io/init.lua8
-rw-r--r--kaldi_io/src/cwrapper_kaldi.cpp9
2 files changed, 15 insertions, 2 deletions
diff --git a/kaldi_io/init.lua b/kaldi_io/init.lua
index 2173230..751247a 100644
--- a/kaldi_io/init.lua
+++ b/kaldi_io/init.lua
@@ -41,6 +41,7 @@ function KaldiReader:__init(global_conf, reader_conf)
end
function KaldiReader:get_data()
+ local fail_to_read_alignment = false
if self.feat_repo:is_end() then
return nil
end
@@ -87,6 +88,9 @@ function KaldiReader:get_data()
local lab_utter = repo:get_utter(self.feat_repo,
feat_utter:nrow(),
self.debug)
+ if lab_utter == nil then
+ fail_to_read_alignment = true
+ end
res[id] = lab_utter
end
-- add corresponding lookup features
@@ -110,5 +114,9 @@ function KaldiReader:get_data()
-- move the pointer to next
self.feat_repo:next()
collectgarbage("collect")
+ if fail_to_read_alignment then
+ nerv.info("[kaldi] utterance %s alignment not found, skip it.", self.feat_repo:key())
+ res = self:get_data()
+ end
return res
end
diff --git a/kaldi_io/src/cwrapper_kaldi.cpp b/kaldi_io/src/cwrapper_kaldi.cpp
index e8b11a1..788128b 100644
--- a/kaldi_io/src/cwrapper_kaldi.cpp
+++ b/kaldi_io/src/cwrapper_kaldi.cpp
@@ -159,8 +159,13 @@ extern "C" {
Matrix *kaldi_label_repo_read_utterance(KaldiLabelRepo *repo, KaldiFeatureRepo *frepo, int nframes,
lua_State *L,
int debug, MContext *context) {
- Matrix *mat;
- kaldi::Posterior targets = repo->targets_reader->Value(frepo->utt);
+ Matrix *mat = NULL;
+ /* check if the alignment of the utterance exists, otherwise return NULL */
+ kaldi::Posterior targets;
+ if (repo->targets_reader->HasKey(frepo->utt))
+ targets = repo->targets_reader->Value(frepo->utt);
+ else
+ return mat;
int n = targets.size() < nframes ? targets.size() : nframes;
int m = (int)targets[0].size();