Given a song and artist, fetches lyrics from Genius, translates them to English using Azure AI Translator, and displays original and translated lyrics side-by-side in the console.
Project description
console-songs
Given a song and artist, fetches lyrics from Genius, translates them to English using Azure AI Translator, and displays original and translated lyrics side-by-side in the console.
Idea
- Fetch song lyrics
- Translate to English
- Display original and English translated lyrics side-by-side
- Save already translated songs in database
Enjoy listening to music and learning a new language!
Install
Requires Python 3.11+ and pipx.
Install the console-songs
script with pipx from PyPi.
pipx install console-songs==2024.11.03
Setup environment variables with your API keys.
export "CS_GENIUS_ACCESS_TOKEN=..."
export "CS_MS_TRANSLATOR_KEY=..."
export "CS_MS_TRANSLATOR_REGION=..."
Reference documentation to get API keys.
Usage
Provide the song and optionally the artist's name.
console-songs song [artist]
Full Usage
(console-songs) patka@Patricks-MacBook-Air console-songs % console-songs --help
usage: console-songs [-h] [-r | --refresh | --no-refresh] [--genius-patch | --no-genius-patch] song [song ...]
positional arguments:
song
options:
-h, --help show this help message and exit
-r, --refresh, --no-refresh
Skip database and refresh song (default: False)
--genius-patch, --no-genius-patch
Use patched version of Genius API (default: True)
Example:
console-songs "Ma ucide ea" "Mihail"
Sample Output
(console-songs) patka@Patricks-MacBook-Air console-songs % console-songs "Ma ucide ea" "Mihail"
Searching for "Ma ucide ea" by Mihail...
Done.
Mă ucide ea by Mihail
https://genius.com/Mihail-ma-ucide-ea-lyrics
Original: English:
========= ========
[Strofa 1] [Verse 1]
E totul în viteză It's all in speed
Delir cât cerul de înalt Delirium as high as the sky
Suntem în antiteză We are in antithesis
Subiecții unui simplu joc murdar The subjects of a simple dirty game
[Pre-refren] [Pre-Chorus]
Ochii mei, rușinați, coboară doritor My eyes, ashamed, descend willingly
...
Full Output
(console-songs) patka@Patricks-MacBook-Air console-songs % console-songs "Ma ucide ea" "Mihail"
Searching for "Ma ucide ea" by Mihail...
Done.
Mă ucide ea by Mihail
https://genius.com/Mihail-ma-ucide-ea-lyrics
Original: English:
========= ========
[Strofa 1] [Verse 1]
E totul în viteză It's all in speed
Delir cât cerul de înalt Delirium as high as the sky
Suntem în antiteză We are in antithesis
Subiecții unui simplu joc murdar The subjects of a simple dirty game
[Pre-refren] [Pre-Chorus]
Ochii mei, rușinați, coboară doritor My eyes, ashamed, descend willingly
Dar te respir, în acest urban decor But I breathe you, in this urban setting
[Refren] [Chorus]
Mă ucide ea, mă ucide ea She's killing me, she's killing me
Încet... Slow...
Îmi vrea inima, îmi vrea inima He wants my heart, he wants my heart
Din piept From the chest
[Strofa 2] [Verse 2]
E atât de grațioasă She's so graceful
Printre mulțimi de oameni Among crowds of people
Plictisiți pe drum Bored on the road
Și pare un dans ascuns And it seems like a hidden dance
Supuși, dansează doi necunoscuți Submissive, two strangers dance
[Pre-refren] [Pre-Chorus]
Ochii mei, rușinați, coboară doritor My eyes, ashamed, descend willingly
Dar te respir, în acest urban decor But I breathe you, in this urban setting
[Refren] [Chorus]
Mă ucide ea, mă ucide ea She's killing me, she's killing me
Încet... Slow...
Îmi vrea inima, îmi vrea inima He wants my heart, he wants my heart
Din piept From the chest
Mă ucide ea, mă ucide ea She's killing me, she's killing me
Încet... Slow...
Îmi vrea inima, îmi vrea inima He wants my heart, he wants my heart
Din piept From the chest
[Punte] [Tips]
Arde pe asfalt și pulsează foc It burns on the asphalt and pulsates fire
Arde, arde revoltat It burns, it burns in revolt
Arde prea frumos, arde inima It burns too beautifully, it burns the heart
Arde, recunosc! It's burning, I admit!
[Strofa 3] [Verse 3]
Mă ucide ea încet, încet She's killing me slowly, slowly
Îmi rupe inima, da, din piept It breaks my heart, yes, out of my chest
Tremură ușor buzele mușcate Bitten lips tremble slightly
Iar gravitația mă atacă And gravity attacks me
Fluturi și vibrații calde pe asfalt Butterflies and warm vibrations on asphalt
De parcă ne plimbăm desculți, prin pat As if we were walking barefoot, in bed
Sirene de incendiu care nu ne pot opri Fire sirens that can't stop us
Iar timpul, un nemernic, numără grăbit And time, an, counts in a hurry
[Outro] [Other]
Mă ucide ea She's killing me
Mă ucide ea She's killing me
Mă ucide ea She's killing me
Mă ucide ea She's killing me
Da, da... Yes, yes...
Development Setup
Requires Python 3.11+ and pipx.
Install the console-songs
script with pipx for developement.
pipx install .
Create an .env
file with your API keys.
CS_GENIUS_ACCESS_TOKEN=...
CS_MS_TRANSLATOR_KEY=...
CS_MS_TRANSLATOR_REGION=...
Reference documentation to get API keys.
Setup a virtual environment:
python3 -m venv .
source bin/activate
Install dependencies:
pip3 install -r requirements.txt
You should now be able to run python3 src/songs.py --help
and see usage.
When making code changes, remember to format code with black:
black .
Unit Tests
Run unit tests with pytest and report coverage.
pytest
Publishing
Publish a new version to PyPi.
python3 -m build
python3 -m pip install --upgrade twine
python3 -m twine upload --repository pypi dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file console_songs-2024.11.3.tar.gz
.
File metadata
- Download URL: console_songs-2024.11.3.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4dc1acfb14e2eda950e00e01161d3eba9dd0d9210e5c79b00699d9c6d11746d0 |
|
MD5 | 1da3068f279dc9cf4ae9ddea6f4d3a77 |
|
BLAKE2b-256 | 68469d733639c2b5ce33aed75b454235ee9acd30b0a6189a839701ebe7e698ed |
File details
Details for the file console_songs-2024.11.3-py3-none-any.whl
.
File metadata
- Download URL: console_songs-2024.11.3-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed079566024a7f34dacd4a1d60e19e7d2bb11d3bb2880ee15d7daeacc3a1af3c |
|
MD5 | f3c9690c86dec5d4ad2a023582557136 |
|
BLAKE2b-256 | 496ec0f9a1ec6358fe89d97dac73262c11c00bba09e2e7632659c05381e84b74 |