def trial_test(path): ''' create the test ndx file param: path : the test file path ''' data = pd.read_csv(path) models = [] segments = [] trials = [] enroll_idmap = sidekit.IdMap('task/idmap.h5') enroll_models = [] for i in range(0, len(enroll_idmap.leftids), 3): enroll_models.append(enroll_idmap.leftids[i]) print(enroll_models) for i in range(len(data.index)): for j in range(5): ind = data['GroupID'][i] * 5 + j models.append(enroll_models[ind]) segments.append(data['FileID'][i]) trials.append('nontarget') key = sidekit.Key(models=np.array(models), testsegs=np.array(segments), trials=np.array(trials)) ndx = key.to_ndx() assert ndx.validate(), 'ndx is not valid' ndx.write('task/ndx.h5')
def trial_dev(path): ''' create the dev ndx and key file param: path : the annotation file path ''' data = pd.read_csv(path) models = [] segments = [] trials = [] enroll_idmap = sidekit.IdMap('task/idmap.h5') enroll_models = [] for i in range(0, len(enroll_idmap.leftids), 3): enroll_models.append(enroll_idmap.leftids[i]) print(enroll_models) for i in range(len(data.index)): for j in range(5): ind = data['GroupID'][i] * 5 + j models.append(enroll_models[ind]) segments.append(data['FileID'][i]) if str(data['SpeakerID'][i]) == enroll_models[ind]: trials.append('target') else: trials.append('nontarget') key = sidekit.Key(models=np.array(models), testsegs=np.array(segments), trials=np.array(trials)) assert key.validate(), 'key is not valid' key.write('task/dev_key.h5') ndx = key.to_ndx() assert ndx.validate(), 'ndx is not valid' ndx.write('task/dev_ndx.h5')
def compute_eer(args): print('Compute eer', end='') key = sidekit.Key(os.getcwd() + '/task/dev_key.h5') score = sidekit.Scores(os.getcwd() + '/task/dev_score.h5') print('\rCompute eer done') dp = sidekit.DetPlot() prior = sidekit.logit_effective_prior(0.01, 1, 1) dp.set_system_from_scores(score, key) minDCF, _, __, ___, eer = sidekit.bosaris.detplot.fast_minDCF( dp.__tar__[0], dp.__non__[0], prior, normalize=True) with open('task/dev_result.txt', 'w') as f: f.write('eer : {:7.2%}\n'.format(eer)) f.write('minDCF : {:7.2%}\n'.format(minDCF)) return eer, minDCF
rsr2015Path = '/info/home/larcher/RSR2015_v1/' # Default for RSR2015 audioDir = os.path.join(rsr2015Path, 'sph/male') # Automatically set the number of parallel process to run. # The number of threads to run is set equal to the number of cores available # on the machine minus one or to 1 if the machine has a single core. nbThread = max(multiprocessing.cpu_count() - 1, 1) # Load IdMap, Ndx, Key from HDF5 files and ubm_list print('Load task definition') enroll_idmap = sidekit.IdMap('/info/home/larcher/task/3sesspwd_eval_m_trn.h5') test_ndx = sidekit.Ndx('/info/home/larcher/task/3sess-pwd_eval_m_ndx.h5') key = sidekit.Key('/info/home/larcher/task/3sess-pwd_eval_m_key.h5') with open('/info/home/larcher/task/ubm_list.txt') as inputFile: ubmList = inputFile.read().split('\n') # Process the audio to save MFCC on disk logging.info("Initialize FeaturesExtractor") extractor = sidekit.FeaturesExtractor( audio_filename_structure=audioDir + "/{}.wav", feature_filename_structure="./features/{}.h5", sampling_frequency=16000, lower_frequency=133.3333, higher_frequency=6955.4976, filter_bank="log", filter_bank_size=40, window_size=0.025,
# on the machine minus one or to 1 if the machine has a single core. nbThread = max(multiprocessing.cpu_count() - 1, 1) ################################################################# # Load IdMap, Ndx, Key from PICKLE files and ubm_list ################################################################# print('Load task definition') enroll_idmap = sidekit.IdMap('task/sre10_coreX-coreX_m_trn.h5', 'hdf5') nap_idmap = sidekit.IdMap('task/sre04050608_m_training.h5', 'hdf5') back_idmap = sidekit.IdMap('task/sre10_coreX-coreX_m_back.h5', 'hdf5') test_ndx = sidekit.Ndx('task/sre10_coreX-coreX_m_ndx.h5', 'hdf5') test_idmap = sidekit.IdMap('task/sre10_coreX-coreX_m_test.h5', 'hdf5') keysX = [] for cond in range(9): keysX.append( sidekit.Key('task/sre10_coreX-coreX_det{}_key.h5'.format(cond + 1))) with open('task/ubm_list.txt', 'r') as inputFile: ubmList = inputFile.read().split('\n') if train: # %% ################################################################# # Process the audio to generate MFCC ################################################################# print('Create the feature server to extract MFCC features') fs = sidekit.FeaturesServer(input_dir=audioDir, input_file_extension='.mfcc', label_dir='./', label_file_extension='.lbl', from_file='spro4',
distribNb = 512 # number of Gaussian distributions for each GMM JVPD_Path = r'C:\Users\yokoo takaya\Desktop\JVPD' # Default for RSR2015 audioDir = os.path.join(JVPD_Path, 'JVPD_ALLsound') # Automatically set the number of parallel process to run. # The number of threads to run is set equal to the number of cores available # on the machine minus one or to 1 if the machine has a single core. nbThread = max(multiprocessing.cpu_count()-1, 1) print('Load task definition') enroll_idmap = sidekit.IdMap('idmap_JVPD.h5') test_ndx = sidekit.Ndx('ndx_JVPD.h5') key = sidekit.Key('key_JVPD.h5') with open('JVPD_filename_all.txt') as inputFile: ubmList = inputFile.read().split('\n') logging.info("Initialize FeaturesExtractor") extractor = sidekit.FeaturesExtractor(audio_filename_structure=audioDir+"/{}.wav", feature_filename_structure="./features_PLP/{}.h5", sampling_frequency=16000, lower_frequency=133.3333, higher_frequency=6955.4976, filter_bank="lin", filter_bank_size=40, window_size=0.025, shift=0.01, ceps_number=19,
enroll_idmap.rightids = np.asarray(segments) enroll_idmap.start = np.empty(enroll_idmap.rightids.shape, dtype='|O') enroll_idmap.stop = np.empty(enroll_idmap.rightids.shape, dtype='|O') enroll_idmap.validate() enroll_idmap.write( '/home/adit/Desktop/enroll_ids1.h5' ) #DCASE2017-baseline-system-master/HDF5_DCASE/enroll_ids4.h5') models, segments, targets = [], [], [] with open( '/home/adit/Desktop/DCASE2017-baseline-system-master/applications/data/TUT-acoustic-scenes-2017-development/evaluation_setup/fold1_evaluate.txt', 'r+') as op: for i in op: i = i.replace('audio/', '').replace('.wav', '') i = i.rstrip('\n').split('\t') models.append(i[1]) segments.append(i[0]) targets.append('target') print(len(models)) print(len(segments)) key = sidekit.Key(models=np.array(models), testsegs=np.array(segments), trials=np.array(targets)) key.write('/home/adit/Desktop/key1.h5') ndx = key.to_ndx() ndx.write('/home/adit/Desktop/ndx1.h5')