The AudioAgent provides text-to-speech (TTS) capabilities using AI models through Prism PHP. Convert any text into natural-sounding speech with multiple voice options and audio formats.
Quick Start
Generate speech from text with just a few lines of code:
Voice Selection
Choose from six distinct AI voices, each with their own character:
Available Voices
Each voice has a shortcut method: alloy(), echo(), fable(), onyx(), nova(), shimmer().
Select your preferred output format based on your use case:
Speech Speed
Adjust the speaking rate between 0.25x and 4.0x:
Model Selection
Override the default model for different quality/speed tradeoffs:
Available Models
Storage
Auto-store with Custom Filename
Auto-store with Generated Filename
Store to Specific Disk
Manual Storage
Working with AudioResponse
The AudioResponse object provides methods to access and manipulate the generated audio:
Embedding in HTML
Async/Queued Generation
For long-running generations or batch processing, use Laravel queues:
Queue Options
Async Return Value
When using async mode, go() returns job information instead of the audio:
User Context
Associate audio generation with a user for tracking and personalization:
Sub-agent Delegation
Allow your LLM agents to generate audio by delegating to the AudioAgent:
Or create the tool directly:
When the LLM calls the generate_audio tool, it can specify:
text (required): The text to convert to speech
voice (optional): Voice selection
format (optional): Output format
Configuration
Environment Variables
Config File
In config/vizra-adk.php:
Complete Example
Here’s a comprehensive example showing common patterns:
Error Handling
API Reference
AudioAgent Methods
AudioResponse Methods