Movatterモバイル変換


[0]ホーム

URL:


Open In App
Next Article:
Application to get live USD/INR rate Using Python
Next article icon

In this article, we are going to write a python script to extract lyrics from the song and bind with its GUI application. We will uselyrics-extractorto get lyrics of a song just by passing in the song name, it extracts and returns the song's title and song lyrics from various websites. Before starting, install thelyrics-extractormodule. Run this command into your terminal.

pip install lyrics-extractor

Requirements

Need an API Key and Engine ID of Google Custom Search JSON API.

Engine ID 

  • Create a Custom Search Engine to get your Engine IDhere.
  • We have to create our own Programmable Search Engine (Google Custom Search Engine) and add Link to fetch lyrics.
  • Programmable Search Engine is based on Google's core search technology.
  • It is a search engine for your website and has a task to find information as the user choose.

Choose any link of one to get your search engine:

https://genius.com/
https://lyricsted.com/
http://www.lyricsbell.com/
https://glamsham.com/
http://www.lyricsoff.com/
https://lyricsmint.com/

JSON API :

  • The custom search JSON API is able to retrieve and display search result from Programmable Search Engine.
  • To use the custom search JSON API we have to create Programmable Search Engine.
  • Visithere to get your API key.

Approach:

  • Import the modules.
from lyrics_extractor import SongLyrics
  • Pass the Google Custom Search JSON API key and Engine ID intoSongLyrics().
extract_lyrics = SongLyrics(Your_API_KEY, GCS_ENGINE_ID)
  • Get the lyrics by passing the song name as a parameter toextract_lyrics.get_lyrics() method.
extract_lyrics.get_lyrics("Shape of You")

Below is the implementation.

Python
# importing modulesfromlyrics_extractorimportSongLyrics# pass the GCS_API_KEY, GCS_ENGINE_IDextract_lyrics=SongLyrics("AIzaSewfsdfsdfOq0oTixw","frewrewrfsac")extract_lyrics.get_lyrics("Tujhse Naraz Nahi Zindagi Lyrics")

Output:

extractlyrics-copy-2


Note: Enter your own API key and engine id otherwise it will generate an error.

Extract lyrics Application with Tkinter: 

Python
# import modulesfromtkinterimport*fromlyrics_extractorimportSongLyrics# user defined functiondefget_lyrics():extract_lyrics=SongLyrics("Aerwerwefwdssdj-nvN3Oq0oTixw","werwerewcxzcsda")temp=extract_lyrics.get_lyrics(str(e.get()))res=temp['lyrics']result.set(res)# object of tkinter# and background set to light greymaster=Tk()master.configure(bg='light grey')# Variable Classes in tkinterresult=StringVar()# Creating label for each information# name using widget LabelLabel(master,text="Enter Song name : ",bg="light grey").grid(row=0,sticky=W)Label(master,text="Result :",bg="light grey").grid(row=3,sticky=W)# Creating label for class variable# name using widget EntryLabel(master,text="",textvariable=result,bg="light grey").grid(row=3,column=1,sticky=W)e=Entry(master,width=50)e.grid(row=0,column=1)# creating a button using the widgetb=Button(master,text="Show",command=get_lyrics,bg="Blue")b.grid(row=0,column=2,columnspan=2,rowspan=2,padx=5,pady=5,)mainloop()

Note: Enter your own API key and engine id otherwise it will generate an error.

Output:


Create a GUI to Extract Lyrics From Song Using Python

Similar Reads

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood ourCookie Policy &Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences

[8]ページ先頭

©2009-2025 Movatter.jp