Create Engaging Audio Experiences with e7mac/beatnet Cognitive Actions

22 Apr 2025
Create Engaging Audio Experiences with e7mac/beatnet Cognitive Actions

In today’s world of digital audio production, having powerful tools at your fingertips can make all the difference. The e7mac/beatnet Cognitive Actions provide developers with capabilities to manipulate and enhance audio files, specifically to generate click tracks with various customizable options. These pre-built actions streamline the integration of audio processing functionalities into your applications, saving you time and effort.

Prerequisites

Before you start using the Cognitive Actions, ensure you have access to the Cognitive Actions API. You will need an API key for authentication, which can be included in the headers of your requests. This key will allow you to access the available actions securely and efficiently.

Cognitive Actions Overview

Generate Audio Click Track

The Generate Audio Click Track action is designed to create a click track from an audio file. This action allows you to emphasize downbeats, overlay the click track on the original audio, and it supports both MP3 and WAV formats.

Input

The input for this action requires a JSON object containing the following fields:

  • audio (required): A URI to the input audio file (supports MP3 and WAV formats).
  • clickTrack (optional): A boolean value indicating whether to generate a separate click track. Default is false.
  • combineClickTrack (optional): A boolean value to specify whether to overlay the generated click track onto the original audio. Default is false.
  • detectDownbeat (optional): A boolean indicating if the click track should emphasize downbeats. This is effective only when a click track is generated. Default is false.

Example Input:

{
  "audio": "https://replicate.delivery/pbxt/JNFJg9bnf1DyV6TkjH645OoAd7VhevU9hdSj391R4j1rhbYb/in.mp3",
  "clickTrack": true,
  "combineClickTrack": true
}

Output

The output from this action will be a JSON object containing links to the generated audio clicks and any combined tracks:

  • beats: A link to the generated click track data.
  • click: A link to the generated click track audio file.
  • combined: A link to the audio file that combines the original audio with the click track.

Example Output:

{
  "beats": "https://assets.cognitiveactions.com/invocations/a593faac-bc11-48e7-865e-c11e4cae8b24/2467f875-07e1-4d64-b435-0c50bb2d3d64.json",
  "click": "https://assets.cognitiveactions.com/invocations/a593faac-bc11-48e7-865e-c11e4cae8b24/45b9dcad-c6dc-41ea-b171-252293221df0.wav",
  "combined": "https://assets.cognitiveactions.com/invocations/a593faac-bc11-48e7-865e-c11e4cae8b24/1747c1fd-1160-4690-a71c-8f294facc554.wav"
}

Conceptual Usage Example (Python)

Below is a conceptual example of how you might call this action using 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 = "102d10d5-9316-423e-97c8-c645800650ee" # Action ID for Generate Audio Click Track

# Construct the input payload based on the action's requirements
payload = {
    "audio": "https://replicate.delivery/pbxt/JNFJg9bnf1DyV6TkjH645OoAd7VhevU9hdSj391R4j1rhbYb/in.mp3",
    "clickTrack": true,
    "combineClickTrack": true
}

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, you'll see how to structure your request, including setting the action ID and input payload. The endpoint URL and request structure are illustrative, so make sure to adapt them to your specific setup.

Conclusion

The e7mac/beatnet Cognitive Actions provide a powerful way for developers to enhance audio applications by generating click tracks and customizing audio outputs. By leveraging these actions, you can streamline audio processing workflows, making it easier to create engaging audio experiences. Explore further use cases, and consider integrating these actions into your next audio project to maximize their potential!