newage/audio-manager

Audio Manager for text-to-speech cloud services

1.2.3 2023-06-26 09:01 UTC

This package is auto-updated.

Last update: 2024-11-26 12:16:14 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

A manager for a popular text-to-speech cloud services (Google, Ivona, Amazon Polly...) on PHP. This project uses PSR-4 autoloading standard, PSR-2 coding style

Install

Via Composer

$ composer require newage/audio-manager

Usage

Setup an Google adapter

$adapter = new \AudioManager\Adapter\Google();
$adapter->getOptions()->setLanguage('en');
$adapter->getOptions()->setEncoding('UTF-8');

Setup an Ivona adapter

$adapter = new \AudioManager\Adapter\Ivona();
$adapter->getOptions()->setAccessKey('...');
$adapter->getOptions()->setSecretKey('...');
$adapter->getOptions()->setLanguage('...'); //Default 'en-US'
$adapter->getOptions()->setVoice('...'); //Default 'Salli'
$adapter->getOptions()->setOutputFormatCodec('...'); //Default 'MP3'
$adapter->getOptions()->setOutputSampleRate('...'); //Default '22050'
$adapter->getOptions()->setParametersRate('...'); //Default 'slow'

Setup an Amazon Polly adapter

$adapter = new \AudioManager\Adapter\Polly();
$adapter->getOptions()->initialize()
    ->setVersion('latest')
    ->setRegion('us-west-2')
    ->setCredentials()
        ->setKey('...')
        ->setSecret('...');

$adapter->getOptions()->setOutputFormat('...'); //Default 'mp3'
$adapter->getOptions()->setLexiconNames('...');
$adapter->getOptions()->setSampleRate('...'); //Default '16000'
$adapter->getOptions()->setTextType('...'); //Default 'text'
$adapter->getOptions()->setVoiceId('...'); //Default 'Salli'

Setup an adapter to manager

$manager = new \AudioManager\Manager($adapter);
$audioContent = $manager->read('text');
$manager->getHeaders();

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email vadim.leontiev@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.