summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--htk_io/init.lua26
-rw-r--r--speech_utils/init.lua21
2 files changed, 27 insertions, 20 deletions
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
diff --git a/speech_utils/init.lua b/speech_utils/init.lua
index 7d5651f..f89f4fd 100644
--- a/speech_utils/init.lua
+++ b/speech_utils/init.lua
@@ -2,26 +2,9 @@ nerv.speech_utils = {}
function nerv.speech_utils.global_transf(feat_utter, global_transf,
frm_ext, frm_trim, gconf)
- local rearranged
--- feat_utter = gconf.cumat_type.new_from_host(feat_utter)
- if frm_ext ~= nil and frm_ext > 0 then
- local step = frm_ext * 2 + 1
- -- expand the feature
- local expanded = gconf.cumat_type(feat_utter:nrow(), feat_utter:ncol() * step)
- expanded:expand_frm(feat_utter, frm_ext)
- -- rearrange the feature (``transpose'' operation in TNet)
- if gconf.rearrange then
- rearranged = expanded:create()
- rearranged:rearrange_frm(expanded, step)
- else
- rearranged = expanded
- end
- else
- rearranged = feat_utter
- end
-- prepare for transf
- local input = {rearranged}
- local output = {rearranged:create()}
+ local input = {feat_utter}
+ local output = {feat_utter:create()}
-- do transf
global_transf:init(input[1]:nrow())
global_transf:propagate(input, output)