Coder Social home page Coder Social logo

robbiebarrat / rapping-neural-network Goto Github PK

View Code? Open in Web Editor NEW
1.0K 65.0 167.0 18.44 MB

Rap song writing recurrent neural network trained on Kanye West's entire discography

Python 100.00%
neural-network lyrics songs rhymes machine learning rap rap-songs generative-art songwriting

rapping-neural-network's Introduction

Rapping-neural-network

This is a generative art project I made for my high school's programming club - which I'm the president/founder of I was the president/founder of until I graduated.

It's a neural network that has been trained on Kanye West's discography, and can use any lyrics you feed it and write a new song word by word that rhymes and has a flow (to an extent).

Quartz did a really nice profile on me and the program here; https://qz.com/920091/a-west-virginia-teen-taught-himself-how-to-build-a-rapping-ai-using-kanye-west-lyrics/

UPDATE: Here's a Google Colab notebook that runs the project: https://goo.gl/GHSWzZ

Let's hear something it made

Okay... Here's a song it wrote word by word using kanye's discography - excuse the vulgarities, the neural network wrote it and not me. https://soundcloud.com/rapping_neural_network/networks-with-attitude

Lyrics to above song

Click to expand

Bust a playa with the kids I never had

All his time, all he had, all he had, all he had

Most you rappers don't even stop to get the most press kit

Playas is jealous cause we got the whole city lit

But without it I'd be worried if they playing that bullshit

You wanna complain about the nights even wilder

I swear to God I hope you have got to hear

I'll touch every curve of your favorite author

No more wasting time, you can't roam without Caesar

Back when Gucci was the best summer ever

Before Cam got the hundred with the peer pressure

She walking around looking like Herve Leger

So next time I'm in between but way more fresher

And they say you never know, never never NEVER

...

You the number one I'mma beat my brother

And I know a sign when I heard it's the magic hour

Get Olga Kurylenko, tell her to do better

That know we get them hammers, go on, call the lawyer

But still supported me when I get richer

This my first pair of shoes, I made the Bulls play better

Or use my arrogance as a wholesaler

Prince Williams ain't do it can't be your damn liar

You say I dress white, but my broad way thicker

If I be Don C, we got that, that thing clear

I dropped out of your body like a wrestler

I can't believe I'm back to a cold killer

Lady Eloise I need another lover

He loved Jesus when he off the power

So I pour the potion, so we gone dress whiter

Old folks talking bout Linda, from last September

Might spend 50 racks on my life like a fucking loser

...

He don't even stop to get this difficult

She told me that I stayed at home with my own vault

She's so precious with the space for the safe belt

Girl he had the strangest feeling lately

Fuck you playa I know it's especially

But let some black people to think logically

Fire Marshall said I could give you this feeling

And wrote hooks about slaves that the youth is missing

I know this part right here, history in the ring

Well I guess she was messin wit me when I'm cumming

I'm way better than some head on a chain gang

On a scale of this, and now you doing your thang

Y'all I know you're living your life so exciting

Started a little blog just to say nothing

I'mma need a fix, girl you was celebrating

Mayonnaise colored Benz I get my engine revving

And my chick in that old lady on Boomerang

Wifey gonna kill me, I do a gangbang

I put an angel in your life so exciting

Right when I do it right if you was celebrating

I was in Benzes, I was still at Burger King

It feel like this but playas don't know what you're drinking

Really Doe told you come on homie they wilding

I swear this right here, feel free to sing along

Shoulda known that was gonna come as it's good I'm young

...

These playas read the pimp manual, but I just want your girl you was clubbin'

First I spin around and vomit, then I made it from the day you just pretendin'

But I bet you they respect the name Kanye from the heart, y'all all frontin'

We in the same thing like a fat trainer takin a bite or somethin

Abbey Lee too, I'm a jerk, you need that happy beginnin', middle and endin'

That mean I forgot better shit than you ever heard about all this name callin'

Cause I can never be as laid back as this flow end, I'mma let Mos begin

And I bet you they respect the name Kanye from the heart, y'all all frontin'

...

My mama used to stay recession free

All my friends says implants is a beat from Ye

I want is what I do, act more stupidly

With no response make you wait longer than A.C.

Loud as a shorty I looked up to this degree

Young Walt Disney, I'ma tell you once ting

