Machine Learning

Music, songs, and agentic AI: building an intuitive smart song in python and evulai

Is a container.

Rap music made me cry, sing, and dance, and read about it. English language. I still remember the first time I sat down and tried to understand Biggie and Tupac. I remember learning about Brooklyn, California, slang, trouble, and all the other powerful messages behind those songs.

Rap music is the best example of how music lyrics alone can make a piece of music art. Some of the best hip-hop songs are literally sampled, some drums, and a lyricist in 4/4 tempo.

And when someone reading The songs may not be necessary either, as they knew the language, because non-English speakers like me, the tools are the same Intelligence he makes life so much easier. Genius is an online music community: If you're looking for song lyrics, Genius is your man. Because of genius, even if I didn't understand what Biggie was saying, I would sit down and read the lyrics, and translate them. Not only that: When a rapper (or an artist in general) makes some reference that is very difficult to understand, intelligence will explain it to you side-bar snippets.

A photo from a relationship https://towardsdatascience.com/music-lyrics-and-agentic-ai-building-a-smart-song-explainer-using-python-and-openai/

But how does creativity do that? How do they produce understandable, up-to-date, useful snippets?

Wow, In 2009, When genius was born, I thought they would produce mainly these types of snippets about what happened: Users can just add their comments, maybe some moderators can update some of them, and that's it, a sealed deal.

However, todaywith the powerful AI technology we have, the pipeline can be made more smooth and efficient. While I believe that an agentic ai will be able to perform the work of a musicologist (for many reasons), I believe that a person with such background knowledge would be I said with agentic ai, which will have them The right tools for creating snippets.

And- that's it What are we doing today? 🙂

We will use Support, Python, and Open it Creating a very simple web application that, given the lyrics, provides clarity on what the text part says. Specificallywe will allow the user to ask questions Regarding the piece of text, what makes gender intelligence “interactive”. We will also provide our AI agent Web Search Results Allowing the LLM to look at other compositions and materials when composing a response.

To smooth things over (and for copyright purposes lol), we'll know again Create our songs, using another AI agent.

It's exciting! Let's get started! 🚀

If you are interested in the final result of this study, skip to – the third part. If you want to do magic with me, start from the next section. There are no judgments. 🙂

1. Design System

Let's start building our program. This is what it looks like:

Photo by the author

Specifically:

  1. The user has the ability to do create a song from scratch using an AI agent. That is optional; A collection of songs is already created and can be used instead.
  2. The user can Select the part of the text and ask a question.
  3. An AI agent can generate an answer in a “mind-like” style.

The AI ​​agent is also equipped with:

a. the “Inner Song Knowledge“, which contains the extracted features / metadata of the song (eg, title, title, etc …).
b. Web search tool, which allows agents to use the web to search for songs and add contextual context

This design is beautiful nursing, Which means it's easy to add bits and pieces to increase the complexity of the program. For example, if you want to make the Janekuma of a song more transparent, you can easily lower the Song States Agent without going crazy over other parts of the code.

Let's build this piece by piece. 🧱

2. Code

2.1 Setup

The entire code can be found in this GitHub folder

Our work structure will be as follows:

  1. A generator generator lyrient, which is generate_madeup_lyrics.py
  2. This page Response to songs, which is qa.py
  3. This page web application itself (the file we will run parallel to), which is lyricsgpt_app.py
  4. The crowd of they don't help (like utils.py, constants.py, config.pyetc…)

The information will be stored in data Folder again.

Photo by the author

I don't want to give you all the little details, so I will only explain the main parts of this building. Let's start with the backbone: Streamlit app.

2.2 Streamlit App

Please note: You will need to have an OpenAi API key ready, for both the SALEDLIT app and anything that requires LLM generation. Besides the Streamlit app, the easiest way to set it up is using the OS: IS.Gegenv(“Vulai_API_KEY”) = “API_KEY”. Inside the app, you will be prompted to copy – paste. Don't worry, it's all local.

Everything works with the following command:

streamlit run lyricsgpt_app.py

– Phi lyricsgpt_app.py The following block of code:

This is quite long, but let's get straight to the point: Every line represents a piece of a web application:

  1. The subject of the web application
  2. Song selectorwhich allows the user to select songs from the data folder (more on this later)
  3. A text block box, where the user can copy and paste part of the words of interest
  4. Question boxingwhere the user asks a question about the segment of interest selected above
  5. The answer boxingwhere LLM can answer the question.

But this “-one“The executor; the dirty work is done by lyricsgpt A module and its objects / functions. Let's take a look at a few!

2.3 gen

