Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for songs without lyrics #24

Merged
merged 27 commits into from
Jan 9, 2025
Merged

Conversation

wenbang24
Copy link
Contributor

One of my favourite songs, Swallow by Casiopea, does not have any lyrics (fusion jazz).
When I tried to use the CLI to make a poster, it presented me with this:
Screenshot 2024-12-28 at 11 01 02 AM
which would always show 'invalid range' no matter what I put in.

This pull request adds a check for if the returned lyrics are None, and raises NoLyricsAvailable.
It also allows users to make posters without lyrics: spotify.Spotify.track() now has a default of no lyrics. In the cli, the user will get an option not to paste lyrics if no lyrics are found.

Finally, it fixes a small line selection error in the docs (5-9 is five lines)

@TrueMyst TrueMyst added bug Something isn't working enhancement New feature or request documentation Improvements or additions to documentation and removed enhancement New feature or request labels Dec 28, 2024
@TrueMyst
Copy link
Owner

Hey there,

The PR looks fantastic! I’ve never come across that issue before, but thank you so much for addressing it. I’m currently on vacation, so I might not be able to properly merge it until next Monday or so, but I’ll do my best to get to it sooner.

Here are a few things I wanted to point out:

  1. The "5-9" in the docs was intentional. If you didn’t know, there’s supposed to be a line break between lines 6 and 7 in the lyrics of Saturn by SZA. You need to include that in the selection process, which gets stripped out later in the code.

  2. You don’t need to include the if __name__ == "main" block in prompt.py. According to Poetry’s documentation, defining a main() function is enough if you want to run the script as a CLI.

  3. LRClib contains almost all the lyrics, except for a few. Some of the missing ones are available on Genius. If you could double-check there, that would be awesome, but I understand it could get complicated, so it’s fine to leave it as is.

  4. The song you searched is instrumental, which explains why there are no lyrics. BeatPrints is meant to generate posters for songs with lyrics, so it’d be great if we could filter out instrumental tracks using Spotify.

Other than that, everything looks great!

@TrueMyst
Copy link
Owner

Or we could do one thing: instead of removing instrumentals, we could turn it into a feature by generating a different type of poster specifically for them.

@TrueMyst TrueMyst requested review from TrueMyst and removed request for TrueMyst December 28, 2024 13:45
@wenbang24
Copy link
Contributor Author

Hi!

Thanks for the feedback!

  1. whoops my bad
  2. Didn't know that, thanks!
  3. sounds good, ill try and implement that (i'll make it optional though since Genius needs an API key)
  4. nooooo pls dont filter them out, the posters still look nice without lyrics
    スワロー_by_casiopea_051 although it could be nice to add something else in place of the lyrics

@TrueMyst
Copy link
Owner

TrueMyst commented Dec 29, 2024

Hey!

Great to see you here!

Thanks for making those changes, they look good. Just a quick heads-up, no need to mess with the alternative lyrics search through Genius for now. That’s something we’ll save for v2. It’ll be a bigger update, so no rush on that.

Also, I’m not gonna filter the songs. But yeah, we do need a way to figure out if a song is instrumental or not. LRClib has this instrumental method,

20241229_102326.jpg

For Spotify, the Search endpoint doesn’t directly say if a track is instrumental, but the Audio Features endpoint has an instrumentalness attribute, which tells us how likely it is. It’s the best option.

20241229_104628.jpg

20241229_104610.jpg

So instead of checking whether the lyrics are available or not we should first check whether it's instrumental or not and then we proceed according to that.

Oh, and about the posters, some people suggested shrinking them for instrumental tracks since there’s no lyrics, but honestly, I’m not a fan of that. It’d look weird and just be a waste of resources. I’d rather fill that gap with something interesting. What do you think we should add?

@TrueMyst
Copy link
Owner

TrueMyst commented Dec 29, 2024

Anyways, sorry lol!!! I don't have my setup with me so I'm typing all of this with a phone. But it seems like you've already started working on genius, so I guess we should consider this as a minor update.

@TrueMyst
Copy link
Owner

If you want, you can come up with some prototype by using photoshop or photopea that you can show :))

@wenbang24
Copy link
Contributor Author

thanks for the feedback!

  1. yes, I agree that shrinking the posters would look weird, especially when putting songs with and without lyrics next to each other.
  2. didn't know that spotify had an instrumentalness feature (thats so cool lol) but yes ill try and implement a check before fetching lyrics
  3. as for what could be put in the empty space, maybe a play/pause/progress thing could look cool? I saw this etsy listing:
    image and maybe we could grab the bottom thing and put it in the empty space (im not much of a graphic designer lol but ill try and whip something up)
    also happy new year!

@TrueMyst
Copy link
Owner

TrueMyst commented Dec 31, 2024

I think it's best if we put some stats in the space, that would probably fix the problem.

And also happy new year to you :))

@wenbang24
Copy link
Contributor Author

after looking at the spotify documentation i found a few stats that we could include:

  • artist followers
  • a waveform visualisation of the audio (not really a stat but looks cool and ig is the equivalent of lyrics?)
    • although the spotify code already looks like a waveform
  • the album the song is from (wouldnt really work for singles though)
  • tempo
  • number of streams
  • position on charts (might need a different api like chartmetric and i dont think that one is free)
  • energy, danceability, etc. (does anyone actually look at this though?)
  • tags/genres
    which of these (or any others) do you think we should include?

@TrueMyst
Copy link
Owner

TrueMyst commented Jan 1, 2025

Hey!

So, we should probably avoid using too many third-party services. The more we rely on them, the messier it gets to deal with conflicts. Like, one might have a feature for a track or album, but another might not, so it’s best to keep things simple.

