-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatlab_loader.py
42 lines (35 loc) · 1.07 KB
/
matlab_loader.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
import os
import sys
import csv
from subprocess import call
"""Call MatLab from command line and execute script given by mls"""
"""
if(str(mls).split('.')[-1]!= 'm'):
print "Not a valid Matlab file"
return
else:
"""
def matlabExec(mls):
cmd="matlab -r "+str(mls)
call(cmd)
def getMFCC(t):
"""Read text file and get mfccs of the song. Return a string of values"""
newinstance = str(t)
mfcc = []
with open(newinstance,"r") as csvf:
mfccReader = csv.reader(csvf,delimiter=',')
for row in mfccReader:
for col in row:
coln = float(col)
mfcc.append(coln)
return mfcc
def getTrainingMFCC(o):
"Get training MFCC data. Return a list of list with inner list representing each song"
mfccreaderold = csv.reader('training.csv')
trainingdata = str(o)
mfcclist = []
with open(trainingdata,"r") as csvf:
mfccReader = csv.reader(csvf,delimiter=',')
for row in mfccReader:
mfcclist.append(row)
return mfcclist