This project implements an audio classification system for Valvular Heart Disease (VHD) detection using Deep Learning (RNN-LSTM).
The preprocessing script handles the reorganization of the dataset into training and testing sets.
- Source Directory:
dataset/train - Target Directory:
dataset/test - Split Ratio: 10% of the training data is moved to the test set for validation.
- Classes Processed:
- AS (Aortic Stenosis)
- MR (Mitral Regurgitation)
- MS (Mitral Stenosis)
- MVP (Mitral Valve Prolapse)
- N (Normal)
The model uses the following mapping for prediction outputs:
| Class | Label | Description |
|---|---|---|
| 0 | AS | Aortic Stenosis |
| 1 | MR | Mitral Regurgitation |
| 2 | MS | Mitral Stenosis |
| 3 | MVP | Mitral Valve Prolapse |
| 4 | N | Normal |
The model utilizes Mel-Frequency Cepstral Coefficients (MFCC) features extracted from audio files to train a Recurrent Neural Network (RNN).
- Library: Librosa
- Features: MFCC (13 coefficients)
- Input Shape: (100, 13) - padded/truncated to 100 time steps.
- Type: Sequential LSTM
- Layers:
- LSTM (128 units)
- Dropout (0.3)
- Dense (64 units, ReLU)
- Dropout (0.3)
- Output Dense (5 units, Softmax)
- Optimizer: Adam
- Loss Function: Categorical Crossentropy
- Metics: Accuracy
- Epochs: 50
- Batch Size: 32
The trained model is saved as model.h5 and converted to TensorFlow.js format for web deployment using tensorflowjs_converter.
Note: Ensure compatible versions of numpy and tensorflowjs are installed to avoid AttributeError: module 'numpy' has no attribute 'bool' during conversion.
- Core: Python 3.x
- ML Framework: TensorFlow / Keras
- Audio Processing: Librosa
- Web Deployment: TensorFlow.js
- API Backend: FastAPI (Dockerized)
This folder contains a Dockerized FastAPI application that serves the trained model.h5 for audio classification.
main.py: The FastAPI application code.Dockerfile: Docker configuration for the API.docker-compose.yml: Docker Compose configuration.requirements.txt: Python dependencies.model.h5: The trained Keras model.
- Docker and Docker Compose installed.
-
Navigate to the
fastapidirectory:cd fastapi -
Build and run the container:
docker-compose up -d --build
The API will be available at
http://localhost:8001.
Upload an audio file to classify it.
Request:
- Key:
file - Type:
File - Value: (Select your audio file, e.g.,
.wav)
Response Example:
{
"filename": "audio_sample.wav",
"prediction": "MR",
"class_id": 1,
"confidence": 0.9999,
"probabilities": {
"AS": 0.0001,
"MR": 0.9999,
"MS": 0.0000,
"MVP": 0.0000,
"N": 0.0000
}
}Visit http://localhost:8001/docs for the interactive Swagger UI.