help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
music-classification
/
__pycache__
RSK World
music-classification
Music Classification Dataset - Genre Classification + Music AI + Audio ML
__pycache__
  • config.cpython-313.pyc5.2 KB
  • quick_start.cpython-313.pyc7 KB
  • setup.cpython-313.pyc2.9 KB
02_automatic_differentiation.ipynbREADME.mdaudio_augmentation.py
README.md
Raw Download

README.md

# Music Classification Dataset

<!--
/**
* Project: Music Classification Dataset
* Author: Molla Samser
* Company: RSK World
* Designer & Tester: Rima Khatun
* Website: https://rskworld.in
* Email: help@rskworld.in, support@rskworld.in
* Phone: +91 93305 39277
* Description: Music genre classification dataset with audio samples
* License: Educational Purpose Only
*/
-->

## šŸ“– Overview

This dataset includes audio samples from multiple music genres with genre labels. Perfect for music information retrieval, genre classification, audio feature extraction, and music analysis applications.

## šŸŽµ Features

- **Multiple music genres** - Classical, Jazz, Rock, Pop, Hip-Hop, Electronic, Country, Blues
- **Labeled audio samples** - Each audio file is properly labeled with its genre
- **Training and test sets** - Pre-split datasets for easy model training
- **Audio features extracted** - MFCC, Spectral Centroid, Chroma, and more
- **Ready for classification models** - Compatible with popular ML frameworks

## šŸ“Š Dataset Structure

```
music-classification/
ā”œā”€ā”€ data/
│ ā”œā”€ā”€ audio/
│ │ ā”œā”€ā”€ classical/
│ │ ā”œā”€ā”€ jazz/
│ │ ā”œā”€ā”€ rock/
│ │ ā”œā”€ā”€ pop/
│ │ ā”œā”€ā”€ hiphop/
│ │ ā”œā”€ā”€ electronic/
│ │ ā”œā”€ā”€ country/
│ │ └── blues/
│ ā”œā”€ā”€ train_data.csv
│ ā”œā”€ā”€ test_data.csv
│ └── features.csv
ā”œā”€ā”€ models/
│ ā”œā”€ā”€ train_model.py
│ ā”œā”€ā”€ predict.py
│ └── saved_models/
ā”œā”€ā”€ notebooks/
│ ā”œā”€ā”€ exploratory_analysis.ipynb
│ └── audio_visualization.ipynb
ā”œā”€ā”€ utils/
│ ā”œā”€ā”€ audio_processor.py
│ └── feature_extractor.py
└── requirements.txt
```

## šŸŽÆ Genre Categories

1. **Classical** - Orchestral, Chamber, Symphony
2. **Jazz** - Swing, Bebop, Fusion
3. **Rock** - Classic Rock, Hard Rock, Alternative
4. **Pop** - Contemporary Pop, Dance Pop
5. **Hip-Hop** - Rap, Trap, Old School
6. **Electronic** - House, Techno, Ambient
7. **Country** - Traditional, Modern Country
8. **Blues** - Delta Blues, Electric Blues

## šŸš€ Getting Started

### Prerequisites

- Python 3.8 or higher
- pip package manager
- Virtual environment (recommended)

### Installation

1. Clone or download this repository
2. Navigate to the project directory
3. Install required packages:

```bash
pip install -r requirements.txt
```

### Quick Start

```python
# Load and analyze audio files
from utils.audio_processor import AudioProcessor
from utils.feature_extractor import FeatureExtractor

# Initialize processors
processor = AudioProcessor()
extractor = FeatureExtractor()

# Load audio file
audio_path = 'data/audio/rock/sample01.wav'
audio_data = processor.load_audio(audio_path)

# Extract features
features = extractor.extract_mfcc(audio_data)
print(f"MFCC Features: {features.shape}")
```

## šŸ”§ Technologies Used

- **Audio Formats**: WAV, MP3
- **Python Libraries**: Librosa, NumPy, Pandas, Scikit-learn
- **Processing**: Audio Feature Extraction, Signal Processing
- **ML Models**: Random Forest, SVM, Neural Networks

## šŸ“ˆ Usage Examples

### 1. Train a Classification Model

```bash
python models/train_model.py --model random_forest --epochs 100
```

### 2. Make Predictions

