From 1078318f2a789301170d21645ca1675f5830ccd2 Mon Sep 17 00:00:00 2001 From: Rob Hallam <0504004h@student.gla.ac.uk> Date: Sat, 31 Aug 2024 15:12:56 +0100 Subject: [PATCH] test: [WFE] functional test of no matching words To check we do not match any words that are not present in a media file with speech, we use the English-language Harvard sentences for audio, and compare to the classic French pangram: "Portez ce vieux whisky au juge blond qui fume" [1] and ensure no Features are produced [1]: "Take this old whisky to the blond judge who is smoking" --- test/test_feature_extractors_functional.py | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/test_feature_extractors_functional.py b/test/test_feature_extractors_functional.py index 7da5cff..cbccede 100644 --- a/test/test_feature_extractors_functional.py +++ b/test/test_feature_extractors_functional.py @@ -254,5 +254,29 @@ class TestWordFEFunctional(FEFunctionalTest): with self.assertRaises(RuntimeError): testfe.run() + def test_audio_word_detection_harvard_no_matching_words(self): + """Test audio word detection feature extractor + Uses: + - sample-manual-audio-harvardsentences-video-colours.mp4 + :: Harvard sentences (list 1) up to item 1.8 ("The birch canoe... The hogs were fed") + plus the sentence: "Portez ce vieux whisky au juge blond qui fume" + -- pass if no features extracted + """ + + SAMPLE_VIDEO = f"{self.SAMPLE_DIR}/sample-manual-audio-harvardsentences-video-colours.mp4" + DETECT_WORDS = "Portez ce vieux whisky au juge blond qui fume".split() + + # create mock source with the video + source = mocks.MockSource(path=SAMPLE_VIDEO) + + # create the feature extractor + testfe = extractors.WordFeatureExtractor(input_files=[source]) + testfe.setup(words=DETECT_WORDS) + testfe.run() + testfe.teardown() + + # ensure no Features: + self.assertEqual(len(testfe.features), 0) + if __name__ == "__main__": unittest.main()