SongGen FoundryVTT Module
SongGen is a FoundryVTT module that integrates with Suno API for generating songs and OpenAI API for creating karaoke lyrics from ambient sounds. This module allows you to dynamically create music for your game sessions and add karaoke effects to your ambient sounds.
Features
- Song Generator: Generate custom music using the Suno API.
- Karaoke Mode: Transcribe ambient sound audio and display synchronized lyrics using OpenAI's Whisper and GPT-4 models.
- Macro Integration: Automatically saves the karaoke sequence as a macro for future use, avoiding repetitive API calls.
Setup Guide
1. Suno API Setup
Obtain Suno API Cookie
- Visit Suno.ai: Go to Suno.ai and log into your account.
- Open Developer Tools: In your browser, press
F12
or right-click and selectInspect
to open the Developer Tools. - Go to the Network Tab: Click on the "Network" tab and refresh the page.
- Find the Cookie: Locate a request with the keyword
client?_clerk_js_version
in its name. - Copy the Cookie: Click on the request, go to the "Headers" tab, find the
Cookie
field, and copy the entire value.
Deploy to Vercel
-
Clone and Deploy: Click the button below to clone the Suno API project and deploy it to Vercel:
-
Add Environment Variable: In the Vercel dashboard, add the environment variable
SUNO_COOKIE
with the value of the cookie you copied from the previous step.
Run Suno API
- Deploy the Project: After configuring the environment variable, deploy the project.
- Test the Deployment: Visit
https://<your-vercel-domain>/api/get_limit
to confirm the deployment is successful. You should see your API usage and limit information.
2. OpenAI API Setup
Obtain OpenAI API Key
- Sign Up/Log In: Go to OpenAI and create an account or log in if you already have one.
- Create API Key: Navigate to the API section and create a new API key.
- Copy API Key: Make sure to copy the key and store it securely, as you'll need to input it into the module settings.
Installation in FoundryVTT
- Download the Module: Install the SongGen module via FoundryVTT's Add-on Modules interface.
- Configure Settings:
- Open the module settings and set the Suno API Base URL to your deployed Vercel app's URL.
- Set the OpenAI API Key to the key you generated from the OpenAI platform.
Usage
Song Generator
- Open the Song Generator: Click the "Piano" icon on the left sidebar and select the "+" button to open the Song Generator form.
- Fill in the Details: Provide the song theme, tags, title, and whether you want instrumental or vocal music.
- Generate and Download: Click "Generate Song" to create the music. The song will automatically be downloaded to your computer.
Karaoke Mode
- Select an Ambient Sound: Go to the Ambient Sound Controls and select the sound you want to add karaoke effects to.
- Run Karaoke: Click the microphone stand icon in the Ambient Sound Controls toolbar. If a macro for the selected sound already exists, it will be executed. Otherwise, the module will generate lyrics, create a sequence, and save it as a macro for future use.
Troubleshooting
- API Key Issues: Ensure your OpenAI API key is correctly set in the module settings.
- Deployment Errors: Double-check your Vercel environment variable setup and make sure the Suno API is correctly deployed.
Contributing
Contributions are welcome! Feel free to fork the project and submit a pull request. If you encounter any issues, please report them on the project's GitHub page.
License
This module is released under the MIT License. See LICENSE
for more details.