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

Side by Side Diff: modules/audio_processing/test/py_quality_assessment/quality_assessment/data_access.py

Issue 3010413002: Total Harmonic Distorsion plus noise (THD+n) score in APM-QA. (Closed)
Patch Set: merge Created 3 years, 2 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 unified diff | Download patch
OLDNEW
1 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 1 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
2 # 2 #
3 # Use of this source code is governed by a BSD-style license 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 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 5 # tree. An additional intellectual property rights grant can be found
6 # in the file PATENTS. All contributing project authors may 6 # in the file PATENTS. All contributing project authors may
7 # be found in the AUTHORS file in the root of the source tree. 7 # be found in the AUTHORS file in the root of the source tree.
8 8
9 """Data access utility functions and classes. 9 """Data access utility functions and classes.
10 """ 10 """
(...skipping 13 matching lines...) Expand all
24 os.makedirs(path) 24 os.makedirs(path)
25 25
26 26
27 class Metadata(object): 27 class Metadata(object):
28 """Data access class to save and load metadata. 28 """Data access class to save and load metadata.
29 """ 29 """
30 30
31 def __init__(self): 31 def __init__(self):
32 pass 32 pass
33 33
34 _GENERIC_METADATA_SUFFIX = '.mdata'
34 _AUDIO_TEST_DATA_FILENAME = 'audio_test_data.json' 35 _AUDIO_TEST_DATA_FILENAME = 'audio_test_data.json'
35 36
36 @classmethod 37 @classmethod
38 def LoadFileMetadata(cls, filepath):
39 """Loads generic metadata linked to a file.
40
41 Args:
42 filepath: path to the metadata file to read.
43
44 Returns:
45 A dict.
46 """
47 with open(filepath + cls._GENERIC_METADATA_SUFFIX) as f:
48 return json.load(f)
49
50 @classmethod
51 def SaveFileMetadata(cls, filepath, metadata):
52 """Saves generic metadata linked to a file.
53
54 Args:
55 filepath: path to the metadata file to write.
56 metadata: a dict.
57 """
58 with open(filepath + cls._GENERIC_METADATA_SUFFIX, 'w') as f:
59 json.dump(metadata, f)
60
61 @classmethod
37 def LoadAudioTestDataPaths(cls, metadata_path): 62 def LoadAudioTestDataPaths(cls, metadata_path):
38 """Loads the input and the reference audio track paths. 63 """Loads the input and the reference audio track paths.
39 64
40 Args: 65 Args:
41 metadata_path: path to the directory containing the metadata file. 66 metadata_path: path to the directory containing the metadata file.
42 67
43 Returns: 68 Returns:
44 Tuple with the paths to the input and output audio tracks. 69 Tuple with the paths to the input and output audio tracks.
45 """ 70 """
46 metadata_filepath = os.path.join( 71 metadata_filepath = os.path.join(
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 @classmethod 145 @classmethod
121 def Save(cls, filepath, score): 146 def Save(cls, filepath, score):
122 """Saves a score into a file. 147 """Saves a score into a file.
123 148
124 Args: 149 Args:
125 filepath: path to the score file. 150 filepath: path to the score file.
126 score: float encoding the score. 151 score: float encoding the score.
127 """ 152 """
128 with open(filepath, 'w') as f: 153 with open(filepath, 'w') as f:
129 f.write('{0:f}\n'.format(score)) 154 f.write('{0:f}\n'.format(score))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698