From df3c5599391422b72e53ebcd0170e1bcc7bdd623 Mon Sep 17 00:00:00 2001 From: Rob Hallam <0504004h@student.gla.ac.uk> Date: Thu, 29 Aug 2024 10:30:35 +0100 Subject: [PATCH] refactor: expose prepend and append tmies in LaughFE To help functional testing, LaughFE's internal adjustment times are exposed. Recap: when a laugh is detected by LaughFE, the time of the laugh itself it not used directly; instead, the resulting Feature has some time prepended to try to capture the thing that caused the laugh. When functional testing the FEs we set up specially-crafted videos with features at known points, so to make sure the LaughterFE is tested correctly we adjust the tests by the amount of time the FE adjusts by so that it properly tests the intended behaviour. @see: - feature_extractors.py::LaughterFeatureExtractor --- pipeline/feature_extractors.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pipeline/feature_extractors.py b/pipeline/feature_extractors.py index cf9dbdb..38063de 100644 --- a/pipeline/feature_extractors.py +++ b/pipeline/feature_extractors.py @@ -47,6 +47,9 @@ class LaughterFeatureExtractor(FeatureExtractor): See: https://github.com/jrgillick/laughter-detection for the laughter-detection library """ + _PREPEND_TIME = 7.0 # seconds before the laugh + _APPEND_TIME = 3.0 # seconds after the laugh + def __init__(self, input_files=None, config=None): """It is expected that input_files is a SourceMedia object""" @@ -94,13 +97,10 @@ class LaughterFeatureExtractor(FeatureExtractor): TODO: config for length adjustments per design doc TODO: play with numbers more to see what works best """ - PREPEND = 7.0 - APPEND = 3.0 - for feature in self.features: # do the pre & post adjustment - feature.interval.move_start(-PREPEND, relative=True) - feature.interval.move_end(APPEND, relative=True) + feature.interval.move_start(-self._PREPEND_TIME, relative=True) + feature.interval.move_end(self._APPEND_TIME, relative=True) def setup(self): """Setup the laughter feature extractor -- validate input files & config