FreestyleGPT: An AI Chat App that Generates Rap Lyrics (2023)

FreestyleGPT: An AI Chat App that Generates Rap Lyrics (1)

⬇️ ️️a demo of the app can be found below ⬇️

When the beat drops and the words start to flow, freestyle rap transforms into a raw, unfiltered form of artistic expression that captivates both the artist and the audience. Freestyle is a style of improvisation, with or without instrumental beats, in which lyrics, aka bars, are recited with no particular subject or structure and without prior memorization.

I’ve always enjoyed listening to the eccentric flows, creative rhymes, and, most of all, jaw-dropping punch lines in freestyle rap. The art form allows for a range of emotions, from lighthearted humor to political commentary, and allows individuals to express themselves uniquely and powerfully. Freestyle rap has become a significant part of contemporary hip-hop culture and has been used as a tool for self-expression, community building, and activism. It encourages artists to tap into their creative potential, break down barriers, and push the boundaries of what is possible in music.

Freestyle rap requires quick thinking, clever wordplay, and an ability to connect ideas seamlessly in a way that resonates with the listener; however, are these skills only a human can master? With the rapid development in the world of natural language processing and text generation, I decided to put this question to the test:

Is there an AI that can freestyle with me bar for bar ❓❓❓

3am Thoughts

The way that a freestyle typically goes is that after one bar is given, another is given based on the former. For example,

Bar 1: I don’t understand why people like eating crepes

Bar 2: I’m surprised that some doctors did surgery on a grape

The above format works for individuals doing a freestyle solo or in a group of friends. With the nature of freestyle in mind, a chat app that generates the next bar would be the ideal format for a freestyling AI.

Regarding how the lyrics would be generated, I looked to the hottest thing on the block right now: ChatGPT. I knew that ChatGPT could write songs and poems, so I assumed it could also write the next bar in a freestyle. It probably can, but the ChatGPT API is not yet available, so I got the next best thing: OpenAI’s latest GPT3 model, Davinci3. Per the documentation, this model is the “most capable GPT-3 model. Can do any task the other models can do, often with higher quality, longer output and better instruction-following. Also supports inserting completions within text.” Since this model supports text completion and instruction following, I decided to use it to impute the next bar.

After I had the format and how to generate the next bar, I needed to pick a medium for the user to interact with the model. I’d been meaning to get into iOS development for a few months, so I decided to use this app as my intro. By having a mobile app, the app's usability significantly increases and allows anyone to have a smooth and well-designed platform to have a freestyle session. I considered building a web app for this project but wanted to prioritize the mobile version first because iOS was more interesting to me. My aim was to simulate the experience I had freestyling late at night in my friend’s car to classic hip-hop beats.

(Video) The first rap written and sung by an AI - ChatGPT crypto project x Snoop Dogg

(Video) Using A.I. To Make Drake Rap About Beans

The blueprint I created from my 3am thoughts threw me in the right direction of knowing what I needed to learn. I knew I needed to do two things:

  1. Learn how to use GPT3 to generate the next bar 🎼
  2. Learn how to build an iOS app 📱

One of those tasks was much more complex than the other.

Getting the next bar

Let’s start with the first of the two steps. OpenAI has a nice playground to mess around with different parameters and inputs to the model to see the resulting output.

FreestyleGPT: An AI Chat App that Generates Rap Lyrics (2)

I toyed around with this for a little bit and got solid results. This is the prompt I ended up using to get the desired output for the app:

(Video) Write Rap Song Using ChatGPT - Free AI Tool

FreestyleGPT: An AI Chat App that Generates Rap Lyrics (3)

I could generate a bar from any text by inputting the above prompt and tuning some of the available parameters to the API; however, this doesn’t mean the bar was always good.

I had trouble with the model returning a response that didn’t rhyme with the input, went completely off-topic, took too long to generate, made no sense in context, or repeated the rhyming word from the input. These issues are partially due to the current state of GPT3, but with the help of some parameter tuning and prompt engineering, I avoided them for the most part.

Learning iOS Dev

Coming into this project, I had zero experience in iOS development. This past summer, though, I did an internship focused on Android development, so I postulated that iOS and Android development would be similar. I’m very much a project-based learner, so I looked up Youtube videos about how to build basic apps in iOS. Upon this initial search, I realized there’s somewhat of a split in the iOS dev community about using SwiftUI or UIKit. SwiftUI is a newer framework that seemed easier to whip up an app with while UIKit is older.

I dabbled in UIKit through CodePath’s iOS course. It was decent and quite similar to Android, which I liked. Then I checked out SwiftUI through different Youtube tutorials. I found that SwiftUI was much easier for me to build nice UIs with and had fewer steps than UIKit, so in the interest of time, I decided to go with SwiftUI.

Once I picked up the basics of SwiftUI, I postulated what I needed to do to build this app. Basically, the app is a chat app between the user and an API. So, I needed to learn how to build a chat app and how to hit an API in Swift. To do this, I followed a tutorial about doing a similar task. This tutorial taught me the bare bones of what I needed to do. Then, I decided to put my own spin on the app. I did this by completely revamping the UI, changing the functionality of the app, switching up some API parameters, and adding more functionality to the app, such as the ability to play the freestyle created and clear current messages along with many other minor changes to make the app my own. Shoutout to my friends that gave me suggestions on how to improve💰.

(Video) I Used Artificial Intelligence to Make a Rap Album (Chat GPT)

FreestyleGPT: An AI Chat App that Generates Rap Lyrics (4)

I stayed up until 6am one night to build the entire project. Then, I spent a few hours the following weekend adding the finishing touches to the app. Here’s the demo:

This app accomplished the purpose of being a freestyle buddy at any time that anyone can use. I finally got to work in iOS development and look forward to creating more apps in the future. I also got to try out GPT3 in a different context than I had before.

What do you think about the app? How do you think it should be improved?

I enjoyed building out this app from scratch and learning two new technologies. The future of AI is looking bright, and I’d like to harness it to make more exciting apps.

If you enjoyed reading about this project, follow me on Medium. I write about my journey building projects like this one, such as predicting sneaker prices, generating conspiracy theories, or a spotify song recommendation system.

What are your thoughts on this project? Let me know in the comments.

(Video) Using A.I to Collab with Legendary Rappers

Feel free to reach out on LinkedIn and follow my work on GitHub. You can also see what I’m up to on my Twitter. All code for this project can be found on the GitHub here.

I appreciate you taking the time to check out my work, and I hope you enjoyed it. I pray you are well and many blessings come your way!



1. Nas - The Metaverse (AI Music w/Lyrics) [Beat by Sedivi]
(Hip Hop Intelligence)
2. I asked ChatGPT to write music
3. We used ChatGPT to make a BANGER - AI ARTISTS???
4. Eminem and Kanye freestylin (Written by ChatGPT)
5. Rick and Morty Rap (made with voice ai)
6. AI Learns to Write Rap Lyrics!
Top Articles
Latest Posts
Article information

Author: Errol Quitzon

Last Updated: 2023/02/02

Views: 6363

Rating: 4.9 / 5 (79 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Errol Quitzon

Birthday: 1993-04-02

Address: 70604 Haley Lane, Port Weldonside, TN 99233-0942

Phone: +9665282866296

Job: Product Retail Agent

Hobby: Computer programming, Horseback riding, Hooping, Dance, Ice skating, Backpacking, Rafting

Introduction: My name is Errol Quitzon, I am a fair, cute, fancy, clean, attractive, sparkling, kind person who loves writing and wants to share my knowledge and understanding with you.