Beispiel #1
0
 def read_data(self, DataListName, FeatureName,shape):
     '''
     Load original data and the feature that you choose to use is needed
     You can choose different output shape.
     :DataListName: The log.txt path
     :FeatureName: The name of the feature that you choose to use
     :shape: The output shape that you prefer
     '''
     Feature = FeatureName.capitalize()
     Data = np.zeros((1,shape))
     Label = []
     processer = PreProcessing(512, 128)
     wav_list, frame_list, energy_list, zcr_list, endpoint_list, Label = processer.process(DataListName)
     if Feature[0] == 'E':
         for i in range(len(zcr_list)):
             temp = processer.effective_feature(energy_list[i], endpoint_list[i])
             temp = processer.reshape(temp, shape)
             Data=np.concatenate((Data,temp),axis = 0)
         Data = Data[1:]
         return Data, Label
     elif Feature[0] == 'Z':
         for i in range(len(zcr_list)):
             temp = processer.effective_feature(zcr_list[i], endpoint_list[i])
             temp = processer.reshape(temp, shape)
             Data=np.concatenate((Data,temp),axis = 0)
         Data = Data[1:]
         return Data, Label
     else:
         print("please choose correct feature, and we will return ZCR by default")
         for i in range(len(zcr_list)):
             temp = processer.effective_feature(zcr_list[i], endpoint_list[i])
             temp = processer.reshape(temp, shape)
             Data=np.concatenate((Data,temp),axis = 0)
         Data = Data[1:]
         return Data, Label
 def setUp(self):
     self.DATA_DIR = './TEST_DIR'
     self.LOG = './TEST_DIR/data_log.txt'
     builder = VoiceDataSetBuilder(
         dst_path=self.DATA_DIR,
         log_file=self.LOG,
         rate=44100)
     builder.build()
     self.pre_process = PreProcessing(frame_size=512, overlap=128)
     plt.ion()
     plt.figure(1)
Beispiel #3
0
 def load_target(self, ModelListName):
     '''
     Load model data
     this is the model data for classification
     :ModelListName: The Model_log.txt path
     '''
     eff_label_list = []
     eff_mfcc = []
     processer = PreProcessing(512, 128)
     wav_list, frame_list, mfcc_list, energy_list, zcr_list, endpoint_list, label_list = processer.process(
         ModelListName)
     for i in range(len(mfcc_list)):
         temp = processer.effective_feature(mfcc_list[i], endpoint_list[i])
         if endpoint_list[i][1] - endpoint_list[i][0] != 0:
             eff_label_list.append(label_list[i])
             eff_mfcc.append(mfcc_list[i])
         else:
             continue
     return eff_mfcc, eff_label_list
Beispiel #4
0
 def read_data(self, DataListName):
     '''
     Load original data
     You can choose different output shape.
     :DataListName: The log.txt path
     '''
     eff_label_list = []
     eff_mfcc = []
     processer = PreProcessing(512, 128)
     wav_list, frame_list, mfcc_list, energy_list, zcr_list, endpoint_list, label_list = processer.process(
         DataListName)
     for i in range(len(mfcc_list)):
         temp = processer.effective_feature(mfcc_list[i], endpoint_list[i])
         if endpoint_list[i][1] - endpoint_list[i][0] != 0:
             eff_label_list.append(label_list[i])
             eff_mfcc.append(mfcc_list[i])
         else:
             continue
     return eff_mfcc, eff_label_list
 def read_data(self, DataListName, FeatureName, shape):
     '''
     Load original data and the feature that you choose to use is needed
     You can choose different output shape.
     :DataListName: The log.txt path
     :FeatureName: The name of the feature that you choose to use
     :shape: The output shape that you prefer
     '''
     Feature = FeatureName.capitalize()
     Data = np.zeros((1, shape))
     zcrdata = np.zeros((1, shape))
     energydata = np.zeros((1, shape))
     eff_label_list = []
     processer = PreProcessing(512, 128)
     wav_list, frame_list, mfcc_list, energy_list, zcr_list, endpoint_list, label_list = processer.process(
         DataListName)
     if Feature[0] == 'E':
         for i in range(len(energy_list)):
             temp = processer.effective_feature(energy_list[i],
                                                endpoint_list[i])
             temp = processer.reshape(temp, shape)
             if len(temp) != 0:
                 eff_label_list.append(label_list[i])
             else:
                 continue
             Data = np.concatenate((Data, temp), axis=0)
         Data = Data[1:]
         return Data, eff_label_list
     elif Feature[0] == 'Z':
         for i in range(len(zcr_list)):
             temp = processer.effective_feature(zcr_list[i],
                                                endpoint_list[i])
             temp = processer.reshape(temp, shape)
             print(np.shape(temp))
             if len(temp) != 0:
                 eff_label_list.append(label_list[i])
             else:
                 continue
             Data = np.concatenate((Data, temp), axis=0)
         Data = Data[1:]
         return Data, eff_label_list
     elif Feature[0] == 'W':
         for i in range(len(zcr_list)):
             temp = processer.effective_feature(zcr_list[i],
                                                endpoint_list[i])
             temp = processer.reshape(temp, shape)
             if len(temp) != 0:
                 eff_label_list.append(label_list[i])
             else:
                 continue
             zcrdata = np.concatenate((zcrdata, temp), axis=0)
         zcrdata = zcrdata[1:]
         for i in range(len(zcr_list)):
             temp = processer.effective_feature(energy_list[i],
                                                endpoint_list[i])
             temp = processer.reshape(temp, shape)
             if len(temp) == 0:
                 continue
             energydata = np.concatenate((energydata, temp), axis=0)
         energydata = energydata[1:]
         data = energydata * zcrdata
         return data, eff_label_list
     else:
         print(
             "please choose correct feature, and we will return ZCR by default"
         )
         for i in range(len(zcr_list)):
             temp = processer.effective_feature(zcr_list[i],
                                                endpoint_list[i])
             temp = processer.reshape(temp, shape)
             if len(temp) != 0:
                 eff_label_list.append(label_list[i])
             else:
                 continue
             Data = np.concatenate((Data, temp), axis=0)
         Data = Data[1:]
         return Data, eff_label_list
 def setUp(self):
     self.WAVE_NUM = 10
     self.WAVE_DURANCE = 1000
     self.wave_list = np.random.randn(self.WAVE_DURANCE, self.WAVE_NUM)
     self.base = PreProcessing(100, 10)
     self.frames = np.array([self.base.Enframe(wave) for wave in self.wave_list])