Skip to content

Instantly share code, notes, and snippets.

@grohith327
Last active November 4, 2019 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save grohith327/ce30475cd508e0f196fb4face38f47ca to your computer and use it in GitHub Desktop.
Save grohith327/ce30475cd508e0f196fb4face38f47ca to your computer and use it in GitHub Desktop.
import numpy as np
import librosa
import os
peak_features = []
peak_labels = []
count = 0
for dirc in sorted(os.listdir('./Dataset')):
print('Reading '+str(dirc))
for files in os.listdir('./Dataset/'+str(dirc)):
data, sf = librosa.load('./Dataset/'+str(dirc)+'/'+str(files))
D = np.abs(librosa.stft(data))
if(D.shape != (1025,87)):
D = np.pad(D,((0,0),(0,1)),'constant')
peak_features.append(D)
peak_labels.append(count)
count += 1
peak_features = np.array(peak_features)
peak_labels = np.array(peak_labels)
print(peak_features.shape)
print(peak_labels.shape)
np.save('./command_spect.npy',peak_features)
np.save('./command_spect_labels.npy',peak_labels)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment