Exemplo n.º 1
0
def recursive_forcealign(basePath):
	dir_contents = os.listdir(basePath)
	for path in dir_contents:
		full_path = os.path.join(basePath, path)
		if os.path.isdir(full_path):
			recursive_forcealign(full_path)
		elif '-transcript.txt' in full_path:
			prefix = path[:path.find('-transcript')]
			if prefix + '.wav' in dir_contents:
				align_output.write_output(force_align("/Users/venkatesh-sivaraman/p2fa/model", os.path.join(basePath, prefix + '.wav'), full_path), os.path.join(basePath, prefix + '-aligned.txt'))
Exemplo n.º 2
0
	if hmmsubdir == "FROM-SR" :
		hmmsubdir = "/" + str(SR)
	
	#prepare mlfile
	prep_mlf(trsfile, input_mlf, word_dictionary, surround_token, between_token)
 
	#prepare scp files
	prep_scp(tmpwav)
	
	# generate the plp file using a given configuration file for HCopy
	create_plp(mypath + hmmsubdir + '/config')
	
	# run Verterbi decoding
	#print "Running HVite..."
	mpfile = mypath + '/monophones'
	if not os.path.exists(mpfile) :
		mpfile = mypath + '/hmmnames'
	viterbi(input_mlf, word_dictionary, output_mlf, mpfile, mypath + hmmsubdir)

	# output the alignment as a Praat TextGrid
	#writeTextGrid(outfile, readAlignedMLF(output_mlf, SR, 0.0))
	# instead, return a nicely formatted object representation
	op = align_output.format_output(output_mlf, sample_rate=SR)
	align.cleanup_working_directory()
	return op

if __name__ == '__main__':
	basePath = "/Users/venkatesh-sivaraman/Desktop/RSI/RichReviewHtkTest/"
	align_output.write_output(force_align("/Users/venkatesh-sivaraman/p2fa/model", basePath + "sample1.wav", basePath + "transcript.txt"), basePath + "output1.txt")
	print "Done"