Here’s what I’m thinking:

We’ll use LRClib to check if a track is instrumental. If it is, we’ll pull some extra details from Spotify, like mood, genre, tempo, and stream count. For mood, we could use words like “Happy” if it crosses a certain threshold (e.g., x > 0.6). This way, we avoid empty spaces on the posters and keep them looking neat.

For tracks with no lyrics, I’m planning to add a sub-project under BeatPrints where users can upload lyrics to LRClib’s database. It’s a win-win. The more people use it, the more lyrics get added, and the fewer gaps we’ll have over time.

Also, I’m thinking of using textualize to make the CLI more fun and interactive in the future.

Oh, and about lyricsgenius, I think it’d be better to revert those changes for now. It’s just making things more complicated than they need to be.

Let me know what you think!

@wenbang24
Copy link
Contributor Author

sounds good! i'll start working on it
btw i've moved everything about lyricsgenius into a branch called genius on my fork (theyre not lost forever 👍)

@wenbang24
Copy link
Contributor Author

so turns out the only spotify api endpoint with genres is the artist endpoint (why don't they classify songs 😔)

@wenbang24
Copy link
Contributor Author

do you think we should keep the option for people to just have a blank poster without the instrumental text?

@wenbang24
Copy link
Contributor Author

wenbang24 commented Jan 3, 2025

also a lot of the songs in my jazz playlist aren't marked as instrumental (i dont think they're in lrclib database) so i changed it to not raise NoLyricsAvailable and just return the instrumental text

Edit: never mind, there was a bug in my testing script (whoops)
Edit 2: just in case, cli lets users pick whether to include instrumental text if instrumental is false and lyrics aren't found (i.e. not in lrclib database)

@TrueMyst
Copy link
Owner

TrueMyst commented Jan 3, 2025

Unrelated to pull request, but I can imagine getting addicted to getting these posters printed by professionals, which at that point probably means this tool won't really be as free as it claims to be for me 💸💸💸 😔

Honestly, same! That’s exactly why I made BeatPrints.. Etsy prices are no joke. The idea was to keep it budget-friendly, but hey, if you’re getting them professionally printed, your wall’s about to look 🎀

@TrueMyst
Copy link
Owner

TrueMyst commented Jan 3, 2025

do you think we should keep the option for people to just have a blank poster without the instrumental text?

I’d strongly recommend against it- I think a blank poster wouldn’t look all that great.

Since spotify.py, lyrics.py, and poster.py work together to make these, any issues can be fixed by tweaking how they connect to keep things running smoothly. If lyrics are not found, we can always prompt user to input it.

@wenbang24
Copy link
Contributor Author

wenbang24 commented Jan 3, 2025

I think a blank poster wouldn’t look all that great.

I agree, however i think having multiple instrumental posters next to each other all with the same text would look a bit weird.
What do you think? Maybe we could randomly pick from a list of instrumental texts?

@TrueMyst
Copy link
Owner

TrueMyst commented Jan 3, 2025

I forgot to mention, but the second text will be chosen randomly from a list. This way, it feels more natural and less repetitive. For now let's just focus getting this feature done. I might even fork your repo to make some nice changes :))

@wenbang24
Copy link
Contributor Author

anything else to do?

@TrueMyst
Copy link
Owner

TrueMyst commented Jan 4, 2025

Great, I'll look into the code and let you know! It might take some time, but hopefully I'll merge it as soon as possible.

@TrueMyst
Copy link
Owner

TrueMyst commented Jan 6, 2025

There are some bugs in your code, that I need to fix, as it may conflict with the API itself.

wenbang24 and others added 3 commits January 8, 2025 19:12
- added placeholders for instrumental tracks
- added method to check if a track is instrumental
- fixed prompt.py"
@TrueMyst
Copy link
Owner

TrueMyst commented Jan 8, 2025

I fixed some code, mind checking them? :)

cli/prompt.py Outdated

except errors.NoLyricsAvailable:
print("\n😦 • Couldn't find lyrics from sources.")
pasteLyrics = questionary.confirm(
"📋 • Would you like to paste the lyrics instead?", default=False
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a lot of instrumental songs are not in the lrcAPI database, so I think we should still give users the option to mark a track as instrumental?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking a track as instrumental when it actually has lyrics but the API doesn’t provide them doesn’t sit right with me. It feels misleading. A better approach might be to label it as “Lyrics Unavailable” or allow users to manually input the lyrics if they want. This keeps things accurate and avoids confusion.

@wenbang24
Copy link
Contributor Author

apart from that, everything looks great 👍 🎉

Copy link
Owner

@TrueMyst TrueMyst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright time to merge it in!

@@ -30,7 +30,7 @@ To generate a track poster, follow the steps below.
# Get the track's metadata and lyrics
metadata = search[0]
lyrics = ly.get_lyrics(metadata)
highlighted_lyrics = ly.select_lines(lyrics, "5-9")
highlighted_lyrics = ly.select_lines(lyrics, "6-9")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be "5-9"

cli/prompt.py Outdated

except errors.NoLyricsAvailable:
print("\n😦 • Couldn't find lyrics from sources.")
pasteLyrics = questionary.confirm(
"📋 • Would you like to paste the lyrics instead?", default=False
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking a track as instrumental when it actually has lyrics but the API doesn’t provide them doesn’t sit right with me. It feels misleading. A better approach might be to label it as “Lyrics Unavailable” or allow users to manually input the lyrics if they want. This keeps things accurate and avoids confusion.

@TrueMyst TrueMyst merged commit dc09f43 into TrueMyst:main Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants