Skip to content

MfrankUg/Py_Girls_Like_You

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Python Music Player with Lyrics Display

A Python program that automatically plays an MP3 file (girls_like_you.mp3) and displays song lyrics character-by-character in the terminal with synchronized timing.

Features

  • 🎵 Automatic Music Playback: Plays MP3 files automatically when the program runs
  • 📝 Animated Lyrics Display: Shows lyrics character-by-character with smooth animation
  • 🔄 Multiple Playback Methods: Automatically tries different audio libraries for maximum compatibility
  • ⏱️ Synchronized Timing: Custom delays between lyrics lines for better synchronization
  • 🛡️ Error Handling: Graceful fallback if one method fails

Requirements

  • Python 3.7 or higher
  • An MP3 file named girls_like_you.mp3 in the project directory

Optional Dependencies

The program will work with any of these installed (it tries them in order):

  1. VLC Media Player (Recommended for best MP3 support)

    • Install VLC from videolan.org
    • Then install: pip install python-vlc
  2. pygame (Lightweight option)

    • Install: pip install pygame
  3. pydub (Requires ffmpeg)

    • Install: pip install pydub simpleaudio
    • Also requires ffmpeg
  4. Windows Default Player (Fallback - works on Windows without any additional setup)

Installation

  1. Clone or download this repository

  2. Install Python dependencies (at least one of the following):

    pip install pygame

    Or for better MP3 support:

    pip install python-vlc
  3. Ensure your MP3 file is in the project directory

    • The file should be named girls_like_you.mp3
    • Place it in the same directory as music.py

How to Run

  1. Open a terminal/command prompt in the project directory

  2. Run the program:

    python music.py
  3. What happens:

    • The program will automatically start playing girls_like_you.mp3
    • Lyrics will appear character-by-character in the terminal
    • The program will continue running until the song finishes
    • Press Ctrl+C to stop the music and exit

Code Explanation

Main Components

1. Audio Library Detection

The program tries to import and initialize multiple audio libraries:

  • vlc - Best for MP3 playback (requires VLC player installed)
  • pygame - Lightweight option
  • pydub - Alternative with ffmpeg support
  • Falls back to Windows default media player if none work

2. Music Playback Functions

  • play_music_vlc(filename): Uses VLC for high-quality MP3 playback
  • play_music_pygame(filename): Uses pygame's mixer module
  • play_music_pydub(filename): Uses pydub with threading for non-blocking playback
  • play_music_windows(filename): Uses Windows default media player as fallback

3. Main Playback Function

play_music(filename) tries each method in order until one succeeds:

  1. VLC (if available)
  2. pygame (if available)
  3. pydub (if available)
  4. Windows default player (on Windows)

4. Lyrics Display

print_lyrics() function:

  • Contains the song lyrics in a list
  • Has corresponding delays for each line
  • Displays each character with a 0.06-second delay
  • Adds custom delays between lines for synchronization

5. Main Execution

When the program runs:

  1. Starts playing the MP3 file
  2. Displays the lyrics with animation
  3. Keeps running until music finishes or user interrupts

Code Structure

music.py
├── Library imports and initialization
├── play_music_vlc() - VLC playback method
├── play_music_pygame() - pygame playback method
├── play_music_pydub() - pydub playback method
├── play_music_windows() - Windows fallback method
├── play_music() - Main playback function (tries all methods)
├── print_lyrics() - Displays animated lyrics
└── Main execution block

Customization

Change the Song

  1. Replace girls_like_you.mp3 with your MP3 file
  2. Update the filename in line 163:
    music_player = play_music("your_song.mp3")

Modify Lyrics

Edit the lyrics list in the print_lyrics() function (lines 139-149):

lyrics = [
    "Your first line here",
    "Your second line here",
    # ... add more lines
]

Adjust Timing

Modify the delays list (line 150) to change pauses between lines:

delays = [0.7, 0.2, 0.5, ...]  # Seconds to wait after each line

Change character display speed (line 157):

time.sleep(0.06)  # Lower = faster, Higher = slower

Troubleshooting

Music Not Playing

  1. Check if the MP3 file exists:

    • Ensure girls_like_you.mp3 is in the same directory as music.py
    • Check the filename matches exactly (case-sensitive)
  2. Install an audio library:

    pip install pygame

    Or for better compatibility:

    pip install python-vlc

    (Note: VLC requires the VLC media player to be installed separately)

  3. On Windows: The program will automatically use Windows Media Player as a fallback

pygame Reports "Corrupt MP3"

  • This is a known issue with pygame's MP3 decoder
  • The program will automatically fall back to another method
  • Your MP3 file is likely fine - try installing VLC for better support

Lyrics Not Displaying

  • Check that the terminal supports the characters used
  • Some special characters may not display correctly in certain terminals

Project Structure

Python_Music/
├── music.py              # Main program file
├── girls_like_you.mp3    # MP3 audio file (you need to add this)
└── README.md            # This file

License

This project is open source and available for personal use.

Notes

  • The program works best with VLC installed for reliable MP3 playback
  • On Windows, it will automatically use the default media player if other methods fail
  • The lyrics animation speed and delays can be customized in the code
  • The program handles errors gracefully and will try multiple methods to play your music

Enjoy your music! 🎵

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages