Create Unique Audio Samples Easily with Stable Audio Open 1.0

26 Apr 2025
Create Unique Audio Samples Easily with Stable Audio Open 1.0

In the ever-evolving landscape of audio production, developers are constantly seeking tools that enhance creativity and streamline workflows. The Stable Audio Open 1.0 API offers a robust solution for generating high-quality audio samples, sound effects, and musical elements using intuitive text prompts. By leveraging a model trained on extensive datasets like Freesound and the Free Music Archive, this service empowers developers to produce unique audio content quickly and efficiently.

Common use cases for Stable Audio Open 1.0 include creating custom soundtracks for games, generating sound effects for animations, or producing unique loops for music production. Whether you're a game developer needing specific sound effects or a musician looking for fresh beats, this API simplifies the process of audio creation, allowing you to focus on your project rather than the intricacies of sound design.

Before diving in, ensure you have your Cognitive Actions API key and a basic understanding of making API calls. With these prerequisites in place, you can harness the full potential of Stable Audio Open 1.0.

Generate Audio Samples

The "Generate Audio Samples" action is designed to create short audio clips, including sound effects and musical riffs, based on your specified text prompts. This action is particularly useful for automating the sound design process, enabling rapid prototyping of audio content.

Input Requirements

To utilize this action, you need to provide a variety of parameters in your request:

  • Prompt: This is the core of your request, where you specify what kind of audio you want to generate (e.g., "128 BPM tech house drum loop").
  • Seed: An optional integer that sets the random seed for generation, allowing for reproducible results.
  • Steps: The number of processing steps, influencing the quality and complexity of the generated audio.
  • Batch Size: Indicates how many audio samples to generate in one request.
  • Sampler Type: Defines the algorithm used during processing.
  • Maximum Sigma and Minimum Sigma: Control the range of randomness in the generated audio.
  • Start Seconds and Total Seconds: Control the starting point and duration of the audio clip.
  • Negative Prompt: An optional field to specify content you want to avoid.
  • Initial Noise Level and Configuration Scale: Parameters that adjust the initial noise and overall configuration settings.

Here is an example input for generating an audio sample:

{
  "seed": -1,
  "steps": 100,
  "prompt": "128 BPM tech house drum loop",
  "batchSize": 1,
  "samplerType": "dpmpp-3m-sde",
  "maximumSigma": 500,
  "minimumSigma": 0.03,
  "startSeconds": 0,
  "totalSeconds": 8,
  "negativePrompt": "",
  "initialNoiseLevel": 1,
  "configurationScale": 6
}

Expected Output

The output will be a link to the generated audio file, offering you immediate access to the sound you've requested. For instance, a successful request might return an output like:

https://assets.cognitiveactions.com/invocations/73bc7161-7fef-4bab-8175-e28a8fa91c27/c448ff95-9c55-4f16-8d47-ac8c0b00e17f.wav

Use Cases for this Specific Action

This action is particularly beneficial for:

  • Game Development: Quickly generate sound effects tailored to specific in-game actions or environments.
  • Music Production: Create unique drum loops or instrument riffs that can be incorporated into larger compositions.
  • Film and Animation: Produce ambient sounds or effects that enhance storytelling and viewer engagement.
import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "32a55951-6788-4187-b163-153d89d4a4c8" # Action ID for: Generate Audio Samples

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "seed": -1,
  "steps": 100,
  "prompt": "128 BPM tech house drum loop",
  "batchSize": 1,
  "samplerType": "dpmpp-3m-sde",
  "maximumSigma": 500,
  "minimumSigma": 0.03,
  "startSeconds": 0,
  "totalSeconds": 8,
  "negativePrompt": "",
  "initialNoiseLevel": 1,
  "configurationScale": 6
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    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 (non-JSON): {e.response.text}")
    print("------------------------------------------------")

In conclusion, Stable Audio Open 1.0's ability to generate diverse audio samples offers developers a powerful tool for enhancing their projects. Whether you're looking to create sound effects, loops, or ambient sounds, this API simplifies the audio generation process, allowing for greater creativity and efficiency in production. As you explore this service, consider how it can elevate your audio projects and streamline your workflow. Happy coding!