werd/ivona-speechcloud-sdk-php

IVONA SpeechCloud SDK for PHP

1.0.4 2016-07-19 06:04 UTC

This package is not auto-updated.

Last update: 2024-04-13 16:23:58 UTC


README

IVONA SpeechCloud SDK for PHP

Latest Stable Version Dependency Status License

Installation

Through Composer:

$ composer require werd/ivona-speechcloud-sdk-php

Usage

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();