This Composer package allows you to convert text into audio using the ElevenLabs API.
To install this package, you can use Composer. Run the following command in your project directory:
composer require innovination/elevenlabs
To use this package, follow these steps:
- Import the package into your PHP file:
use Innovination\Elevenlabs;
- Create an instance of the
Elevenlabs
class:
$elevenlabs = new ElevenLabs();
- Add ElevenLabs API key to your
.env
file
XI_API_KEY='your-api-key'
- Convert text to audio:
//Required
$elevenlabs->voice_id = 'voice-id-on-elevenlabs';
$elevenlabs->text = "Hello, world!";
//Optional
$elevenlabs->file_prefix = "prefix"; // default is audio
$elevenlabs->path = "folder-name"; //default folder is audio
$audioFile = $elevenlabs->generateAudio();
The generateAudio
method will return the path to the generated audio file along with status
as sucess
or error