Giter Club home page Giter Club logo

lyrics_cloud's Introduction

lyrics_cloud

Trying things with music lyrics.

Installation

You need to set a python environment (tested version: 3.10.5). Then, in your shell, type:

git clone [email protected]:MiguelLaura/lyrics_cloud.git
cd lyrics_cloud
pip install .

Contributing

To install the Git hooks:

pre-commit install

Before committing, black and generate_readme.py will automatically run.

To change the README file, change README.template.md first and generate the README after (or let the pre-commit do it). You'll need to add the new functions to generate_readme.py in DOCS.

Usage

Command line

Get the lyrics to artists' songs

usage: python -m lyrics_cloud.artists_lyrics [-h] [--method [list,file]] --artists ARTISTS --output-file OUTPUT_FILE --token TOKEN

options:
  -h, --help            show this help message and exit
  --method [list,file]
  --artists ARTISTS     list of artists or text file with one artist per line
  --output-file OUTPUT_FILE
                        csv file to write the results
  --token TOKEN         token for the genius API (https://docs.genius.com/)

Recommender system

usage: python -m lyrics_cloud.content_based_recommender [-h] --artist ARTIST --csv-file CSV_FILE --title TITLE

options:
  -h, --help           show this help message and exit
  --artist ARTIST      artist singing the song to get recommendations from
  --csv-file CSV_FILE  csv file containing the lyrics
  --title TITLE        song title to get recommendations from

Word cloud

usage: python -m lyrics_cloud.word_cloud [-h] --artist ARTIST --csv-file CSV_FILE --title TITLE

options:
  -h, --help           show this help message and exit
  --artist ARTIST      artist singing the song to get recommendations from
  --csv-file CSV_FILE  csv file containing the lyrics
  --title TITLE        song title to get recommendations from

Scraper

get_artists_from_file

Function to get artists from a txt file.

Arguments

  • file str - name of the input file (txt format).

Yields

str - artist's name.

get_lyrics

Function to write lyrics from a list of artists into a csv file.

Arguments

  • artists list[str] - list of artists name.
  • output_file str - name of the output file (csv format).
  • token str - token for the genius API (https://docs.genius.com/).

Recommender

build_recommender_word2vec

Function to load and train the word2vec model on the corpus.

Arguments

  • corpus list[list[str] - corpus of songs.

Returns

model - trained word2vec model.

create_avg_word2vec_embeddings

Function to create the averaged word2vec embeddings.

Arguments

  • df_lyrics Series - lyrics.
  • model - trained word2vec model.

Returns

list[float] - lyrics averaged word2vec embeddings.

recommend_with_word2vec

Function to recommend a song based on a title and artist.

Arguments

  • idx int - index of the item to get recommendations from.
  • embeddings list[float] - averaged word2vec embeddings.
  • nb_reco int - number of recommendations to return.

visualize_embeddings

Function to visualize the word2vec embeddings.

Arguments

  • w2v - trained word2vec model.

Returns

dataframe - PCA dataframe.


Word cloud

generate_word_cloud

Function to plot a text word cloud.

Arguments

  • text str - text to output in the word cloud.

Utils

clean_lyrics

Function to clean the lyrics.

Arguments

  • lyrics str - lyrics of a song.

Returns

str - cleaned lyrics.

prepare_text

Function to prepare the text (remove stop words, punctuation, etc.).

Arguments

  • text str - text to prepare.

Returns

str - cleaned and tokenized text.

lyrics_cloud's People

Contributors

miguellaura avatar

Watchers

 avatar

lyrics_cloud's Issues

interface

  • to visualize lyrics
  • to select action to do

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.