diff options
Diffstat (limited to 'kaldi_io/src')
-rw-r--r-- | kaldi_io/src/cwrapper_kaldi.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
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(); |