diff --git a/msaf/featextract.py b/msaf/featextract.py index 6b1a5a49..e8ab2269 100644 --- a/msaf/featextract.py +++ b/msaf/featextract.py @@ -117,6 +117,14 @@ def save_features(out_file, features): Dictionary containing the features. """ logging.info("Saving the JSON file in %s" % out_file) + out_json = convert_features(features) + # Actual save + with open(out_file, "w") as f: + json.dump(out_json, f, indent=2) + + +def convert_features(features): + """created to enable a not-saving-json case""" out_json = {"metadata": {"version": {"librosa": librosa.__version__}}} out_json["analysis"] = { "dur": features["anal"]["dur"], @@ -154,9 +162,7 @@ def save_features(out_file, features): except: logging.warning("No annotated beats") - # Actual save - with open(out_file, "w") as f: - json.dump(out_json, f, indent=2) + return out_json def compute_beat_sync_features(features, beats_idx): diff --git a/msaf/input_output.py b/msaf/input_output.py index 99ee17b4..163c9008 100644 --- a/msaf/input_output.py +++ b/msaf/input_output.py @@ -228,6 +228,7 @@ def get_features(audio_path, annot_beats=False, framesync=False): return get_features_from_memory(feat, annot_beats, framesync) + def get_features_from_memory(feats, annot_beats=False, framesync=False): # Beat Synchronous Feats diff --git a/msaf/run.py b/msaf/run.py index 4bb8840d..157231cb 100644 --- a/msaf/run.py +++ b/msaf/run.py @@ -354,8 +354,10 @@ def process(in_path, annot_beats=False, feature="hpcp", ds_name="*", # msaf.utils.ensure_dir(os.path.dirname(file_struct.features_file)) # both lines move to.. # msaf.featextract.save_features(file_struct.features_file, all_features) # ..the end of this function. # Get correct features - config["features"] = all_features - + feats_converted = featextract.convert_features(all_features) + config["features"] = msaf.io.get_features_from_memory(all_features, + annot_beats=annot_beats, + framesync=framesync) # And run the algorithms est_times, est_labels = run_algorithms_from_memory(all_features, in_path, boundaries_id,