So I am trying to make a rudimentary emotion classifier using the pyAudioAnalysis library, and I have collected a small datasample to test if it works. my code is as following:
from pyAudioAnalysis import audioAnalysis as aA
aA.trainClassifierWrapper('svm', False,
["C:\Users\gover_000\Desktop\Angry",
"C:\Users\gover_000\Desktop\Happy",
"C:\Users\gover_000\Desktop\Sad",
"C:\Users\gover_000\Desktop\Scared",
"C:\Users\gover_000\Desktop\Neutral"],
"testSVM")
If I execute this, it gives this error:
Traceback (most recent call last) <ipython-input-7-2e5393432e89> in <module>()
5 "C:\Users\gover_000\Desktop\Scared",
6 "C:\Users\gover_000\Desktop\Neutral"],
----> 7 "testSVM")
C:\Users\gover_000\Documents\GitHub\Emotion-Recognition-Prototype\pyAudioAnalysis\audioAnalysis.pyc in trainClassifierWrapper(method, beatFeatures, directories, modelName)
88 raise Exception("At least 2 directories are needed")
89 aT.featureAndTrain(directories, 1, 1, aT.shortTermWindow, aT.shortTermStep,
---> 90 method.lower(), modelName, computeBEAT=beatFeatures)
91
92
C:\Users\gover_000\Documents\GitHub\Emotion-Recognition-Prototype\pyAudioAnalysis\audioTrainTest.pyc in featureAndTrain(listOfDirs, mtWin, mtStep, stWin, stStep, classifierType, modelName, computeBEAT, perTrain)
275 featureNames = ["features" + str(d + 1) for d in range(numOfFeatures)]
276
--> 277 writeTrainDataToARFF(modelName, features, classNames, featureNames)
278
279 for i, f in enumerate(features):
C:\Users\gover_000\Documents\GitHub\Emotion-Recognition-Prototype\pyAudioAnalysis\audioTrainTest.pyc in writeTrainDataToARFF(modelName, features, classNames, featureNames)
1097 for c, fe in enumerate(features):
1098 for i in range(fe.shape[0]):
-> 1099 for j in range(fe.shape[1]):
1100 f.write("{0:f},".format(fe[i, j]))
1101 f.write(classNames[c]+"\n")
IndexError: tuple index out of range
I know shape[1]
is supposed to return the columns of an array dimension.
but why does it return an error here
Okay so I found the problem.
The problem was that one of my classifiers didn't have enough files, it needed atleast 2. so after adding more it worked again!