Closed xav12358 closed 5 years ago
Hi, I am confused about the same thing, maybe a little more than you are. Can you please tell me how you know that the input_feature.py file is generating the development files? I can't find where it is storing the files it generates.
@xav12358 @Chegde8 hello both, I get confused on the same things, do you get solution?
@xav12358 @peter05010402 Hi, I did a little reading on hdf5 file types and think I did figure it out. I tried to follow the file structure that the hdf5 example files had. Here is the code snippet:
eval_try.hdf5 is the file which contains evaluation and enrollment data. "lab" is an array of labels. "feat" is a matrix of features. Here I have the same data for evaluation and enrollment. You will just need to make separate arrays of "lab" and "feat" for both of them. I added this at the end of the original "input_features.py" code. Note that, for the above code snippet, the hdf5 files will be stored in the folder in which input_features.py is saved, i.e. in /code/0-input.
To use these files for development, enrollment and evaluation phases just open these files as "fileh" instead of the ones already given in the code.
Do let me know if you need clarification on anything I have just said or if there is an error and I have misunderstood something.
@Chegde8 Thank you for your code. I got an error's follow:
could you send me your input_features.py? Thank you! peterxjm.de@gmail.com
I think the error is saying that you are storing an empty array into eval_try.hdf5. I will email my input_features.py to you :)
@Chegde8 Thank you!!!
@Chegde8 , Could you please send your input_features.py?
Hi @Chegde8 , @peter05010402 and @xav12358 ,
I added the following to the input_features.py:
idx = 0
f = open('file_path_test1.txt','r')
for line in f:
idx = idx + 1
#print (idx)
lab = []
feat = []
for i in range(idx):
feature, label = dataset.__getitem__(i)
lab.append(label)
feat.append(feature)
print(feature.shape)
print(label)
######################
## creating hdf5 file ##
######################
h5file = tables.open_file('/root/3D_CNN/3D-convolutional-speaker-recognition/data/evaluation_test.hdf5', 'w')
label_test = h5file.create_carray(where = '/', name = 'label_enrollment', obj = lab, byteorder = 'little')
label_array = h5file.create_carray(where = '/', name = 'label_evaluation', obj = lab, byteorder = 'little')
utterance_test = h5file.create_earray(where = '/', name = 'utterance_enrollment', chunkshape = [1,20,80,40], obj = feat, byteorder = 'little')
utterance_train = h5file.create_earray(where = '/', name = 'utterance_evaluation', `chunkshape = [1,20,80,40]`, obj = feat, byteorder = 'little')
n5file.close()`
It gave me the following error:
ValueError: the shape ((0, 1, 20, 80, 40)) and chunkshape ((1, 20, 80, 40)) ranks must be equal.
I recognized that lab
and feat
are arrays and each one has 9 elements (# of wav files I want to test). Each element of the feat
array has the features of each wav file in my wav list. So what I did is I changed chunkshape
values to be chunkshape = [9,20,80,40,1]
and the evaluation_test.hdf5 file was created with no error.
When I used hdf5 file I created I got bad results and I'm trying to figure out what's the problem.
Based on the structure of the program, is it allowed to make multiple models from multiple wav files at once? Or I need to enroll each model alone?!
Hi @MSAlghamdi , Do you get different results when chunkshape is 1 and when it is 9?
According to me the only thing that changes when you change chunkshape is that the the shape of data written to the hdf5 file in one I/O operation changes. So instead of writing one feature each time, all 9 are written to the hdf5 file at once . I don't know how this would change the results.
Also I am not sure if changing chunkshape has anything to do with whether multiple models from multiple wav files are created at once. The model creation happens in the training and enrollment phases, not in the input phase. In this script we just produce the files which are used later.
But again, I am really not an expert on how hdf5 files work. So what I have said above might not be completely correct.
Also, your question got me thinking, do the training and enrollment codes make different models for each wav file, or do they create one model for each speaker based on the labels? Essentially, will the performance be better if I use multiple short wav files per speaker or one long wav file per speaker?
PS: @MSAlghamdi , do you still want me to send you my input_features.py file? I think you have already gotten it, but asking just in case.
@Chegde8
No, thank you. I just built main and it did work.
datasetTest = AudioDataset(files_path='file_path_test.txt', audio_dir='Audio',
transform=Compose([CMVN(), Feature_Cube(cube_shape=(20, 80, 40), augmentation=True), ToOutput()]))
datasetTrain = AudioDataset(files_path='file_path_train.txt', audio_dir='Audio',
transform=Compose([CMVN(), Feature_Cube(cube_shape=(20, 80, 40), augmentation=True), ToOutput()]))
############### TEST DATASET ####################
idx_test = 0
f1 = open('file_path_train.txt','r')
for line in f1:
idx_test = idx_test + 1
lab_test = []
feat_test = []
for i in range(idx_test):
feature, label = datasetTest.__getitem__(i)
lab_test.append(label)
# feature.shap= (1, 20, 80, 40).
# make it like: (1, 80, 40, 20)
feature = feature.swapaxes(1, 2).swapaxes(2, 3)
feat_test.append(feature[0,:,:,:])
############### TRAIN DATASET ####################
idx = 0
f = open('file_path_train.txt','r')
for line in f:
idx = idx + 1
lab_train = []
feat_train = []
for i in range(idx):
feature, label = datasetTrain.__getitem__(i)
lab_train.append(label)
feature = feature.swapaxes(1, 2).swapaxes(2, 3)
feat_train.append(feature[0,:,:,:])
h5file = tables.open_file('/root/3D_CNN/3D-convolutional-speaker-recognition/data/devel_try.hdf5', 'w')
label_test = h5file.create_carray(where = '/', name = 'label_test', obj = lab_test, byteorder = 'little')
label_array = h5file.create_carray(where = '/', name = 'label_train', obj = lab_train, byteorder = 'little')
utterance_test = h5file.create_earray(where = '/', name = 'utterance_test', chunkshape = [8,80,40,20], obj = feat_test, byteorder = 'little')
utterance_train = h5file.create_earray(where = '/', name = 'utterance_train', chunkshape = [13,80,40,20], obj = feat_train, byteorder = 'little')
h5file.close()
the .h5 file was created in a good shape. There's another issue popped up when I ran the demo that could be solved if I store the feature in a npy array.
I'll let you know when it's solved.
@Chegde8 hello, I added your code and change the first line as:
with open("eval_try.hdf5", "w") as h5file:
but got this error:
AttributeError: '_io.TextIOWrapper' object has no attribute 'create_carray'
ummmm, sorry im the new of SV, could u please send ur input_features.py? Thanks!
aaron_lu47@163.com
@xav12358 @peter05010402 Hi, I did a little reading on hdf5 file types and think I did figure it out. I tried to follow the file structure that the hdf5 example files had. Here is the code snippet:
eval_try.hdf5 is the file which contains evaluation and enrollment data. "lab" is an array of labels. "feat" is a matrix of features. Here I have the same data for evaluation and enrollment. You will just need to make separate arrays of "lab" and "feat" for both of them. I added this at the end of the original "input_features.py" code. Note that, for the above code snippet, the hdf5 files will be stored in the folder in which input_features.py is saved, i.e. in /code/0-input.
To use these files for development, enrollment and evaluation phases just open these files as "fileh" instead of the ones already given in the code.
Do let me know if you need clarification on anything I have just said or if there is an error and I have misunderstood something.
could you send me your input_features.py? Thank you! @MSAlghamdi
@Chegde8 could you send me your input_features.py? Thank you! obsidian_lrx@aliyun.com
Hello,
I have a dataset of voices. I want to generate development and enrollment hdf5 file. The input_feature.py file seams to generate development files (nx80x40x20). How can I generate the enrollment file?