audialmusic.ai · API reference
Python SDK for the Audial API: split stems, get a song's BPM, key and sections, lyrics with word timestamps, audio to MIDI, mastering, sample packs, and Serum 2 or Vital presets from a sample.
| You want to… | Call |
|---|---|
| Get the BPM and key of a song (free, never uses a run) | audial.analyze("song.mp3") |
| Find a song's structure: sections (intro, verse, chorus…) with start times, bars and a tempo map | audial.segment("song.mp3") |
| Get lyrics with a start and end time for every word | audial.lyrics(analysis_id) after segment |
| Get energy and danceability per section (a Spotify audio-features replacement) | audial.audio_features(analysis_id) after segment |
| Pull the vocals (an acapella) or the instrumental out of a song | audial.stem_split("song.mp3") |
| Convert audio to MIDI, one .mid per stem | audial.generate_midi("song.mp3") |
| Master a mix, optionally to a reference track | audial.master("mix.wav") |
| Turn a song or loop into a sample pack | audial.generate_samples("song.mp3"), or generate_samples(analysis_id=…) after segment |
| Make a Serum 2 or Vital preset from a one-shot sample | audial.sound2serum("hit.wav") / audial.sound2vital("hit.wav") |
Every account gets 2 free runs on any function. After that a plan is needed: $10 a month or $100 a year for 100 credits a month (plans).
The Audial SDK provides a user-friendly interface to Audial's powerful audio processing capabilities. With just a few lines of code, you can perform professional-grade audio operations including:
- Stem Splitting: Separate tracks into individual components (vocals, drums, bass, other)
- Audio Analysis: Extract BPM, key signatures, and other audio metadata
- Song Analysis: Find a track's sections, tempo and bars in about half a minute, then add audio features, tags, timed lyrics or a sample pack, one call each
- Audio Mastering: Apply professional mastering to your tracks
- Sample Pack Generation: Create reusable samples from finished tracks or short loops
- MIDI Generation: Convert audio to MIDI data
- Sound-to-Vital Resynthesis: Turn one isolated sound (not a loop) into a Vital synth preset
- Sound-to-Serum 2 Resynthesis: Turn one isolated sound (not a loop) into a Serum 2 preset
- Text-to-Vocal Synthesis: Sing lyrics in the timbre of a reference voice clip
Every account gets 2 free runs on any function. Once they are used, a function needs a plan; without one the API answers HTTP 402 SUBSCRIPTION_REQUIRED and the SDK raises SubscriptionRequiredError. Files are always given as local paths — the SDK uploads them for you.
The SDK supports both a Python API for integration into your projects and a command-line interface for direct use.
What changed in 2.0: analysis format 5
audial.segment()returns the analysis underanalysis, in format 5: the same object the API and the website's JSON button give. Every fact appears once, every section carries its own numbers, the key is at the top level, and units are stated. Theaudio_segmentationandsegmentationkeys are gone. Older analyses come back in format 5 too.audial.audio_features(),audial.tags()andaudial.lyrics()return their block of that object:{key, camelot, features, sections},{genres, instruments, moods, stems, description}and{vocal_start, lines}.- Gone:
song_analysis,segment_analysis,phrases, artist tags,first_vocal_beat_time(nowlyrics.vocal_start) and the other duplicates listed in the changelog.expand_beatsis False by default: read beats and bars withaudial.grid.beats_of(result).Everything is listed in the changelog, with how to update a 1.x script.
Before installing the Audial SDK, ensure you have the following:
- Python 3.7 or higher
- pip package manager (typically included with Python)
- An Audial account: sign in with
audial login, or create an API key under Apps & API Keys in your profile on the Audial website
The simplest way to install the Audial SDK is via pip:
pip install audial-sdkIf you want the latest development version, you can install directly from the GitHub repository:
# Clone the repository
git clone https://github.com/AudialAI/audial-sdk.git
# Navigate to the project directory
cd audial-sdk
# Install the package
pip install -e .audial loginThis opens a page in your browser. Approve it and you are signed in: there is no API key or
user ID to copy. The sign-in is saved on your computer (~/.audial/credentials.json, readable
only by you) and is used by the audial command, by Python scripts that import audial, and
by the Audial MCP server. audial whoami shows the account in use, audial logout signs out,
and each connected computer can be disconnected under Apps & API Keys in your profile at
audialmusic.ai. On a machine without a browser, audial login --no-browser prints the link
to open elsewhere. From Python, audial.login() does the same.
Where nobody is there to sign in, create an API key under Apps & API Keys in your profile and
give it to the SDK in one of the ways below. A key that starts with aud_ is all you need;
AUDIAL_USER_ID is only required with an older key that does not. A key set in the
environment takes priority over a saved sign-in.
Set the AUDIAL_API_KEY environment variable (and AUDIAL_USER_ID with an older key):
Linux/macOS:
export AUDIAL_API_KEY=your_api_key_here
export AUDIAL_USER_ID=your_user_id_hereWindows (Command Prompt):
set AUDIAL_API_KEY=your_api_key_here
set AUDIAL_USER_ID=your_user_id_hereWindows (PowerShell):
$env:AUDIAL_API_KEY = "your_api_key_here"
$env:AUDIAL_USER_ID = "your_user_id_here"To point the SDK at a different Audial API host (for example a staging deployment), set AUDIAL_API_BASE_URL to that host's /api base:
export AUDIAL_API_BASE_URL=https://your-host.example.com/apiWhen it is unset the SDK talks to https://api.audialmusic.ai/api.
Create a file named .env in your project directory:
AUDIAL_API_KEY=your_api_key_here
AUDIAL_USER_ID=your_user_id_here
Use the built-in configuration command:
# Set API key via CLI
audial config --api-key your_api_key_here
# Only with an older key that does not start with aud_: set your User ID
audial config --user-id your_user_id_here
# Set results folder
audial config --results-folder path/to/results/folder
# Show current configuration
audial config --showSet the API key programmatically in your Python code:
import audial
audial.config.set_api_key("your_api_key_here")
# Only with an older key that does not start with aud_:
# audial.config.set_user_id("your_user_id_here")By default, all results are saved to ./audial_results/. You can change this:
# In Python
audial.config.set_results_folder("path/to/custom/folder")
# Or via command line
audial config --results-folder path/to/custom/folderYou can verify that the SDK is correctly installed and configured:
# Check the version
python -c "import audial; print(audial.__version__)"
# Check configuration
audial config --showIf you encounter issues during installation:
If you have dependency conflicts, try installing in a virtual environment:
# Create and activate a virtual environment
python -m venv audial-env
source audial-env/bin/activate # Linux/macOS
# or
audial-env\Scripts\activate # Windows
# Install the SDK
pip install audial-sdkIf you encounter permission errors during installation:
# Install for the current user only
pip install --user audial-sdkIf you get authentication errors:
- Verify your API key is correct (an older key that does not start with
aud_also needs your User ID) - Check that they are being properly set/loaded
- Ensure your account has the necessary permissions
import audial
# Configure your API key (or run `audial login` once and skip this)
audial.config.set_api_key("your_api_key_here")
# Stem splitting
result = audial.stem_split("path/to/audio.mp3")
print(f"Vocals saved to: {result['files']['files']['vocals.mp3']}")
print(f"Drums saved to: {result['files']['files']['drums.mp3']}")
# Audio analysis
analysis = audial.analyze("path/to/audio.mp3")
print(f"BPM: {analysis['analysis']['bpm']}")
print(f"Key: {analysis['analysis']['key']}")
# Song analysis: sections, tempo and bars in about half a minute...
song = audial.segment("path/to/audio.mp3", genre="Tech House")
for section in song["analysis"]["sections"]:
print(section["label"], section["start"])
# ...then audio features, tags and timed lyrics, one call each
features = audial.audio_features(song["analysis_id"])
lyrics = audial.lyrics(song["analysis_id"])Split an audio track into its component parts:
# Basic stem splitting
result = audial.stem_split("path/to/audio.mp3")
# Advanced options
result = audial.stem_split(
"path/to/audio.mp3",
stems=["vocals", "drums", "full_song_without_vocals"],
target_bpm=120,
target_key="Cmaj",
algorithm="primaudio" # or "quintessound"
)Available stems:
vocals- Vocal trackdrums- Drum trackbass- Bass trackother- All other instrumentsfull_song_without_vocals- Full mix minus vocalsfull_song_without_drums- Full mix minus drumsfull_song_without_bass- Full mix minus bassfull_song_without_other- Full mix minus other instruments
Extract metadata from an audio track:
analysis = audial.analyze("path/to/audio.mp3")
print(f"BPM: {analysis['analysis']['bpm']}")
print(f"Key: {analysis['analysis']['key']}")Analysis finds your track's sections, tempo, bars and key in about half a minute. Send the mix: no stems are needed. Add audio features, tags, lyrics or a sample pack afterwards, one call each, whenever you like.
A clip of 30 s or less is analysed as a loop: structure is "loop" and there is one LOOP
section, with the tempo fitted so the clip is a whole number of bars (sections[0]["bars"]). Its
sample pack adds drum loops under drum_loops/. Clips under 1.5 s are refused with
AUDIO_INVALID.
song = audial.segment("path/to/audio.mp3", genre="Tech House")
analysis_id = song["analysis_id"]
data = song["analysis"]
print(data["bpm"], data["time_signature"], data["key"], data["camelot"])
for section in data["sections"]:
print(f"{section['start']:7.2f} {section['label']} ({section['bars']} bars from bar {section['start_bar']})")genre picks dance section names (INTRO, UP, CHORUS, DOWN, OUTRO) or song section names
(INTRO, VERSE, UP, CHORUS, OUTRO); edm=True or edm=False chooses directly.
Each add-on is its own call on the analysis id, any time later. It waits for its result and returns it:
features = audial.audio_features(analysis_id) # key, camelot, features, per-section numbers
tags = audial.tags(analysis_id) # genres, instruments, moods, stems, description
lyrics = audial.lyrics(analysis_id) # vocal_start, timed lines with word timings
pack = audial.generate_samples(analysis_id=analysis_id) # drums, bass and melody loops
print(features["features"]["energy"], [s["energy"] for s in features["sections"]])
print(tags["genres"], tags["stems"]["drums"]) # {"instruments": [...], "moods": [...]} or {"silent": True}
for line in lyrics["lines"]:
print(line["start"], [word for word, start, end in line["words"]])| Function | Returns (each also has warnings, a list) |
|---|---|
audio_features(id) |
{"key", "camelot", "features": {energy, danceability, loudness_lufs, mode, mode_confidence, tatum}, "sections": [{label, start, end, energy, danceability, loudness_lufs}, ...]} |
tags(id) |
{"genres", "instruments", "moods", "stems": {drums, bass, melody, vocals}, "description"} |
lyrics(id) |
{"vocal_start", "lines": [{start, end, words: [[word, start, end], ...]}, ...]} |
These are the blocks the add-ons fill in the analysis, read from the merged view, so they match
what segment() and the website show.
Energy and danceability run from 0 to 1 (0–100%). Energy reflects loudness, rhythmic activity
and low end. Danceability reflects how strong and regular the beat is. Both are measured per
section, so a drop reads higher than its breakdown. loudness_lufs is integrated loudness
(ITU-R BS.1770) in LUFS. A value that wasn't measured is None. A stem part with no sound is
{"silent": True}; a track without vocals has vocal_start None and no lines.
Tags, lyrics and the sample pack read the analysis's stems, which are made automatically in the
background as soon as the analysis starts. Until they are ready the API answers
409 STEMS_NOT_READY ("This track is still being prepared. Try again in a minute."); the SDK
keeps trying for up to wait_s seconds (default 600). Audio features need only the mix.
An analysis counts as one run. Everything you add to it (features, tags, lyrics, a sample pack)
is included. Calling those on their own, without an analysis, counts as a run each. Calling an add-on
again returns the same result (rerun=True makes a new one).
segment() returns the analysis (format 5) with every add-on generated so far. Every time is
in seconds on the track's timeline:
{
"analysis_id": "-Pq0...",
"analysis": {
"format_version": 5, "duration": 391.027, "bpm": 129.0, "tempo_mode": "constant",
"time_signature": "4/4",
"key": "Bmin", "camelot": "10A", # None when no key was found
"structure": "dance", # "dance" or "song": which section names are used
"bar1": 5.768, # the first downbeat
"grid": {...}, # the tempo map (below)
"lead_in": {"start": 0.0, "end": 5.768}, # None when bar 1 starts the file
"sections": [{"label": "INTRO", "start": 5.768, "end": 35.511, "start_bar": 1, "bars": 16,
"fills": [], # times of the drum fills in the section
"energy": 0.599, "danceability": 0.58, "loudness_lufs": -10.42}, ...],
# each present once its add-on has run:
"features": {"energy": 0.597, "danceability": 0.474, "loudness_lufs": -8.94,
"mode": "Natural Minor", "mode_confidence": 0.806, "tatum": "1/32"},
"tags": {"genres": [...], "instruments": [...], "moods": [...], "stems": {...}},
"description": "This track is ...",
"lyrics": {"vocal_start": 0.171, "lines": [...]}
},
"execution": {...}, # the analysis execution
"files": {"folder": "...", "files": {"analysis.json": "..."}} # the analysis object as saved
}analysis.json holds the analysis object itself, as the website's JSON button saves it.
segment(path, features=[...]) still works as it did in 1.5: it runs the segmentation
pipeline, which makes the analysis and then the add-ons those features need, and the result
already holds them. It takes longer, because tags and lyrics wait for the stems.
Beats and bars aren't listed one by one. grid describes them: where each constant-tempo piece
starts, its BPM, and its bar and beat. Every beat time is start + k × 60 / bpm. Most tracks
have one piece.
grid = data["grid"]
grid["beat_count"], grid["bar_count"] # totals, no expansion needed
audial.grid.beats_of(data) # (beat times, bar times) of an analysis of any format
audial.grid.beat_times(data) # every beat time
audial.grid.bar_times(data) # the start of every bar from bar 1
audial.grid.expand(data) # [(time, bar, beat), ...]; bars 0 and below are the lead-inBeats per bar come from time_signature (4 when there is none). Each function also takes the
whole segment() result, a grid on its own, or an older analysis file (format 4, or formats 2
and 3, which list beat_times and bar_times). segment(path, expand_beats=True) adds
beat_times and bar_times to the analysis for you.
Apply professional mastering to your tracks:
# Basic mastering
mastered = audial.master("path/to/audio.mp3")
# With reference track
mastered = audial.master(
"path/to/audio.mp3",
reference_file="path/to/reference.mp3"
)Generate a sample pack from an audio track. From a file, this runs the sample-pack
pipeline: the analysis and the stems start together, then the pack is built from them, in a
single API call. Tempo and key are detected automatically.
samples = audial.generate_samples(
"path/to/audio.mp3",
job_type="sample_pack",
components=["drums", "bass", "melody"],
genre="Tech House"
)From an analysis you already have, the pack reuses its stems and sections, and is included with the analysis:
pack = audial.generate_samples(analysis_id=song["analysis_id"], components=["drums", "bass"])
print(pack["components"]) # {"drums": {"status": "ok"}, "bass": {"status": "ok"}}samples["execution"] is the pipeline status, so you can see what each step
did. The same job can be run directly:
status = audial.pipelines.run("sample-pack", "path/to/audio.mp3",
options={"components": ["drums", "bass"],
"genre": "Tech House"})
print(status["outputs"]["samples"]) # sample URLsConvert audio to MIDI:
# Single file
midi = audial.generate_midi("path/to/audio.mp3", bpm=120)
# Multiple files
midi = audial.generate_midi(
["path/to/file1.mp3", "path/to/file2.mp3"],
bpm=140
)A pipeline is several Audial functions run as one job: you send the file once and the API feeds each step's output into the next.
| Pipeline | Steps |
|---|---|
sample-pack |
prepare (the analysis and its stems, together) -> sample-pack |
segmentation |
segmentation (the analysis) -> add-ons (the features, tags and lyrics asked for) |
status = audial.pipelines.run(
"sample-pack",
"path/to/audio.mp3",
options={"components": ["drums", "bass", "melody"], "genre": "Tech House"},
on_progress=lambda s: print(s["state"], s.get("currentStep")),
)
print(status["state"]) # "completed"
print(status["outputs"]["samples"]) # sample URLsrun() uploads the file, polls until the pipeline finishes, and raises
AudialError naming the step that failed if one does. Other calls:
audial.pipelines.run(name, file_path, options=None, wait=True,
poll_interval=5, on_progress=None, api_key=None)
audial.pipelines.get(pipeline_id) # current status
audial.pipelines.cancel(pipeline_id) # stop it
audial.pipelines.list(limit=20) # {"items": [...], "nextCursor": ...}Options are components, genre, bpm, keyString and featuresToExtract;
everything omitted gets the API's default, and BPM and key are detected from
the file when you do not send them. A segmentation pipeline reports the
analysis with every add-on as outputs.analysis, and any add-on that could
not be made in outputs.warnings.
generate_samples(file) and segment(file, features=[...]) run these
pipelines for you and download the results, so use pipelines.run() directly
when you want the URLs, the per-step timings, or control over polling.
Turn a short (<=20s) audio clip into a Vital synth preset:
result = audial.sound2vital("path/to/clip.wav")
print(f"Preset: {result['preset']}")Turn a short (<=20s) audio clip into a Serum 2 preset. No Audial plugin is needed --
open the downloaded .SerumPreset file directly in Xfer's Serum 2. Serum runs take
about 2.5 minutes, plus up to another 2.5 minutes if a worker has to cold-start:
result = audial.sound2serum("path/to/clip.wav")
print(f"Preset: {result['preset']}")Sing lyrics in the timbre of a reference voice clip, following a melody:
result = audial.text2vox(
reference_file="path/to/voice_clip.wav",
lyrics="la la la la",
midi_file="path/to/melody.mid",
)The MIDI must be one note at a time: a single melody line, not chords or harmony. A file with chords or overlapping notes is refused before anything runs, and nothing is charged.
lyrics_mode="per_note" gives you a syllable per MIDI note: the lyrics are pipe-delimited,
one token per note, and a hold keeps the previous syllable going through the next note.
| Token | Meaning |
|---|---|
grace |
Sung on this note |
- |
Hold: continue the previous syllable through this note (the documented form) |
+ |
Hold as well (a Synthesizer V habit) |
| empty | Hold as well -- what a double pipe produces |
So a word can span notes:
result = audial.text2vox(
reference_file="voice_clip.wav",
midi_file="melody.mid", # 9 notes
lyrics="amazing|-|-|grace|-|how|sweet|the|sound", # 9 tokens
lyrics_mode="per_note",
)"amazing" is sung across notes 1-3 and "grace" across notes 4-5. There is no rest token: a note that should be silent should not be in the MIDI. The token count must equal the note count, and the first token must be a syllable -- which the SDK checks before it uploads anything:
from audial.api.exceptions import AudialValidationError
try:
audial.text2vox(..., lyrics="-|grace", lyrics_mode="per_note")
except AudialValidationError as e:
print(e) # note 1 has no syllable; the first note needs one
print(e.position) # 1 -- the note the message is about
audial.text2vox_tokens("amazing|-|-|grace") # the tokens that will be sentSee Per-note lyrics for the full reference.
Audial's GPU workers scale to zero, so the first job after an idle period waits a few minutes for a worker to start and load the model; every run after it is fast. The API reports that phase on the execution it already returns, so the SDK can explain the wait instead of looking hung.
Every function that polls takes an optional on_progress callback, and audial.status()
answers the same question before a job is submitted:
tracker = audial.warmup.WarmupTracker()
audial.sound2vital("kick.wav", on_progress=lambda status: [
print(line) for line in tracker.changes(status)
])
# Warming up the machine - the first request takes a few minutes longer than
# usual (about 3 min); every run after this is faster
# Working on your job...
audial.status("text2vox")
# {'items': [{'function': 'text2vox', 'warm': False, 'queued': 0,
# 'expectedColdStartMs': 180000, 'expectedRunMs': 42000}]}The add-ons (audio_features, tags, lyrics) run on their own machines, so the first one
after a quiet period can wait for a start too ("Starting up — this can take a minute");
their on_progress reports it the same way, and audial.status("tags") asks ahead.
The CLI does both for you: it checks before it submits and prints each phase as it
changes. audial status shows every function at once. See Cold Starts and Service
Status.
The SDK provides a powerful command-line interface:
# Stem splitting
audial stem-split audio.mp3 --stems vocals,drums,bass,other
# Audio analysis
audial analyze audio.mp3
# Song analysis, then its add-ons (an analysis id, or a file: it is analysed first)
audial segment audio.mp3 --genre "Tech House"
audial features <analysis_id>
audial tags <analysis_id>
audial lyrics audio.mp3
# Mastering
audial master audio.mp3 --reference reference.mp3
# Sample pack generation
audial generate-samples audio.mp3 --components drums bass melody
audial generate-samples --analysis-id <analysis_id>
# Pipelines: several steps in one call
audial pipeline sample-pack audio.mp3 --genre "Tech House" --components drums bass
audial pipeline segmentation audio.mp3 --json
# MIDI generation
audial generate-midi audio.mp3 --bpm 120
# Sound-to-Vital resynthesis
audial sound2vital clip.wav
# Sound-to-Serum 2 resynthesis
audial sound2serum clip.wav
# Text-to-vocal synthesis
audial text2vox voice_clip.wav "la la la la" --midi melody.mid
audial text2vox voice_clip.wav "amazing|-|-|grace|-|how|sweet|the|sound" \
--midi melody.mid --lyrics-mode per_note
# Which services have a worker awake right now
audial status
# Configuration
audial config --api-key your_api_key_here
audial config --user-id your_user_id_here # only with an older key
audial config --results-folder path/to/results
audial config --showFunctions that make files return a consistent result structure (segment() adds
analysis_id and analysis; the add-ons audio_features, tags and lyrics
return their block of the analysis and save it as <analysis_id>_analysis/<name>.json):
{
"execution": {
# API response data
"exeId": "execution-id",
"state": "completed",
# Other execution data...
},
"files": {
"folder": "./audial_results/execution-id_function-type",
"files": {
"filename1.mp3": "./audial_results/execution-id_function-type/filename1.mp3",
"filename2.mp3": "./audial_results/execution-id_function-type/filename2.mp3",
# Other downloaded files...
}
}
}from audial.api.exceptions import (
AudialError,
AudialAuthError,
AudialAPIError,
AudialValidationError,
SubscriptionRequiredError,
AudialLimitReached,
)
try:
result = audial.stem_split("path/to/audio.mp3")
except AudialValidationError as e:
print(f"Unusable input: {e} (position {e.position})")
except SubscriptionRequiredError as e:
print(f"Subscription required: {e}")
except AudialLimitReached as e:
# Monthly API calls used up (HTTP 402 API_LIMIT_REACHED). Never retried.
print(e) # Monthly API limit reached (100/100). Resets 2026-12-23. More calls: ...
print(e.limit, e.used, e.resets_at, e.upgrade_url) # resets_at is a UTC datetime
except AudialAuthError as e:
print(f"Authentication error: {e}")
except AudialAPIError as e:
print(f"API error: {e}")
except AudialError as e:
print(f"General error: {e}")The add-ons raise AudialAPIError with e.code set when the API refuses them (HTTP 409):
STEMS_NOT_READY: "This track is still being prepared. Try again in a minute." The stems were still being made afterwait_sseconds, or could not be made ("We couldn't prepare this track.").ADDON_UNAVAILABLE: "This result can't be added to this analysis." For example an older analysis that kept no stems.
See the API Documentation for detailed information about all functions and their parameters.
The SDK includes example scripts in the examples directory:
- Stem Splitting
- Audio Analysis
- Song Analysis with Audio Features and Tags
- Lyrics with Word Timings
- Audio Mastering
- Sample Pack Generation
- MIDI Generation
- Music Generation
- Sound-to-Vital Resynthesis
- Sound-to-Serum 2 Resynthesis
- Text-to-Vocal Synthesis
This project is licensed under the MIT License - see the LICENSE file for details.
For issues, questions, or feedback, please create an issue on our GitHub repository or contact contact@audialmusic.ai.
Powered by Audial.
