Downloads · 30 days
0
foduucom/baby-cry-classification
baby-cry-classification is a audio classification model from foduucom. Use it for the audio classification task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
<p align="center" <img src="https://huggingface.co/foduucom/baby-cry-classification/resolve/main/Baby-cry.jpg" alt="Image" style="width:500px; height:300px;" </p
Downloads · 30 days
0
Access
Public
Updated Jul 23, 2024
Repo size
114 KB
Likes
20
Public
Click a slice to open those files.
.jpg699 KB · 85%
From the Hugging Face model README
The Baby Cry Classifier is an advanced machine learning model designed to analyze and categorize different types of baby cries. This innovative tool aims to assist parents, caregivers, and healthcare professionals in understanding and responding to babys' needs more effectively.
Interpreting an baby's cries can be challenging, especially for new parents or in high-stress situations. Babies communicate their needs primarily through crying, but distinguishing between different types of cries (e.g., hunger, discomfort, tiredness) can be difficult. This uncertainty can lead to:
Our baby Cry Classifier addresses these challenges by:
By accurately identifying the reason behind an baby's cry, caregivers can respond more promptly and appropriately to the baby's needs. This can lead to:
In healthcare settings, the baby Cry Classifier can be a useful diagnostic tool:
This model opens up new avenues for research in:
Data Collection: The model is trained on baby cry audio samples, carefully labeled with their corresponding causes.
Feature Extraction: Advanced signal processing techniques are used to extract relevant acoustic features from the audio samples.
Machine Learning: A sophisticated machine learning algorithm is employed to learn the patterns associated with different types of cries.
Classification: When presented with a new audio sample, the model analyzes it and classifies it into one of the predefined categories.
pip install numpy pandas scikit-learn joblib librosa
Clone this repository:
git clone https://huggingface.co/nehulagrawal/baby-cry-classification
cd baby-cry-classifier
Download the pre-trained model files: 'model.joblib' 'label.joblib'
import joblib
import librosa
import numpy as np
loaded_model = joblib.load('model.joblib')
loaded_le = joblib.load('label.joblib')
def extract_features(file_path):
try:
# Load audio file and extract features
y, sr = librosa.load(file_path, sr=16000)
mfcc = np.mean(librosa.feature.mfcc(y=y, sr=sr, n_mfcc=40,n_fft=n_fft,hop_length=hop_length,win_length=win_length,window=window).T,axis=0)
mel = np.mean(librosa.feature.melspectrogram(y=y, sr=sr,n_fft=n_fft, hop_length=hop_length, win_length=win_length, window='hann',n_mels=n_mels).T,axis=0)
stft = np.abs(librosa.stft(y))
chroma = np.mean(librosa.feature.chroma_stft(S=stft, y=y, sr=sr).T,axis=0)
contrast = np.mean(librosa.feature.spectral_contrast(S=stft, y=y, sr=sr,n_fft=n_fft,
hop_length=hop_length, win_length=win_length,
n_bands=n_bands, fmin=fmin).T,axis=0)
tonnetz =np.mean(librosa.feature.tonnetz(y=y, sr=sr).T,axis=0)
features = np.concatenate((mfcc, chroma, mel, contrast, tonnetz))
# print(shape(features))
return features
except:
print("Error: Exception occurred in feature extraction")
return None
def predict_cry(file_path):
# Load the saved model and LabelEncoder
loaded_model = joblib.load('model.joblib')
loaded_le = joblib.load('label.joblib')
# Extract features from the new audio file
features = extract_features(file_path)
if features is not None:
# Reshape features to match the input shape expected by the model
features = features.reshape(1, -1)
# Make prediction
prediction = loaded_model.predict(features)
# Convert prediction back to original label
predicted_label = loaded_le.inverse_transform(prediction)
return predicted_label[0]
else:
return "Error: Could not extract features from the audio file"
# Example usage
file_path = 'path/to/your/file.wav'
result = predict_cry(file_path)
print(f"Predicted cry type: {result}")
Model Performance The baby Cry Classifier has undergone extensive testing to evaluate its effectiveness. Here's an overview of its performance: Accuracy Metrics:
| class | precision | recall | f1-score |
|---|---|---|---|
| 0 | 0.00 | 0.00 | 0.00 |
| 1 | 0.67 | 0.67 | 0.67 |
| 2 | 0.75 | 0.33 | 0.46 |
| 3 | 0.50 | 0.43 | 0.46 |
| 4 | 0.25 | 0.50 | 0.33 |
| accuracy | 0.38 | ||
| macro avg | 0.43 | 0.39 | 0.38 |
| weighted avg | 0.51 | 0.38 | 0.41 |
Overall Accuracy:
You can integrate this model into your own applications, such as:
This project is licensed under the MIT License - see the LICENSE.md file for details.
For inquiries and contributions, please contact us at [email protected].
@ModelCard{
author = {Nehul Agrawal and
Priyal Mehta},
title = {baby Cry Classifier},
year = {2024}
}