gpt4 book ai didi

python - pyAudioAnalysis,元组索引超出范围

转载 作者:行者123 更新时间:2023-12-03 00:14:29 25 4
gpt4 key购买 nike

因此,我尝试使用pyAudioAnalysis library做一个基本的情绪分类器,并且我已经收集了一个小的数据样本来测试它是否有效。我的代码如下:

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")

如果执行此操作,则会出现此错误:
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

我知道 shape[1]应该返回数组维度的列。
但是为什么它在这里返回错误

最佳答案

好的,所以我发现了问题。

问题是我的分类器之一没有足够的文件,它至少需要2个。因此,添加更多分类器后,它又可以工作了!

关于python - pyAudioAnalysis,元组索引超出范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40127473/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com