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

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

Issue 2989823002: Input signal creation for non-existing input signal files (Closed)
Patch Set: merge Created 3 years, 5 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/test_data_generation.py
diff --git a/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/test_data_generation.py b/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/test_data_generation.py
index 2fa49da6e385765c410a044ce3b76ef233441761..3d54da5fc2af3890841d89f615fce3ab6e411943 100644
--- a/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/test_data_generation.py
+++ b/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/test_data_generation.py
@@ -33,6 +33,7 @@ except ImportError:
from . import data_access
from . import exceptions
+from . import input_signal_creator
from . import signal_processing
@@ -109,6 +110,12 @@ class TestDataGenerator(object):
base_output_path: base path where output is written.
"""
self.Clear()
+
+ # If the input signal file does not exist, try to create using the
+ # available input signal creators.
+ if not os.path.exists(input_signal_filepath):
+ self._CreateInputSignal(input_signal_filepath)
+
self._Generate(
input_signal_filepath, test_data_cache_path, base_output_path)
@@ -119,6 +126,33 @@ class TestDataGenerator(object):
self._apm_output_paths = {}
self._reference_signal_filepaths = {}
+ @classmethod
+ def _CreateInputSignal(cls, input_signal_filepath):
+ """Creates a missing input signal file.
+
+ The file name is parsed to extract input signal creator and params. If a
+ creator is matched and the parameters are valid, a new signal is generated
+ and written in |input_signal_filepath|.
+
+ Args:
+ input_signal_filepath: Path to the input signal audio file to write.
+
+ Raises:
+ InputSignalCreatorException
+ """
+ filename = os.path.splitext(os.path.split(input_signal_filepath)[-1])[0]
+ filename_parts = filename.split('-')
+
+ if len(filename_parts) < 2:
+ raise exceptions.InputSignalCreatorException(
+ 'Cannot parse input signal file name')
+
+ signal = input_signal_creator.InputSignalCreator.Create(
+ filename_parts[0], filename_parts[1].split('_'))
+
+ signal_processing.SignalProcessingUtils.SaveWav(
+ input_signal_filepath, signal)
+
def _Generate(
self, input_signal_filepath, test_data_cache_path, base_output_path):
"""Abstract method to be implemented in each concrete class.

Powered by Google App Engine
This is Rietveld 408576698