From acd1bc3cf812f69a6260179b584f2a3f0e6d6b80 Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 5 Aug 2015 08:03:39 +0800 Subject: put global transformation in a separate library --- htk_io/htk_io-scm-1.rockspec | 1 + htk_io/init.lua | 24 +++++++----------------- 2 files changed, 8 insertions(+), 17 deletions(-) (limited to 'htk_io') 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 -- cgit v1.2.3-70-g09d2