【MFCC】MFCC增量用于计算相关性

算法思想:
设 M a x t r i x 为 N , J 维 矩 阵 、 S i z e 为 M 设Maxtrix为N, J维矩阵、Size为M MaxtrixN,JSizeM
V e c t o r 1 是 表 示 M a t r i x 的 第 1 行 Vector_1 是表示Matrix的第1行 Vector1Matrix1
则 : ( N e w V e c t o r ) i = ∑ 1 ≤ j ≤ M j ∗ [ ( v e c t o r ) ( i + j ) − ( v e c t o r ) ( i − j ) ] 则:(NewVector)_i = \sum\limits_{1 \le j \le M} j*[(vector)_(i+j_) - (vector)_(i-j_)] (NewVector)i=1jMj[(vector)(i+j)(vector)(ij)]
其 中 : i f ( i + j ) > N : i + j = N ; i f ( i − 1 ) < 0 : i − j = 0 其中:if (i+j) > N : i+j = N;if (i-1)<0: i-j=0 :if(i+j)>N:i+j=Nif(i1)<0:ij=0
i ∈ [ 0 , N ) , i ∈ Z i ∈[0, N), i∈Z i[0,N),iZ
代码实现

def calculate_delta(vector, correlation_numb=2):
    """
    Calculate and returns the delta of given feature vector matrix for evaluating correlation
    :param vector:
    :param correlation_numb:
    :return:
    """
    rows, cols = vector.shape
    deltas = zeros((rows, 20))  # initial vector of deltas
    n = correlation_numb   # 2 order vector shape
    for i in range(rows):
        index = []
        j = 1
        while j <= n:
            if i - j < 0:
                first = 0
            else:
                first = i - j
            if i + j > rows - 1:
                second = rows - 1
            else:
                second = i + j
            index.append((second, first))
            j += 1
        deltas[i] = sum([(i + 1) * (vector[index[i][0]] - vector[index[i][1]]) for i in range(len(index))]) / 10
    return deltas

具体例子

// 原矩阵Matrix
[[1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5]	Vector1
 [5 6 7 8 5 5 6 7 8 5 5 6 7 8 5 5 6 7 8 5]  Vector2
 [1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5]	...
 [5 6 7 8 5 5 6 7 8 5 5 6 7 8 5 5 6 7 8 5]	...
 [1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5]
 [5 6 7 8 5 5 6 7 8 5 5 6 7 8 5 5 6 7 8 5]
 [1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5]
 [5 6 7 8 5 5 6 7 8 5 5 6 7 8 5 5 6 7 8 5]
 [1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5]
 [5 6 7 8 5 5 6 7 8 5 5 6 7 8 5 5 6 7 8 5]]
 // 增量向量 size设置为3
 [(1, 0), (2, 0), (3, 0)]
[(2, 0), (3, 0), (4, 0)]
[(3, 1), (4, 0), (5, 0)]
[(4, 2), (5, 1), (6, 0)]
[(5, 3), (6, 2), (7, 1)]
[(6, 4), (7, 3), (8, 2)]
[(7, 5), (8, 4), (9, 3)]
[(8, 6), (9, 5), (9, 4)]
[(9, 7), (9, 6), (9, 5)]
[(9, 8), (9, 7), (9, 6)]
// 计算后的增量,
[[0.4 0.4 0.4 0.4 0.  0.4 0.4 0.4 0.4 0.  0.4 0.4 0.4 0.4 0.  0.4 0.4 0.4 0.4 0. ]
 [0.8 0.8 0.8 0.8 0.  0.8 0.8 0.8 0.8 0.  0.8 0.8 0.8 0.8 0.  0.8 0.8 0.8  0.8 0. ]
 [0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0. ]
 [0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0. ]
 [0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0. ]
 [0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0. ]
 [0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0. ]
 [0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0.  0. ]
 [0.8 0.8 0.8 0.8 0.  0.8 0.8 0.8 0.8 0.  0.8 0.8 0.8 0.8 0.  0.8 0.8 0.8  0.8 0. ]
 [0.4 0.4 0.4 0.4 0.  0.4 0.4 0.4 0.4 0.  0.4 0.4 0.4 0.4 0.  0.4 0.4 0.4  0.4 0. ]]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值