summaryrefslogtreecommitdiff
path: root/htk_io
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2015-08-05 08:03:39 +0800
committerDeterminant <[email protected]>2015-08-05 08:03:39 +0800
commitacd1bc3cf812f69a6260179b584f2a3f0e6d6b80 (patch)
treee46c94f1c2d2864f2274f37b92842acfb2e6fa75 /htk_io
parent08e33afa533af1f026ac271446a0c873fe0bb5cb (diff)
put global transformation in a separate library
Diffstat (limited to 'htk_io')
-rw-r--r--htk_io/htk_io-scm-1.rockspec1
-rw-r--r--htk_io/init.lua24
2 files changed, 8 insertions, 17 deletions
diff --git a/htk_io/htk_io-scm-1.rockspec b/htk_io/htk_io-scm-1.rockspec
index a251d24..ed01d0f 100644
--- a/htk_io/htk_io-scm-1.rockspec
+++ b/htk_io/htk_io-scm-1.rockspec
@@ -12,6 +12,7 @@ description = {
}
dependencies = {
"nerv >= scm-1",
+ "speech_utils >= scm-1",
"lua >= 5.1"
}
build = {
diff --git a/htk_io/init.lua b/htk_io/init.lua
index 27ece6e..af1f740 100644
--- a/htk_io/init.lua
+++ b/htk_io/init.lua
@@ -1,4 +1,5 @@
require 'libhtkio'
+require 'speech_utils'
local TNetReader = nerv.class("nerv.TNetReader", "nerv.DataReader")
function TNetReader:__init(global_conf, reader_conf)
@@ -32,26 +33,15 @@ function TNetReader:get_data()
local step = frm_ext * 2 + 1
-- read HTK feature
local feat_utter = self.feat_repo:cur_utter(self.debug)
- -- expand the feature
- local expanded = self.gconf.cumat_type(feat_utter:nrow(), feat_utter:ncol() * step)
- expanded:expand_frm(self.gconf.cumat_type.new_from_host(feat_utter), frm_ext)
- -- rearrange the feature (``transpose'' operation in TNet)
- local rearranged = expanded:create()
- rearranged:rearrange_frm(expanded, step)
- -- prepare for transf
- local input = {rearranged}
- local output = {rearranged:create()}
- -- do transf
- self.global_transf:init(input[1]:nrow())
- self.global_transf:propagate(input, output)
- -- trim frames
- expanded = self.gconf.mmat_type(output[1]:nrow() - frm_ext * 2, output[1]:ncol())
- output[1]:copy_toh(expanded, frm_ext, feat_utter:nrow() - frm_ext)
- res[self.feat_id] = expanded
+ -- global transf
+ local transformed = nerv.speech_utils.global_transf(feat_utter,
+ self.global_transf, frm_ext, self.gconf)
+
+ res[self.feat_id] = transformed
-- add corresponding labels
for id, repo in pairs(self.lab_repo) do
local lab_utter = repo:get_utter(self.feat_repo,
- expanded:nrow(),
+ transformed:nrow(),
self.debug)
res[id] = lab_utter
end