def vad_gmm_list(audio_list, model_list, model_file, feature_type, 
            n_coeffs_per_frame, acc_frames, results_dir, working_dir, samp_period, win_length):
    features_dir = os.path.join(working_dir,feature_type)
    acc_features_dir = features_dir+'_frames'
    fea_file_list = os.path.join(working_dir,'feature_files.list')
    if not os.path.exists(features_dir):
        os.makedirs(features_dir)
    if not os.path.exists(acc_features_dir):
        os.makedirs(acc_features_dir)
    vef.fea_extract(audio_list,feature_type,n_coeffs_per_frame,features_dir,samp_period, win_length)
    vef.create_corresponding_list_assert(audio_list,features_dir,fea_file_list,'fea')
    vef.accumulate_feature_vectors(fea_file_list,acc_frames,acc_features_dir)
    vef.create_corresponding_list_assert(audio_list,acc_features_dir,fea_file_list,'fea')
      
    test_gmm_classifier(fea_file_list, model_list, model_file, results_dir)    
def estimate_channel_gmm(audio_list, model_list, model_file, feature_type, 
                         n_coeffs_per_frame, acc_frames, results_dir, working_dir):
    features_dir = os.path.join(working_dir,feature_type)
    acc_features_dir = features_dir+'_frames'
    fea_file_list = os.path.join(working_dir,'feature_files.list')
    if not os.path.exists(features_dir):
        os.makedirs(features_dir)
    if not os.path.exists(acc_features_dir):
        os.makedirs(acc_features_dir)
    vef.fea_extract(audio_list,feature_type,n_coeffs_per_frame,features_dir)
    vef.create_corresponding_list_assert(audio_list,features_dir,fea_file_list,'fea')
    vef.accumulate_feature_vectors(fea_file_list,acc_frames,acc_features_dir)
    vef.create_corresponding_list_assert(audio_list,acc_features_dir,fea_file_list,'fea')
      
    test_gmm_classifier.test_gmm_classifier(test_list=fea_file_list, model_list=model_list, 
                                            model_file=model_file, results_dir=results_dir, 
                                            mode='single')    
Beispiel #3
0
def vad_gmm_list(audio_list, model_list, model_file, feature_type,
                 n_coeffs_per_frame, acc_frames, results_dir, working_dir,
                 samp_period, win_length):
    features_dir = os.path.join(working_dir, feature_type)
    acc_features_dir = features_dir + '_frames'
    fea_file_list = os.path.join(working_dir, 'feature_files.list')
    if not os.path.exists(features_dir):
        os.makedirs(features_dir)
    if not os.path.exists(acc_features_dir):
        os.makedirs(acc_features_dir)
    vef.fea_extract(audio_list, feature_type, n_coeffs_per_frame, features_dir,
                    samp_period, win_length)
    vef.create_corresponding_list_assert(audio_list, features_dir,
                                         fea_file_list, 'fea')
    vef.accumulate_feature_vectors(fea_file_list, acc_frames, acc_features_dir)
    vef.create_corresponding_list_assert(audio_list, acc_features_dir,
                                         fea_file_list, 'fea')

    test_gmm_classifier(fea_file_list, model_list, model_file, results_dir)
def estimate_channel_gmm(audio_list, model_list, model_file, feature_type,
                         n_coeffs_per_frame, acc_frames, results_dir,
                         working_dir):
    features_dir = os.path.join(working_dir, feature_type)
    acc_features_dir = features_dir + '_frames'
    fea_file_list = os.path.join(working_dir, 'feature_files.list')
    if not os.path.exists(features_dir):
        os.makedirs(features_dir)
    if not os.path.exists(acc_features_dir):
        os.makedirs(acc_features_dir)
    vef.fea_extract(audio_list, feature_type, n_coeffs_per_frame, features_dir)
    vef.create_corresponding_list_assert(audio_list, features_dir,
                                         fea_file_list, 'fea')
    vef.accumulate_feature_vectors(fea_file_list, acc_frames, acc_features_dir)
    vef.create_corresponding_list_assert(audio_list, acc_features_dir,
                                         fea_file_list, 'fea')

    test_gmm_classifier.test_gmm_classifier(test_list=fea_file_list,
                                            model_list=model_list,
                                            model_file=model_file,
                                            results_dir=results_dir,
                                            mode='single')
