-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_feature_vectors.py
57 lines (54 loc) · 1.49 KB
/
generate_feature_vectors.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
"""features.mfcc() - Mel Frequency Cepstral Coefficients
features.fbank() - Filterbank Energies
features.logfbank() - Log Filterbank Energies
features.ssc() - Spectral Subband Centroids
"""
from features import mfcc
from features import logfbank
import scipy.io.wavfile as wav
coun=0
kkk=7
while (kkk==7):
(rate,sig) = wav.read("blues.0000"+str(kkk)+".wav")
mfcc_feat = mfcc(sig,rate)
fbank_feat = logfbank(sig,rate, winlen=0.03, winstep=0.03)
#print fbank_feat[0]
normalised=[]
for i in fbank_feat:
sublist=[]
for j in i:
sublist.append(int(round(j/22*7)))
normalised.append(sublist)
with open("blue.txt", "a") as myfile:
for i in normalised:
print i
for j in i:
myfile.write(str(j))
coun+=1
kkk=kkk+1
'''
kkk=10
while (kkk<100):
(rate,sig) = wav.read("blues.000"+str(kkk)+".wav")
mfcc_feat = mfcc(sig,rate)
fbank_feat = logfbank(sig,rate, winlen=0.03, winstep=0.03)
#print fbank_feat[0]
normalised=[]
for i in fbank_feat:
sublist=[]
for j in i:
sublist.append(int(round(j/22*7)))
normalised.append(sublist)
with open("blue.txt", "a") as myfile:
for i in normalised:
print i
for j in i:
myfile.write(str(j))
coun+=1
kkk=kkk+1
print coun
"""
i=0
C:\Users\MegK\Desktop\wavs\ble\blues.0000"+
"""
'''