IVONA SpeechCloud SDK for PHP
Through Composer:
$ composer require werd/ivona-speechcloud-sdk-php
use Werd\Ivona\SpeechCloud;
use Werd\Ivona\Models\Input;
use Werd\Ivona\Models\OutputFormat;
use Werd\Ivona\Models\Parameters;
use Werd\Ivona\Models\Voice;
use Werd\Ivona\Models\Lexicon;
$speechCloud = new SpeechCloud([
'access_key' => '<your-key>',
'secret_key' => '<your-secret-key>',
'region' => '<region>' // E.g. eu-west-1
]);
// CreateSpeech
$data = $speechCloud->createSpeech(new Input([
Input::DATA => 'The word or sentence You want to synthesize'
]), new OutputFormat(), new Parameters(), new Voice());
header('Content-Type: audio/mpeg');
echo $data; // Audio stream - use it as You please
$data = $speechCloud->createSpeech(new Input([
Input::DATA => 'Je Suis Charlie'
]), new OutputFormat(), new Parameters(), new Voice([
Voice::NAME => 'Celine',
Voice::LANGUAGE => 'fr-FR'
]));
// ListVoices
$data = $speechCloud->listVoices(new Voice());
$data = $speechCloud->listVoices(new Voice([
Voice::LANGUAGE => 'en-US',
Voice::GENDER => Voice::GENDER_MALE
])); // Filter American English male voices etc.
// PutLexicon
$data = $speechCloud->putLexicon(new Lexicon([
Lexicon::NAME => 'Test',
Lexicon::CONTENTS => '<PLS>'
]));
// GetLexicon
$data = $speechCloud->getLexicon('Test');
// DeleteLexicon
$data = $speechCloud->deleteLexicon('Test');
// ListLexicons
$data = $speechCloud->listLexicons();