项目作者: ggiuffre

项目描述 :
Generate lyrics with TensorFlow and the Genius API
高级语言: Python
项目地址: git://github.com/ggiuffre/tf-lyrics.git
创建时间: 2020-02-27T21:29:19Z
项目社区:https://github.com/ggiuffre/tf-lyrics

开源协议:MIT License

下载


tflyrics

Generate intriguing lyrics with TensorFlow and an internet connection.

tflyrics is a Python package that allows you to easily select lyrics of
specific artists from genius.com, and train a deep
neural network to generate text that sounds similar to those lyrics. This
work was inspired from The Unreasonable Effectiveness of Recurrent Neural
Networks
and
Text generation with an
RNN
.

Usage

  1. from tflyrics import Poet, LyricsGenerator
  2. artists = ['Bob Dylan', 'Tim Buckley', 'The Beatles']
  3. gen = LyricsGenerator(artists, per_artist=5)
  4. p = Poet()
  5. p.train_on(gen, n_epochs=10)
  6. poem = p.generate(start_string='Hey ', n_gen_chars=1000)
  7. print(poem)

A LyricsGenerator object makes it easy for you to create a data pipeline
that feeds from the Genius API directly into a recurrent neural network; a
Poet object is a wrapper around a recurrent neural network.

You can find another, more data-intensive example on
Google Colab.
This example also shows that LyricsGenerator doesn’t need to wait for all
songs to be downloaded before providing the first training examples.

Note that the Genius API requires you to have an access token. Without
that, tflyrics won’t be able to get lyrics for you. You can get an access
token for free at docs.genius.com. Once you have
it you can either pass it under the token argument of a LyricsGenerator
constructor, or store it as en environment variable (with export GENIUS_ACCESS_TOKEN='<your token here>'). tflyrics will detect this
environment variable automatically, if it exists.

Installation

You can install this package with pip:

  1. pip install -q tflyrics

Or, if you want the latest (possibly not stable) version, you can install
tflyrics from source with:

  1. pip install -e git+https://github.com/ggiuffre/tf-lyrics.git#egg=tflyrics