Roon Extension: AI Guest DJ | Open AI for Roon

Hi all!

I have been playing around with OpenAI / ChatGPT and created a Roon extension that goes with it. It’s inspired by the Sonic Sage feature currently available in Plex Amp.

Short description:
Extension that uses OpenAI to generates playlists based on a prompt

Description:
This extensions uses OpenAI (using your own API Key) or ChatGPT (requires GPT Plus) to generate playlists. It currently has the following features:

  • Use GPT-4 or GPT-3
  • Verifies songs with Spotify (for cover image and song names)
  • Matches songs with your Roon library
  • Option to select a different versions of a song
  • Show OpenAI search history and spent tokens

Requirements
Using the Open AI feature of the extension requires an Open AI API Key. You can find your API keys in your User settings of Open AI. It also requires a “Pay-as-you-go” account with sufficient credits.

Installation
Installing the AI Guest DJ extension can be done via Docker or using NPM. See the Github or NPM link below. It is build using Next.Js so it requires a minimum node version 18.

NPM Library
Github

Once installed, visit an official Roon Client:

  1. Go to Settings > extensions
  2. Click the “Enable” button besides “AI Guest DJ”

Known Issue
Sometimes the GPT returns an invalid JSON object. Which cannot be parsed directly. I’m working on a fix for this

Example playlists
With your prompt a playlist is generated and stored. Below you some examples of generated playlists.
Jazz Rap Vibes
Upbeat Party
Classical Piano

More info
https://aiguestdj.com/

Have a look on Github or aiguestdj.com for more info. Or ping me here to get support.

Screenshots

5 Likes

This is very, very cool. Thanks for creating and sharing it.

It’s very clever how you set this up. This is the first time that I’ve used a GPT that (indirectly) influences something in my home.

I’m able to use it from the ChatGPT site but when I try to use it via the extension, I get this error:

It doesn’t matter whether or not I have “Use GPT-4” enabled.

I do plan to play with this further - it’s a really cool addition to Roon. Thanks again!

Thanks! Strange that this is happening. I’ve just updated the extension so it gives you more meaning full messages. My first thought would be that the API key is not correct.

Which installation method did you use to install the extension? I’ve mostly been using the docker/portainer setup during testing.

In the meantime you could also use the custom GPT

Hi.

I stood up your Docker container. Thanks for providing that option.

I created a new API key. Using the Custom GPT works fine, though I’ve had it error out a couple of times.

I picked up your updated container. This is the updated error I now see with the extension. No stack trace on mine.

A bit more. When using your updated container and the extension with GPT-3 (3.5?), I was getting a “Network Error”. I tried it a few times and it changed to this:

Is the API key I provide you used when using the custom GPT? Or is it only used with the extension?

When using the Open AI feature in the extension it uses the API key that you provide. The only place where the API key is present is in the environment variable due to security concerns. It doesn’t use that key with the custom GPT. But I’m not sure how Open AI measures quotas. I haven’t experienced a lot of quota limitations using the API.

It seems to be a credits/account-type issue. Could you check if your account is setup in such a way that it supports GPT-4?

Using Open AI API or a custom GPT requires an Open AI account with sufficient credits. In most scenarios the “Pay as you go” approach with the API is the cheapest. I played around with the API a lot and it takes some effort to reach the $20 mark.

Edit: I also noticed that sometimes it fails to return a valid JSON object. I’m working on a solution for this.

Thanks for the help!

My question about API key usage wasn’t regarding where it’s stored, but about where it’s used. You were clearly wondering if I’d set it up correctly in my yaml file. I was trying to figure out if the fact that the custom GPT worked was an indicator that I had.

I have a ChatGPT “Plus” subscription. I thought that was enough to get me API access but you’re correct that it isn’t. I set up a billing/quota for API usage and I’m able to use the extension now. You might want to specifically clarify this.

I showed this to my wife and she was pretty excited. She prompted something like:

“An EDM mix for working out. Tracks should be at least 80 BPM and high energy”

She liked what she got but one oddity about the mix is that it had at least one track on it that was a karaoke version of a well-known contemporary song. I wonder if your GPT prompt could be modified to say something like:

“Do not include karaoke versions of songs unless you have been explicitly asked to do so” or something like that.

Anyhow…thanks again!

