diff options
author | Yimmon Zhuang <[email protected]> | 2015-08-26 15:04:05 +0800 |
---|---|---|
committer | Yimmon Zhuang <[email protected]> | 2015-08-26 15:04:05 +0800 |
commit | 76d64a91f72a19221e7ff9461860b214cbff216f (patch) | |
tree | f8bbf650dd2c54c3b3e0797e488723825f171dcb /kaldi_io/init.lua | |
parent | 5c90a652862c464b5bfe2e5777ff20ae25beb4a0 (diff) | |
parent | 6495879e76dc0a2efe7b214b58d1d73a4ed3a931 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'kaldi_io/init.lua')
-rw-r--r-- | kaldi_io/init.lua | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/kaldi_io/init.lua b/kaldi_io/init.lua index 9fdb080..930705e 100644 --- a/kaldi_io/init.lua +++ b/kaldi_io/init.lua @@ -6,7 +6,6 @@ function KaldiReader:__init(global_conf, reader_conf) self.feat_id = reader_conf.id self.frm_ext = reader_conf.frm_ext self.gconf = global_conf - self.global_transf = reader_conf.global_transf self.debug = global_conf.debug if self.debug == nil then self.debug = false @@ -15,9 +14,20 @@ function KaldiReader:__init(global_conf, reader_conf) self.lab_repo = {} for id, mlf_spec in pairs(reader_conf.mlfs) do + if mlf_spec.format == nil then + nerv.error("format spec is expected for label %s", id) + end self.lab_repo[id] = nerv.KaldiLabelRepo(mlf_spec.targets_rspecifier, mlf_spec.format) end + self.lookup_repo = {} + for id, lookup_spec in pairs(reader_conf.lookup) do + if lookup_spec.map_rspecifier == nil then + nerv.error("map spec is expected for lookup %s", id) + end + self.lookup_repo[id] = nerv.KaldiLookupFeatureRepo(lookup_spec.targets_rspecifier, + lookup_spec.map_rspecifier) + end end function KaldiReader:get_data() @@ -28,17 +38,32 @@ function KaldiReader:get_data() -- read Kaldi feature local feat_utter = self.feat_repo:cur_utter(self.debug) -- global transf - local transformed = nerv.speech_utils.global_transf(feat_utter, - self.global_transf, self.frm_ext, 0, self.gconf) - res[self.feat_id] = transformed + res[self.feat_id] = feat_utter -- add corresponding labels for id, repo in pairs(self.lab_repo) do local lab_utter = repo:get_utter(self.feat_repo, - self.frm_ext, - transformed:nrow(), + feat_utter:nrow(), self.debug) res[id] = lab_utter end + -- add corresponding lookup features + for id, repo in pairs(self.lookup_repo) do + local lookup_utter = repo:get_utter(self.feat_repo, + feat_utter:nrow(), + self.debug) + local nrow = lookup_utter:nrow() + if nrow < feat_utter:nrow() then + -- repeat the last frame + local nlu = lookup_utter:create(feat_utter:nrow()) + nlu:copy_from(lookup_utter, 0, nrow) + row = nlu[nrow - 1] + for i = 0, feat_utter:nrow() - nrow - 1 do + nlu:copy_from(nlu, nrow - 1, nrow, nrow + i) + end + lookup_utter = nlu + end + res[id] = lookup_utter + end -- move the pointer to next self.feat_repo:next() collectgarbage("collect") |