Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ce1febb

Browse filesBrowse files
committed
Rewritten the delta calculation in a more vectorial form
1 parent e1e029a commit ce1febb
Copy full SHA for ce1febb

1 file changed

+3-1Lines changed: 3 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎python_speech_features/base.py‎

Copy file name to clipboardExpand all lines: python_speech_features/base.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,12 @@ def delta(feat, N):
179179
:param N: For each frame, calculate delta features based on preceding and following N frames
180180
:returns: A numpy array of size (NUMFRAMES by number of features) containing delta features. Each row holds 1 delta feature vector.
181181
"""
182+
if N < 1:
183+
raise ValueError('N must be an integer >= 1')
182184
NUMFRAMES = len(feat)
183185
denominator = 2 * sum([i**2 for i in range(1, N+1)])
184186
delta_feat = numpy.empty_like(feat)
185187
padded = numpy.pad(feat, ((N, N), (0, 0)), mode='edge') # padded version of feat
186188
for t in range(NUMFRAMES):
187-
delta_feat[t] = numpy.sum([n * padded[N+t + n] for n in range(-N, N+1)], axis=0) / denominator
189+
delta_feat[t] = numpy.dot(numpy.arange(-N, N+1), padded[t : t+2*N+1]) / denominator # [t : t+2*N+1] == [(N+t)-N : (N+t)+N+1]
188190
return delta_feat

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.