Create Unique Music Tracks with IlleniumGen Cognitive Actions

21 Apr 2025
Create Unique Music Tracks with IlleniumGen Cognitive Actions

In the world of digital art and music, the ability to generate unique sounds based on prompts and existing audio files is a game-changer. The IlleniumGen Cognitive Actions offer developers an exciting opportunity to integrate music generation capabilities into their applications. By leveraging these pre-built actions, you can create music that resonates with specific styles or themes, making it easier to enhance user experiences through sound.

Prerequisites

Before diving into the music generation capabilities of IlleniumGen, ensure you have:

  • An API key for the Cognitive Actions platform.
  • An understanding of how to send HTTP requests with JSON payloads.

To authenticate your requests, you will typically pass your API key in the headers of your HTTP calls.

Cognitive Actions Overview

Generate Music with IlleniumGen

Description: This action allows you to generate music by providing a prompt text and optional audio files to influence the melody and style. It supports the continuation of input audio and various output formats, making it versatile for different use cases.

Input

The action accepts the following input parameters:

  • seed: integer (optional) - Seed for the random number generator. If -1 or not set, a random seed will be used.
  • topK: integer (optional) - Restricts sampling to the top K most probable tokens. Default is 250.
  • topP: number (optional) - Restricts sampling to tokens with a cumulative probability of P. Default is 0, activating top K sampling.
  • prompt: string (required) - Textual description of the style or content of music to generate.
  • duration: integer (optional) - Duration of the generated audio in seconds. Default is 8.
  • inputAudio: string (optional) - URI for an audio file that guides music generation.
  • temperature: number (optional) - Determines the diversity of the sampling process. Default is 1.
  • continuation: boolean (optional) - Determines the role of input audio. Default is false.
  • modelWeights: string (optional) - Defines the set of MusicGen model weights to use.
  • outputFormat: string (optional) - Defines the file format for the generated audio output. Default is "wav".
  • continuationEnd: integer (optional) - Specifies when to stop using the input audio for continuation.
  • continuationStart: integer (optional) - Start time of the audio file to use for continuation. Default is 0.
  • multiBandDiffusion: boolean (optional) - Enables Multi-Band Diffusion decoding if true.
  • normalizationStrategy: string (optional) - Specifies the method for audio normalization. Default is "loudness".
  • classifierFreeGuidance: integer (optional) - Adjusts the influence of input conditions on output. Default is 3.

Example Input:

{
  "topK": 250,
  "topP": 0,
  "prompt": "illenium",
  "duration": 8,
  "temperature": 1,
  "continuation": false,
  "outputFormat": "wav",
  "continuationStart": 0,
  "multiBandDiffusion": false,
  "normalizationStrategy": "loudness",
  "classifierFreeGuidance": 3
}

Output

The action typically returns a URL to the generated audio file. For instance:

https://assets.cognitiveactions.com/invocations/3d0ce5e7-e185-43f6-a434-2e30915f6ef2/7809585a-e8ac-45c5-beb2-0b1869140cf7.wav

Conceptual Usage Example (Python)

Here's a conceptual Python code snippet demonstrating how a developer might invoke the IlleniumGen action:

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 = "545bc484-3c03-4ca2-b0e6-dd580ff49aaf"  # Action ID for Generate Music with IlleniumGen

# Construct the input payload based on the action's requirements
payload = {
    "topK": 250,
    "topP": 0,
    "prompt": "illenium",
    "duration": 8,
    "temperature": 1,
    "continuation": False,
    "outputFormat": "wav",
    "continuationStart": 0,
    "multiBandDiffusion": False,
    "normalizationStrategy": "loudness",
    "classifierFreeGuidance": 3
}

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 code snippet, replace the YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key and make any necessary adjustments to the endpoint URL. The action ID is specified for the music generation task, and the input payload is structured according to the input schema defined above.

Conclusion

The IlleniumGen Cognitive Actions provide a powerful way to generate custom music tracks tailored to specific themes or styles. By integrating these actions into your application, you can enhance user experiences with unique soundscapes, opening up new creative possibilities. Consider exploring various prompts and audio inputs to see how they influence the generated music, and imagine the ways you can adapt this technology for your projects!