Skip to content

Audio

Atlas provides three focused audio modalities — speech, music, and sound effects — each with a dedicated API.

Speech (TTS & STT)

Convert text to speech or transcribe audio to text:

php
use Atlasphp\Atlas\Atlas;

$response = Atlas::speech('openai', 'tts-1')
    ->instructions('Hello, welcome to Atlas!')
    ->withVoice('alloy')
    ->asAudio();

Full documentation

Music

Generate music from text prompts:

php
$response = Atlas::music('elevenlabs')
    ->instructions('An upbeat jazz piano track')
    ->withDuration(30)
    ->asAudio();

Full documentation

Sound Effects

Generate sound effects from text descriptions:

php
$response = Atlas::sfx('elevenlabs')
    ->instructions('Thunder with heavy rain')
    ->withDuration(5)
    ->asAudio();

Full documentation

Low-Level API

Atlas::audio() is the underlying entry point that all three modalities build on. Use it directly for advanced use cases or future audio capabilities:

php
$response = Atlas::audio('openai', 'tts-1')
    ->instructions('Direct audio API usage')
    ->withVoice('alloy')
    ->asAudio();

Supported Providers

ProviderTTSSTTSFXMusicFeatures
OpenAItts-1, tts-1-hdwhisper-1Voices, speed, format
ElevenLabseleven_multilingual_v2Yeseleven_text_to_sound_v2YesVoices, cloning, languages, SFX, music
xAIgrok-2-audioTTS

Storing Audio

php
$response->store('public');
$response->storeAs('audio/greeting.mp3', 'public');

Automatic Storage

When persistence is enabled, generated audio is automatically stored to disk and tracked as an Asset record — no manual store() call needed. See each sub-page or Media & Assets for details.

Persisted Asset

When persistence is enabled, generated audio is automatically stored to disk:

php
if ($response->asset) {
    $response->asset->path;       // Storage path
    $response->asset->mime_type;  // "audio/mpeg"
    $response->asset->disk;       // Filesystem disk
}

See Media & Assets for the complete storage guide.

Queue Support

All audio modalities support queue dispatch:

php
Atlas::speech('openai', 'tts-1')
    ->instructions('Generate a long audiobook chapter')
    ->withVoice('nova')
    ->queue()
    ->asAudio()
    ->then(fn ($response) => $response->store('public'));

See Speech, Music, and Sound Effects for modality-specific queue examples.

AudioResponse

PropertyTypeDescription
datastringRaw audio binary data
format?stringAudio format (mp3, wav, etc.)
metaarrayAdditional metadata
asset?AssetLinked asset (when persistence enabled)

Released under the MIT License.