This commit is contained in:
@ -1,4 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
import requests
|
||||
from pyAudioAnalysis import audioTrainTest as aT
|
||||
from pyAudioAnalysis.audioTrainTest import load_model, load_model_knn
|
||||
from utils import config
|
||||
from .abcpreprocessor import AbcPreProcessor
|
||||
|
||||
"""
|
||||
@ -15,9 +19,28 @@ class SoundPreProcessor(AbcPreProcessor):
|
||||
"""
|
||||
SoundPreProcessor class, responsible for detecting birb chirps in sound sample.
|
||||
"""
|
||||
def preprocesssignal(self, signal):
|
||||
|
||||
def preprocesssignal(self, signal: str) -> bool:
|
||||
"""
|
||||
Classify a sound sample.
|
||||
:param signal: Access path of the sound sample up for processing.
|
||||
:return:
|
||||
"""
|
||||
pass
|
||||
# TODO: Dynamic model injection?
|
||||
r = requests.get(f"http://model-service/model/{config.MODEL_ID}/details")
|
||||
r.raise_for_status()
|
||||
|
||||
model_details = r.json()
|
||||
|
||||
if model_details['type'] == 'knn':
|
||||
classifier, mean, std, classes, mid_window, mid_step, short_window, short_step, compute_beat \
|
||||
= load_model_knn(config.MODEL_ID + "MEANS")
|
||||
|
||||
else:
|
||||
classifier, mean, std, classes, mid_window, mid_step, short_window, short_step, compute_beat \
|
||||
= load_model(config.MODEL_ID + "MEANS")
|
||||
|
||||
target_id = classes.index(config.TARGET_NAME)
|
||||
|
||||
class_id, probability = aT.file_classification(signal, config.MODEL_ID, "svm")
|
||||
return class_id == target_id
|
||||
|
Reference in New Issue
Block a user