This folder contains Python examples for integrating with the Tonn API for automated audio mixing, mastering, and analysis.
pip install -r ../requirements.txtThis installs:
requests- HTTP clientpython-dotenv- Load.envfiles automatically
Get your API key from tonn-portal.roexaudio.com
On macOS/Linux:
export TONN_API_KEY=your_api_key_hereOn Windows (Command Prompt):
set TONN_API_KEY=your_api_key_hereOn Windows (PowerShell):
$env:TONN_API_KEY="your_api_key_here"cd examples
python 01_mix_analysis.py your_track.wav POP| # | Script | Description |
|---|---|---|
| 01 | mix_analysis.py |
Analyze your mix for loudness, dynamics, and issues |
| 02 | mix_comparison.py |
Compare two mixes side-by-side |
| 03 | mix_enhance.py |
Automatically enhance a stereo mix |
| 04 | multitrack_mix.py |
Mix multiple stems with AI-assisted settings |
| 05 | audio_cleanup.py |
Clean up noisy recordings |
| 06 | batch_mastering.py |
Master an entire album/EP consistently |
python/
├── README.md # This file
├── examples/ # Runnable example scripts
│ ├── 01_mix_analysis.py
│ ├── 02_mix_comparison.py
│ ├── 03_mix_enhance.py
│ ├── 04_multitrack_mix.py
│ ├── 05_audio_cleanup.py
│ └── 06_batch_mastering.py
├── shared/ # Shared utilities (import in your own code)
│ ├── __init__.py
│ ├── client.py # TonnClient class
│ └── config.py # Configuration helpers
└── payloads/ # Example JSON payloads
├── multitrack_mix.json
├── final_mix_settings.json
└── album_mastering.json
The shared/ folder contains reusable code you can use in your own projects:
from shared import TonnClient
# Create a client
client = TonnClient()
# Upload a local file and get its cloud URL
url = client.upload_local_file("my_track.wav")
# Make API requests
response = client.post("/mixanalysis", {"mixDiagnosisData": {...}})
# Download results
client.download_file(download_url, "output.wav").mp3- MP3 audio.wav- WAV audio.flac- FLAC audio
When analyzing or processing audio, specify a musical style:
ROCK/ROCK_INDIEPOPELECTRONICHIPHOP_GRIMEACOUSTICSINGER_SONGWRITERJAZZCLASSICAL- And more...
pip install -r ../requirements.txtMake sure you're running from the examples/ directory:
cd python/examples
python 01_mix_analysis.py ...Set your API key or create a .env file in the project root:
# Option 1: Environment variable
export TONN_API_KEY=your_key_here
# Option 2: Create .env file
echo "TONN_API_KEY=your_key_here" > ../../.envSee the full Troubleshooting Guide.