Beispiel #5
0
def test_gmm_classification(models=None, n_samples=10000, working_dir=os.getcwd(),
                            apply_hlda=False, hlda_nuisance_dims=2, do_not_generate_features=False):
    test_percentage = 0.2
    samp_period = 0.01
    generate_features = not do_not_generate_features
    
    if not os.path.exists(working_dir):
        os.makedirs(working_dir)

    fea_dir = os.path.join(working_dir, 'features')
    lab_dir = os.path.join(working_dir, 'lab')
    list_dir = os.path.join(working_dir, 'lists')
    model_dir = os.path.join(working_dir, 'models')
    results_dir = os.path.join(working_dir, 'results')
    if not os.path.exists(list_dir):
        os.makedirs(list_dir)
    if not os.path.exists(fea_dir):
        os.makedirs(fea_dir)
    if not os.path.exists(lab_dir):
        os.makedirs(lab_dir)
    if not os.path.exists(model_dir):
        os.makedirs(model_dir)
    if not os.path.exists(results_dir):
        os.makedirs(results_dir)
        
    # Create a list of the model names
    model_list = os.path.join(working_dir,'models.list')
    ml = open(model_list,'w')
    labels = []
    for md in models:
        ml.write('{}\n'.format(md.name))
        labels.append(md.name)
    ml.close()
        
    tst_file_list = os.path.join(list_dir,'test_files.list')
    trn_file_list = os.path.join(list_dir,'train_files.list')

    if generate_features:
        fea_file_names = write_feature_files(models, n_samples, 
                                             fea_dir, lab_dir)
        n_fea_files = len(fea_file_names)
        logging.info('Number of feature files: {}'.format(n_fea_files))
        n_train_files = int(round(n_fea_files*(1-test_percentage)))
    
        trn_list = open(trn_file_list,'w')    
        for f_n in fea_file_names[0:n_train_files]:
            trn_list.write("{}\n".format(os.path.join(fea_dir,f_n)))
        trn_list.close()
        tst_list = open(tst_file_list,'w')
        for f_n in fea_file_names[n_train_files:n_fea_files-1]:
            tst_list.write("{}\n".format(os.path.join(fea_dir,f_n)))
        tst_list.close()
       
    n_mixes = models[0].n_components
    n_dims = models[0].means.shape[1]
    train_gmm_classifier.train_M_sized_gmm_classifier(n_mixes, n_dims, 'USER', trn_file_list, 
                                                      model_list, lab_dir, model_dir, apply_hlda, 
                                                      hlda_nuisance_dims)
    model_file = os.path.join(model_dir,'newMacros')
    test_gmm_classifier.test_gmm_classifier(tst_file_list, model_list, model_file, results_dir)

    ref_annotations_list = os.path.join(list_dir,'labels.list')
    hyp_annotations_list = os.path.join(list_dir,'hyp.list')
    lists.create_corresponding_list_assert(tst_file_list,lab_dir,ref_annotations_list,'lab')
    lists.create_corresponding_list_assert(tst_file_list,results_dir,hyp_annotations_list,'rec')
    conf_matrix = evaluate_gmm_classifier.evaluate_results_list(ref_annotations_list, 
                                                                hyp_annotations_list,
                                                                samp_period, labels)
    logging.info('Confusion matrix: {}'.format(conf_matrix))   
Beispiel #6
0
def test_gmm_classification(models=None,
                            n_samples=10000,
                            working_dir=os.getcwd(),
                            apply_hlda=False,
                            hlda_nuisance_dims=2,
                            do_not_generate_features=False):
    test_percentage = 0.2
    samp_period = 0.01
    generate_features = not do_not_generate_features

    if not os.path.exists(working_dir):
        os.makedirs(working_dir)

    fea_dir = os.path.join(working_dir, 'features')
    lab_dir = os.path.join(working_dir, 'lab')
    list_dir = os.path.join(working_dir, 'lists')
    model_dir = os.path.join(working_dir, 'models')
    results_dir = os.path.join(working_dir, 'results')
    if not os.path.exists(list_dir):
        os.makedirs(list_dir)
    if not os.path.exists(fea_dir):
        os.makedirs(fea_dir)
    if not os.path.exists(lab_dir):
        os.makedirs(lab_dir)
    if not os.path.exists(model_dir):
        os.makedirs(model_dir)
    if not os.path.exists(results_dir):
        os.makedirs(results_dir)

    # Create a list of the model names
    model_list = os.path.join(working_dir, 'models.list')
    ml = open(model_list, 'w')
    labels = []
    for md in models:
        ml.write('{}\n'.format(md.name))
        labels.append(md.name)
    ml.close()

    tst_file_list = os.path.join(list_dir, 'test_files.list')
    trn_file_list = os.path.join(list_dir, 'train_files.list')

    if generate_features:
        fea_file_names = write_feature_files(models, n_samples, fea_dir,
                                             lab_dir)
        n_fea_files = len(fea_file_names)
        logging.info('Number of feature files: {}'.format(n_fea_files))
        n_train_files = int(round(n_fea_files * (1 - test_percentage)))

        trn_list = open(trn_file_list, 'w')
        for f_n in fea_file_names[0:n_train_files]:
            trn_list.write("{}\n".format(os.path.join(fea_dir, f_n)))
        trn_list.close()
        tst_list = open(tst_file_list, 'w')
        for f_n in fea_file_names[n_train_files:n_fea_files - 1]:
            tst_list.write("{}\n".format(os.path.join(fea_dir, f_n)))
        tst_list.close()

    n_mixes = models[0].n_components
    n_dims = models[0].means.shape[1]
    train_gmm_classifier.train_M_sized_gmm_classifier(n_mixes, n_dims, 'USER',
                                                      trn_file_list,
                                                      model_list, lab_dir,
                                                      model_dir, apply_hlda,
                                                      hlda_nuisance_dims)
    model_file = os.path.join(model_dir, 'newMacros')
    test_gmm_classifier.test_gmm_classifier(tst_file_list, model_list,
                                            model_file, results_dir)

    ref_annotations_list = os.path.join(list_dir, 'labels.list')
    hyp_annotations_list = os.path.join(list_dir, 'hyp.list')
    lists.create_corresponding_list_assert(tst_file_list, lab_dir,
                                           ref_annotations_list, 'lab')
    lists.create_corresponding_list_assert(tst_file_list, results_dir,
                                           hyp_annotations_list, 'rec')
    conf_matrix = evaluate_gmm_classifier.evaluate_results_list(
        ref_annotations_list, hyp_annotations_list, samp_period, labels)
    logging.info('Confusion matrix: {}'.format(conf_matrix))