def create_bfcr(filename):
"""Creates a BFCR instance for a given file.
This helper function loads a label file and its corrosponding mgc file and
creates a bfcr file from them. The paths of both files are determined
automatically.
:params filename: filename from which the BFCR instaces are created
:returns: an instance of the BFCR class
"""
filename = os.path.splitext(os.path.basename(filename))[0]
label_file = LABEL_DIR + filename + '.lab'
mgc_file = MGC_DIR + filename + '.mgc'
mgc_matrix = np.fromfile(mgc_file, dtype=np.float32).reshape(-1, MGCORD+1)
bfcr = BFCR(label_file)
bfcr.encode_feature(mgc_matrix, 'mgc', NUM_BASES)
return bfcr
评论列表
文章目录