Python Tkinter GUI to Extract Lyrics From Song Using Google Custom Search JSON API Full Project For Beginners

You are currently viewing Python Tkinter GUI to Extract Lyrics From Song Using Google Custom Search JSON API Full Project For Beginners


Welcome folks today in this blog post we will be extracting lyrics from song in tkinter using google custom search json api. This will be a fun project for python beginners. All the source code of the project will be given below.



Get Started



In order to get started you need to install the following libraries with the help of pip command


pip install tkinter


pip install lyrics-extractor



Getting Search Engine ID



For this module lyrics-extractor we need the search engine id. For that you need to go here and fill out the form to get your search engine id. The screenshots are given below.






Here inside the search engine field you can provide any of the below sites to fetch the lyrics from song







Custom Search JSON API key



For this application we are using google custom search json api so we will need the api key. So you can go to google developer console website and get your api key.











Now you need to make a file and copy paste the following code to it



# import modules 
from tkinter import *
from lyrics_extractor import SongLyrics 

# user defined funtion 
def get_lyrics(): 
    extract_lyrics = SongLyrics( 
        "##yourapikey##", "##yoursearchengineid###") 
    temp = extract_lyrics.get_lyrics(str(e.get())) 
    res = temp['lyrics'] 

# object of tkinter 
# and background set to light grey 
master = Tk() 
master.configure(bg='light grey') 

# Variable Classes in tkinter 
result = StringVar() 

# Creating label for each information 
# name using widget Label 
Label(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 lebel for class variable 
# name using widget Entry 
Label(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 widget 
b = Button(master, text="Show", 
        command=get_lyrics, bg="Blue") 

b.grid(row=0, column=2, columnspan=2, 
    rowspan=2, padx=5, pady=5,) 





If you execute the python script and replacing your api key and search engine id and type the following command on command line








Leave a Reply