diff options
author | uphantom <[email protected]> | 2015-08-28 18:37:12 +0800 |
---|---|---|
committer | uphantom <[email protected]> | 2015-08-28 18:37:12 +0800 |
commit | e56c91ff6eecdb1663bb1722a4081ef2f190e9c0 (patch) | |
tree | 06cbe7394ba26c6a2657fddc1ebc59006fa5eee5 /speech_utils | |
parent | 9e1a0931be43ea80fe7d41154007839b637d4e08 (diff) |
suport multi-thread reader
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 + |