def __init__(self, scp_file, utt2label_file, M):
        'Initialization'
        self.M = M
        self.scp_file = scp_file
        self.utt2len = ako.read_key_len(scp_file)
        self.utt2label = ako.read_key_label(utt2label_file)
        self.feat_gen = ko.read_mat_scp(scp_file)  # feature generator

        self.utt2mat = {}
        for key, mat in self.feat_gen:
            self.utt2mat[key] = mat
    def __init__(self, scp_file, utt2label_file):
        'Initialization'
        self.scp_file = scp_file
        self.utt2label = ako.read_key_label(utt2label_file)
        self.feat_gen = ko.read_mat_scp(scp_file)  # feature generator

        mats, labels = [], []  # construct feature and label matrices
        for key, mat in self.feat_gen:
            mats.append(mat)
            labels.append(np.repeat(self.utt2label[key], len(mat)))
        self.label_mat = np.hstack(labels)
        self.feat_mat = np.vstack(mats)
Beispiel #3
0
 def __init__(self, scp_file, utt2label_file):
     'Initialization'
     self.scp_file = scp_file
     self.utt2label = ako.read_key_label(utt2label_file)
     self.key_list = ako.read_all_key(scp_file)
from __future__ import print_function
import adv_kaldi_io as ako

test_scp = '/export/b19/jlai/cstr/spoof/baseline/v1/data/train_cqcc/feats.scp'
test_utt2label = '/export/b19/jlai/cstr/spoof/baseline/v1/data/train_cqcc/utt2label'
test_key = 'M0001-T_1000027'

all_key = ako.read_all_key(test_scp)
mat = ako.read_mat_key(test_scp, test_key)
length = ako.read_total_len(test_scp)
print(length)  # 938016
label = ako.read_key_label(test_utt2label)
key_map = ako.read_key_len(test_scp)
print(key_map)
Beispiel #5
0
evaluation_scp = '/export/b19/jlai/cstr/spoof/model/src/data_reader/spec/eval_spec_cmvn_tensor.scp'

params = {'batch_size': 32,
          'shuffle': False,
          'num_workers': 0}
max_epochs = 1

training_set, validation_set, evaluation_set = SpoofDataset(train_scp, train_utt2label), SpoofDataset(validation_scp, validation_utt2label), SpoofDataset(evaluation_scp, evaluation_utt2label)

training_generator = data.DataLoader(training_set, **params)
validation_generator = data.DataLoader(validation_set, **params)
evaluation_generator = data.DataLoader(evaluation_set, **params)

validation_generator2 = data.DataLoader(validation_set, **params)

dev_utt2label  = ako.read_key_label(validation_utt2label)
eval_utt2label = ako.read_key_label(evaluation_utt2label)
gen_1, gen_2 = {}, {}
for epoch in range(max_epochs):
    for i_batch, sample_batched in enumerate(validation_generator):
        #key = sample_batched[0][0]
        #label = dev_utt2label[key]
        gen_1[i_batch] = sample_batched[1]
        if i_batch == 10: break 
    for i_batch, sample_batched in enumerate(validation_generator2):
        #key = sample_batched[0][0]
        #label = dev_utt2label[key]
        gen_2[i_batch] = sample_batched[1] 
        if i_batch == 10: break 

for i,value in gen_1.items():