This project demonstrates MFCC (Mel-Frequency Cepstral Coefficients) computation from scratch and uses a PyTorch-based neural network for speech recognition.
The system includes:
- Custom MFCC feature extraction pipeline (FFT → Mel Filter Bank → DCT)
- Dataset creation and management
- Neural network training using PyTorch
- Prediction of unknown audio samples
Audio → FFT → Mel Filter Bank → Log Energies → DCT → MFCC (13-D) → Dataset Manager → PyTorch Model → Softmax Classification
Handles audio preprocessing:
- Loads WAV audio file
- Applies pre-emphasis filtering
- Frames signal into short segments
- Applies Hanning window
- Computes FFT per frame
Performs frequency transformation:
- Converts Hz to Mel scale
- Builds triangular filter banks
- Computes log Mel energies
- Maps frequency bins to FFT spectrum
Extracts MFCC features:
- Applies Discrete Cosine Transform (DCT)
- Keeps 13 MFCC coefficients (excluding 0th)
- Produces frame-wise MFCC matrix
- Computes feature vector (mean across frames)
Handles dataset creation:
- Extracts MFCC features from DCT.py
- Stores labeled samples in mfcc_dataset.csv
- Ensures consistent feature formatting for training
Jupyter Notebook for training:
- Loads dataset
- Encodes labels
- Normalizes MFCC features
- Trains PyTorch neural network
- Evaluates model performance
- Saves trained model and preprocessors
Old KNN-based classifier replaced by neural network for better accuracy and scalability.
Audio → MFCC extraction → Normalization → PyTorch model → Softmax → Label
- Record audio using the provided recording script.
- Add labeled data using dataset_manager.py.
- Train the model using mfcc_train.ipynb.
- Run inference on unknown audio samples using the trained model.
- Python 3.11
- All dependencies are listed in requirements.txt
Install dependencies:
pip install -r requirements.txt
- MFCC extraction is fully custom (no external MFCC libraries used).
- Consistent audio length improves model accuracy.
- Same preprocessing must be used during training and inference.
- Neural network replaces KNN for better generalization.
This project is for educational and research purposes only.