PHP code example of runapi-ai / elevenlabs
1. Go to this page and download the library: Download runapi-ai/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/ */
runapi-ai / elevenlabs example snippets
unApi\Elevenlabs\ElevenlabsClient;
$client = new ElevenlabsClient(); // reads RUNAPI_API_KEY
$task = $client->textToSpeech->create([
'model' => 'text-to-speech-multilingual-v2',
'text' => 'Welcome to the launch briefing.',
]);
$status = $client->textToSpeech->get($task->id);
$transcript = $client->speechToText->run([
'model' => 'speech-to-text',
'source_audio_url' => 'https://cdn.runapi.ai/public/samples/voice.mp3',
]);
$result = $client->textToSpeech->run([
'model' => 'text-to-speech-multilingual-v2',
'text' => 'A concise product update for the team.',
]);
echo $result->audios[0]->url . PHP_EOL;
echo $transcript->text . PHP_EOL;