PHP code example of ekandreas / sayit

1. Go to this page and download the library: Download ekandreas/sayit 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/ */

    

ekandreas / sayit example snippets


$factory = TextToSpeech::make(
    $aws_key,
    $aws_secret,
    $aws_region,
    $aws_bucket
)
    ->voice("Elin")
    ->engine('neural')
    ->generate("Hej på dig, det här kommer att läsas upp i en mp3 efter generering.")
    ->store("your-folder");

// the url now points to a public s3 folder "your-folder" with a unique mp3 file generated from the text above.
$url = $factory->url();

$factory = TextToSpeech::make(
    $aws_key,
    $aws_secret,
    $aws_region,
    $aws_bucket
)
    ->elevenlabs($elevenlabs_key, $elevenlabs_voice_id) // optional third argument: model, default "eleven_multilingual_v2"
    ->generate("Hej på dig, det här kommer att läsas upp i en mp3 efter generering.")
    ->store("your-folder");

$factory = TextToSpeech::make($aws_key, $aws_secret, $aws_region, $aws_bucket)
    ->elevenlabs($elevenlabs_key, $host_voice_id)
    ->generate("Välkommen till Lindenytt radio.")
    ->elevenlabsVoice($reporter_voice_id)
    ->append($article1)
    ->append($article2)
    ->store("radio", "radio-2026-10-19"); // optional file name, default a unique id

// or, with one voice
$factory->generateMany([$intro, $article1, $article2])->store("radio");

TextToSpeech::make($aws_key, $aws_secret, $aws_region, $aws_bucket)
    ->delete($url); // the url returned by ->url(), or an S3 key