Straight to jail, yo, in a Bentley shining

Why you trying to make it just ring and ring

Now why would I listen to T-Pain and sing

Everything I throw them all laughing

So glad I ain't gotta borrow nothing

So I promised her everything

I've been waiting on this rocket, Yao Ming

I don't drink the drama that your dude bring

Kanye West is the making of a romantic

Play strings for the World's game, this is tragic

...and this is the making of a romantic

I done wore designers I won't get specific

The layers to my roots, I'm like a paraplegic

Come on, let's take a lot more than the music

I mean, after all the way we was magic

...

Setup

Install (with python 2.x)

pip install -U -r requirements.txt 

Usage

See documented_model.py for notes as python comments.

Data preperation

If you'd like to use Kanye's lyrics - skip this section Lyrics.txt comes with Kanye's entire discography in it. You can either use this, or fill it with other lyrics.

Guide to using your own lyrics with lyrics.txt

  • Avoid including things like "[bridge]" or "[intro]"

  • Seperate each line by a newline

  • Avoid non alphanumeric characters (besides basic punctuation)

  • You don't have to retype everything - just copy and paste from some lyrics website

Training

Skip this part if you are using the default kanye lines

  • In model.py, change the variable artist to the name of the new artist you've used in lyrics.txt

  • In model.py, change the variable train_mode to True

  • Run the program with python model.py, and allow training to finish.

Generating raps

  • In model.py, if you've trained a new network, the variable train_mode will be True, set this back to False

  • Run the program with python model.py

  • The rap will be written to the output of your terminal, and also to a file called neural_rap.txt

Performing raps

  • speech.py will "rap" the generated songs with a text to speech over a generic rap beat (beat.mp3), just run python speech.py

How it works

Alright, so basically a markov chain will look at the lyrics you entered and generate new lines. Then, it feeds this to a recurrent neural net that will generate a sequence of tuples in the format of

(desired rhyme, desired count of syllables)

The program will then sift through the lines the markov chain generated, and match the lines to their corresponding tuples. The result is the rap.

Future goals:

  1. Use lyrebird.ai to have it rap in Kanye's voice... I'll probably have to hire a Kanye voice impersonator to supply me with 5 minutes of audio to train the net with though... Either that or jailbreak an old iPod and use it to do text to speech with Siri's voice.

  2. Bring back the seperate 'verses' and appropriate pauses that the first version had.

  3. Generative rap beats that it can rap over.

