Remix Your Music with sakemin/musicgen-remixer Cognitive Actions

24 Apr 2025
Remix Your Music with sakemin/musicgen-remixer Cognitive Actions

In today's digital age, music creation has evolved significantly, allowing developers to leverage advanced tools for generating and remixing music. The sakemin/musicgen-remixer offers a powerful API integration that enables developers to transform existing music tracks into various styles through its Cognitive Actions. By utilizing these pre-built actions, developers can save time and effort, focusing on creative aspects rather than the underlying complexities of music generation.

Prerequisites

Before you start integrating the sakemin/musicgen-remixer Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform, which you’ll use for authentication.
  • Familiarity with making HTTP requests and handling JSON data.

Conceptually, authentication typically involves passing your API key in the request headers. This is crucial to securely access the Cognitive Actions.

Cognitive Actions Overview

Remix Music with MusicGen Chord

The Remix Music with MusicGen Chord action allows you to transform audio tracks into different styles. By uploading a track with vocals and providing a text-based style description, you can produce a remixed background track.

Input

The input for this action consists of several properties defined in a JSON object. Here’s the schema:

{
  "seed": "integer (optional)",
  "prompt": "string (required)",
  "modelType": "string (optional)",
  "topTokens": "integer (optional)",
  "temperature": "number (optional)",
  "audioFileInput": "string (required)",
  "inputSensitivity": "integer (optional)",
  "audioOutputFormat": "string (optional)",
  "chromaCoefficient": "number (optional)",
  "includeInstrumental": "boolean (optional)",
  "cumulativeProbability": "number (optional)",
  "extendedChordVocabulary": "boolean (optional)",
  "audioNormalizationStrategy": "string (optional)",
  "beatSynchronizationThreshold": "number (optional)",
  "decodeWithMultiBandDiffusion": "boolean (optional)"
}
Example Input

Here’s a practical example of the JSON payload needed to invoke this action:

{
  "prompt": "bossa nova",
  "modelType": "stereo-chord",
  "topTokens": 250,
  "temperature": 1,
  "audioFileInput": "https://replicate.delivery/pbxt/Jo5eWjg3NvEVtAowTbAOAUiyplQjUA4Sfn0QkOhm8FdQEmv5/Ditto-2-NewJeans.mp3",
  "inputSensitivity": 3,
  "audioOutputFormat": "wav",
  "chromaCoefficient": 1,
  "cumulativeProbability": 0,
  "extendedChordVocabulary": false,
  "audioNormalizationStrategy": "loudness",
  "decodeWithMultiBandDiffusion": false
}

Output

Upon successful execution, the action typically returns a URL pointing to the generated audio file:

[
  "https://assets.cognitiveactions.com/invocations/89711707-05aa-41cf-b190-2917b21c171e/daeea4c8-069f-40ba-bb6a-4b0addb9bc30.wav"
]

This URL can be used to access the remixed audio track.

Conceptual Usage Example (Python)

Here’s how you might call the Remix Music with MusicGen Chord action using a hypothetical endpoint in Python:

import requests
import json

# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"  # Hypothetical endpoint

action_id = "7c372920-68bf-4b5e-a1a0-3ead0bfe073a"  # Action ID for Remix Music with MusicGen Chord

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "bossa nova",
    "modelType": "stereo-chord",
    "topTokens": 250,
    "temperature": 1,
    "audioFileInput": "https://replicate.delivery/pbxt/Jo5eWjg3NvEVtAowTbAOAUiyplQjUA4Sfn0QkOhm8FdQEmv5/Ditto-2-NewJeans.mp3",
    "inputSensitivity": 3,
    "audioOutputFormat": "wav",
    "chromaCoefficient": 1,
    "cumulativeProbability": 0,
    "extendedChordVocabulary": False,
    "audioNormalizationStrategy": "loudness",
    "decodeWithMultiBandDiffusion": False
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json"
}

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json={"action_id": action_id, "inputs": payload}  # Hypothetical structure
    )
    response.raise_for_status()  # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body: {e.response.text}")

In this example, you replace the API key and endpoint with your own. The action ID and input payload are structured as per the action's requirements. The endpoint URL and request structure are illustrative and should be modified based on actual API specifications.

Conclusion

The sakemin/musicgen-remixer Cognitive Actions offer an exciting way to remix music effortlessly. By using the Remix Music with MusicGen Chord action, developers can easily create diverse musical styles and enhance their applications with innovative audio capabilities. Explore further use cases and consider integrating this action into your music applications to provide users with engaging and unique musical experiences!