Views
No views yet
| Metric | Score |
|---|---|
| Accuracy | 86.38% |
| F1 Score | 85.43% |
| Precision | 86.07% |
| ROC AUC | 0.9864 |
| Label | Emoji | Meaning |
|---|---|---|
| belly pain | 🤢 | Baby has stomach pain |
| burping | 💨 | Baby needs to burp |
| cold_hot | 🌡️ | Baby is too cold or hot |
| discomfort | 😣 | Baby is uncomfortable |
| hungry | 🍼 | Baby is hungry |
| laugh | 😄 | Baby is happy/laughing |
| lonely | 🥺 | Baby wants attention |
| noise | 🔊 | Background noise detected |
| scared | 😨 | Baby is startled/scared |
| silence | 🤫 | No crying detected |
| tired | 😴 | Baby is sleepy |
1import joblib
2import librosa
3import numpy as np
4from huggingface_hub import hf_hub_download
5
6model = joblib.load(hf_hub_download("Nerdy37/baby-cry-analyzer", "best_model.pkl"))
7scaler = joblib.load(hf_hub_download("Nerdy37/baby-cry-analyzer", "scaler.pkl"))
8
9label_names = [
10 'belly pain', 'burping', 'cold_hot', 'discomfort',
11 'hungry', 'laugh', 'lonely', 'noise', 'scared', 'silence', 'tired'
12]
13
14def predict(audio_path):
15 audio, sr = librosa.load(audio_path, sr=22050, duration=5, mono=True)
16 mfcc = np.mean(librosa.feature.mfcc(y=audio, sr=sr, n_mfcc=40).T, axis=0)
17 chroma = np.mean(librosa.feature.chroma_stft(y=audio, sr=sr).T, axis=0)
18 mel = np.mean(librosa.feature.melspectrogram(y=audio, sr=sr).T, axis=0)
19 features = scaler.transform([np.hstack([mfcc, chroma, mel])])
20 pred = model.predict(features)[0]
21 prob = model.predict_proba(features)[0]
22 return label_names[pred], f"{max(prob)*100:.1f}%"
23
24label, confidence = predict("baby_cry.wav")
25print(f"Prediction: {label} ({confidence})")hungry class has lower accuracy (28.7%) due to acoustic similarity
with discomfort, burping, and cold_hot