summaryrefslogtreecommitdiff
path: root/speech_utils/init.lua
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 /speech_utils/init.lua
parent08e33afa533af1f026ac271446a0c873fe0bb5cb (diff)
put global transformation in a separate library
Diffstat (limited to 'speech_utils/init.lua')
-rw-r--r--speech_utils/init.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/speech_utils/init.lua b/speech_utils/init.lua
new file mode 100644
index 0000000..5148664
--- /dev/null
+++ b/speech_utils/init.lua
@@ -0,0 +1,23 @@
+nerv.speech_utils = {}
+
+function nerv.speech_utils.global_transf(feat_utter, global_transf, frm_ext, gconf)
+ local res = {}
+ local step = frm_ext * 2 + 1
+ -- expand the feature
+ local expanded = gconf.cumat_type(feat_utter:nrow(), feat_utter:ncol() * step)
+ expanded:expand_frm(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
+ global_transf:init(input[1]:nrow())
+ global_transf:propagate(input, output)
+ -- trim frames
+ expanded = gconf.mmat_type(output[1]:nrow() - frm_ext * 2, output[1]:ncol())
+ output[1]:copy_toh(expanded, frm_ext, feat_utter:nrow() - frm_ext)
+ collectgarbage("collect")
+ return expanded
+end