Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Unified Diff: webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/data_access.py

Issue 2711313004: APM Quality Assessment tool, audioproc_f Python wrapper (Closed)
Patch Set: rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/data_access.py
diff --git a/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/data_access.py b/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/data_access.py
index d3967c651a4b46a41a486a471c9d34cf454a40f4..90956442e27ab49548604cfcb0f9e86d36351d35 100644
--- a/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/data_access.py
+++ b/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/data_access.py
@@ -6,6 +6,7 @@
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
+import json
import os
def make_directory(path):
@@ -15,3 +16,55 @@ def make_directory(path):
if os.path.exists(path):
return
os.makedirs(path)
+
+
+class Metadata(object):
+ """
+ Data access class to save and load metadata.
+ """
+
+ def __init__(self):
+ pass
+
+ _AUDIO_IN_REF_FILENAME = 'audio_in_ref.txt'
+
+ @classmethod
+ def load_audio_in_ref_paths(cls, metadata_path):
+ """
+ Metadata loader for input and reference audio track paths.
+ """
+ metadata_filepath = os.path.join(metadata_path, cls._AUDIO_IN_REF_FILENAME)
+ with open(metadata_filepath) as f:
+ audio_in_filepath = f.readline().strip()
+ audio_ref_filepath = f.readline().strip()
+ return audio_in_filepath, audio_ref_filepath
+
+ @classmethod
+ def save_audio_in_ref_paths(cls, output_path, audio_in_filepath,
+ audio_ref_filepath):
+ """
+ Metadata saver for input and reference audio track paths.
+ """
+ output_filepath = os.path.join(output_path, cls._AUDIO_IN_REF_FILENAME)
+ with open(output_filepath, 'w') as f:
+ f.write('{}\n{}\n'.format(audio_in_filepath, audio_ref_filepath))
+
+
+class AudioProcConfigFile(object):
+ """
+ Data access class to save and load audioproc_f argument lists to control
+ the APM flags.
+ """
+
+ def __init__(self):
+ pass
+
+ @classmethod
+ def load(cls, filepath):
+ with open(filepath) as f:
+ return json.load(f)
+
+ @classmethod
+ def save(cls, filepath, config):
+ with open(filepath, 'w') as f:
+ json.dump(config, f)

Powered by Google App Engine
This is Rietveld 408576698