Fetch and Index Genius Song Lyrics
Connects to Genius API to load song lyrics, metadata, and album art into Documents. Get song lyrics by artist, URL, ID, or lyrics snippet.
Maintainer of this project? Claim this page to edit the listing.
1.0.0Add to Favorites
Why it matters
Access and process lyrics from the Genius API to build a searchable knowledge base of song information. This asset enables rich querying of song content, metadata, and artist information.
Outcomes
What it gets done
Retrieve song lyrics, metadata, and album art from Genius.
Search for songs based on lyric snippets, artist names, or tags.
Load specific songs using their Genius URL or ID.
Index song data for efficient querying and analysis.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/li-reader-readers-genius | bash Overview
LlamaIndex Readers Integration: Genius
This integration connects to the Genius API to fetch song lyrics, metadata, and album art. It loads this data into `Documents` for use with LlamaIndex. Functions include searching by lyrics, loading songs by artist, URL, or ID, and retrieving songs by tag. Use this integration when you need to programmatically access song lyrics and metadata from Genius for AI applications, such as lyric analysis or music information retrieval. Avoid using it if your needs extend beyond text-based song content or do not involve the Genius API.
What it does
This integration connects to the Genius API to retrieve song lyrics, associated metadata, and album art. It loads this information into Documents, making it readily available for use within AI applications.
When to use - and when NOT to
Use this integration when you need to programmatically access song lyrics and metadata from Genius. This includes scenarios like building a lyric analysis tool, creating a music recommendation engine based on lyrical content, or populating a knowledge base with song information.
Do not use this integration if you need to access audio files or if your use case does not involve song lyrics or metadata available through the Genius API. It is specifically designed for text-based song content.
Inputs and outputs
Inputs:
- An access token obtained from the Genius API.
- Parameters for specific functions, such as
artist_name,song_url,song_id,lyricssnippet, ortag.
Outputs:
Documentobjects containing song lyrics, metadata, and album art.- Lists of
Documentobjects, depending on the function called.
Integrations
This loader is designed to be used as a way to load data into LlamaIndex.
Who it's for
This integration is for developers and data scientists working with AI assistants and LlamaIndex who need to incorporate song lyrics and music metadata into their projects. It is particularly useful for those building applications that analyze song content, search for music based on lyrical themes, or require detailed song information.
pip install llama-index-readers-genius
from llama_index.readers.genius import GeniusReader
access_token = "your_generated_access_token"
loader = GeniusReader(access_token)
documents = loader.search_songs_by_lyrics("Imagine")
from llama_index.core import VectorStoreIndex, download_loader
from llama_index.readers.genius import GeniusReader
access_token = "your_generated_access_token"
loader = GeniusReader(access_token)
documents = loader.search_songs_by_lyrics("Imagine")
index = VectorStoreIndex.from_documents(documents)
index.query(
"What artists have written songs that have the lyrics imagine in them?"
)
Source README
LlamaIndex Readers Integration: Genius
pip install llama-index-readers-genius
This loader connects to the Genius API and loads lyrics, metadata, and album art into Documents.
As a prerequisite, you will need to register with Genius API and create an app in order to get a client_id and a client_secret. You should then set a redirect_uri for the app. The redirect_uri does not need to be functional. You should then generate an access token as an instantiator for the GeniusReader.
Usage
Here's an example usage of the GeniusReader. It will retrieve songs that match specific lyrics. Acceptable arguments are lyrics (str): The lyric snippet you're looking for and will return List[Document]: A list of documents containing songs with those lyrics.
GeniusReader Class Methods
load_artist_songs
- Description: Fetches all or a specified number of songs by an artist.
- Arguments:
artist_name(str): The name of the artist.max_songs(Optional[int]): Maximum number of songs to retrieve.
- Returns: List of
Documentobjects with song lyrics.
load_all_artist_songs
- Description: Fetches all songs of an artist and saves their lyrics.
- Arguments:
artist_name(str): The name of the artist.
- Returns: List of
Documentobjects with the artist's song lyrics.
load_artist_songs_with_filters
- Description: Loads the most or least popular song of an artist based on filters.
- Arguments:
artist_name(str): The artist's name.most_popular(bool):Truefor most popular song,Falsefor least popular.max_songs(Optional[int]): Max number of songs to consider for popularity.max_pages(int): Max number of pages to fetch.
- Returns:
Documentwith lyrics of the selected song.
load_song_by_url_or_id
- Description: Loads a song by its Genius URL or ID.
- Arguments:
song_url(Optional[str]): URL of the song on Genius.song_id(Optional[int]): ID of the song on Genius.
- Returns: List of
Documentobjects with the song's lyrics.
search_songs_by_lyrics
- Description: Searches for songs by a snippet of lyrics.
- Arguments:
lyrics(str): Lyric snippet to search for.
- Returns: List of
Documentobjects with songs matching the lyrics.
load_songs_by_tag
- Description: Loads songs by a specific tag or genre.
- Arguments:
tag(str): Tag or genre to search for.max_songs(Optional[int]): Max number of songs to fetch.max_pages(int): Max number of pages to fetch.
- Returns: List of
Documentobjects with song lyrics.
from llama_index.readers.genius import GeniusReader
access_token = "your_generated_access_token"
loader = GeniusReader(access_token)
documents = loader.search_songs_by_lyrics("Imagine")
Example
This loader is designed to be used as a way to load data into LlamaIndex.
LlamaIndex
from llama_index.core import VectorStoreIndex, download_loader
from llama_index.readers.genius import GeniusReader
access_token = "your_generated_access_token"
loader = GeniusReader(access_token)
documents = loader.search_songs_by_lyrics("Imagine")
index = VectorStoreIndex.from_documents(documents)
index.query(
"What artists have written songs that have the lyrics imagine in them?"
)
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.