if not os.path.exists(output_fldr): os.makedirs(output_fldr) logPath = os.path.join(output_fldr, "log.txt") if os.path.exists(logPath): os.remove(logPath) rep = localrepo.instance(ui.ui(), '.', False) revision_num = rep.changelog.headrevs()[0] # create logger logging.basicConfig(filename=logPath, level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') logging.info("python " + " ".join(sys.argv)) logging.info("Revision number for code: " + str(revision_num)) if not arguments.normalize: logging.info("Not normalizing inputs.") data_src = htkdb_cm.htkdb_cm(arguments.db_name, arguments.db_path, arguments.num_frames_per_pt, arguments.use_delta) data_src._speaker_cmn = arguments.speaker_cmn data_src._speaker_cmvn = arguments.speaker_cmvn data_src._normalize = arguments.normalize nn_train = nnet_train.nn() nn_train.load(model_file) per = perform_averaged_decoding(nn_train, data_src, arguments.num_averages, output_fldr, arguments.db_name) print "PER = %.4f"%per
parser.add_argument('--num_frames_per_pt', type=int, default=15, help='# of frames per pt') parser.add_argument('db_path', help='Path to validation database') parser.add_argument('model_file', type=str, help='file with neural network parameters') parser.add_argument('predictions_file', type=str, help='output folder') arguments = parser.parse_args() data_src = speech_data.speech_data(arguments.db_path, arguments.num_frames_per_pt) data_src.normalize_data() nnet = nnet_train.nn() nnet.load(arguments.model_file) pred_lst, num_output_frames = nnet.create_predictions(data_src) predictions_mat = zeros((pred_lst[-1].shape[0], num_output_frames)) utt_indices = zeros((len(pred_lst), 2), dtype='int32') num_so_far = 0 for index, predictions in enumerate(pred_lst): predictions_mat[:, num_so_far:(num_so_far+predictions.shape[1])] = \ predictions utt_indices[index, 0] = num_so_far num_so_far += predictions.shape[1] utt_indices[index, 1] = num_so_far