Code for the "PyTorch for Audio + Music Processing" series on The Sound of AI YouTube channel.
This repository is a comprehensive collection of resources and code for understanding and implementing deep learning models for audio tasks using PyTorch and Torchaudio. It serves as a practical guide, moving from basic neural network implementations to building a complete sound classification system (CNN) trained on the UrbanSound8K dataset.
While this v2 release is fully functional and optimized for current environments, it may differ from the original version shown in the course. The codebase has been updated to reflect modern best practices and improved dependency management. Consequently, the original course version has been deprecated; however, it remains available in the legacy branch for those wishing to follow the video content exactly.
To run the sound classification lessons (8-10), you will need the UrbanSound8K dataset. We provide an automated downloader to handle the acquisition, path sanitization, and folder organization for you.
- Quick Start: Run
python dataset_downloader.pyfrom the root directory. - Options: Supports
--COPYflag to preserve your Kaggle cache.
Full Instructions: Please check the Instructions UrbanSound8K file for help using the downloader script or manual download steps.
- Course Overview: Video | Slides
- Implementing and Training a Neural Network: Video | Code
- Making Predictions with PyTorch Models: Video | Code
- Custom Audio PyTorch Dataset: Video | Code
- Extracting Mel Spectrograms: Video | Code
- Pre-processing Audio (Padding/Truncating): Video | Code
- Pre-processing on GPU: Video | Code
- Implementing a CNN for Sound Classification: Video | Code
- Training a Sound Classifier: Video | Code
- Predictions with a Sound Classifier: Video | Code
To ensure the models and scripts execute correctly, please follow these steps from your terminal:
Before running inference, ensure you have the necessary dependencies installed:
pip install -r requirements.txtEach class is self-contained. Move into the specific directory for the lesson you are studying:
cd 'class/folder/name' # Replace with the specific directory path (ensure it is enclosed in quotes).Run the main script using Python:
python inference.py # Replace with the specific script name