Skip to content
Snippets Groups Projects
Commit 17d1a879 authored by Pavel KORSHUNOV's avatar Pavel KORSHUNOV
Browse files

extending win slicing

parent 687d3298
Branches
No related tags found
No related merge requests found
Pipeline #
...@@ -140,6 +140,9 @@ class DiskAudio(Base): ...@@ -140,6 +140,9 @@ class DiskAudio(Base):
m_total_length = len(features) m_total_length = len(features)
features_size = features.shape[1] features_size = features.shape[1]
if m_total_length < win_size:
return None, None
# compute the number of sliding windows # compute the number of sliding windows
m_num_win = int((m_total_length - win_size) / sliding_step) + 1 m_num_win = int((m_total_length - win_size) / sliding_step) + 1
...@@ -153,9 +156,10 @@ class DiskAudio(Base): ...@@ -153,9 +156,10 @@ class DiskAudio(Base):
# the resulted shape is # the resulted shape is
# (number of windows, window size, size of each feature vector) # (number of windows, window size, size of each feature vector)
# we assume each value of features is 4 bytes # we assume each value of features is 4 bytes
windows = stride_tricks.as_strided(features, windows = stride_tricks.as_strided(features,
shape=(m_num_win, win_size, features_size), shape=(m_num_win, win_size, features_size),
strides=(features_size * 4, features_size * 4, 4)) strides=(features_size * 4, features_size * 4, 4))
# make sure the array is divided into equal chunks # make sure the array is divided into equal chunks
#windows = numpy.split(features[:int(win_size) * int(m_num_win)], int(m_num_win)) #windows = numpy.split(features[:int(win_size) * int(m_num_win)], int(m_num_win))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment