RibbID_SVM / predict.py
Calotriton's picture
Upload predict.py
c3a1f6a verified
raw
history blame contribute delete
626 Bytes
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 30 17:02:31 2025
@author: User
"""
# predict.py
import joblib
import numpy as np
# Cargar modelo y scaler
scaler = joblib.load("scaler.joblib")
model = joblib.load("svm_mfcc_model.joblib")
def predict_species(mfcc_features: np.ndarray) -> str:
"""
Predicts the species given MFCC features (shape: [n_mfcc, n_frames]).
"""
# Flatten or average across time if needed
features = mfcc_features.mean(axis=1) # shape (n_mfcc,)
features = scaler.transform([features])
prediction = model.predict(features)
return prediction[0]