summaryrefslogtreecommitdiff
path: root/speech_utils/init.lua
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2015-08-31 16:18:02 +0800
committerDeterminant <ted.sybil@gmail.com>2015-08-31 16:18:02 +0800
commit93722f9d133bd6a941bb1f7ba336857bc5d5093b (patch)
tree073d2624bf99644a2a2c3864c0e5efee478e7be7 /speech_utils/init.lua
parent7acd14eca701deaffb2d16262528da37ee23263a (diff)
parent014bbfb7e64999a75f9e0dc52267a36741281624 (diff)
Merge branch 'fastnn' of github.com:Nerv-SJTU/nerv-speech into fastnnfastnn
Diffstat (limited to 'speech_utils/init.lua')
-rw-r--r--speech_utils/init.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/speech_utils/init.lua b/speech_utils/init.lua
index f89f4fd..1bfec16 100644
--- a/speech_utils/init.lua
+++ b/speech_utils/init.lua
@@ -14,3 +14,35 @@ function nerv.speech_utils.global_transf(feat_utter, global_transf,
collectgarbage("collect")
return expanded
end
+
+function nerv.speech_utils.feat_expand(feat_utter, frm_ext, gconf)
+ local rearranged
+ if frm_ext > 0 then
+ local step = frm_ext * 2 + 1
+ -- expand the feature
+ local expanded = gconf.mmat_type(feat_utter:nrow(), feat_utter:ncol() * step)
+ expanded:expand_frm(feat_utter, frm_ext)
+
+ -- rearrange the feature (``transpose'' operation in TNet)
+ rearranged = gconf.mmat_type(feat_utter:nrow() - frm_ext*2, feat_utter:ncol() * step)
+ rearranged:rearrange_frm(expanded, step, frm_ext, feat_utter:nrow() - frm_ext)
+ else
+ rearranged = feat_utter
+ end
+
+ collectgarbage("collect")
+ return rearranged
+end
+
+
+function nerv.speech_utils.normalize(mat, global_transf)
+ -- prepare for transf
+ local input = {mat}
+ local output = {mat:create()}
+ -- do transf
+ global_transf:init(input[1]:nrow())
+ global_transf:propagate(input, output)
+
+ return output[1]
+end
+