Close Menu
    Trending
    • “The success of an AI product depends on how intuitively users can interact with its capabilities”
    • How to Crack Machine Learning System-Design Interviews
    • Music, Lyrics, and Agentic AI: Building a Smart Song Explainer using Python and OpenAI
    • An Anthropic Merger, “Lying,” and a 52-Page Memo
    • Apple’s $1 Billion Bet on Google Gemini to Fix Siri
    • Critical Mistakes Companies Make When Integrating AI/ML into Their Processes
    • Nu kan du gruppchatta med ChatGPT – OpenAI testar ny funktion
    • OpenAI’s new LLM exposes the secrets of how AI really works
    ProfitlyAI
    • Home
    • Latest News
    • AI Technology
    • Latest AI Innovations
    • AI Tools & Technologies
    • Artificial Intelligence
    ProfitlyAI
    Home » Music, Lyrics, and Agentic AI: Building a Smart Song Explainer using Python and OpenAI
    Artificial Intelligence

    Music, Lyrics, and Agentic AI: Building a Smart Song Explainer using Python and OpenAI

    ProfitlyAIBy ProfitlyAINovember 14, 2025No Comments11 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    is rap.

    Rap music made me cry, sing, and dance, and it’s also how I discovered the English language. I nonetheless keep in mind the primary time I sat down and tried to know Biggie and Tupac. I keep in mind studying about Brooklyn, about California, the slang, the struggles, and all the opposite highly effective messages behind these songs.

    Rap music is the perfect instance of how lyrics alone could make music a chunk of artwork. Among the greatest hip-hop songs are actually a pattern, some drums, and an individual speaking poetry on a 4/4 tempo.

    And whereas for somebody studying the lyrics won’t even be obligatory, as they know the language, for non-English audio system like myself, instruments like Genius made life extremely simpler. Genius is an internet lyrics music collector: for those who’re on the lookout for the lyrics of a track, Genius is your man. Because of Genius, even when I didn’t perceive what Biggie was saying, I might sit down and skim the lyrics, then Google them and translate them. Not solely that: when a rapper (or a singer on the whole) makes a particular reference that’s too arduous to know, Genius will make clear that for you thru some side-bar snippets.

    Picture from Genius [link]

    However how does Genius try this? How do they produce such insightful, up-to-date, helpful snippets?

    Nicely, in 2009, when Genius was born, I might say they might primarily produce these sorts of snippets manually: customers would simply add their remark, perhaps some moderator might overview a few of them, and that’s it, closed deal.

    Nonetheless, in the present day, with the highly effective AI applied sciences that now we have, the pipeline may be made a lot smoother and environment friendly. Whereas I don’t imagine that an agentic AI would have the ability to do the job of a music skilled (for thus many causes), I imagine that an individual with such area data might be helped by the agentic AI, which would offer them with the appropriate instruments to create the snippets.

    And that is what we’re doing in the present day. 🙂

    We’ll use Streamlit, Python, and OpenAI to construct an excellent easy internet app that, given a track’s lyrics, gives clarification to what the piece of textual content means. Extra particularly, we’re going to enable the person to ask questions in regards to the piece of textual content, making the Genius thought extra “interactive”. We’re additionally going to present our AI Agent the Internet Search outcomes to permit the LLM to have a look at different songs and assets when crafting the reply.

    To spice issues up (and for copyright functions lol), we’re going to additionally create our personal songs, utilizing one other AI agent.

    Thrilling! Let’s get began! 🚀

    In case you are within the closing results of this experiment, skip to the third part. If you wish to craft the magic with me, begin from subsequent part. No judgments. 🙂

    1. System Design

    Let’s first design our system. That is the way it appears:

    Picture made by writer

    Extra particularly:

    1. The Person has the power to create the track from scratch utilizing an AI Agent. That’s elective; a batch of songs has already been generated and can be utilized as a substitute.
    2. The Person can choose a component of the textual content and ask a query.
    3. The AI Agent can generate the response in a “Genius-like” model.

    The AI Agent can also be geared up with:

    a. The “Inside Tune Data“, which consists of the extracted options/metadata of the track (e.g., vibe, title, theme, and so on…).
    b. The Internet Search Software, which permits the agent to surf the net to search for songs and add context to the query

    This design has good modularity, that means it’s simple so as to add bits and items to extend the complexity of the system. For instance, if you wish to make the track era extra refined, you possibly can simply tweak the Tune Technology Agent with out going loopy over the opposite elements of the code.

    Let’s construct this piece by piece. 🧱

    2. Code

    2.1 Setup

    The entire code may be discovered on this Github folder

    The construction of our work might be as follows:

    1. A lyrics generator, which is generate_madeup_lyrics.py
    2. The lyrics reply, which is qa.py
    3. The internet app itself (the file we’ll run by means of Streamlit), which is lyricsgpt_app.py
    4. A bunch of helpers (equivalent to utils.py, constants.py, config.py, and so on…)

    The info might be saved in a knowledge folder as nicely.

    Picture made by writer

    I don’t need to bore you with all of the tiny particulars, so I’ll solely describe the principle parts of this construction. Let’s begin with the core: the Streamlit app.

    2.2 Streamlit App

    Please word: you will have to have a OpenAI API key prepared, for each the Streamlit app and no matter requires the LLM era. Exterior of the Streamlit app, the best manner is to set it utilizing OS: os.getenv(“OPENAI_API_KEY”) = “api_key”. Throughout the app, you’ll be prompted to copy-paste it. Don’t fear, it’s all native.

    The entire thing runs with the next command:

    streamlit run lyricsgpt_app.py

    The place lyricsgpt_app.py is the next block of code:

    That is fairly lengthy, however fairly simple: each line represents a chunk of the net app:

    1. The title of the net app
    2. The track selector, which permits the person to pick out the lyrics from the information folder (extra about this later)
    3. The field for the block of textual content, the place the person can copy and paste the a part of the lyrics of curiosity
    4. The query field, the place the person can ask a query in regards to the a part of the lyrics of curiosity chosen above
    5. The reply field, the place the LLM can reply the query.

    However that is “solely” the executor; the soiled work is completed by the lyricsgpt module and its objects/features. Let’s see a number of!

    2.3 Lyrics Generator

    This half is elective and never included within the internet app, which focuses on the Genius-like Lyrics Explainer. Be happy to skip this in case you are fascinated about that. However I’ve to say it: this half is fairly cool.

    For the lyrics era, the sport is easy:

    • You give me a title, vibe, theme, and a few hidden message in a twist.
    • I provide the lyrics.

    For instance:

    Produces:

    Verse 1
    Beneath the town lights, whispers danced alongside the skyline, we have been shining by means of the night time, like diamonds in a midnight sky. However love was only a high-rise dream, constructed on fragile seams, now I’m pulling off the freeway, leaving echoes in between.

    Refrain
    And it’s all glitter within the rearview, fading into shades of blue, each chuckle and each tear, drifting out of view. Because the street unrolls forward, I let the reminiscences stew, it’s simply glitter within the rearview, letting go of me and also you.

    [Some more LLM Generated Text]

    Outro
    So I drive into the silence, the place the previous can’t misconstrue, leaving glitter within the rearview, and the shards of me and also you. It’s simply glitter within the rearview, a love story gone too quickly.

    Fairly cool, proper? The code to do this is the next:

    You possibly can play with it by modifying SONG_PROMPTS, which appears like this:

    Each time you generate a track, it would go right into a JSON file. By default, that’s knowledge/generated_lyrics.json. You don’t must essentially generate a track; there are already some examples I made in there.

    2.4 Lyrics Explainer

    The good factor about this entire Agentic period is the period of time you save to construct these things. The entire Query-Answering logic, plus the power of the AI to make use of on-line internet search, is on this block of code:

    This does all of it: reply the query, reads the lyrics metadata, and integrates data on-line if prompted/wanted.

    I didn’t need to get too fancy, however you possibly can truly equip the agent with the web_search software. On this case, I’m parsing the knowledge immediately; for those who give the LLM the software, it may possibly resolve when and if search on-line.

    Okay, however does this work? How do the outcomes appear to be? Let’s discover out!

    3. The magic!

    That is an instance of the net app.

    1. You copy-paste your OpenAI API key, and you choose a track. Say “Glitter within the Rearview”.
    Picture made by writer

    2. Choose the a part of curiosity. For instance, let’s say I’m an Italian man (which I’m lol), and I exploit meters, so I don’t know the way far a mile is. I might additionally prefer to know if there’s a reference to one thing particular when the singer says 13 miles (“13 miles to freedom” is the primary sentence within the bridge)

    3. See the magic!

    Picture made by writer

    Let’s strive one thing tougher. Right here, I pasted the entire second verse, and I requested the AI to present me which singer would write one thing like this.

    The AI factors out Taylor Swift and Adele. Particularly the Taylor Swift reference is extraordinarily correct, because the songs about breakups and love tales are her best hits. She additionally on her reputation and the way her life is affected by it in songs like “I do know locations”:

    Lights flash and we’ll run for the fences, Allow them to say what they need, we gained’t hear it

    Taylor Swift – I do know locations

    I’ll admit I needed to Google that.

    4. Some pondering…

    Now, that is removed from good: it’s a plug-and-play weekend venture, lower than an MVP. Nonetheless, it gives three widespread takeaways:

    1. When supplied with the appropriate instruments and metadata, the LLM actually shines and gives insightful data (just like the Taylor Swift suggestion)
    2. Constructing an LLM wrapper is manner simpler than it was even 5 months in the past. The way in which this expertise is evolving means that you can be extra productive than ever.
    3. Agentic AI can actually be utilized in every single place. Somewhat than getting scared about it, it’s greatest to embrace it and see what we will do with it.

    5. Conclusions

    Thanks for spending time with me; it means rather a lot ❤️. Right here’s what now we have executed collectively:

    • Designed a Genius-inspired system powered by Agentic AI that may clarify track lyrics interactively.
    • Developed the backend parts in Python and Streamlit, from the lyrics generator to the Q&A engine.
    • Constructed the AI agent with inside track data and an internet search software for contextual solutions.
    • Constructed an app that may interpret lyrics intelligently.
    • Had some enjoyable whereas doing that, I hope. 🙂

    I need to shut with my 2 cents. On my each day commute, I hearken to podcasts (often interviews) of artists who make music, and so they clarify the songs, the references, and the lyrics. If somebody replaces these musicians with an AI, I’m going to RIOT. Not (solely) as a result of I just like the individuals themselves, however as a result of I imagine that they’ll clarify issues with a ardour, a depth, and an empathy that LLMs should not capable of present (and I believe they by no means will).

    Nonetheless, if we offer music critics with these sorts of AI instruments, their work turns into a lot simpler, and so they can 10x their productiveness.

    7. Earlier than you head out!

    Thanks once more to your time. It means rather a lot ❤️

    My title is Piero Paialunga, and I’m this man right here:

    Picture made by writer

    I’m initially from Italy, maintain a Ph.D. from the College of Cincinnati, and work as a Knowledge Scientist at The Commerce Desk in New York Metropolis. I write about AI, Machine Studying, and the evolving function of information scientists each right here on TDS and on LinkedIn. When you favored the article and need to know extra about machine studying and observe my research, you possibly can:

    A. Observe me on Linkedin, the place I publish all my tales
    B. Observe me on GitHub, the place you possibly can see all my code
    C. For questions, you possibly can ship me an electronic mail at piero.paialunga@hotmail



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleAn Anthropic Merger, “Lying,” and a 52-Page Memo
    Next Article How to Crack Machine Learning System-Design Interviews
    ProfitlyAI
    • Website

    Related Posts

    Artificial Intelligence

    “The success of an AI product depends on how intuitively users can interact with its capabilities”

    November 14, 2025
    Artificial Intelligence

    How to Crack Machine Learning System-Design Interviews

    November 14, 2025
    Artificial Intelligence

    Critical Mistakes Companies Make When Integrating AI/ML into Their Processes

    November 14, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    Markus Buehler receives 2025 Washington Award | MIT News

    April 5, 2025

    Docling: The Document Alchemist | Towards Data Science

    September 12, 2025

    AI system learns from many types of scientific information and runs experiments to discover new materials | MIT News

    September 25, 2025

    AI Agents Processing Time Series and Large Dataframes

    April 23, 2025

    Shaip Launches Generative AI Platform for Experimentation, Evaluation, & Monitoring of AI Applications

    April 7, 2025
    Categories
    • AI Technology
    • AI Tools & Technologies
    • Artificial Intelligence
    • Latest AI Innovations
    • Latest News
    Most Popular

    How to Approach Data Collection for Conversational AI

    May 5, 2025

    What If I Had AI in 2020: Rent The Runway Dynamic Pricing Model

    August 22, 2025

    A platform to expedite clean energy projects | MIT News

    April 7, 2025
    Our Picks

    “The success of an AI product depends on how intuitively users can interact with its capabilities”

    November 14, 2025

    How to Crack Machine Learning System-Design Interviews

    November 14, 2025

    Music, Lyrics, and Agentic AI: Building a Smart Song Explainer using Python and OpenAI

    November 14, 2025
    Categories
    • AI Technology
    • AI Tools & Technologies
    • Artificial Intelligence
    • Latest AI Innovations
    • Latest News
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us
    Copyright © 2025 ProfitlyAI All Rights Reserved.

    Type above and press Enter to search. Press Esc to cancel.