From 8a5916192a5376b8270c36094ed7ea21efcf805a Mon Sep 17 00:00:00 2001 From: Rob Hallam <0504004h@student.gla.ac.uk> Date: Thu, 29 Aug 2024 09:50:50 +0100 Subject: [PATCH] test: add negative test to TestLoudAudioFEFunctional Video file with silent audio (generated with sox) -- should produce no features since "-inf" are filtered by the FE --- test/test_feature_extractors_functional.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/test_feature_extractors_functional.py b/test/test_feature_extractors_functional.py index 706b509..bd565b8 100644 --- a/test/test_feature_extractors_functional.py +++ b/test/test_feature_extractors_functional.py @@ -86,6 +86,28 @@ class TestLoudAudioFEFunctional(FEFunctionalTest): # check if the highest scoring feature is within the peak range self.assertTrue(sorted_features[0].interval.start >= PEAK_START) + def test_audio_loudness_functional_no_features(self): + """Test audio loudness feature extractor using a silent video. This should produce no features + since "-inf" results from pyloudnorm are filtered out by the FE. + + Use: + - sample_videos/sample-manual-audio-blank-video-colours.mp4 + :: silent video (30s) + -- pass if no features extracted + """ + SAMPLE_VIDEO = f"{self.SAMPLE_DIR}/sample-manual-audio-blank-video-colours.mp4" + + # create mock source with the video + source = mocks.MockSource(path=SAMPLE_VIDEO) + + # create the feature extractor + testfe = extractors.LoudAudioFeatureExtractor(input_files=[source]) + testfe.setup() + testfe.run() + testfe.teardown() + + # check if the feature was extracted: + self.assertFalse(testfe.features) if __name__ == "__main__":