From 58e2319aff94f4734ca7b6270c74c5f017b96b20 Mon Sep 17 00:00:00 2001 From: Joseph Keshet Date: Sun, 3 Jul 2016 10:18:46 +0300 Subject: [PATCH] . --- formants.py | 9 +++++---- helpers/utilities.py | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/formants.py b/formants.py index d4f56e2..b963de0 100644 --- a/formants.py +++ b/formants.py @@ -6,6 +6,7 @@ from helpers.utilities import * import shutil + def predict_from_times(wav_filename, preds_filename, begin, end): tmp_features_filename = tempfile._get_default_tempdir() + "/" + next(tempfile._get_candidate_names()) + ".txt" print tmp_features_filename @@ -38,16 +39,16 @@ def predict_from_textgrid(wav_filename, preds_filename, textgrid_filename, textg # run over all intervals in the tier for interval in textgrid[tier_index]: if re.search(r'\S', interval.mark()): - tmp_features_filename = generate_tmp_filename() - tmp_preds = generate_tmp_filename() + tmp_features_filename = generate_tmp_filename("features") + tmp_preds = generate_tmp_filename("preds") features.create_features(wav_filename, tmp_features_filename, interval.xmin(), interval.xmax()) easy_call("th load_estimation_model.lua " + tmp_features_filename + ' ' + tmp_preds) csv_append_row(tmp_preds, preds_filename) else: # process first tier for interval in textgrid[0]: if re.search(r'\S', interval.mark()): - tmp_features_filename = generate_tmp_filename() - tmp_preds = generate_tmp_filename() + tmp_features_filename = generate_tmp_filename("features") + tmp_preds = generate_tmp_filename("preds") features.create_features(wav_filename, tmp_features_filename, interval.xmin(), interval.xmax()) easy_call("th load_estimation_model.lua " + tmp_features_filename + ' ' + tmp_preds) csv_append_row(tmp_preds, preds_filename) diff --git a/helpers/utilities.py b/helpers/utilities.py index 0b43356..19eaa47 100644 --- a/helpers/utilities.py +++ b/helpers/utilities.py @@ -62,6 +62,7 @@ def logging_defaults(logging_level="INFO"): logging.basicConfig(level=logging_level, format='%(asctime)s.%(msecs)d [%(filename)s] %(levelname)s: %(message)s', datefmt='%H:%M:%S') + def num_lines(filename): lines = 0 for _ in open(filename, 'rU'):