我们已经编程了一种设备(由ra berry pi 3组成),可以坐在一个房间里,并根据现有的GMM对房间进行表征。我们的代码可以成功运行,直到在第17或19次迭代中引发错误为止。我们已经缩小了代码在哪里出现问题的范围,但是我们不确定为什么。
我们是初学者,所以为怪异的格式道歉...这对我们来说都是新的。
在此先感谢您提供的任何帮助或见解!
sz
我们认为问题发生在这一行:
from sklearn import preprocessing
import python_speech_features as mfcc
def calculate_delta(array):
"""Calculate and returns the delta of given feature vector matrix"""
rows,cols = array.shape
deltas = np.zeros((rows,20))
N = 2
for i in range(rows):
index = []
j = 1
while j <= N:
if i-j < 0:
first = 0
else:
first = i-j
if i+j > rows -1:
second = rows -1
else:
second = i+j
index.append((second,first))
j+=1
deltas[i] = ( array[index[0][0]]-array[index[0][1]] + (2 * (array[index[1][0]]-array[index[1][1]])) ) / 10
return deltas
def extract_features(audio,rate):
try:
"""extract 20 dim mfcc features from an audio, performs CMS and combines
delta to make it 40 dim feature vector"""
# audio is audio signal from which to compute features -> should be n*1 array
# rate is samplerate of the signal we are working with
# 0.025 is the length of the analysis window in seconds (default is 25ms)
# 0.01 is the step between successive windows in seconds (default is 10ms)
# 20 is number of cepstrum to return (default is 13)
# append energy is true if zeroth cepstral coefficient is replaced with log of total frame energy
# mfcc() returns a numpy array of size (NUMFRAMES by numcep) containing features, each row holds 1 feature vector
# further possible parameters & their defaults can be found at python-speech-features.readthedocs.io/en/latest/
mfcc_feat = mfcc.mfcc(audio,rate, 0.025, 0.01, 20, appendEnergy = True)
# Scale all data onto one scale, eliminating sparsity & following same concept of Normalization & Standardization
mfcc_feat = preprocessing.scale(mfcc_feat)
delta = calculate_delta(mfcc_feat)
combined = np.hstack((mfcc_feat,delta))
print("Features extracted")
return combined
except Exception as e:
print(e)
print("Extract features failed.")
它给我们的错误是:
后端终止(返回码:-9)
答案 0 :(得分:0)
返回码:-9表示信号9,表示
SIGKILL。 SIGKILL信号发送到进程以使其立即终止(终止)。与SIGTERM和SIGINT相比,此信号不能被捕获或忽略,并且接收过程在接收到该信号后无法执行任何清除操作。
这可能就是为什么它没有被异常捕获的原因。