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

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

Issue 2714543005: Evaluation controller, evaluation score abstract class, and score data access. (Closed)
Patch Set: 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/eval_scores.py
diff --git a/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/eval_scores.py b/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/eval_scores.py
index 50ee17252d482c99979ea43a983a562ba74208a1..2565dce9f253b2716467888898c849310bc00040 100644
--- a/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/eval_scores.py
+++ b/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/eval_scores.py
@@ -6,6 +6,11 @@
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
+import logging
+import os
+
+from .data_access import ScoreFile
+
class EvaluationScore(object):
NAME = None
@@ -13,7 +18,12 @@ class EvaluationScore(object):
REGISTERED_CLASSES = {}
def __init__(self):
- pass
+ self._reference_signal = None
+ self._reference_signal_filepath = None
+ self._tested_signal = None
aleloi2 2017/03/02 17:42:23 Question: what will the _*_signal members contain?
+ self._tested_signal_filepath = None
+ self._output_filepath = None
+ self._score = None
@classmethod
def register_class(cls, class_to_register):
@@ -23,6 +33,58 @@ class EvaluationScore(object):
"""
cls.REGISTERED_CLASSES[class_to_register.NAME] = class_to_register
+ @property
+ def output_filepath(self):
+ return self._output_filepath
+
+ @property
+ def score(self):
+ return self._score
+
+ def set_reference_signal_filepath(self, filepath):
+ """
+ Set the path to the audio track used as reference signal.
+ """
+ self._reference_signal_filepath = filepath
+
+ def set_tested_signal_filepath(self, filepath):
+ """
+ Set the path to the audio track used as test signal.
+ """
+ self._tested_signal_filepath = filepath
+
+ def _load_reference_signal(self):
+ assert self._reference_signal_filepath is not None
+ # TODO(alessio): load signal.
+ self._reference_signal = None
+
+ def _load_tested_signal(self):
+ assert self._tested_signal_filepath is not None
+ # TODO(alessio): load signal.
+ self._tested_signal = None
+
+ def run(self, output_path):
+ self._output_filepath = os.path.join(output_path, 'score-{}.txt'.format(
+ self.NAME))
+ try:
+ # If the score has already been computed, load.
+ self._load_score()
+ logging.debug('score found and loaded')
+ except FileNotFoundError:
+ # Compute the score.
+ logging.debug('score not found, compute')
+ self._run(output_path)
+
+ def _run(self, output_path):
+ # Abstract method.
+ raise NotImplementedError()
+
+ def _load_score(self):
+ return ScoreFile.load(self._output_filepath)
+
+ def _save_score(self):
+ return ScoreFile.save(self._output_filepath, self._score)
+
@EvaluationScore.register_class
class AudioLevelScore(EvaluationScore):
@@ -40,12 +102,16 @@ class AudioLevelScore(EvaluationScore):
def __init__(self):
super().__init__()
+ def _run(self, output_path):
+ # TODO(alessio): implement.
+ self._score = 0.0
+ self._save_score()
+
@EvaluationScore.register_class
class PolqaScore(EvaluationScore):
"""
- Compute the POLQA score. It requires that the POLQA_PATH environment variable
- points to the PolqaOem64 executable.
+ Compute the POLQA score.
Unit: MOS
Ideal: 4.5
@@ -57,3 +123,7 @@ class PolqaScore(EvaluationScore):
def __init__(self):
super().__init__()
+ def _run(self, output_path):
+ # TODO(alessio): implement.
+ self._score = 0.0
+ self._save_score()

Powered by Google App Engine
This is Rietveld 408576698