Last active
November 4, 2019 08:02
-
-
Save grohith327/ce30475cd508e0f196fb4face38f47ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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