-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_spectraldata.py
100 lines (43 loc) · 1.61 KB
/
get_spectraldata.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
''' Use this when you want to obtain final training data in the form of numpy array and labels to feed into keras
Only run when you have finished recording your dataset using get_words
'''
from get_mfcc import *
import numpy as np
from import_words import importAllFromDir
def getTrainingData():
print ("GETTING YOU SHUFFLED PREPROCESSED NUMPY DATA AND LABELS AS 'SOUNDDATA' AND 'LABELS' TO FEED INTO MODEL...")
print
print
# we first obtained a shuffled dataset of both ll and non ll chunks in one array, along with their corresponding labels array
ll_data, ll_labels = importAllFromDir('../LL_chunks')
nonll_data, nonll_labels = importAllFromDir('../nonLL_chunks')
final_data = []
final_labels = []
for data in ll_data:
final_data.append(data)
for data in nonll_data:
final_data.append(data)
for label in ll_labels:
final_labels.append(label)
for label in nonll_labels:
final_labels.append(label)
print (len(final_data))
print (len(final_labels))
'''
#shuffling
shuffle_in_unison_scary(final_data, final_labels)
#processing and cleaning
reduceDensity(final_data)
trimChunks(final_data)
assertConstantChunkSize(final_data)
weightedAverage(final_data, 0.99)
trimChunks(final_data)
assertConstantChunkSize(final_data)
normalizeSoundData(final_data)
assertZeroMean(final_data)
assertUnitVariance(final_data)
'''
print ("DONE!")
return final_data, np.array(final_labels)
if __name__ == '__main__':
data, labels = getTrainingData()