使用plp,TypeError进行特征提取期间遇到错误:ufunc'add'不包含签名匹配的循环

时间:2019-01-04 06:31:43

标签: python machine-learning speech-recognition feature-extraction

  

当我在pycharm上执行此程序时,比发现有关error的错误,   更改我的代码中要求的内容,请任何人帮助我。我怎样才能修改它TypeError:ufunc   “ add”不包含带有签名匹配的循环。

#!usr/bin/python
import pandas as pd
import numpy
import numpy.matlib
import scipy
from scipy.fftpack.realtransforms import dct
from SIDEKIT.sidekit.frontend.vad import pre_emphasis
from sidekit.frontend.io import *
from sidekit.frontend.normfeat import *
from sidekit.frontend.features import *
import scipy.io.wavfile as wav
import numpy as np
from six.moves import input as raw_input

def readWavFile(wav):
        #given a path from the keyboard to read a .wav file
        #wav = raw_input('Give me the path of the .wav file you want to read: ')
        inputWav = 'C:/Users/KALEEM/PycharmProjects/kaleem_wavprocessing/12-Speech_Signal_Processing_and_Classification-master/feature_extraction_techniques'+wav
        return inputWav
#reading the .wav file (signal file) and extract the information we need
def initialize(inputWav):
        rate , signal  = wav.read(readWavFile(inputWav)) # returns a wave_read object , rate: sampling frequency
        sig = wave.open(readWavFile(inputWav))
        # signal is the numpy 2D array with the date of the .wav file
        # len(signal) number of samples
        sampwidth = sig.getsampwidth()
        print ('The sample rate of the audio is: ',rate)
        print ('Sampwidth: ',sampwidth)
        return signal ,  rate
def PLP():
        folder = raw_input('Give the name of the folder that you want to read data: ')
        amount = raw_input('Give the number of samples in the specific folder: ')
        for x in range(1,int(amount)+1):
                wav = '/'+folder+'/'+str(x)+'.wav'
                print (wav)
                #inputWav = readWavFile(wav)
                signal,rate = initialize(wav)
                #returns PLP coefficients for every frame
                plp_features = 'plp(signal,rasta=True)'
                meanFeatures(plp_features[0])
#compute the mean features for one .wav file (take the features for every frame and make a mean for the sample)
def meanFeatures(plp_features):
        #make a numpy array with length the number of plp features
        mean_features=np.zeros(len(plp_features[0]))
        #for one input take the sum of all frames in a specific feature and divide them with the number of frames
        for x in range(len(plp_features)):
                for y in range(len(plp_features[x])):
                        mean_features[y]+=plp_features[x][y]
        mean_features = (mean_features / len(plp_features))
        print (mean_features)

#def main():
PLP()
#main()
  

给出要读取数据的文件夹的名称:示例   特定文件夹中的样本数:5追溯(最新   最后调用):文件   “ C:/用户/KALEEM/PycharmProjects/kaleem_wavprocessing/12-Speech_Signal_Processing_and_Classification-master/feature_extraction_techniques/plp.py”,   第53行,在       PLP()文件“ C:/Users/KALEEM/PycharmProjects/kaleem_wavprocessing/12-Speech_Signal_Processing_and_Classification-master/feature_extraction_techniques/plp.py”,   PLP中的第40行       meanFeatures(plp_features [0])文件“ C:/Users/KALEEM/PycharmProjects/kaleem_wavprocessing/12-Speech_Signal_Processing_and_Classification-master/feature_extraction_techniques/plp.py”,   第48行,在meanFeatures中       mean_features [y] + = plp_features [x] [y] TypeError:ufunc'add'不包含签名匹配类型为dtype('      

进程以退出代码1完成

0 个答案:

没有答案