Vizra ADK is in maintenance mode. It continues to work and receives compatibility fixes, but no new features are planned. For evaluating AI agents — now built on the official Laravel AI SDK — check out Vizra Evals, its successor for the evaluation use-case. Coming from ADK? See the migration guide.
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.
Generate speech from text with just a few lines of code:
use Vizra\VizraADK\Agents\AudioAgent;// Simple TTS generation$audio = AudioAgent::run('Welcome to our application')->go();// Save the audio$audio->storeAs('welcome.mp3');// Get the URL$url = $audio->url();
Override the default model for different quality/speed tradeoffs:
// Use HD model for higher quality$audio = AudioAgent::run('Premium narration content') ->using('openai', 'tts-1-hd') ->go();// Use mini model for faster generation$audio = AudioAgent::run('Quick notification') ->using('openai', 'gpt-4o-mini-tts') ->go();
$audio = AudioAgent::run('Hello world')->go();// Store with custom filename$audio->storeAs('greetings/hello.mp3');// Or auto-generate filename$audio->store();
The AudioResponse object provides methods to access and manipulate the generated audio:
$audio = AudioAgent::run('Sample text') ->nova() ->format('mp3') ->go();// Access audio data$audio->data(); // Raw binary audio data$audio->base64(); // Base64-encoded audio$audio->toDataUri(); // Data URI for embedding (data:audio/mpeg;base64,...)// Metadata$audio->text(); // Original input text$audio->voice(); // Voice used (e.g., 'nova')$audio->format(); // Format (e.g., 'mp3')$audio->mimeType(); // MIME type (e.g., 'audio/mpeg')$audio->metadata(); // Full metadata array// Storage status$audio->isStored(); // Check if audio was stored$audio->url(); // Get URL (stored or data URI)$audio->path(); // Get storage path$audio->disk(); // Get storage disk used
$audio = AudioAgent::run('Play this message')->go();// Using data URI (no storage needed)$html = '<audio controls src="' . $audio->toDataUri() . '"></audio>';// Using stored URL$audio->store();$html = '<audio controls src="' . $audio->url() . '"></audio>';
Allow your LLM agents to generate audio by delegating to the AudioAgent:
use Vizra\VizraADK\Agents\BaseLlmAgent;use Vizra\VizraADK\Tools\DelegateToMediaAgentTool;class AssistantAgent extends BaseLlmAgent{ protected string $name = 'assistant'; protected string $instructions = <<<'PROMPT' You are a helpful assistant. When the user asks you to read something aloud or create audio, use the generate_audio tool to convert text to speech. PROMPT; protected array $tools = [ DelegateToMediaAgentTool::class, ]; protected array $mediaAgents = [ \Vizra\VizraADK\Agents\AudioAgent::class, ];}
Or create the tool directly:
use Vizra\VizraADK\Tools\DelegateToMediaAgentTool;class NarratorAgent extends BaseLlmAgent{ protected function tools(): array { return [ DelegateToMediaAgentTool::forAudio(), ]; }}
When the LLM calls the generate_audio tool, it can specify:
# Provider and modelVIZRA_ADK_AUDIO_PROVIDER=openaiVIZRA_ADK_AUDIO_MODEL=tts-1# DefaultsVIZRA_ADK_AUDIO_VOICE=alloyVIZRA_ADK_AUDIO_FORMAT=mp3VIZRA_ADK_AUDIO_SPEED=1.0