--- title: "songs" author: "Prof. Eric A. Suess" format: html --- I read the Medium post [Introducing geniusR](https://medium.com/@JosiahParry/introducing-geniusr-b0177ce7b4d7) a while ago and gave it a try. Since then this package has become the [genius](https://github.com/JosiahParry/genius) package, without the R. This package give access to the [genius](https://genius.com/) website so we can load song lyrics into R. This package does not require an API key. **Alternatively:** There are other packages that could be used to download song lyrics and other packages to download other information about songs. But they all seem to require registering to obtain an API keys. 1. The [geniusr](https://ewenme.github.io/geniusr/) package is an alternative to the [genius](https://github.com/JosiahParry/genius) package. Notice this is a different package then the package with a captial R, that became the genius package. 2. The [discogger](https://ewenme.github.io/discogger/) package can be installed from github. It can be used to download songs from the [discogs](https://www.discogs.com/) website. 3. The [spotifyr](https://www.rcharlie.com/spotifyr/) can be used to connect to the [Spotify](https://www.spotify.com/us/) API. ```{r} library(pacman) p_load(geniusr, tidyverse, tidytext, tm, wordcloud) ``` ```{r} genius_token() ``` How many times does Kanye West say Good Morning in his song Good Morning? ```{r} get_lyrics_search(artist_name = "Kanye West", song_title = "Good Morning") %>% # get lyric bigrams unnest_tokens(bigram, line, token = "ngrams", n = 2) %>% # look for good morning filter(bigram == "good morning") %>% # count bigram frequency nrow() ``` Lets download the lyrics for the Jimi Hendrix song Purple Haze from Genius. ```{r} Jimi_Purple_Haze <- get_lyrics_search(artist_name = "The Jimi Hendrix Experience", song_title = "Purple Haze") Jimi_Purple_Haze ``` Search Genius for Jim Hendrix songs. ```{r} search_artist(search_term = "Jimi Hendrix") Jimi <- search_genius(search_term = "Jimi Hendrix") Jimi ``` ```{r} get_song_df(song_id = 65315) ``` ```{r} Jimi_songs <- get_album_tracklist_search(artist_name = "Jimi Hendrix", album_name = "Are You Experienced [US Version]") Jimi_songs ``` ```{r} Jimi_lyrics <- rbind( get_lyrics_search(artist_name = "The Jimi Hendrix Experience", song_title = "Purple Haze"), get_lyrics_search(artist_name = "The Jimi Hendrix Experience", song_title = "Manic Depression"), get_lyrics_search(artist_name = "The Jimi Hendrix Experience", song_title = "Hey Joe") ) Jimi_lyrics ``` ```{r} Jimi_lyrics2 <- Jimi_lyrics %>% select(line, song_name) Jimi_lyrics2 ``` ```{r, warning=FALSE} par(mfrow=c(1,3)) Jimi_lyrics2 %>% filter(song_name == "Purple Haze") %>% select(line) %>% unnest_tokens(word, line) %>% count(word, sort = TRUE) %>% with(wordcloud(word, n)) Jimi_lyrics2 %>% filter(song_name == "Manic Depression") %>% select(line) %>% unnest_tokens(word, line) %>% count(word, sort = TRUE) %>% with(wordcloud(word, n)) Jimi_lyrics2 %>% filter(song_name == "Hey Joe") %>% select(line) %>% unnest_tokens(word, line) %>% count(word, sort = TRUE) %>% with(wordcloud(word, n)) ```