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:
use Atlasphp\Atlas\Atlas;
$response = Atlas::speech('openai', 'tts-1')
->instructions('Hello, welcome to Atlas!')
->withVoice('alloy')
->asAudio();Music
Generate music from text prompts:
$response = Atlas::music('elevenlabs')
->instructions('An upbeat jazz piano track')
->withDuration(30)
->asAudio();Sound Effects
Generate sound effects from text descriptions:
$response = Atlas::sfx('elevenlabs')
->instructions('Thunder with heavy rain')
->withDuration(5)
->asAudio();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:
$response = Atlas::audio('openai', 'tts-1')
->instructions('Direct audio API usage')
->withVoice('alloy')
->asAudio();Supported Providers
| Provider | TTS | STT | SFX | Music | Features |
|---|---|---|---|---|---|
| OpenAI | tts-1, tts-1-hd | whisper-1 | — | — | Voices, speed, format |
| ElevenLabs | eleven_multilingual_v2 | Yes | eleven_text_to_sound_v2 | Yes | Voices, cloning, languages, SFX, music |
| xAI | grok-2-audio | — | — | — | TTS |
Storing Audio
$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:
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:
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
| Property | Type | Description |
|---|---|---|
data | string | Raw audio binary data |
format | ?string | Audio format (mp3, wav, etc.) |
meta | array | Additional metadata |
asset | ?Asset | Linked asset (when persistence enabled) |