blob: 7d5651fa8d793ddf492ab6ded6dda24edf4c1b8b (
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
27
28
29
30
31
32
33
|
nerv.speech_utils = {}
function nerv.speech_utils.global_transf(feat_utter, global_transf,
frm_ext, frm_trim, gconf)
local rearranged
-- feat_utter = gconf.cumat_type.new_from_host(feat_utter)
if frm_ext ~= nil and frm_ext > 0 then
local step = frm_ext * 2 + 1
-- expand the feature
local expanded = gconf.cumat_type(feat_utter:nrow(), feat_utter:ncol() * step)
expanded:expand_frm(feat_utter, frm_ext)
-- rearrange the feature (``transpose'' operation in TNet)
if gconf.rearrange then
rearranged = expanded:create()
rearranged:rearrange_frm(expanded, step)
else
rearranged = expanded
end
else
rearranged = feat_utter
end
-- 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.cumat_type(output[1]:nrow() - frm_trim * 2, output[1]:ncol())
expanded:copy_fromd(output[1], frm_trim, feat_utter:nrow() - frm_trim)
collectgarbage("collect")
return expanded
end
|