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.
- 🎵 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
- Python 3.7 or higher
- An MP3 file named
girls_like_you.mp3in the project directory
The program will work with any of these installed (it tries them in order):
-
VLC Media Player (Recommended for best MP3 support)
- Install VLC from videolan.org
- Then install:
pip install python-vlc
-
pygame (Lightweight option)
- Install:
pip install pygame
- Install:
-
pydub (Requires ffmpeg)
- Install:
pip install pydub simpleaudio - Also requires ffmpeg
- Install:
-
Windows Default Player (Fallback - works on Windows without any additional setup)
-
Clone or download this repository
-
Install Python dependencies (at least one of the following):
pip install pygame
Or for better MP3 support:
pip install python-vlc
-
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
- The file should be named
-
Open a terminal/command prompt in the project directory
-
Run the program:
python music.py
-
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+Cto stop the music and exit
- The program will automatically start playing
The program tries to import and initialize multiple audio libraries:
vlc- Best for MP3 playback (requires VLC player installed)pygame- Lightweight optionpydub- Alternative with ffmpeg support- Falls back to Windows default media player if none work
play_music_vlc(filename): Uses VLC for high-quality MP3 playbackplay_music_pygame(filename): Uses pygame's mixer moduleplay_music_pydub(filename): Uses pydub with threading for non-blocking playbackplay_music_windows(filename): Uses Windows default media player as fallback
play_music(filename) tries each method in order until one succeeds:
- VLC (if available)
- pygame (if available)
- pydub (if available)
- Windows default player (on Windows)
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
When the program runs:
- Starts playing the MP3 file
- Displays the lyrics with animation
- Keeps running until music finishes or user interrupts
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
- Replace
girls_like_you.mp3with your MP3 file - Update the filename in line 163:
music_player = play_music("your_song.mp3")
Edit the lyrics list in the print_lyrics() function (lines 139-149):
lyrics = [
"Your first line here",
"Your second line here",
# ... add more lines
]Modify the delays list (line 150) to change pauses between lines:
delays = [0.7, 0.2, 0.5, ...] # Seconds to wait after each lineChange character display speed (line 157):
time.sleep(0.06) # Lower = faster, Higher = slower-
Check if the MP3 file exists:
- Ensure
girls_like_you.mp3is in the same directory asmusic.py - Check the filename matches exactly (case-sensitive)
- Ensure
-
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)
-
On Windows: The program will automatically use Windows Media Player as a fallback
- 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
- Check that the terminal supports the characters used
- Some special characters may not display correctly in certain terminals
Python_Music/
├── music.py # Main program file
├── girls_like_you.mp3 # MP3 audio file (you need to add this)
└── README.md # This file
This project is open source and available for personal use.
- 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! 🎵