예제 #1
0
파일: timit.py 프로젝트: adhaka/kthasrdnn
def readTIMITSSL(datapath='timit-mfcc-mono-tr.pfile.gz', format='pfile', shared=False, listify=False, mapping=48, percent_data=0.99, randomise=True):
	file_reader = PfileIO(datapath)
	file_reader.readpfileInfo()
	file_reader.readPfile(randomise=randomise)
	x, y = file_reader.generate_features(listify)
	if isinstance(x, (list, tuple)):
		xmat = np.vstack(x)
		ymat = np.concatenate(y)
		x = xmat
		y = ymat

	total_samples = xmat.shape[0]
	total_labels = int(percent_data*total_samples)
	x_lab = x[:total_labels]
	if mapping == 48:
		if isinstance(y, (list, tuple)):
			y = map(lambda x:map_y_48(x), y)
		else:
			y = map_y_48(y)
	elif mapping == 39:
		if isinstance(y, (list, tuple)):
			y = map(lambda x:map_y_39(x), y)
		else:
			y = map_y_39(y)

	y_lab = y[:total_labels]
	x_unlab = x[total_labels:]
	return x_lab, y_lab, x_unlab  
예제 #2
0
파일: timit.py 프로젝트: adhaka/kthasrdnn
def readTIMIT(datapath='timit-mfcc-mono-tr.pfile.gz', format='pfile', shared=False, listify=False, mapping=48, percent_data=1., randomise=False):
	file_reader = PfileIO(datapath)
	file_reader.readpfileInfo()
	file_reader.readPfile(randomise=randomise)
	x, y = file_reader.generate_features(listify)

	if percent_data < 1. :
		x, y = partition_data(x, y, percent_data)

	# stats = Counter(y)
	if mapping == 48:
	# if y is a list, then iterate otherwise apply function once.	
		if isinstance(y, (list, tuple)) :
			y = map(lambda x: map_y_48(x), y)
		else:	
			y = map_y_48(y)
	elif mapping == 39:
		if isinstance(y, (list, tuple)):
			y = map(lambda x: map_y_39(x), y)
		else:	
			y = map_y_39(y)

	# print stats.most_common(100)
	if shared == True:
		x, y = shared_dataset((x, y))
	
	return x, y