```bash
python models/predict.py --audio sample_music.wav
```

### 3. Extract Audio Features

```bash
python utils/feature_extractor.py --input data/audio/jazz/ --output features/
```

## šŸ“Š Dataset Statistics

- **Total Samples**: 1000+ audio files
- **Duration**: 30 seconds per sample
- **Sample Rate**: 22050 Hz
- **Format**: WAV (lossless), MP3 (compressed)
- **Split Ratio**: 80% Training, 20% Testing

## šŸŽ“ Difficulty Level

**Intermediate** - Requires basic understanding of:
- Python programming
- Audio signal processing
- Machine learning concepts
- Library usage (Librosa, Scikit-learn)

## šŸ“„ File Descriptions

### Data Files

- `train_data.csv` - Training dataset with file paths and labels
- `test_data.csv` - Testing dataset for model evaluation
- `features.csv` - Extracted audio features for all samples

### Scripts

- `audio_processor.py` - Audio loading and preprocessing utilities
- `feature_extractor.py` - Feature extraction functions
- `train_model.py` - Model training pipeline
- `predict.py` - Prediction and inference script

## šŸŽÆ Applications

- Music genre classification
- Music recommendation systems
- Audio content analysis
- Music information retrieval
- Playlist generation
- Audio tagging and categorization

## šŸ“š Resources