Once I get the lyrebird.ai thing working where it can rap and imitate someone's voice, I really want to do some type of 'album' where there's a separate track on it for each really popular dead rapper (The 90's had some really good ones, Notorious B.I.G., Big L, etc.) - where each track would have the network rapping with lyrics / flow in the style of the said rapper, and imitating their voice with lyrebird's network (admit it, the current text to speech I have is pretty trash). Kind of like an AI resurrection of dead rappers...

rapping-neural-network's People

Contributors

jc1987 avatar robbiebarrat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rapping-neural-network's Issues

Cannot generate new lyrics

I'd love to test the program but unfortunately I'm getting errors when I try to generate a new lyrics even with the default settings (as in without training it with new lyrics).

File "model.py", line 300, in <module> main(depth, train_mode) File "model.py", line 277, in main model = create_network(depth) File "model.py", line 29, in create_network model.load_weights(str(artist + ".rap")) File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 2701, in load_weights import h5py

I have tested it on a virtual environment and native, on a mac and on a linux (Ubuntu) but I'm getting the same error.
I'm using:
Python 2.7
Tensorflow 1.4.1
Keras 1.2.2
numpy 1.12.1

Any idea of what could be the cause of that?

Freezing on "word-by-word"

Using the following info I'm getting no progression (waited several hours) on a 300kb lyrics.txt file. Line by line works fine.

training = 0
epoch = 100
word_by_word = 1

Any suggestions on changes I could make?

Unicode decode error

Hi,
Great job, i am trying to generate raps with default kanye lines but i have the following error:
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 42992: character maps to

thanks for your help

OSX: No module named scipy

I got the following error when trying to run python deeprap.py on OSX.

I fixed the error by executing the following command: pip install scipy.

Maybe we can add scipy to the requirements.txt file.

Thanks for your work.

String index out of range

Hello,
I saw the #21 issue and I'm experiencing the same problem:
When i try to work with my lyrics (which are in french, for information), I've got this message:

Traceback (most recent call last):
  File "model.py", line 300, in <module>
    main(depth, train_mode)
  File "model.py", line 289, in main
    x_data, y_data = build_dataset(bars, rhyme_list)
  File "model.py", line 144, in build_dataset
    line_list = [line, syllables(line), rhyme(line, rhyme_list)]
  File "model.py", line 43, in syllables
    if word[0] in vowels:
IndexError: string index out of range

I tried to remove double spaces and I replaced "-" by "โ€”" but it still not work.

String index out of range?

Hello! This may be a silly question, as I am indeed a fresh newbie. Sorry for the inconvenience!

I've been trying to train a new set of lyrics, but I get the error described below. I figured I must have done something wrong with my lyrics file, despite having checked for weird punctuation and symbols and anything else that stood out. But I can't find out what it is - I even tried adding lyrics to the original Kanye lyrics file and it will take some new lyrics and train fine but eventually I'll add one that makes it break. What could I possibly be doing wrong?

Traceback (most recent call last):
File "model.py", line 300, in
main(depth, train_mode)
File "model.py", line 289, in main
x_data, y_data = build_dataset(bars, rhyme_list)
File "model.py", line 144, in build_dataset
line_list = [line, syllables(line), rhyme(line, rhyme_list)]
File "model.py", line 43, in syllables
if word[0] in vowels:
IndexError: string index out of range

Congratulations on your work, thank you for your attention and again - sorry if this is too pedestrian! I'm still learning. :)

Model Architecture ?

Hello, first of all, this work is cool ! Nice job !
I would like to ask what model is used by this project ?

problem with model.py on python 3

So it didn't work at all on python 2 so i changed the code a little to make sure it runs on python 3 and after fixing some issues the train mode worked, but when i tried to generate lyrics i ran into a problem
File "model3f.py", line 219, in calculate_score
score = 1.0 - (abs((float(desired_syllables) - float(syllables))) + abs((float(desired_rhyme) - float(rhyme)))) - penalty
TypeError: float() argument must be a string or a number, not 'NoneType'

i guess the issue is in rhyme function, it runs into an exception and returns None, not float needed and that causes the problem, but i dont know how to fix it.
Any suggestions? here are model files i use (t is for train and f is for generation mode)
I also changed artist name and all "rap" words to "lyrics" , i guess it doesen't affect anything
neural network.zip

That solved part of the issue, thanks

          That solved part of the issue, thanks

However now I run into this problem:
`=========
Total params: 2,248
Trainable params: 2,248
Non-trainable params: 0


Traceback (most recent call last):
File "model.py", line 300, in
main(depth, train_mode)
File "model.py", line 277, in main
model = create_network(depth)
File "model.py", line 29, in create_network
model.load_weights(str(artist + ".rap"))
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 2708, in load_weights
self.load_weights_from_hdf5_group(f)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 2781, in load_weights_from_hdf5_group
' elements.')
ValueError: Layer #0 (named "lstm_1" in the current model) was found to correspond to layer lstm_1 in the save file. However the new layer lstm_1 expects 12 weights, but the saved weights have 3 elements.

Originally posted by @littlevoices in #20 (comment)

anxcamera-permissions.xml

content://com.sec.android.app.myfiles.FileProvider/external/mnt/media_rw/420C-18FB/ANXCamera_v204R-2_alioth_fixed_portrait/system/etc/default-permissions/anxcamera-permissions.xml

how do i run this program?

I would like to know how to run your program. i installed the latest python, i opened windows cmd, typed py but that's all i know how to do...Can you help me run your program?

Pybrain help

I'm having a problem running deeprap.py in terminal, I keep getting a "No module named 'structure'" error. And I have Pybrain version 0.3.3 installed on my mac.

rhmyeindex() and rhyme() questions

As per @robbiebarrat's request, I am posting some questions I have about the Rapping Neural Network code in model.py so that others who may have the same questions in the future can see this.

Original Email:
Hello Robbie,

I am analyzing your code for your Rapping Neural Network project and trying to figure out what each part of your program does. Currently, I am stuck on the rhymeindex() and rhyme() functions in model.py. Near the end of the rhymeindex() function, you reverse the 2-letter endings in rhyme_master_list and sort them, then reverse them. However, when I print the rhyme_master_list on line 75 and the reverselist on line 77, reverselist is not the reversed 2-letter endings from rhyme_master_list and I'm not sure why that is. Overall on this last part, would you be able to explain the reasoning behind having the reverselist and what you are meaning to do here?

For the rhyme() function, I am confused as to what the purpose of the float_rhyme is. I see it is being used in build_dataset() to construct the 2x2 input for the network. But how does the LSTM use this to help construct a rap?

If you have time to explain these to me, I would be very grateful.

.rhymes file not getting rhymes

I modified some of the code to work (as this repo hasn't been updated in a while), and the training/generating works, other than the fact that the rhymes aren't saved and therefore the final rap doesn't rhyme. Granted, I am using 16000 lines of Eminem's discography, so that may be the issue. Thanks in advance anyone who can help.
Zipped Files:
Diss-Track-Rapping-NeuralNet.zip

Freezing on word by word

I have edited my lyrics file so that when training the error message:
("Hm, for some reason we couldn't do anything with this line - remove symbols from it and try again: ")
doesnt show but when generating mode is on word by word still freezes
line by line works though

privapp-permissions-anxcamera.xml

content://com.sec.android.app.myfiles.FileProvider/external/mnt/media_rw/420C-18FB/ANXCamera_v204R-2_alioth_fixed_portrait/system/etc/permissions/privapp-permissions-anxcamera.xml

max() arg is an empty sequence error when generating rap

Hi,
I got this error when I try to generate rap with my custom training data.

Traceback (most recent call last): File "documented_model.py", line 412, in <module> main(depth, train_mode) File "documented_model.py", line 405, in main rap = vectors_into_song(vectors, bars, rhyme_list) File "documented_model.py", line 356, in vectors_into_song max_score = max(fixed_score_list) ValueError: max() arg is an empty sequence

Do you have an Idea of where it come from ?

Thanks in Advance.

Unique lyrics?

This script works well for reordering existing bars.

Does anyone know a way to generate unique lyrics?
Maybe by taking multiple lines and combining them, or using paraphrases?

Rhyme with last 3 characters

Hi,
I wanted to use the rhyme for German Lyrics. Therefore it would make sense to use the last 3 characters of the last word for rhyming.
What do I need to change?
I changed two functions, rhymeindex:
rhymeslistends.append(i[-3:])
rhymescheme = word[-3:]
and rhyme:
rhymeslistends.append(i[-3:])
rhymescheme = word[-3:]
When I train the model the file .rhymes has a list of 3 characters. When I run the script for generating the rap it is just empty.
The function score returns nan as desired_syllables and desired_rhyme are nan. Could you give me an advice what to change as well?
Thanks!

If epochs are defined, folder names stay default

First off, very nifty script and it's easy to work with. Maybe I'm misunderstanding something but when I define a specific epoch count

training = 1 #training of 0 means you just want to have it write a rap - training of 1 will train the network on the contents of lyrics.txt
epoch = 105 #this is just the number of the folder you would like to load (folder contains the trained net and rhymes)

I still get folders 100, 200, etc. (e.g., "just wrote 100/...").

Another question is when the training concludes? I'm up to epoch 400 now.

Non-Rap

Could this be made to make non rap style lyrics? like say every rage against the machine lyrics were put in, would it turn into rap style lyrics?

Error in running model.py

When I try to generate the lyrics, I get the error:

ValueError: Layer #0 (named "lstm_1" in the current model) was found to correspond to layer lstm_1 in the save file. However the new layer lstm_1 expects 12 weights, but the saved weights have 3 elements.

How can I correct this?

TypeError: Received unknown keyword arguments: {'epochs': 5}

Hello!
Thanks for you work, it's really nice (especcially a idea of generating kanye songs :) )

But i have a trouble,
I'm trying to training model (by python model ), and after Alright, building the list of all the rhymes and show all bigram, get this:

Traceback (most recent call last):
File "model.py", line 300, in
main(depth, train_mode)

File "model.py", line 290, in main
train(x_data, y_data, model)

File "model.py", line 273, in train
verbose=1)

File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 661, in fit
str(kwargs))

TypeError: Received unknown keyword arguments: {'epochs': 5}

My environment:
Ubuntu 64bit,
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.