A simple Markov chains lyric generator written in Python.
This small project generate new lyrics based on the lyrics of a given artist. For example, you can ask the script to generate Pink Floyd-like lyrics, so it will read all the lyrics from Pink Floyd and generate a new one with the same style.
I've made a small "database" too, so whenever you load all lyrics from a given artist it will be saved on your computer under the db folder. This way we can avoid a lot of API calls (that are quite expensive).
- PyMarkovChain (install it using
pip3 install PyMarkovChain
) - requests (install it using
pip3 install requests
) - Wikya Lyrics API (you don't need to install/configure it)
- Python 3
The program expects the following arguments:
python3 py-simple-lyric-generator.py "<name of the artist>" <number_of_phrases_to_generate>
For example, if you want to generate 10 sentences based on Pink Floyd lyrics you should run:
python3 py-simple-lyric-generator.py "Pink Floyd" 10
Then you'll get somewhat like that:
I'd be gone
Cause I'm the man on the outside looking in
Playing to rules
Lotuses lean on each other in yearning
The Schoolmaster
And all that you see
And if you don't mind
It's awfully considerate of you to leave, Lucy
Wheeling, soaring, gliding b Instrumental He made his way to the see-saw It's awfully considerate of you to think of me here
Don't accept that what's hap One sound, one single kiss
If you want to reset cached artists from the database, just run the following:
chmod +x clean_db.sh
./clean_db.sh
This's my first experiment within lyrics generation with Markov chains, but I've read some texts and a lot of examples. In order to understand how can I generate lyrics, please check the following links:
- Lyricize: A Flask App to Create Lyrics Using Markov Chains [very useful]
- Text generation with Markov chains
- Generating pseudo random text with Markov chains using Python
And here you can check some projects on Github that helped me:
- Lyrics Can Be Easy
- taytay [Taylor-Swift-like lyric generator, I really want to read their code, they have awesome results]
- PyMarkovChain
The py-simple-lyric-generator
was created by Fernando Paladini on 01-17-2016, but it was heavily based on another open-source projects you can find at the web. If you have any issue, doubt, problem or suggestion, please feel free to create a new Issue or even contact me at fnpaladini at gmail dot com.