-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmaking_multi_frame_VAD.py
More file actions
49 lines (40 loc) · 1.44 KB
/
making_multi_frame_VAD.py
File metadata and controls
49 lines (40 loc) · 1.44 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 5 23:37:56 2016
@author: keums
"""
import numpy as np
def making_multi_frame_VAD(features, num_frames = 1, max_bin = 41, min_bin = 0):
'''
making multi-frame features for training
|Parameters|
----------
features: shape(features)
the result of SCDNN(res=1) of melody extraction.
num_frame:
the number of frame
max_bin:
the size of features = 40 * note_res +1
nim_bin: 0(default)
|Returns|
-------
x: shape(num_feature[0], num_features[1]*num_frames)
the multi-frame featrues
'''
max_num = np.shape(features)[0]
x = np.zeros(shape = (max_num, num_frames*(max_bin-min_bin)))
h_frames = int((num_frames-1)/2)
total_num = 0
for j in range(max_num):
if num_frames > 1 :
if j < h_frames:
x[total_num] = np.reshape(features[0:num_frames,min_bin:max_bin], (num_frames*(max_bin-min_bin)))
elif j >= max_num-h_frames:
x[total_num] = np.reshape(features[np.shape(features)[0]- num_frames:,min_bin:max_bin], (num_frames*(max_bin-min_bin)))
else:
x[total_num] = np.reshape(features[j-h_frames:j+h_frames+1,min_bin:max_bin], (num_frames*(max_bin-min_bin)))
else:
x[total_num] = features[j:j+1,min_bin:max_bin]
total_num = total_num + 1
x = x[:total_num]
return x