Code Monkey home page Code Monkey logo

Comments (5)

teticio avatar teticio commented on May 30, 2024

The code should still work for your local files. What error do you get? I did rewrite the code for generating playlists more efficiently but that is in the deej-ai.online-app project which is linked to Spotify as you say. There is a more efficient way of generating the vectors using the calc_mp3tovecs and calc_tfidf scripts in the train directory. They were written with Spotify preview mp3s in mind, but will work with any (flat) directory of mp3s (MP3ToVec.py will work with nested directories).

from deej-ai.

Chaphasilor avatar Chaphasilor commented on May 30, 2024

Not getting any error so far, other than the CLI not accepting "foreign" tracks when the web tool does. I was just looking to re-use part of the integration work that you did for Spotify :)

I'll give it a go, maybe it's easier than expected ^^

from deej-ai.

teticio avatar teticio commented on May 30, 2024

I'm not sure I understand. Can you give a more detailed example of what you are trying to do and what you mean by CLI / web tool in this context? Thanks!

from deej-ai.

Chaphasilor avatar Chaphasilor commented on May 30, 2024

Sure!

As described in the readme, I ran the following command: python MP3ToVec.py Pickles mp3tovec --scan c:/your_music_library (with an updated path of course). Now I can start the web tool by running python Deej-A.I.py Pickles mp3tovec.
At the top, there's an area where I can simply drag-and-drop an mp3 file, and it will generate a mix based on that song. That can be any mp3.

However, I'm trying to generate m3u playlists instead, because this allows me to use the created mix in Jellyfin. Therefore, I'm running the command python Deej-A.I.py Pickles mp3tovec --playlist playlist_outfile.m3u --inputsong startingsong.mp3.
The problem seems to be that "startingsong.mp3" has to be in the existing keys, because if I use a path that was not within the scanned directory from the first command, I get the following error:

nsongs 10  
36 MP3s
Outfile playlist: playlist_outfile.m3u
Input song selected: C:\Users\Chaphasilor\Desktop\test.mp3
Requested 10 songs
Traceback (most recent call last):
  File "C:\Users\Chaphasilor\Code\Deej-AI\Deej-A.I.py", line 491, in <module>
    tracks = make_playlist([input_song], size=n_songs + 1, noise=noise, lookback=lookback)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Chaphasilor\Code\Deej-AI\Deej-A.I.py", line 208, in make_playlist
    similar = most_similar(positive=playlist[-lookback:], topn=max_tries, noise=noise)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Chaphasilor\Code\Deej-AI\Deej-A.I.py", line 179, in most_similar
    mp3_vec_i = np.sum([mp3tovec[i] for i in positive] + [-mp3tovec[i] for i in negative], axis=0)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Chaphasilor\Code\Deej-AI\Deej-A.I.py", line 179, in <listcomp>
                        ~~~~~~~~^^^
KeyError: 'C:\\Users\\Chaphasilor\\Desktop\\test.mp3

If I use a path from C:\\your-music-library\, it all works fine.

As for what I'm trying to do, in the end:

  1. Pass the Jellyfin ID of any song to Deej-AI
  2. Have Deej-AI analyze the song and generate a playlist of similar tracks from my library
  3. Output the Jellyfin IDs of all songs in the playlists, so that I can add them to the queue

That means I need to:

  • generate the waveforms/vectors based on my entire library
  • pass the Jellyfin ID to Deej-AI
  • have Deej-AI output a list of Jellyfin IDs

Given that you've done something very similar for Spotify (plus the whole downloading previews part), I was wondering if there was a way to build on top of the Spotify stuff, or if I would need to implement my own solution that translates Jellyfin IDs to file paths, passes that to Deej-AI, and then translates the resulting file paths from the playlist file back to Jellyfin IDs. But that would be cumbersome, that's why I would like to use Jellyfin IDs all the way through, just like you did with Spotify IDs (I assume).

from deej-ai.

teticio avatar teticio commented on May 30, 2024

Sorry for the delay.

Yes, the JoinTheDots.py script is expecting you to give it an already analyzed mp3, and the only way of knowing that is to pass the "key". The DeejAI.py script that runs the Flask webapp has some extra code which analyzes any mp3 track on the fly and then builds the playlist based on this, so you could take this code. But, as I say, these scripts are a bit old and clunky. If you are going to do anything at all serious, I would take inspiration from the train/calc_mp3tovecs.py, train/calc_tfidf.py and deej-ai.online/backend/deejai.py scripts. You would need to use the first two to pre-calculate the vectors for your entire library and you could adapt the functions to analyze a track and create playlists etc from the latter. I regret not having made the deejai.py code a bit more modular by separating out the Spotify dependencies, but I haven't really had the time to do that.

Good luck!

from deej-ai.

Related Issues (20)

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.