File size: 626 Bytes
c3a1f6a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# -*- 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] |