From b50ec827c6fd7d95375e627a1bedd1236ef02e8c Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 26 Aug 2015 15:42:43 +0800 Subject: ... --- htk_io/init.lua | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'htk_io') diff --git a/htk_io/init.lua b/htk_io/init.lua index b836e15..abaa794 100644 --- a/htk_io/init.lua +++ b/htk_io/init.lua @@ -29,7 +29,31 @@ function TNetReader:get_data() end local res = {} -- read HTK feature - local feat_utter = self.feat_repo:cur_utter(self.debug) + local raw = self.gconf.cumat_type.new_from_host(self.feat_repo:cur_utter(self.debug)) + 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) + expanded:expand_frm(raw, self.frm_ext) + -- rearrange the feature (``transpose'' operation in TNet) + if self.gconf.rearrange then + rearranged = expanded:create() + rearranged:rearrange_frm(expanded, step) + else + rearranged = expanded + end + else + rearranged = raw + end + local feat_utter + if self.gconf.frm_trim then + 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) + end res[self.feat_id] = feat_utter -- add corresponding labels for id, repo in pairs(self.lab_repo) do -- cgit v1.2.3-70-g09d2