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 9"""Evaluator of the APM module. 10""" 11 12import logging 13 14 15class ApmModuleEvaluator(object): 16 """APM evaluator class. 17 """ 18 19 def __init__(self): 20 pass 21 22 @classmethod 23 def Run(cls, evaluation_score_workers, apm_input_metadata, 24 apm_output_filepath, reference_input_filepath, 25 render_input_filepath, output_path): 26 """Runs the evaluation. 27 28 Iterates over the given evaluation score workers. 29 30 Args: 31 evaluation_score_workers: list of EvaluationScore instances. 32 apm_input_metadata: dictionary with metadata of the APM input. 33 apm_output_filepath: path to the audio track file with the APM output. 34 reference_input_filepath: path to the reference audio track file. 35 output_path: output path. 36 37 Returns: 38 A dict of evaluation score name and score pairs. 39 """ 40 # Init. 41 scores = {} 42 43 for evaluation_score_worker in evaluation_score_workers: 44 logging.info(' computing <%s> score', 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[evaluation_score_worker.NAME] = evaluation_score_worker.score 55 56 return scores 57