summaryrefslogtreecommitdiff
path: root/speech_utils
diff options
context:
space:
mode:
Diffstat (limited to 'speech_utils')
-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
+