This component is optional and is not included in the Web application, which focuses on Versius-Ling Lyrics Chazer. Feel free to skip this if you are interested in that. But I have to say: This part is cool.

For song generation, the game is simple:

  • You guys give me a a noun, a whistle, title, And another hidden message in the twisted.
  • Me I gave it to you music lyrics.

For example:

Produce:

Verse 1
Under the city lights, the rumors danced along the sky, it was shining at night, like diamonds in the midnight sky. But love was just a lofty dream, built in a fragile gut, now I'm driving out the highway, leaving echoes in between.

A hymn
And everything glows in retrospect, shrinking into blue shadows, all laughter and all tears, pulling without looking. As the road UROLLS forward, I allow the stew of memory, only glowing in retrospect, to stop for me and you.

[Some more LLM Generated Text]

Out of the snow
So I drive in silence, where the past can't be doubted, left glowing in retrospect, and shards of me and you. It's just glorious in retrospect, the love story gone too soon.

Very nice, right? The code to do the following:

You can play with it by changing Songs_Prompletswhich looks like this:

Every time you produce a song, it will go into You're going file. By default, that is Data / Build_Plyrics.json. You don't have to produce a song; There are already some examples I've done there.

2.4 Descriptive adjective

The coolest thing about this agentic era is this The amount of time you save building these things. This page – complete Answering questions, and AI's ability to run online web searches, in this code block:

This does it all: the answer Question, It is read Songs Metadata, and it arranges details online if prompted / required.

I didn't want to get too fancy, but you can actually equip the agent with web_search work item. In this case, I enter the details directly; If you give the tool this tool, it can decide when to search online.

Okay, but does this work? What do the results look like? Let's take a look!

3. Magic!

This is an example web application.

  1. Your paste Open the API key, and select a song. It says “glitter in hindsight”.
Photo by the author

2. Select an area of ​​interest. For example, let's say I'm Italian (which I am lol), and I use it desiso I don't know how far mile is. I would also like to know if there is a reference to something specific when the singer says 13 miles (“thirteen miles of freedom” is the first sentence on the bridge)

3. See the magic!

Photo by the author

Let's try something harder. Here, I paste the whole second verse, and I asked the AI ​​to give me which artist to write something like this.

AI identifies Taylor Swift and – Cereli. Especially the Taylor Swift reference is very accurate, as songs about breakups and love stories are her biggest hits. He brought up his popularity and how it affects his life in songs like “I know places”:

The lights are on and we're going to mimic the fence, let them say they want you, we won't hear it

Taylor Swift – I Know Places

I will admit I had to Google that.

4. Some think…

Now, This is not entirely far: It's a plug-and-play weekend project, under MVP. However, it offers three features for full portability:

  1. When provided with the right tools and metadata, LLM really shines and provides insightful insights (like taylor swift's suggestion)
  2. Building an LLM Wrapper is way It's easier than it was even 5 months ago. The way this technology evolves allows you to be more productive than ever before.
  3. Agentic AI can really be used all over. Instead of being afraid of it, it's better to accept it and see what we can do about it.

5. Conclusions

Thank you for spending time with me; It means a lot ❤️. Here's what we did together:

  • It's built on an intelligently inspired system powered by agentic ai That would explain the lyrics of the songs they interact with.
  • Developed bacsender components in Python and Strindlitfrom a lyrics generator to a Q&A engine.
  • Build an AI agent With inside track information and a Web search tool for state answers.
  • He built an An app that can translate songs intelligently.
  • He had some fun While doing that, I hope. 🙂

I want to close with my 2 cents. In my daily walk, I listen Podcasts (usually conversations) of local artists Who makes the music, and explains the songs, directions, and lyrics. If someone takes those artists with AI, I'll go Cause dust. not (only) Because I love it people themselves, but because I believe they will explain things with passion, depth, and sensitivity that LLMs can't provide (and I think they won't).

However, if we provide music critics with these kinds of AI tools, their work becomes much easier, and they can improve their productivity.

7. Before you go out!

Thanks again for your time. It means a lot ❤

My name is Piero Paialanga, and I am a person here:

Photo by the author

I am from Italy, hold a PH.D. from the University of Cincinnatiand work as Data scientist on the trading desk New York City. I write about AI, Machine Learning, and the emerging role of the data scientist both here on TDS and on LinkedIn. If you liked the article and want to know more about machine learning and follow my course, you can:

A. Follow me LinkedInwhere I publish all my stories
B. Follow me A certain medicine kikiwhere you can see all my code
C. For questions, you can email me at piero.paiali@hotmail

Source link

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button