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

[feature] Add command for track predictions #1

Open
AntonVanAssche opened this issue Nov 24, 2024 · 0 comments
Open

[feature] Add command for track predictions #1

AntonVanAssche opened this issue Nov 24, 2024 · 0 comments

Comments

@AntonVanAssche
Copy link
Owner

Description:

This feature would introduce a new command: predict which would accept the playlist_id as argument. The goal is to predict and recommend songs for a given playlist based on its audio characteristics and the user’s playlist.

Command Syntax:

  • Base command: jamjar predict <playlist_id>
  • Options:
    • amount: jamjar predict <playlist_id> --amount 5

Functionality:

  1. Analyze the audio features of tracks within the specified playlist using Spotify’s /audio-features/ endpoint.
{
  "acousticness": 0.00242,
  "analysis_url": "https://api.spotify.com/v1/audio-analysis/2takcwOaAZWiXQijPHIx7B",
  "danceability": 0.585,
  "duration_ms": 237040,
  "energy": 0.842,
  "id": "2takcwOaAZWiXQijPHIx7B",
  "instrumentalness": 0.00686,
  "key": 9,
  "liveness": 0.0866,
  "loudness": -5.883,
  "mode": 0,
  "speechiness": 0.0556,
  "tempo": 118.211,
  "time_signature": 4,
  "track_href": "https://api.spotify.com/v1/tracks/2takcwOaAZWiXQijPHIx7B",
  "type": "audio_features",
  "uri": "spotify:track:2takcwOaAZWiXQijPHIx7B",
  "valence": 0.428
}
  1. Generate a set of recommended tracks based on similarities in audio characteristics (e.g., danceability, energy, valence) or patterns in the user’s playlist history.
  2. Output the results in JSON format, suitable for further processing or visualization.

Example Output:

{
  "predictions": [
    {
      "track_name": "New Track 1",
      "track_url": "https://spotify.com",
      "artist_name": "Artist A",
      "likelihood": 0.92,
      "audio_features": {
        "danceability": 0.85,
        "energy": 0.88,
        "valence": 0.7,
        "tempo": 120
      }
    },
    {
      "track_name": "New Track 2",
      "track_url": "https://spotify.com",
      "artist_name": "Artist B",
      "likelihood": 0.85,
      "audio_features": {
        "danceability": 0.65,
        "energy": 0.75,
        "valence": 0.8,
        "tempo": 105
      }
    }
  ]
}

Require Changes:

  1. Integration with Spotify’s /audio-features/ endpoint.
  2. Database: Update the tracks table to store the required audio features. This may require a migration script.
  3. Algorithm for recommendations.
  4. Command logic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant