Index: modules/audio_processing/test/py_quality_assessment/quality_assessment/data_access.py |
diff --git a/modules/audio_processing/test/py_quality_assessment/quality_assessment/data_access.py b/modules/audio_processing/test/py_quality_assessment/quality_assessment/data_access.py |
index 826a0899abd7830ad03248fe612b449431a8cddb..c488859b8908d79f6e034e9b6eb2a166daf0e88f 100644 |
--- a/modules/audio_processing/test/py_quality_assessment/quality_assessment/data_access.py |
+++ b/modules/audio_processing/test/py_quality_assessment/quality_assessment/data_access.py |
@@ -31,8 +31,33 @@ class Metadata(object): |
def __init__(self): |
pass |
+ _GENERIC_METADATA_SUFFIX = '.mdata' |
_AUDIO_TEST_DATA_FILENAME = 'audio_test_data.json' |
+ @classmethod |
+ def LoadFileMetadata(cls, filepath): |
+ """Loads generic metadata linked to a file. |
+ |
+ Args: |
+ filepath: path to the metadata file to read. |
+ |
+ Returns: |
+ A dict. |
+ """ |
+ with open(filepath + cls._GENERIC_METADATA_SUFFIX) as f: |
+ return json.load(f) |
+ |
+ @classmethod |
+ def SaveFileMetadata(cls, filepath, metadata): |
+ """Saves generic metadata linked to a file. |
+ |
+ Args: |
+ filepath: path to the metadata file to write. |
+ metadata: a dict. |
+ """ |
+ with open(filepath + cls._GENERIC_METADATA_SUFFIX, 'w') as f: |
+ json.dump(metadata, f) |
+ |
@classmethod |
def LoadAudioTestDataPaths(cls, metadata_path): |
"""Loads the input and the reference audio track paths. |