LyricsAI – A Song Lyrics Retrieval Library

alt text

LyricsAI is a versatile library designed for Android developers to effortlessly retrieve song lyrics through web scraping. Developed by Abdelhakim Khaouiti, this library provides a seamless way to access lyrics, making it an excellent addition to music-related Android applications.


Last Modified

  • Last Modified: 2023-10-22

How to Use

To use the LyricsAI library in your Android project, follow these steps:

Step 1. Add the JitPack Repository and Dependencies

First, add the JitPack repository to your root build.gradle file to enable the use of the LyricsAI library. Add it at the end of the repositories section:

dependencyResolutionManagement {
    repositories {
        maven { url '' }

Next, add the LyricsAI library as a dependency in your app’s build.gradle file. Be sure to replace Tag with the specific release version you want to use: latest version is

dependencies {
    implementation 'com.github.khaouitiabdelhakim:LyricsAI:Tag'

Please note that this library uses web scraping to retrieve lyrics, which can be resource-intensive. Therefore, it’s essential to perform these operations in the background using Coroutines.

Step 2. Adding Coroutines Dependency

To handle asynchronous operations efficiently, you should add Coroutines dependencies to your project. Add the following dependencies with the latest version:

// For Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'

Step 3. Creating a Coroutine Scope

To use the LyricsAI library in a Coroutine scope, you can create a CoroutineScope with a specific dispatcher:

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch

// Create a CoroutineScope
val scope = CoroutineScope(Job() + Dispatchers.Main)

Step 4. Retrieving Lyrics

You can now use the CoroutineScope to retrieve lyrics in the background. Here’s how to do it:

scope.launch {
    // To retrieve lyrics by song title
    val title = "YourSongTitle"
    val lyrics = LyricsAI.findLyricsBySongTitle(title)

    // To retrieve lyrics by both song title and artist
    val title = "YourSongTitle"
    val artist = "ArtistName"
    val lyrics = LyricsAI.findLyricsBySongTitleAndArtist(title, artist)

This approach ensures that the library’s operations are performed asynchronously and won’t block the main thread, offering a smoother user experience in your Android application.

Please ensure you handle network and web scraping exceptions in your application as needed.


  • Retrieve song lyrics with a simple song title query or a combination of title and artist.
  • Web scraping capabilities to efficiently extract lyrics.
  • Ideal for integration into music-related applications, karaoke apps, and more.


We extend our gratitude to the open-source community for their valuable contributions.

This library is designed to enhance your Android applications with easy access to song lyrics. Feel free to use LyricsAI in your projects while respecting its authorship. If you encounter issues, have suggestions for improvement, or want to contribute, we encourage you to get involved.


View Github