예제 #1
0
import os as os
import scikits.audiolab as audlab
import cPickle, gzip, sys
import numpy as np
import math, shutil
from spectral import get_mfcc
from util_func import parse_arguments, parse_classes

arg_elements = [sys.argv[i] for i in range(1, len(sys.argv))]
arguments = parse_arguments(arg_elements)
name_var = arguments['data_type']
classes = parse_classes(arguments['classes'])
# name_var = 'test'
window_step = float(arguments['window_step'])
window_size = float(arguments['window_size'])
highfreq = int(arguments['highfreq'])
lowfreq = int(arguments['lowfreq'])
size = int(arguments['size'])
N = int(arguments['N'])
slide = int(arguments['slide'])
exp_path = arguments['exp_path']
threshold = int(arguments['threshold'])
compute_delta = arguments['deltas']
shutil.copyfile('/home/piero/Documents/Scripts/format_pickle_data.py',
                os.path.join(exp_path, 'format_pickle_data.py'))
N_classes = len(classes)
label_dic = {}
for k in range(N_classes):
    label_dic[classes[k]] = k
initial_path = '/home/piero/Documents/Speech_databases/DeGIV/29-30-Jan/'\
                        +name_var+'_labels' # label files
예제 #2
0
import os as os
import scikits.audiolab as audlab
import cPickle, gzip, sys
import numpy as np
import math, shutil
from spectral import get_mfcc
from util_func import parse_arguments, parse_classes

arg_elements = [sys.argv[i] for i in range(1, len(sys.argv))]
arguments = parse_arguments(arg_elements)
name_var = arguments['data_type']
classes = parse_classes(arguments['classes'])
# name_var = 'test'
window_step = float(arguments['window_step'])
window_size = float(arguments['window_size'])
highfreq = int(arguments['highfreq'])
lowfreq = int(arguments['lowfreq'])
size = int(arguments['size'])
N = int(arguments['N'])
slide = int(arguments['slide'])
exp_path = arguments['exp_path']
threshold = int(arguments['threshold'])
compute_delta = arguments['deltas']
shutil.copyfile('/home/piero/Documents/Scripts/format_pickle_data3.py', os.path.join(exp_path,'format_pickle_data3.py'))
N_classes = len(classes)
label_dic = {}
for k in range(N_classes):
    label_dic[classes[k]] = k
initial_path = '/home/piero/Documents/Speech_databases/DeGIV/29-30-Jan/'+name_var+'_labels' # label files
target_path = os.path.join(exp_path,'data')
os.chdir(initial_path)
예제 #3
0
import numpy
import sys
import os
import cPickle, gzip
import numpy as np
import util_func as utils
from liblatex import *

arg_elements = [sys.argv[i] for i in range(1, len(sys.argv))]
arguments = utils.parse_arguments(arg_elements)
pred_file = arguments['pred_file']
class_str = arguments['classes']
filepath = arguments['filepath']
datapath = arguments['datapath']
nametex= arguments['nametex']
if '.gz' in pred_file:
    pred_mat = cPickle.load(gzip.open(pred_file, 'rb'))
else:
    pred_mat = cPickle.load(open(pred_file, 'rb'))

# load the testing set to get the labels
test_data, test_labels = cPickle.load(gzip.open(datapath+'/test.pickle.gz', 'rb'))
test_labels = test_labels.astype(numpy.int32)

confusion_matrix = np.zeros((pred_mat.shape[1], pred_mat.shape[1])) # rows represent predicted classes and columns
                                                                                                                    # represent true classes
class_occurrence = np.zeros((1,pred_mat.shape[1]))
correct_number = 0.0

for i in xrange(pred_mat.shape[0]):
    p = pred_mat[i,:]