summaryrefslogtreecommitdiff
path: root/kaldi_io/src
diff options
context:
space:
mode:
authorEric Bi <[email protected]>2015-12-01 17:03:39 +0800
committerEric Bi <[email protected]>2015-12-01 17:03:39 +0800
commit119f9091ea60d81efabd7d20ff2490b9e7084778 (patch)
treed8e059138204e0dc4cc31d7936df6f7775a94dc8 /kaldi_io/src
parentf9b78f6bc35cd5c0c117a5e523ef6aab96dee5c3 (diff)
add detection of utterances without alignment, and skip them
Diffstat (limited to 'kaldi_io/src')
-rw-r--r--kaldi_io/src/cwrapper_kaldi.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/kaldi_io/src/cwrapper_kaldi.cpp b/kaldi_io/src/cwrapper_kaldi.cpp
index d16f316..542f1d0 100644
--- a/kaldi_io/src/cwrapper_kaldi.cpp
+++ b/kaldi_io/src/cwrapper_kaldi.cpp
@@ -150,8 +150,12 @@ extern "C" {
Matrix *kaldi_label_repo_read_utterance(KaldiLabelRepo *repo, KaldiFeatureRepo *frepo, int nframes,
lua_State *L,
int debug) {
- 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();