summaryrefslogtreecommitdiff
path: root/speech_utils/init.lua
blob: 514866469b0e135326b1b025cfa18360c1593147 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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