- [Librosa Documentation](https://librosa.org/)
- [Audio Signal Processing Tutorial](https://www.audiocontentanalysis.org/)
- [Music Information Retrieval](https://musicinformationretrieval.com/)

## šŸ‘¤ Author Information

**Name**: Molla Samser
**Company**: RSK World
**Designer & Tester**: Rima Khatun
**Website**: [https://rskworld.in](https://rskworld.in)
**Email**: help@rskworld.in, support@rskworld.in
**Phone**: +91 93305 39277

## šŸ“ License

This dataset is provided for **educational purposes only**. Please refer to the [disclaimer](https://rskworld.in/disclaimer.php) for more information.

## šŸ¤ Contributing

For questions, suggestions, or contributions, please contact us through our website or email.

## āš ļø Disclaimer

Content used for educational purposes only. View full [disclaimer](https://rskworld.in/disclaimer.php).

---

**Ā© 2026 RSK World - Free Programming Resources & Source Code**

*Founded by Molla Samser with Designer & Tester Rima Khatun*

utils/audio_augmentation.py
Raw Download
Find: Go to:
"""
Audio Augmentation Module for Music Classification

Project: Music Classification Dataset
Author: Molla Samser
Company: RSK World
Designer & Tester: Rima Khatun
Website: https://rskworld.in
Email: help@rskworld.in, support@rskworld.in
Phone: +91 93305 39277
Description: Advanced audio augmentation techniques for data augmentation
License: Educational Purpose Only
"""

import numpy as np
import librosa
import warnings
warnings.filterwarnings('ignore')


class AudioAugmenter:
    """
    Audio augmentation class for data augmentation
    
    Author: Molla Samser (RSK World)
    Website: https://rskworld.in
    Email: help@rskworld.in
    """
    
    def __init__(self, sample_rate=22050):
        """
        Initialize AudioAugmenter
        
        Args:
            sample_rate: Sample rate of audio files
        """
        self.sample_rate = sample_rate
    
    def add_noise(self, audio: np.ndarray, noise_factor: float = 0.005) -> np.ndarray:
        """
        Add random noise to audio
        
        Args:
            audio: Input audio array
            noise_factor: Amount of noise to add
            
        Returns:
            Augmented audio with noise
        """
        noise = np.random.randn(len(audio))
        augmented_audio = audio + noise_factor * noise
        return augmented_audio.astype(audio.dtype)
    
    def time_stretch(self, audio: np.ndarray, rate: float = 1.0) -> np.ndarray:
        """
        Time stretch audio without changing pitch
        
        Args:
            audio: Input audio array
            rate: Stretch factor (>1.0 speeds up, <1.0 slows down)
            
        Returns:
            Time-stretched audio
        """
        return librosa.effects.time_stretch(audio, rate=rate)
    
    def pitch_shift(self, audio: np.ndarray, n_steps: int = 0) -> np.ndarray:
        """
        Shift pitch of audio
        
        Args:
            audio: Input audio array
            n_steps: Number of semitones to shift
            
        Returns:
            Pitch-shifted audio
        """
        return librosa.effects.pitch_shift(
            audio, 
            sr=self.sample_rate, 
            n_steps=n_steps
        )
    
    def time_shift(self, audio: np.ndarray, shift_max: float = 0.2) -> np.ndarray:
        """
        Shift audio in time
        
        Args:
            audio: Input audio array
            shift_max: Maximum shift as fraction of audio length
            
        Returns:
            Time-shifted audio
        """
        shift = int(np.random.uniform(-shift_max, shift_max) * len(audio))
        return np.roll(audio, shift)
    
    def change_volume(self, audio: np.ndarray, factor: float = 1.0) -> np.ndarray:
        """
        Change volume of audio
        
        Args:
            audio: Input audio array
            factor: Volume factor (>1.0 louder, <1.0 quieter)
            
        Returns:
            Volume-adjusted audio
        """
        return audio * factor
    
    def add_reverb(self, audio: np.ndarray, reverb_factor: float = 0.1) -> np.ndarray:
        """
        Add simple reverb effect
        
        Args:
            audio: Input audio array
            reverb_factor: Amount of reverb
            
        Returns:
            Audio with reverb
        """
        delay = int(0.1 * self.sample_rate)
        reverb = np.zeros(len(audio) + delay)
        reverb[:len(audio)] = audio
        reverb[delay:] += audio * reverb_factor
        return reverb[:len(audio)]
    
    def random_augmentation(self, audio: np.ndarray) -> np.ndarray:
        """
        Apply random augmentation
        
        Args:
            audio: Input audio array
            
        Returns:
            Randomly augmented audio
        """
        augmentation = np.random.choice([
            'noise', 'time_stretch', 'pitch_shift', 
            'time_shift', 'volume', 'reverb'
        ])
        
        if augmentation == 'noise':
            return self.add_noise(audio, np.random.uniform(0.001, 0.01))
        elif augmentation == 'time_stretch':
            return self.time_stretch(audio, np.random.uniform(0.8, 1.2))
        elif augmentation == 'pitch_shift':
            return self.pitch_shift(audio, np.random.randint(-3, 4))
        elif augmentation == 'time_shift':
            return self.time_shift(audio, 0.2)
        elif augmentation == 'volume':
            return self.change_volume(audio, np.random.uniform(0.7, 1.3))
        elif augmentation == 'reverb':
            return self.add_reverb(audio, np.random.uniform(0.05, 0.15))
        
        return audio
    
    def augment_batch(self, audio_list: list, augmentations_per_sample: int = 2) -> list:
        """
        Augment a batch of audio samples
        
        Args:
            audio_list: List of audio arrays
            augmentations_per_sample: Number of augmented versions per sample
            
        Returns:
            List of original + augmented audio samples
        """
        augmented_list = []
        
        for audio in audio_list:
            # Add original
            augmented_list.append(audio)
            
            # Add augmented versions
            for _ in range(augmentations_per_sample):
                aug_audio = self.random_augmentation(audio)
                augmented_list.append(aug_audio)
        
        return augmented_list


# Example usage
if __name__ == "__main__":
    """
    Demo script for AudioAugmenter
    
    Author: Molla Samser
    Company: RSK World
    Website: https://rskworld.in
    """
    augmenter = AudioAugmenter()
    
    # Create dummy audio
    dummy_audio = np.random.randn(44100)
    
    print("Audio Augmentation Demo")
    print("Author: Molla Samser | RSK World")
    print("Website: https://rskworld.in")
    print("\nAugmentation techniques available:")
    print("- Add noise")
    print("- Time stretch")
    print("- Pitch shift")
    print("- Time shift")
    print("- Volume change")
    print("- Reverb")
    
    # Test augmentation
    noisy = augmenter.add_noise(dummy_audio)
    print(f"\nOriginal shape: {dummy_audio.shape}")
    print(f"Augmented shape: {noisy.shape}")
    
    print("\n© 2026 RSK World - Molla Samser")

215 lines•6.3 KB
python
šŸš€ Support RSK World

Subscribe to our YouTube channel for latest tutorials & updates!



Click subscribe & support our work ā¤ļø

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer