def _delta(feat, N):
"""Compute delta features from a feature vector sequence.
Args:
feat: A numpy array of size (NUMFRAMES by number of features)
containing features. Each row holds 1 feature vector.
N: For each frame, calculate delta features based on preceding and
following N frames
Returns:
A numpy array of size (NUMFRAMES by number of features) containing
delta features. Each row holds 1 delta feature vector.
"""
if N < 1:
raise ValueError('N must be an integer >= 1')
NUMFRAMES = len(feat)
denominator = 2 * sum([i**2 for i in range(1, N + 1)])
delta_feat = np.empty_like(feat)
# padded version of feat
padded = np.pad(feat, ((N, N), (0, 0)), mode='edge')
for t in range(NUMFRAMES):
# [t : t+2*N+1] == [(N+t)-N : (N+t)+N+1]
delta_feat[t] = np.dot(np.arange(-N, N + 1),
padded[t: t + 2 * N + 1]) / denominator
return delta_feat
wav2feature_python_speech_features.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录