Over the weekend, 16-year-old coder Samarth Jajoo combined his love for hip-hop with his precocious understanding of mathematics and computer programming to create a fake lyrics generator called lyrics.rip. As displayed in the site’s notes, it uses Genius' public API to generate the lyrics,
Song lyrics generator based on a genre (country, rap, R&B, rock) and an emotion (angry, happy, depressed). Lyrics are sampled statistically from real songs using Markov chains. Can we generate music with AI? Taryn Southern, a popular youtuber recently made the first album that was fully produced using AI! In this video, she'll talk.
As the Indian prodigy explained on Reddit, he coded the site in just six hours with a fellow intern at the start-up Repl.it named Linus Lee.
“I love hip-hop and was fooling around with these things called Markov Chains yesterday,” Jajoo wrote on Reddit. “I tried generating fake lyrics for artists based on their top 20 songs, and it was crazy to me how real they sounded. Six hours later, @thesephist and I built https://www.lyrics.rip!”
Check out some examples below:
Although artists like Lil Nas X, Rihanna, and Drake aren’t necessarily using lyrics generators to write their songs, artificial intelligence is already changing the way music is being made. In August 2018, former American Idol contestant and YouTube vlogger Taryn Southern spoke with The Verge about her album, I AM AI, which is entirely composed and produced by the AI platforms Amper, IBM Watson Beat, and Google Magenta.
“Using AI, I’m writing my lyrics and my vocal melodies to the actual music and using that as a source of inspiration,” Southern said. “I find that really fun, and because I’m able to iterate with the music and give it feedback and parameters and edit as many times as I need, it still feels like it’s mine in a sense.”
More recently, academic and experimental pop artist Holly Herndon built and trained an AI program called Spawn to help create her album, PROTO, which was released this May. She has said machine learning used by programs such as Spawn can play a pivotal role in avoiding sample issues.
“In nurturing collaboration with the enhanced capacities of Spawn, I am able to create music with my voice that far surpass the physical limitations of my body,” Herndon wrote in a 2018 press release. “Spawn is already pretty good at learning to recreate signature composition styles or vocal characters, and will only get better, sufficient that anyone collaborating with her might be able to mimic the work of, or communicate through the voice of, another.”
Create your own fake lyrics at lyrics.rip, and read about Markov chains here.
This article was updated to reflect that lyrics.rip uses Genius' public API.
NOTE: this repository has git submodules. So clone with --recurse-submodules.Learn about them here.
See the blog postWriting billion songs with C# and Deep Learningfor a detailed explanation how it works.
This project mainly serves as a demonstration ofGradient,our TensorFlow binding for C# and other .NET languages.
Other Gradient samples.
This is a deep learning-powered song lyrics generator, based onGPT-2, wrapped as a ASP.NET Core website.
It generates songs word by word (or rather token by token), usingthe statistical relationships learned by a deep learning model, calledGPT-2.The actual generator code is inGradientTextGenerator class.
Text generation is pretty slow even with a powerful GPU,so we have a bunch of caches in /Web to provide a better user experience.There is also PregeneratedSongProvider,which continuously creates new texts in the background to ensure clicking'Make Random' button gives an instant result.
Detailed explanation in a blog post
- Download and install Python and TensorFlow as described inGradient documentation
- Install Python package, called
regex
(python -m pip install regex --user
) - Install the latest .NET Core SDK
- After cloning the repository, enter the
Web
folder and rundotnet ef database update
.That should createsongs.db
file in the same directory. - Edit
appsettings.json
(seeappsettings.Development.json
for an example):- add
'DB': 'sqlite'
- modify
DefaultConnection
to'DefaultConnection': 'Data Source=songs.db'
- add
- Run
dotnet run web
. This should print some logs.Wait forNow listening on: http://
, then open that URL in the browser.It will take up to 4 minutes to generate the first song.
NOTE: training requires a lot of RAM (>16GB), and will be slow on non-GPU
- Download the original 117M GPT-2 model by runningone of download_model.* scripts in External/Gradient-Samples/GPT-2from the same directory.
- Download and extract any lyrics dataset (I usedEvery song you have heard (almost)!),and unpack it if needed.
- From the command line in the same directory (GPT-2), run
dotnet run train --include *.csv --column Lyrics path/to/lyrics/folder --run Lyrics
(change thecolumn
parameter to the name of the lyrics column in you dataset)
NOTE: dev instance was trained with
train -i '*.csv' --column=Lyrics Downloadsevery-song-you-have-heard-almost -r Lyrics --checkpoint=fresh --save-every=100 -n 3
.If training from IDE, set working directory to GPT-2(which should contain models
subfolder downloaded previously).- Interrupt training process, when samples start looking good.
- Try the trained model by running
dotnet run --run Lyrics