AI Learns to Write Rap Lyrics!
Gaming
Introduction
Introduction
Hi everyone, it's Carrie! I've always considered myself a musical person. Given my experience with AI in composing Baroque and jazz music, it felt only natural to evolve my musical endeavors into rap. While Suraj Revolt has tackled this challenge before me, I'm excited to create my own rap using AI technology.
The Algorithm
To begin, I utilized Andre Carpathia's recurrent neural network (RNN) code. An RNN allows a neural network to maintain a memory of past inputs through a hidden state, making it suitable for generating sequences like lyrics. Though I'm familiar with RNNs, I wanted to introduce a unique twist to create something distinctly musical.
It's essential to credit Boyinaband, a talented rapper who previously engaged with my AI-generated lyrics. Our collaboration, although promising, resulted in lost footage, leading me to speculate that perhaps AI had other intentions. Thus, I employed a Python module to leverage Google's text-to-speech software, giving our AI a voice to rap its own lyrics.
Gathering Data
Before generating rap lyrics, I needed a solid dataset. With the help of my brother, we compiled a sizeable collection from the original hip-hop lyrics archive, spanning works of rap legends like Kendrick Lamar and Eminem. After stitching approximately 6,000 songs, we created a dataset comprising around 17 million text characters—a relatively small amount of data for such a wealth of information.
Training the AI
As I trained the algorithm, I noted how quickly it developed an understanding of the structure of rap lyrics. In less than a second, the AI began refining its output, learning to format the text more coherently while gradually discarding odd patterns. Over time, it developed essential grammar rules and started using line breaks and common rap terms effectively.
However, I faced challenges with certain aspects, including how the AI handled swear words and specific phrases. To navigate this, I decided to censor explicit language while replacing a particularly sensitive word with "ninja."
Following more extensive training, after about ten minutes, the RNN produced lyrics that increasingly resembled real rap texts. Though longer arrangements could be somewhat jumbled, several one-liners emerged that felt authentic.
Rhythm and Flow
One critical element lacking in the early outputs was rhythm. I had two approaches to address this: manually aligning syllables to a chosen beat or automating the rhythm alignment within my algorithm.
The manual method was labor-intensive, taking two hours of my time to match syllables to their respective beats, which revealed the potential of this AI-generated rap. However, noticing the time-consuming nature of this process, I shifted focus to algorithmic time alignment.
To achieve this, I concentrated on identifying the beginning and end of syllables, snapping them to the nearest beat using a robust analysis of audio amplitude. I enhanced this process using the phase vocoder feature from the Python library, audio TSM, ensuring that the pitch remained intact while adjusting timing.
Final Product
After refining the alignment and ensuring that important beats were respected, I was thrilled to present the end result. By leveraging both human intuition and algorithmic precision, the AI-generated rap took its final shape—an impressive fusion of technology and artistry.
Conclusion
The journey of training an AI to write and perform rap lyrics was a remarkable experience, culminating in a project that I am eager to share. The outcome symbolizes the potential of artificial intelligence in creative domains, illustrating our ability to bridge technology with human artistry.
Keywords
- AI
- Rap Lyrics
- Recurrent Neural Network
- Data Training
- Rhythm
- Text-to-Speech
- Suraj Revolt
- Boyinaband
FAQ
What was the purpose of this project?
The project aimed to explore the capabilities of AI in generating rap lyrics and performing them using text-to-speech technology.
What data was used to train the AI?
The AI was trained on a dataset compiled from the original hip-hop lyrics archive, including works by rap icons like Kendrick Lamar and Eminem.
What challenges did you face during the project?
Some challenges included ensuring proper formatting, handling explicit language, and implementing rhythm in the rap flow.
How did you improve the rhythm of the generated rap?
I focused on aligning the beginning and end of syllables to the nearest beats while utilizing audio processing techniques to maintain pitch integrity.
What was the ultimate result of the AI's training?
The AI successfully generated a rap song that showcased a blend of uniquely crafted lyrics and rhythmic flow, highlighting the potential of AI in creative music.