diff options
author | Determinant <[email protected]> | 2015-08-31 16:18:02 +0800 |
---|---|---|
committer | Determinant <[email protected]> | 2015-08-31 16:18:02 +0800 |
commit | 93722f9d133bd6a941bb1f7ba336857bc5d5093b (patch) | |
tree | 073d2624bf99644a2a2c3864c0e5efee478e7be7 /speech_utils | |
parent | 7acd14eca701deaffb2d16262528da37ee23263a (diff) | |
parent | 014bbfb7e64999a75f9e0dc52267a36741281624 (diff) |
Merge branch 'fastnn' of github.com:Nerv-SJTU/nerv-speech into fastnnfastnn
Diffstat (limited to 'speech_utils')
-rw-r--r-- | speech_utils/init.lua | 32 |
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 + |