summaryrefslogtreecommitdiff
path: root/speech_utils/init.lua
blob: 0b65edc4e52560de07e94e08068520c4cb77f598 (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
24
25
26
nerv.speech_utils = {}

function nerv.speech_utils.global_transf(feat_utter, network,
                                        frm_ext, frm_trim, gconf)
    -- prepare for transf
    local input = {feat_utter}
    local output = {feat_utter:create()}
    -- do transf
    local batch_size = input[1]:nrow()
    network:mini_batch_init({seq_length = table.vector(batch_size, 1),
                            new_seq = {},
                            do_train = false,
                            input = {input},
                            output = {output}})
    network:propagate()
    -- trim frames
    if gconf.use_cpu then
        mat_type = gconf.mmat_type
    else
        mat_type = gconf.cumat_type
    end
    expanded = mat_type(output[1]:nrow() - frm_trim * 2, output[1]:ncol())
    expanded:copy_from(output[1], frm_trim, feat_utter:nrow() - frm_trim)
    collectgarbage("collect")
    return expanded
end