-
Notifications
You must be signed in to change notification settings - Fork 8
/
Fprev_sub.py
52 lines (46 loc) · 1.59 KB
/
Fprev_sub.py
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
50
51
# -*- coding: utf-8 -*-
'''
* Copyright (C) 2017 Music Technology Group - Universitat Pompeu Fabra
*
* This file is part of EUSIPCO2017 phoneme classification
*
* pypYIN is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation (FSF), either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the Affero GNU General Public License
* version 3 along with this program. If not, see http://www.gnu.org/licenses/
*
* If you have any problem about this python version code, please contact: Rong Gong
* rong.gong@upf.edu
*
*
* If you want to refer this code, please use this article:
*
'''
import numpy as np
# import matplotlib.pyplot as plt
def Fprev_sub(x,w=2):
'''
# D = prev_sub(X,W) calculate the shifted x, with shifting frames 2
input feature*frame
'''
# pad data by repeating first and last columns
if w > 0:
# shift to right
xx = np.hstack((np.tile(x[:,0], (w,1)).transpose(), x[:,:-w]))
if w < 0:
# shift to left
xx = np.hstack((x[:,-w:], np.tile(x[:,-1], (-w,1)).transpose()))
if w==0:
raise ValueError("shifting frame coef can't be 0.")
# plt.figure()
# plt.pcolormesh(xx)
# plt.show()
return xx