Edit: Watchtower picked up your latest which does now display stack traces :slight_smile:

1 Like

Great to hear that it’s working! I will update the extension this week with your suggestion. My first thought is to add the option to view and modify the instructions passed to OpenAI.

I’m also working on a user area to view, modify and expand previously created playlists. This will also include the option to remove songs from the generated playlist. Building this area will take a bit of time though.

@gTunes A new version is ready in docker. With the option to modify the way Open AI is handeling prompts.

@DrCWO Would it be possible to add this extension to RooExtend as well? Or does RooExtend always require node version 8. The UI is build using Next.JS and that has a minimum node version of 18.

Hi Jaap, noce work!
Node 18 will be fine :smiley:
I currently offer rooAIDJ that also offers to get playlists with ChatGPT. With it an iOS App is available for iPhone, iPad, Mac and Apple Watch.

But this already attracts my attention and @Klaus_Engel will try soon. After discussion with him we will decide what to do.

Best DrCWO

Awesome! Unfortunately I don’t have any Apple mobile devices so I can’t check out rooAIDJ. But the video looks awesome.

Let me know what I need to do if you decide to add the extension to rooExtend.

This won‘t happen before I‘m back from my South East Asia trip end of April. So you have all your time for further improvements.
Is your Roon Extension compatible with the Roon Extension Manager?

Good to know, sounds like a great trip!

How can I verify the compatibility with the extension manager? I now simply use the roon-kit to make it work. I couldn’t find any where to add my own extension to the extension manager.

Thanks for the update! I should have time to play with it later today.

rooExtend, from @DrCWO, supports Roon Extension Manager and my recommendation would be for you to get your extension into it. That would mean that anyone running Roon Extension Manager, on any platform, would have access.

The documentation you need for this is here: https://github.com/TheAppgineer/roon-extension-generator/blob/master/README.md

Since extensions running in Extension Manager run in docker containers, and you’ve already worked most of that out, it might be pretty straightforward for you to get yours working there.

Hope this helps!

1 Like

Hi.

I have a question about the new feature which allows for modifying how OpenAI handles prompts.

Can you confirm that this is the new UI?

I assume you have a large, more complex prompt somewhere that tells ChatGPT that it is an expert DJ who is going to make playlists on request. Is that correct? So this supplements that?

That’s correct. This only appends to some larger explanation of how it should respond. The goal is that you should be able to finetune your personal preferences. My configuration is currently as follows:

Each playlist should contain at least 30 songs.
You should create meaning-full matches between the songs.
Do not include any instrumental or karaoke songs.

I like larger playlists. But it does take a bit longer to generate those and it costs more tokens.

Thanks for the docs of the extension-manager. It seems pretty straight forward so I will dive into that as soon as I get the chance.

1 Like

I’m curious to try this playlist generation. Can you share an idea of the cost of tokens to generate one of your longer playlists?

I like longer playlists with 200-300 tracks.

Thank in advance.

I’ve played around a bit and to be honest it’s a challenge to get to 200. Often it simply denies the request saying that it cannot create a playlist with that data (GPT-3.5) or it only returns 25 tracks (GPT-4). Only when adding multiple genres to the request I got to something a bit larger.

The created playlists seem to cost around the 1700-2000 tokens. Even the larger one.

Using Chat-GPT confirms my thoughts as it begins saying “Generate a playlist of at least 200 songs is challenging”. The first try ended with 15 songs only.

Please share your findings when you do play around with it! The first feeling I have is that you really need to specify a broad selection with multiple genres and multiple era’s.

Hi all :wave:

A month has passed and I had some time to work on an update for AI Guest DJ. It has now been added to the Roon Extension manager so the installation process is way easier! Thanks @Jan_Koudijs for your help :muscle:

Note: I was forced to rename the docker repository name for it to work with the Roon Extension Manager integration. So the original docker image is not updated. My advice would be to simply re-install via the extension manager.

New features:

  • Handle larger playlists better like this one
  • Browse previously created playlist (by you and others)
  • Like playlists in the Browse section
  • Plex integration (for those who are running Plex and Roon)
  • You can click on the “AI Guest DJ” link in the extension manager to go to the extension

I’m still working on some new parts but if you have any feature requests, just let me know!

=====
Installation screenshots (Roon Extension Manager):

1 Like

Spotify getting into the mix!

1 Like