Skip to content

Instantly share code, notes, and snippets.

@fedden
Created November 20, 2017 11:15
Show Gist options
  • Save fedden/9f259ea301724379ffb8cf628b4067ed to your computer and use it in GitHub Desktop.
Save fedden/9f259ea301724379ffb8cf628b4067ed to your computer and use it in GitHub Desktop.
import numpy as np
# Create some random MFCC shaped features as a sequence of 10 values
feature_sequence = np.random.random((10, 13))
# Get the standard deviation
stddev_features = np.std(feature_sequence, axis=0)
# Get the mean
mean_features = np.mean(feature_sequence, axis=0)
# Get the average difference of the features
average_difference_features = np.zeros((16,))
for i in range(0, len(feature_sequence) - 2, 2):
average_difference_features += feature_sequence[i] - feature_sequence[i+1]
average_difference_features /= (len(feature_sequence) // 2)
average_difference_features = np.array(average_difference_features)
# Concatenate the features to a single feature vector
concat_features_features = np.hstack((stddev_features, mean_features))
concat_features_features = np.hstack((concat_features_features, average_difference_features))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment