Spectrum is an AI that uses deep learning to generate rap song lyrics.
View Demo
Report Bug
Request Feature
Open In Colab
Spectrum is an AI that uses deep learning to generate rap song lyrics.
This project is built using Python, Tensorflow, and Flask.
# clone the repo
git clone https://github.com/YigitGunduc/Spectrum.git
# install requirements
pip install -r requirements.txt
# navigate to the Spectrum/AI folder
cd Spectrum/AI
# pass verbose, epochs, save_at arguments and run train.py
python3 train.py -h, --help --epochs EPOCHS --save_at SAVE_AT --verbose VERBOSE --rnn_neurons RNN_NEURONS
--embed_dim EMBED_DIM --dropout DROPOUT --num_layers NUM_LAYERS --learning_rate LEARNING_RATE
All the arguments are optional if you leave them empty model will construct itself with the default params
Call eval.py from the command line with seed text as an argument
python3 eval.py --seed SEEDTEXT
or
from model import Generator
model = Generator()
model.load_weights('../models/model-5-epochs-256-neurons.h5')
generatedText = model.predict(start_seed=SEED, gen_size=1000)
print(generatedText)
- If you have tweaked the model's parameters while training initialize the model with the parameters you trained
# navigate to the Spectrum folder
cd Spectrum
# run app.py
python3 app.py
# check out http://0.0.0.0:8080
spectrum has a free web API you can send request to it as shown below
import requests
response = requests.get("https://spectrumapp.herokuapp.com/api/generate/SEEDTEXT")
#raw response
print(response.json())
#cleaned up response
print(response.json()["lyrics"])
epochs = 30
batch size = 128
number of layers = 2(hidden) + 1(output)
number of RNN units = 256
dropout prob = 0.3
embedding dimensions = 64
optimizer = Adam
loss = sparse categorical crossentropy
These hyperparameters are the best that I can found but you have to be careful while dealing with the hyperparameters because this model can over or underfit quite easily and GRUs performs better than LSTMs
>>> from model import Generator
>>> model = Generator()
>>> model.load_weights('../models/model-5-epochs-256-neurons.h5')
>>> model.summary()
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
embedding (Embedding) (1, None, 64) 6400
_________________________________________________________________
gru (GRU) (1, None, 256) 247296
_________________________________________________________________
gru_1 (GRU) (1, None, 256) 394752
_________________________________________________________________
dense (Dense) (1, None, 100) 25700
=================================================================
Total params: 674,148
Trainable params: 674,148
Non-trainable params: 0
_________________________________________________________________
>>> model.hyperparams()
Hyper Parameters
+--------------------------+
|rnn_neurons | 256|
|embed_dim | 64|
|learning_rate | 0.0001|
|dropout | 0.3|
|num_layers | 2|
+--------------------------+
>>>
See the open issues for a list of proposed features (and known issues).
WARNING: There is some offensive language ahead, please stop reading here if you are a sensitive person. The texts below have been generated by Spectrum
Seed : today
Prediction :
If that don't, yeah
Weint off the music
It's like a fired-enother foar fool straight for an exactly
Nigga why I id my Door Merican muthafucka
Ng answered by need for blazy hard
The family wish fans dishes rolled up
How better just wanna die
Match all about the moment in I glory
Fire is that attention is the flop and pipe those peokin' distriors
Bitch I been hard and I'm like the Scales me and we're going to school like all-off of the allegit to get the bitches
Yeah kinda too legit back into highin'
A year have it would plobably want
And we all bustin' the conscious in the cusfuckers won't ha
Quite warkie and it's blow, and what? I cannot love him,
Alugal Superman, and the revolution likes migh
I ain't still not I uest the neighborhoo
Powers all too bad show, you crite your bac
When I say way too fathom
If you wanna revell, money, where your face we'll blin
Pulf me very, yo, they pull out for taught nothin' off
I pass a with a nigga hang some, pleas
Fuck me now, it's a
======================================================================
Seed : hello
Prediction :
hellow motherfucker
You wanna talk on the pockets on Harlotom
I'm legit some more than Volumon
Ridicalab knowledge is blessin' some of your honierby man
We just bust the Flud joke with shoulders on the Statue
Lecock it on everybody want your dices to speak
While she speak cents look back to Pops
He was a nigga when I got behind pictures any Lil Sanvanas
Used to in her lady yaught they never had a bitch
He'll break the jird little rappers kill your children is
I'm prayin' back to ready for that bitch just finished And mised to the gamr
Every eyes on and about that getting common
I'm going to attractived with its
I just went by the crowd get the promise to buy the money-a star big down
Can one sall 'em in me tryna get them days that's how I can break the top
Well, that's hug her hands he screaming like a fucking hip-hop but put a Blidze like rhymin'
Yeah I slack like a Job let your cops got a generres
These West of it today flamping this
Black Kuttle crib, said "Ju Conlie, hold up, fuck the
======================================================================
Seed : bestfriend
Prediction :
bestfriend
Too much time we tonight
The way I know is a please have no self-back when I be for the fucking weed and a game
What the fuck we wanna be working on the streets make it like a stay down the world is from the head of the real brain
Chain don't come back to the grass
My dick is the one to tell you I'm the fuck
So see me we gon' be fans when you had to hear the window you come to the dick when a little cooleng and I was calling what the fuck is it good as the crown
And I'm representing you finally waitin' in your girl
This is the corner with my brother
I'm just a damn door and the real motherfuckers come got the point my shit is the money on the world
I get it then the conscious that's why I cripp
I might take my own shit so let me have a bad bitch
I'm just had and make the fuck is in the single of the window
I think I ain't got the world is all my gone be mine
They ain't like the half the best between my words
And I'm changing with the heads of the speech
Fuck a bunch of best of a fuck
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.