PHP code example of sergix44 / oddcast-tts-php

1. Go to this page and download the library: Download sergix44/oddcast-tts-php 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/ */

    

sergix44 / oddcast-tts-php example snippets


use SergiX44\OddcastTTS\Oddcast;

$tts = new Oddcast();
$tts->setText('Hello my friend!')

$url = $tts->getUrl(); // the url to the .mp3 file
$stream = $tts->getAudio(); // the audio file
$tts->save('path/to/file.mp3'); // save the mp3 on the filesystem


use SergiX44\OddcastTTS\Oddcast;
use \SergiX44\OddcastTTS\Voices\Italian\Raffaele;

$tts = new Oddcast(Raffaele::class);
$url = $tts->setText('Hello my friend!')->getUrl();


use SergiX44\OddcastTTS\Oddcast;
use \SergiX44\OddcastTTS\Voices\Italian\Raffaele;

$tts = new Oddcast();
$url = $tts->setText('Hello my friend!')
  ->setVoice(Raffaele::class)
  ->getUrl(); // you can chain all the calls together

composer