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.
pipx install .
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+
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
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.2.tar.gz
.
File metadata
- Download URL: console_songs-2024.11.2.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 114017a1ce784af8d7d737900e3f7eac7b7c3c4e2372bb9728753d215cbbbb4f |
|
MD5 | f5ca7f034e91afe7ea589f3d9365b1a7 |
|
BLAKE2b-256 | 2e73adc7455a2c6389fd326c9cee3e0e5cc0efdc2b70cee107c30d60748363d4 |
File details
Details for the file console_songs-2024.11.2-py3-none-any.whl
.
File metadata
- Download URL: console_songs-2024.11.2-py3-none-any.whl
- Upload date:
- Size: 17.7 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 | f4e351b1a50c29283f648dd36e3a5bc0bc1028745f25655541548a0880af3199 |
|
MD5 | 8314fce5d407f97f6a9626436e43314e |
|
BLAKE2b-256 | e01897e4ca3a01280ab4ec83a7442108b67dbdbc41a6a6f3b81dad215beb3a3c |