Create Unique Music with Livestock Auctioneer Style Using Cognitive Actions

24 Apr 2025
Create Unique Music with Livestock Auctioneer Style Using Cognitive Actions

The fofr/musicgen-livestock-auctioneer API offers a powerful Cognitive Action designed to generate music in the unique style of a livestock auctioneer. This action allows developers to create captivating audio experiences by customizing various parameters such as tempo, duration, and output formats. By leveraging these pre-built actions, developers can save time and effort, focusing on enhancing user experiences in their applications.

Prerequisites

Before getting started with the Cognitive Actions, ensure you have:

  • An API key for the Cognitive Actions platform, which will be used for authentication.
  • Basic knowledge of JSON for structuring requests and handling responses.

Authentication typically involves passing your API key in the request headers. This ensures secure access to the action services.

Cognitive Actions Overview

Generate Music with Livestock Auctioneer Style

The Generate Music with Livestock Auctioneer Style action is designed to create music tailored to a specific theme, in this case, the lively and engaging style of a livestock auctioneer. This action allows for extensive customization, including tempo, duration, and input influences, making it a versatile tool for music generation.

  • Category: music-generation

Input

The input schema for this action is structured as a JSON object with the following parameters:

  • seed (integer): A seed for the random number generator. Setting this to None or -1 will use a random seed.
  • topK (integer, default: 250): Limits sampling to the k most probable tokens.
  • topP (number, default: 0): Limits sampling to tokens with a cumulative probability of p.
  • prompt (string): A textual prompt that describes the characteristics of the music to be generated (e.g., "auctioneer, 130bpm").
  • duration (integer, default: 8): Duration of the generated audio in seconds.
  • inputAudio (string, URI): An audio file URI that influences the generated music.
  • temperature (number, default: 1): Determines the diversity of the sampling process; higher values yield more diverse outputs.
  • continuation (boolean, default: false): When True, the generated music extends the inputAudio.
  • modelWeights (string): Specifies the MusicGen model weights to use.
  • continuationEnd (integer): Defines the end time for the inputAudio used in continuation.
  • guidanceStrength (integer, default: 3): Adjusts the influence level of inputs on the output.
  • continuationStart (integer, default: 0): Specifies the start time of the inputAudio for continuation.
  • outputAudioFormat (string, default: "wav"): Format of the generated audio output (options: "wav", "mp3").
  • multiBandDiffusion (boolean, default: false): If True, EnCodec tokens are decoded using MultiBand Diffusion.
  • audioNormalizationStrategy (string, default: "loudness"): Normalization strategy for the audio.
Example Input
{
  "topK": 250,
  "topP": 0,
  "prompt": "auctioneer, 130bpm",
  "duration": 8,
  "temperature": 1,
  "continuation": false,
  "guidanceStrength": 3,
  "continuationStart": 0,
  "outputAudioFormat": "wav",
  "multiBandDiffusion": false,
  "audioNormalizationStrategy": "loudness"
}

Output

The action typically returns a link to the generated audio file. For instance, a successful invocation might return:

https://assets.cognitiveactions.com/invocations/ca821f4b-e589-4025-be20-c3475c346ef8/870099c1-662e-4136-9f0c-c5b53dd5a44c.wav

This URL points to the generated audio in WAV format.

Conceptual Usage Example (Python)

Here's a conceptual Python code snippet demonstrating how to invoke the Generate Music with Livestock Auctioneer Style 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 = "4883f875-3e82-4368-9b42-905a04bb0021" # Action ID for Generate Music with Livestock Auctioneer Style

# Construct the input payload based on the action's requirements
payload = {
    "topK": 250,
    "topP": 0,
    "prompt": "auctioneer, 130bpm",
    "duration": 8,
    "temperature": 1,
    "continuation": False,
    "guidanceStrength": 3,
    "continuationStart": 0,
    "outputAudioFormat": "wav",
    "multiBandDiffusion": False,
    "audioNormalizationStrategy": "loudness"
}

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 COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload section is structured to match the input requirements of the action. The endpoint URL and the request structure are illustrative and may differ in actual implementation.

Conclusion

The Generate Music with Livestock Auctioneer Style action provides a unique way to create engaging audio experiences using customizable parameters. By integrating this Cognitive Action into your applications, you can generate distinctive music that enhances user interaction. Consider exploring additional use cases, such as creating themed playlists or soundscapes for events, to fully leverage the capabilities of this API.