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
This commit is contained in:
@@ -2,6 +2,7 @@ import pytest
|
|||||||
import librosa
|
import librosa
|
||||||
from src.preprocessing.normalize import normalize_audio
|
from src.preprocessing.normalize import normalize_audio
|
||||||
from src.preprocessing.trim import trim_audio
|
from src.preprocessing.trim import trim_audio
|
||||||
|
from src.preprocessing.classify import classify_audio
|
||||||
from src.input.file_reader import read_audio
|
from src.input.file_reader import read_audio
|
||||||
|
|
||||||
def test_normalize_audio():
|
def test_normalize_audio():
|
||||||
@@ -18,3 +19,10 @@ def test_trim_audio():
|
|||||||
trimmed_audio = trim_audio(audio, sr)
|
trimmed_audio = trim_audio(audio, sr)
|
||||||
|
|
||||||
assert len(trimmed_audio) <= len(audio)
|
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}"
|
||||||
Reference in New Issue
Block a user