1. Go to this page and download the library: Download samandar/laravel-elevenlabs library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
samandar / laravel-elevenlabs example snippets
use Samandar\LaravelElevenLabs\Facades\ElevenLabs;
// Text-to-Speech
$result = ElevenLabs::audio()->textToSpeech('Hello, world!');
// Speech-to-Text
$uploadedFile = request()->file('audio');
$result = ElevenLabs::audio()->speechToText($uploadedFile);
// Speech-to-Speech conversion
$result = ElevenLabs::audio()->speechToSpeech(
'voice_id_here',
$uploadedFile
);
// Streaming TTS
$stream = ElevenLabs::audio()->streamTextToSpeech('Hello streaming!');
foreach ($stream as $chunk) {
// Process audio chunk
echo $chunk;
}
// Save audio to file
$saved = ElevenLabs::audio()->saveAudioToFile(
$audioContent,
storage_path('app/speech.mp3')
);
// Text-to-Speech with file saving
$result = ElevenLabs::audio()->textToSpeechAndSave(
'Hello, this will be saved!',
storage_path('app/test-speech.mp3')
);
// 🆕 NEW: Audio Isolation (experimental)
// Note: This method is experimental and may change as ElevenLabs finalizes the endpoint.
$isolatedAudio = ElevenLabs::audio()->audioIsolation($uploadedFile);
// 🆕 NEW: Sound Generation - Create sound effects from text
$soundEffect = ElevenLabs::audio()->soundGeneration(
'Thunder and rain sounds', // Text description
10, // Duration in seconds (optional)
'strong' // Prompt influence or guidance (optional)
);
// Get available voices
$voices = ElevenLabs::voice()->getVoices();
// Get specific voice details
$voice = ElevenLabs::voice()->getVoice('voice_id_here');
// Add custom voice
$result = ElevenLabs::voice()->addVoice(
'My Custom Voice',
$audioFiles, // Array of UploadedFile objects
'Description of the voice'
);
// Edit voice settings
$result = ElevenLabs::voice()->editVoiceSettings('voice_id', [
'stability' => 0.7,
'similarity_boost' => 0.8
]);
// Delete voice
$result = ElevenLabs::voice()->deleteVoice('voice_id');
// Get shared voices from community
$sharedVoices = ElevenLabs::voice()->getSharedVoices();
// Pronunciation dictionaries
$dictionaries = ElevenLabs::voice()->getPronunciationDictionaries();
$result = ElevenLabs::voice()->addPronunciationDictionary(
'My Dictionary',
[['string' => 'word', 'phoneme' => 'pronunciation']]
);
// 🆕 NEW: Create voice previews
$result = ElevenLabs::voice()->createVoicePreviews(
'Hello, this is a voice preview test',
'voice_id_here'
);
);
// Conversational AI settings
$settings = ElevenLabs::ai()->getConversationalAISettings();
$result = ElevenLabs::ai()->updateConversationalAISettings($newSettings);
// Knowledge base management
$result = ElevenLabs::ai()->createKnowledgeBaseFromURL('https://docs.example.com');
$knowledgeBases = ElevenLabs::ai()->getKnowledgeBases();
$result = ElevenLabs::ai()->deleteKnowledgeBase('kb_id');
// Knowledge base documents (file upload)
$multipart = [
[
'name' => 'file',
'contents' => fopen(storage_path('app/docs.pdf'), 'r'),
'filename' => 'docs.pdf'
]
];
$doc = ElevenLabs::ai()->createKnowledgeBaseDocumentFromFile($multipart);
$docContent = ElevenLabs::ai()->getKnowledgeBaseDocumentContent('document_id');
// RAG Index overview
$rag = ElevenLabs::ai()->getRagIndexOverview();
// Workspace secrets
$secrets = ElevenLabs::ai()->getWorkspaceSecrets();
// 🆕 NEW: Signed URL and Widget
$signed = ElevenLabs::ai()->getSignedUrl('agent_id_here');
$widget = ElevenLabs::ai()->getAgentWidgetConfig('agent_id_here');
// 🆕 NEW: Tools and MCP Servers
$tools = ElevenLabs::ai()->listTools();
$tool = ElevenLabs::ai()->getTool('tool_id');
$createdTool = ElevenLabs::ai()->createTool(['name' => 'Search Tool']);
$dependentAgents = ElevenLabs::ai()->getDependentAgents('tool_id');
$mcpServers = ElevenLabs::ai()->listMcpServers();
$createdMcp = ElevenLabs::ai()->createMcpServer(['name' => 'Internal MCP']);
$approval = ElevenLabs::ai()->createMcpApprovalPolicy(['policy' => 'allow_all']);
// Dashboard settings
$dashboard = ElevenLabs::ai()->getDashboardSettings();
// 🆕 NEW: AI Agents Management
// List all conversational AI agents with pagination
$agents = ElevenLabs::ai()->getAgents('cursor_here', 10);
// Create a new AI agent
$agentData = [
'name' => 'Customer Support Agent',
'prompt' => 'You are a helpful customer support assistant.',
'voice_id' => '21m00Tcm4TlvDq8ikWAM',
'language' => 'en'
];
$newAgent = ElevenLabs::ai()->createAgent($agentData);
// 🆕 NEW: Conversations Management
// List conversations with pagination and filters
$conversations = ElevenLabs::ai()->getConversations(
'cursor_here',
10 // page size
);
// Get specific conversation details
$conversation = ElevenLabs::ai()->getConversation('conversation_id');
// Get conversation audio file
$audio = ElevenLabs::ai()->getConversationAudio('conversation_id');
// 🆕 NEW: Batch Calling
// Submit a batch calling job
$callsData = [
[
'phone_number' => '+1234567890',
'message' => 'Hello, this is a test call.'
],
[
'phone_number' => '+0987654321',
'message' => 'Another test message.'
]
];
$batchJob = ElevenLabs::ai()->submitBatchCalling($callsData);
// Get batch calling status
$status = ElevenLabs::ai()->getBatchCalling('batch_id');