def load_data(path):
data = []
label_index = np.array([], dtype=int)
label_count = 0
wav_files_count = 0
for root, dirs, files in os.walk(path):
# get all wav files in current dir
wav_files = [file for file in files if file.endswith('.wav')]
data_same_person = []
# extract logfbank features from wav file
for wav_file in wav_files:
(rate, sig) = wav.read(root + "/" + wav_file)
fbank_beats = logfbank(sig, rate, nfilt=40)
# save logfbank features into same person array
data_same_person.append(fbank_beats)
# save all data of same person into the data array
# the length of data array is number of speakers
if wav_files:
wav_files_count += len(wav_files)
data.append(data_same_person)
# return data, np.arange(len(data))
return data
评论列表
文章目录