From dc81f36d744490276dec641dbe4bedf87f22d1ed Mon Sep 17 00:00:00 2001 From: Joel Mathew Thomas <90510078+joelmathewthomas@users.noreply.github.com> Date: Thu, 26 Dec 2024 01:02:10 +0530 Subject: [PATCH] Add test case for classify_audio function - Implemented test case to verify audio classification with YAMNet - Used 'cafe_crowd_talk.wav' as test file, expecting 'Speech' as the output class --- tests/test_preprocessing.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/test_preprocessing.py b/tests/test_preprocessing.py index 208bb5b..0a57873 100644 --- a/tests/test_preprocessing.py +++ b/tests/test_preprocessing.py @@ -2,6 +2,7 @@ import pytest import librosa from src.preprocessing.normalize import normalize_audio from src.preprocessing.trim import trim_audio +from src.preprocessing.classify import classify_audio from src.input.file_reader import read_audio def test_normalize_audio(): @@ -17,4 +18,11 @@ def test_trim_audio(): audio, sr = read_audio(file_path) trimmed_audio = trim_audio(audio, sr) - assert len(trimmed_audio) <= len(audio) \ No newline at end of file + assert len(trimmed_audio) <= len(audio) + +def test_classify(): + file_path = "samples/cafe_crowd_talk.wav" + expected_class = "Speech" + predicted_class = classify_audio(file_path) + + assert predicted_class == expected_class , f"Expected {expected_class}, but got {predicted_class}" \ No newline at end of file