Skip to content

Stylegunhawk/Muisc_Classification_and_Recommender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎡 Music Recommender

A web application that predicts music genres, extracts audio features, and recommends similar songs based on machine learning.

πŸš€ Features

  • Welcome Page: Modern animated landing page (Urban Beatzs) with quick navigation
  • Contact Form: Users can send feedback or queries (saved to contacts.json)
  • About, Genre Analysis, Audio Features Pages: Informative pages for users
  • Genre Prediction: Analyzes audio files to predict music genre using a TensorFlow/Keras model
  • Audio Feature Extraction: Extracts energy, danceability, loudness, and more
  • Song Recommendations: Suggests similar songs based on genre and audio features
  • YouTube Integration: Downloads songs directly from YouTube for analysis
  • Audio Playback: Built-in player for uploaded/downloaded songs
  • Genre Fun Facts: Displays a random fun fact, tip, and icon for each predicted genre
  • Modern UI: Animated visualizer, responsive design, and toast notifications

🧠 Machine Learning Model

The application uses a trained TensorFlow model that can classify songs into 10 genres:

  • Blues
  • Classical
  • Country
  • Disco
  • Hip-Hop
  • Jazz
  • Metal
  • Pop
  • Reggae
  • Rock

πŸ› οΈ Technical Stack

  • Backend: Python, Flask
  • Machine Learning: TensorFlow, Keras
  • Audio Processing: librosa, soundfile
  • Data Analysis: pandas, scikit-learn
  • Frontend: HTML, CSS, JavaScript
  • External Tools: yt-dlp for YouTube downloads

πŸ“ Project Structure

MusicRecommender/
β”œβ”€β”€ app.py                 # Main Flask application
β”œβ”€β”€ extract_features.py    # Audio feature extraction
β”œβ”€β”€ recommend.py           # Song recommendation system
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ data/                  # Dataset for recommendations
β”œβ”€β”€ model/                 # Trained ML model
β”œβ”€β”€ static/                # CSS, JS, images, videos
β”‚   β”œβ”€β”€ style.css          # Main styles
β”‚   β”œβ”€β”€ main.js            # Main JS logic
β”‚   β”œβ”€β”€ navbar.js, navbar.css
β”‚   └── ...
β”œβ”€β”€ templates/             # HTML templates
β”‚   β”œβ”€β”€ welcome.html       # Animated landing page
β”‚   β”œβ”€β”€ index.html         # Main page with player and song list
β”‚   β”œβ”€β”€ result.html        # Results page with predictions
β”‚   β”œβ”€β”€ about.html         # About page
β”‚   β”œβ”€β”€ contact.html       # Contact form
β”‚   β”œβ”€β”€ genre-analysis.html# Genre info
β”‚   β”œβ”€β”€ audio-features.html# Audio features info
β”‚   └── 404.html, 500.html # Error pages
β”œβ”€β”€ uploads/               # Uploaded and downloaded audio files
β”œβ”€β”€ utils/                 # Helper functions
β”‚   β”œβ”€β”€ file_utils.py      # File handling utilities
β”‚   └── model_utils.py     # Model prediction utilities
β”œβ”€β”€ genre_facts.json       # Fun facts, tips, and icons for each genre
β”œβ”€β”€ contacts.json          # Stores contact form submissions
└── ...

🌐 Main Routes & Endpoints

  • / : Welcome page (Urban Beatzs)
  • /index : Main app (upload, play, analyze, download)
  • /about : About the project
  • /contact : Contact form
  • /genre-analysis : Genre info
  • /audio-features : Audio features info
  • /download : POST endpoint for YouTube song download
  • /uploads/<filename> : Serve uploaded/downloaded audio

πŸš€ Getting Started

Prerequisites

  • Python 3.8+ to Python 3.10
  • pip
  • yt-dlp (for YouTube downloads)
  • 4GB RAM minimum
  • 2GB free disk space
  • Internet connection for YouTube downloads

Installation

  1. Clone the repository:
    git clone https://github.com/yourusername/MusicRecommender.git
    cd MusicRecommender
  2. Create and activate a virtual environment:
    python -m venv env
    .\env\Scripts\Activate.ps1
  3. Install dependencies:
    pip install -r requirements.txt
    pip install yt-dlp
  4. Run the app:
    python app.py
  5. Open your browser at http://127.0.0.1:5000

πŸŽ₯ Demo

[Add screenshots or GIF of your application in action]

⚠️ Error Handling

  • Invalid audio file formats
  • Failed YouTube downloads
  • Network connectivity issues
  • File permission errors
  • Memory limitations
  • Custom 404 and 500 error pages

πŸ”§ Troubleshooting

  • YouTube Download Fails: Update yt-dlp, check internet, try a different URL
  • Audio Analysis Error: Use supported formats (MP3, WAV), check file integrity, ensure enough memory
  • Model Prediction Issues: Clear browser cache, restart app, check model files in /model

πŸ‘₯ Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“Š Web Interface

Main Page

  • Music player with controls and animated visualizer
  • List of uploaded/downloaded songs (with search)
  • YouTube search and download
  • Song analysis button

Results Page

  • Predicted genre with confidence scores
  • Extracted audio features (energy, danceability, loudness, etc.)
  • Song recommendations
  • Random fun fact, tip, and icon for the genre

Welcome, About, Contact, Genre/Audio Info Pages

  • Modern animated welcome page
  • About page with project and tech info
  • Contact form (saves to contacts.json)
  • Genre and audio feature info pages

🎀 Genre Fun Facts

  • Results page displays a random fun fact, tip, and icon for each predicted genre, loaded from genre_facts.json
  • Each genre has multiple unique facts/tips
  • Backend randomly selects a fact for the predicted genre and passes it to the UI

Customizing Genre Facts

  • Edit genre_facts.json to add or update facts, tips, or icons for any genre

πŸ–ŒοΈ Modern UI Enhancements

  • Animated confidence bars, genre icons, and a visually engaging, rhythm-inspired layout
  • Responsive design for desktop and mobile
  • Toast notifications for user feedback

πŸ›£οΈ Ready for React (Optional)

  • Backend is API-ready and can be connected to a React frontend in the future

🧩 How It Works

  1. Upload or Download: Add songs by uploading files or downloading from YouTube
  2. Select and Play: Choose a song to play in the built-in player
  3. Analyze: Click "Analyze Song" to process the selected song
  4. View Results: See the predicted genre, audio features, recommendations, and fun facts

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgements

  • librosa for audio processing

  • TensorFlow for machine learning

  • Flask for web framework

  • yt-dlp for YouTube downloads

  • Disclaimer: This project was developed independently by the authors as a part of an academic course project. No institutional resources were used, and no intellectual property agreement was signed with the university. The authors retain full ownership under the MIT License.

  • Β© 2025 Urban Beatzs Project Authors. All rights reserved.

About

Music recommendation and classification

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors