File size: 1,351 Bytes
7d5a744
 
 
 
 
 
 
 
0a99c6e
 
 
 
 
 
 
 
 
 
 
 
 
 
7d5a744
 
c0a53d4
7d5a744
 
eb24ca0
 
 
0a99c6e
7d5a744
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import gradio as gr
import lyricsgenius
import re

# Initialize Genius API client
genius = lyricsgenius.Genius("YOUR_GENIUS_ACCESS_TOKEN")

def get_lyrics_from_link(link):
    try:
        # Extract song path from Genius link
        song_path = re.search(r"genius\.com/([\w-]+)-lyrics$", link)
        if song_path:
            # Search song by song path
            song = genius.search_song(song_path.group(1).replace("-", " "))
            if song:
                return song.lyrics
            else:
                return "Song not found. Please check the link."
        else:
            return "Invalid link format. Please provide a correct Genius lyrics link."
    except Exception as e:
        return f"An error occurred: {str(e)}"

# Create Gradio interface
with gr.Blocks(theme="Hev832/niceandsimple") as demo:
    gr.Markdown("## Get Lyrics from Genius Link")
    
    link_input = gr.Textbox(label="Genius Link", 
                            placeholder="Enter Genius lyrics link here...", 
                            value="https://genius.com/Maimymayo-silly-billy-with-lyrics-hit-single-real-cover-lyrics")  # Example link added
    output = gr.Textbox(label="Lyrics", lines=15)
    
    get_lyrics_button = gr.Button("Get Lyrics")
    get_lyrics_button.click(get_lyrics_from_link, inputs=link_input, outputs=output)

demo.launch()