A Python application that identifies a song through your microphone and fetches detailed information about it.
Sngfetch is a Python app designed to retrieve data about a song by analyzing audio captured through your microphone.
With Sngfetch, you can:
- Identify a song.
- Fetch song metadata (e.g., title, artist, album).
- Optionally retrieve the song lyrics.
Sngfetch utilizes three APIs:
- Shazam API: To identify the song and its metadata.
Note: The shazam api is accessed trough shazamio.
- Deezer API: To provide additional details about the song.
- Genius API: (Optional) To fetch song lyrics.
Note: To use the Genius API, you'll need to create a free account and register an application to get your client access token.
Make sure you have the following:
- Python 3.7+
Only if you are running the python file yourself.
- A microphone-enabled device.
-
Clone the repository:
git clone https://github.com/pyth0g/Sngfetch.git cd Sngfetch
-
Here you can either use a packaged python binary from the ./bin folder (windows or linux), or you can run the python file:
This should work but there are some issues with shazamio that can arise:
python -m venv .venv source .venv/bin/activate pip install -r requirements.txt cd src python sngfetch.py -h
In case you get an error when installing the packages try:
python -m venv .venv source .venv/bin/activate git clone https://github.com/shazamio/shazamio-core.git cd shazamio-core pip install . cd .. pip install -r requirements.txt cd src python sngfetch.py -h
If you wish to package the app yourself:
- Make sure that if you are using a virtual environment your source is in the env, then run:
This will create a dist folder in which is your executable.
pip install pyinstaller pyinstaller sngfetch.spec
- Run the file with the instructions from Running.
- These are all the possible flags:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-l, --lyrics Display the lyrics of the song fetched.
-ls, --lyrics-setup Setup the access token for the Genius API.
-cd, --continuous-until-different [CONTINUOUS_UNTIL_DIFFERENT]
Keep searching even after a song is found, you can specify the delay between searches after the flag, stop by keyboard interrupt.
-c, --continuous [CONTINUOUS]
Keep searching even after a song is found, you can specify the delay between searches after the flag, stop by keyboard interrupt.
-hi, --history [HISTORY]
Show the history of fetched songs or a specific song by title.
-hic, --history-clear
Clear all the history of fetched songs.
-m, --minimalist [MINIMALIST]
Display data in a more minimal style the amount of data can be controlled with an integer (0..2) after the flag.
-r, --remove REMOVE Remove a song from the history by it's title.
-d, --duration DURATION
The default duration of each audio sample to be taken in seconds.
-t, --total TOTAL The total amount of time to listen for in seconds.
-inc, --increase INCREASE
Increase the duration of each audio sample to be taken in seconds.
-i, --infinite Keep trying until interrupted.
-s, --size SIZE The size of the cover art.
--debug Debug mode.
-ve, --verbosity VERBOSITY
Set the verbosity level of debug (will only have affect if debug is on).
--disable-stdout Disable stdout and remove it from log.
--log Log all the output in sngfetch_i.log in the current directory (recommended to use in conjunction with disable-stdout).
--freeze FREEZE Freeze basic song data to specified json file.
To setup lyrics fetching you will need to:
- Visit https://genius.com/api-clients and sign up for an account.
- Click on New API Client, fill out the form (you can put in any data) and click save.
- Click on Generate Access Token (bellow Client Secret) and copy the token.
- Run the program with the
-ls
or--lyrics-setup
flag, it will create the file where you can store the token. - The program will prompt you to open the file, confirm and paste the token in after
Access-Token:
Contributions are welcome! Here's how you can contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature/YourFeature
). - Commit your changes (
git commit -m 'Add YourFeature'
). - Push to the branch (
git push origin feature/YourFeature
). - Open a pull request.
Distributed under the MIT License. See LICENSE.txt for more information.
For any questions or issues, please open an issue on the GitHub repository.
I will try to get back to you as soon as possible.