Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1ea76b7

Browse files
Added Lyrics Generator Using Genius API
1 parent 6eeeec4 commit 1ea76b7

File tree

5 files changed

+207
-0
lines changed

5 files changed

+207
-0
lines changed

‎Lyrics_Genius_API/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Lyrics_Download
2+
3+
This script can be used to download lyrics of any number of songs, by any number of Artists, until the API Limit is met.
4+
The script uses [Genius API](https://docs.genius.com/). It is a dedicated platform meant for music only.
5+
6+
# Setup Instruction
7+
8+
- You need an API client, (it's free) follow the steps [here](https://docs.genius.com/).
9+
- `pip install lyricsgenius` to install dedicated package.
10+
- Good to go, Follow guidelines mentioned as comments in code.
11+
- The script is pretty much interactive, ensure you follow the guidelines.
12+
13+
# Output
14+
15+
Lyrics of Top 3 Songs by coldplay -
16+
17+
![](img/lyrics.PNG)
18+
19+
Resulting Text File -
20+
21+
![](img/result.PNG)
22+
23+
## Author(s)
24+
25+
Made by [Vybhav Chaturvedi](https://www.linkedin.com/in/vybhav-chaturvedi-0ba82614a/).
26+
27+
## Disclaimers, if any
28+
29+
Kindly go through this [page](https://genius.com/static/terms) and follow the guidelines and rules related to
30+
**Genius API**.

‎Lyrics_Genius_API/img/lyrics.PNG

29.1 KB
Loading[フレーム]

‎Lyrics_Genius_API/img/result.PNG

66.7 KB
Loading[フレーム]

‎Lyrics_Genius_API/lyrics.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import lyricsgenius as lg
2+
3+
# File for writing the Lyrics
4+
filename = input('Enter a filename: ') or 'Lyrics.txt'
5+
file = open(filename, "w+")
6+
7+
# Acquire a Access Token to connect with Genius API
8+
genius = lg.Genius('Client_Access_Token_Goes_Here',
9+
# Skip song listing
10+
skip_non_songs=True,
11+
# Terms that are redundant song names with same lyrics, e.g. Old Town Raod and Old Town Road Remix
12+
# have same lyrics
13+
excluded_terms=["(Remix)", "(Live)"],
14+
# In order to keep headers like [Chorus], [Bridge] etc.
15+
remove_section_headers=True)
16+
17+
# List of Artist and Maximum Songs
18+
input_string = input("Enter name of Artists separated by spaces: ")
19+
artists = input_string.split(" ")
20+
21+
22+
def get_lyrics(arr, max_song):
23+
"""
24+
Returns: Number of songs grabbed by Function
25+
Saves : Text File with Lyrics
26+
Parameters :
27+
arr : Artist
28+
max_song : Number of maximum songs to be grabbed
29+
"""
30+
# Write lyrics of k songs by each artist in arr
31+
c = 0
32+
# A counter
33+
for name in arr:
34+
try:
35+
songs = (genius.search_artist(name, max_songs=max_song, sort='popularity')).songs
36+
s = [song.lyrics for song in songs]
37+
# A custom delimiter
38+
file.write("\n \n <|endoftext|> \n \n".join(s))
39+
c += 1
40+
print(f"Songs grabbed:{len(s)}")
41+
except:
42+
print(f"some exception at {name}: {c}")
43+
44+
45+
# Function Call
46+
get_lyrics(artists, 3)

‎Lyrics_Genius_API/lyrics.txt

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
Come up to meet you, tell you I'm sorry
2+
You don't know how lovely you are
3+
I had to find you, tell you I need you
4+
Tell you I set you apart
5+
Tell me your secrets, and ask me your questions
6+
Oh, let's go back to the start
7+
Running in circles, coming up tails
8+
Heads on a science apart
9+
10+
Nobody said it was easy
11+
It's such a shame for us to part
12+
Nobody said it was easy
13+
No one ever said it would be this hard
14+
Oh, take me back to the start
15+
16+
I was just guessing at numbers and figures
17+
Pulling the puzzles apart
18+
Questions of science, science and progress
19+
Do not speak as loud as my heart
20+
Tell me you love me, come back and haunt me
21+
Oh, and I rush to the start
22+
Running in circles, chasing our tails
23+
Coming back as we are
24+
25+
Nobody said it was easy
26+
Oh, it's such a shame for us to part
27+
Nobody said it was easy
28+
No one ever said it would be this hard
29+
I'm going back to the start
30+
31+
Oh-ooh ooh-ooh-ooh-ooh
32+
Ah-ooh ooh-ooh-ooh-ooh
33+
Oh-ooh ooh-ooh-ooh-ooh
34+
Oh-ooh ooh-ooh-ooh-ooh
35+
36+
<|endoftext|>
37+
38+
I used to rule the world
39+
Seas would rise when I gave the word
40+
Now in the morning I sleep alone
41+
Sweep the streets I used to own
42+
43+
I used to roll the dice
44+
Feel the fear in my enemy's eyes
45+
Listen as the crowd would sing
46+
Now the old King is dead, long live the King
47+
One minute I held the key
48+
Next the walls were closed on me
49+
And I discovered that my castles stand
50+
Upon pillars of salt and pillars of sand
51+
52+
I hear Jerusalem bells are ringing
53+
Roman Cavalry choirs are singing
54+
Be my mirror, my sword and shield
55+
My missionaries in a foreign field
56+
For some reason I can't explain
57+
Once you'd gone there was never
58+
Never an honest word
59+
And that was when I ruled the world
60+
61+
It was the wicked and wild wind
62+
Blew down the doors to let me in
63+
Shattered windows and the sound of drums
64+
People couldn't believe what I'd become
65+
Revolutionaries wait
66+
For my head on a silver plate
67+
Just a puppet on a lonely string
68+
Oh, who would ever want to be king?
69+
70+
I hear Jerusalem bells are ringing
71+
Roman Cavalry choirs are singing
72+
Be my mirror, my sword and shield
73+
My missionaries in a foreign field
74+
For some reason I can't explain
75+
I know Saint Peter won't call my name
76+
Never an honest word
77+
But that was when I ruled the world
78+
79+
Oh-oh-woah, oh-oh, oh
80+
Oh-oh-woah, oh-oh, oh
81+
Oh-oh-woah, oh-oh, oh
82+
Oh-oh-woah, oh-oh, oh
83+
84+
(Oh-oh-woah, oh-oh, oh) I hear Jerusalem bells are ringing
85+
(Oh-oh-woah, oh-oh, oh) Roman Cavalry choirs are singing
86+
(Oh-oh-woah, oh-oh, oh) Be my mirror, my sword and shield
87+
(Oh-oh-woah, oh-oh, oh) My missionaries in a foreign field
88+
(Oh-oh-woah, oh-oh, oh) For some reason I can't explain
89+
(Oh-oh-woah, oh-oh, oh) I know Saint Peter won't call my name
90+
Never an honest word
91+
But that was when I ruled the world
92+
93+
Mmm, mmm, mmm, mmm
94+
Mmm, mmm, mmm, mmm
95+
Mmm, mmm...
96+
97+
<|endoftext|>
98+
99+
When you try your best, but you don't succeed
100+
When you get what you want, but not what you need
101+
When you feel so tired, but you can't sleep
102+
Stuck in reverse
103+
And the tears come streaming down your face
104+
When you lose something you can't replace
105+
When you love someone, but it goes to waste
106+
Could it be worse?
107+
108+
Lights will guide you home
109+
And ignite your bones
110+
And I will try to fix you
111+
112+
And high up above or down below
113+
When you're too in love to let it go
114+
But if you never try, you'll never know
115+
Just what you're worth
116+
117+
Lights will guide you home
118+
And ignite your bones
119+
And I will try to fix you
120+
121+
122+
Tears stream down your face
123+
When you lose something you cannot replace
124+
Tears stream down your face, and I
125+
Tears stream down your face
126+
I promise you I will learn from my mistakes
127+
Tears stream down your face, and I
128+
129+
Lights will guide you home
130+
And ignite your bones
131+
And I will try to fix you

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /