1# Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 2# 3# Use of this source code is governed by a BSD-style license 4# that can be found in the LICENSE file in the root of the source 5# tree. An additional intellectual property rights grant can be found 6# in the file PATENTS. All contributing project authors may 7# be found in the AUTHORS file in the root of the source tree. 8"""Evaluator of the APM module. 9""" 10 11import logging 12 13 14class ApmModuleEvaluator(object): 15 """APM evaluator class. 16 """ 17 18 def __init__(self): 19 pass 20 21 @classmethod 22 def Run(cls, evaluation_score_workers, apm_input_metadata, 23 apm_output_filepath, reference_input_filepath, 24 render_input_filepath, output_path): 25 """Runs the evaluation. 26 27 Iterates over the given evaluation score workers. 28 29 Args: 30 evaluation_score_workers: list of EvaluationScore instances. 31 apm_input_metadata: dictionary with metadata of the APM input. 32 apm_output_filepath: path to the audio track file with the APM output. 33 reference_input_filepath: path to the reference audio track file. 34 output_path: output path. 35 36 Returns: 37 A dict of evaluation score name and score pairs. 38 """ 39 # Init. 40 scores = {} 41 42 for evaluation_score_worker in evaluation_score_workers: 43 logging.info(' computing <%s> score', 44 evaluation_score_worker.NAME) 45 evaluation_score_worker.SetInputSignalMetadata(apm_input_metadata) 46 evaluation_score_worker.SetReferenceSignalFilepath( 47 reference_input_filepath) 48 evaluation_score_worker.SetTestedSignalFilepath( 49 apm_output_filepath) 50 evaluation_score_worker.SetRenderSignalFilepath( 51 render_input_filepath) 52 53 evaluation_score_worker.Run(output_path) 54 scores[ 55 evaluation_score_worker.NAME] = evaluation_score_worker.score 56 57 return scores 58