MusicTools
is a Python class that provides tools for working with music files. It includes functionality for finding the BPM (Beats Per Minute), detecting the key of a song, and extracting vocals and beats.
To use the MusicTools
class, you need to have the following Python libraries installed:
You can install these libraries using the following command:
pip install librosa numpy soundfile
To use the MusicTools
class, follow these steps:
- Import the class:
from music_tools import MusicTools
- Create an instance of the
MusicTools
class, providing the file path of the music file as an argument:
music_tools = MusicTools(filepath="path/to/your/music/file.mp3")
- Access the tools provided by the class, such as BPM detection, key finding, and vocal-beat extraction:
bpm = music_tools.bpm_detector()
print(f"The BPM of the song is: {bpm}")
key = music_tools.key_finder()
print(f"The key of the song is: {key}")
music_tools.vocal_beat_extractor()
print("Vocal and beat files extracted successfully.")
- Initializes the
MusicTools
class with an optionalfilepath
.
- Loads the music file specified by
filepath
and sets they
(audio signal) andsr
(sampling rate) attributes.
- Finds the BPM (Beats Per Minute) of the loaded music file and returns it as a formatted string.
- Calculates the chroma features of the loaded music file and determines the key of the song.
- Separates the vocal and beat components of the loaded music file and saves them as separate audio files on the desktop.
For a complete example of using the MusicTools
class, refer to the provided script example_usage.py
.
Feel free to customize the README according to your needs, and if you have additional features or considerations, you can include them in the documentation.