A PHP library to convert text to speech using various services

Overview

speaker

A PHP library to convert text to speech using various services

Full documentation is available at http://duncan3dc.github.io/speaker/
PHPDoc API documentation is also available at http://duncan3dc.github.io/speaker/api/

release build coverage

Quick Example

getAudioData()); ">
$google = new \duncan3dc\Speaker\Providers\GoogleProvider;
$tts = new \duncan3dc\Speaker\TextToSpeech("Hello World", $google);
file_put_contents("/tmp/hello.mp3", $tts->getAudioData());

Read more at http://duncan3dc.github.io/speaker/

Services

  • Acapela - Paid voice as a service
  • AmazonPolly - AWS service with a 12 month free tier
  • Google - Unadvertised service with 100 character limit
  • Picotts - An offline command line version
  • ResponsiveVoice - Unadvertised service running over a javascript engine
  • Voice RSS - Free/paid service requires registration

Changelog

A Changelog has been available since the beginning of time

Where to get help

Found a bug? Got a question? Just not sure how something works?
Please create an issue and I'll do my best to help out.
Alternatively you can catch me on Twitter

duncan3dc/speaker for enterprise

Available as part of the Tidelift Subscription

The maintainers of duncan3dc/speaker and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Comments
  • Replace escapeshellarg to avoid removal of special caracters

    Replace escapeshellarg to avoid removal of special caracters

    The escapeshellarg function is removing some UTF8 caracters from the $text string. For example, all letter with accent, commonly used in french are removed. My proposed fix is probably not the most elegant solution, but would work on any platform, regardless of the installed locale.

    opened by fdp2 10
  • How to setup

    How to setup

    Hi API look great BUT... I need to know how could it be installed to my scratch php application. I cloned via git and then composer install.

    Kindly tell me other steps. Thanks

    question 
    opened by waqadeer 9
  • How to handle errors?

    How to handle errors?

    I don't have any idea how to handle the errors. Currently, Im using GoogleProvider.

    When I entered a string like this: sbsks nfpsosi skslsoj sksls, the script throw me errors:

    Fatal error: Uncaught exception 'GuzzleHttp\Exception\ServerException' with message 'Server error: 503' in /home/xxxx/public_html/api/tts/vendor/guzzlehttp/guzzle/src/Middleware.php:68 Stack trace: #0 /home/xxxx/public_html/api/tts/vendor/guzzlehttp/promises/src/Promise.php(199): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response)) #1 /home/xxxx/public_html/api/tts/vendor/guzzlehttp/promises/src/Promise.php(152): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #2 /home/xxxx/public_html/api/tts/vendor/guzzlehttp/promises/src/TaskQueue.php(60): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() #3 /home/xxxx/public_html/api/tts/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(96): GuzzleHttp\Promise\TaskQueue->run() #4 /home/xxxx/public_html/api/tts/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(123): GuzzleHttp\Handler\CurlMultiHandler->tick() #5 /home/xxxx/public_html/api/tts/vendor/guzzlehttp/promises/src/Promise.php(240): GuzzleHttp in /home/xxxx/public_html/api/tts/vendor/guzzlehttp/guzzle/src/Middleware.php on line 68
    
    question 
    opened by dausruddin 8
  • I haven't Jumped Yet!!

    I haven't Jumped Yet!!

    Duncan, I have a friend who has become physically impaired particularly where speech is concerned. I am by far no programmer... at best an ok kludge. I have a project/toy that i have been working at that I think could benefit my friend... the project is mypersonaldictionary.com what I'd love to do is add a button that will cause the users device to speak the text in the box...

    I hope this post is received well as i suspect that many of my concerns likely have been dealt fatal blows.

    question 
    opened by talibbash 3
  • Google tts error 503

    Google tts error 503

    I get the error message for 503 service Unavailable. I have try some python library and it call success. Please help :( ( ! ) GuzzleHttp\Exception\ServerException: Server error:GET http://translate.google.com/translate_tts?q=hello+world&tl=en&client=duncan3dc-speakerresulted in a503 Service Unavailableresponse: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head><meta http-equiv="content-type" content="te (truncated...) in /Applications/XAMPP/xamppfiles/htdocs/tangthuvien/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 111

    question 
    opened by naruto2302 3
  • Better way to do this

    Better way to do this

    I noticed almost of providers needs API Key or had limited use , I suggest to build one or update with Responsive Voice , it's free and support more than 40 language :)

    opened by xc0d3rz 3
  • error exception: Will not follow more than 5 redirects

    error exception: Will not follow more than 5 redirects

    I'm getting this message when trying to speak a text with any of voxygen's voices. The error is the same on both a local and a remote server. I'm even using an application and today I discovered that problem. Until then it was working normal. I went to the voxygen website and tested it there and it looks normal too. What's going on?

    bug 
    opened by gabrielschuck 2
  • symfony/process v2.3.0 conflicts with symfony/console

    symfony/process v2.3.0 conflicts with symfony/console

    C:\xampp\htdocs\october>composer require duncan3dc/speaker Using version ^1.1 for duncan3dc/speaker ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages.

    Problem 1 - Installation request for duncan3dc/speaker ^1.1 -> satisfiable by duncan3dc/speaker[1.1.0]. - Conclusion: remove symfony/console v3.4.11 - Conclusion: don't install symfony/console v3.4.11 - duncan3dc/speaker 1.1.0 requires symfony/process ^2.3 -> satisfiable by symfony/process[v2.8.49]. - symfony/process v2.8.49 conflicts with symfony/console[v3.4.11]. - Installation request for symfony/console (locked at v3.4.11) -> satisfiable by symfony/console[v3.4.11].

    Installation failed, reverting ./composer.json to its original content.

    enhancement 
    opened by Vutik 1
  •  didn't know what i should do exactly ..

    didn't know what i should do exactly ..

    I'm developing a website that teaches the Italian language,, I need tts to help the student recognizing the pronunciation of the words

    so please could you help me,, I have tried the google API but it doesn't work anymore

    start with me step by step, please .. thank you

    question 
    opened by samaal 1
  • can't get it to work

    can't get it to work

    tried the .php example, i thought it may be that google doesn't offer a TTS api any longer?

    haven't tried the others.
    getting a 500 'page isn't working'

    <?php 
    error_reporting(E_ALL);
    require_once "vendor/autoload.php";
    
    use duncan3dc\Speaker\TextToSpeech;
    use duncan3dc\Speaker\Providers\GoogleProvider;
    
    $provider = new GoogleProvider("en");
    
    $tts = new TextToSpeech("Hello World", $provider);
    $tts->save("/tmp/hello.mp3");
    ?>
    
    question 
    opened by ghost 1
  • hi, i want set language to be 'zh-cn', but PicottsProvider not work. it not support chinese yet?

    hi, i want set language to be 'zh-cn', but PicottsProvider not work. it not support chinese yet?

        function speak ($text = "您好", $lang = "zh-cn") {
            if (empty($text)) {
                return "";
            }
    
            $fileName = '/tmp/' . md5($text . $lang) . '.mp3';
    
            if (file_exists($fileName)) {
                return $fileName;
            }
    
            $provider = new PicottsProvider();
            $provider->setLanguage($lang);
    
            $tts = new TextToSpeech($text, $provider);
            $tts->save($fileName);
    
            return $fileName;
        }
    

    $lang = "zh-cn" dont work, cant you tell me why? thank you very much🌺

    question 
    opened by Promise-W 1
Owner
Craig Duncan
Craig Duncan
Prepare your Laravel apps incredibly fast, with various commands, services, facades and boilerplates.

Grafite Builder Grafite has archived this project and no longer supports or develops the code. We recommend using only as a source of ideas for your o

Grafite Inc 997 Dec 22, 2022
A PHP component to convert HTML into a plain text format

html2text html2text is a very simple script that uses DOM methods to convert HTML into a format similar to what would be rendered by a browser - perfe

Jevon Wright 423 Dec 29, 2022
Laravel package to convert English numbers to Bangla number or Bangla text, Bangla month name and Bangla Money Format

Number to Bangla Number, Word or Month Name in Laravel | Get Wordpress Plugin Laravel package to convert English numbers to Bangla number or Bangla te

Md. Rakibul Islam 50 Dec 26, 2022
Some Joomla! 4.x Web Services Api Examples and Experiments to raise the level of awareness of the huge potiental of Joomla! 4.x Web Services.

j4x-api-examples WHY? If you are a Joomla! developer or want to become a Joomla! developer there is a new resource for you The Official New Joomla! Ma

Mr Alexandre ELISÉ 11 Nov 29, 2022
Laminas\Text is a component to work on text strings

laminas-text This package is considered feature-complete, and is now in security-only maintenance mode, following a decision by the Technical Steering

Laminas Project 38 Dec 31, 2022
Zend\Text is a component to work on text strings from Zend Framework

zend-text Repository abandoned 2019-12-31 This repository has moved to laminas/laminas-text. Zend\Text is a component to work on text strings. It cont

Zend Framework 31 Jan 24, 2021
PHP Text Analysis is a library for performing Information Retrieval (IR) and Natural Language Processing (NLP) tasks using the PHP language

php-text-analysis PHP Text Analysis is a library for performing Information Retrieval (IR) and Natural Language Processing (NLP) tasks using the PHP l

null 464 Dec 28, 2022
StickWithIt is an online food ordering website created using PHP. You can view and purchase various items as well as remove items from the cart.

StickWithIt (App Name) StickWithIt is an online food ordering website created using PHP. The database used here is MYSQL database. The tool used here

Jenil Gajjar 1 May 11, 2022
A FREE Wordpress Plugin to compress and convert images using cwebp, jpegoptim and optipng.

Squidge Is FREE WordpPress Plugin built for developers in mind compressing and convert images using jpegoptim, optipng, cwebp, and libavif. It's extre

Ainsley Clark 23 Dec 10, 2022
PHP FFmpeg - An Object Oriented library to convert video/audio files with FFmpeg / AVConv

PHP FFmpeg An Object Oriented library to convert video/audio files with FFmpeg / AVConv. Check another amazing repo: PHP FFMpeg extras, you will find

Alchemy 10 Dec 31, 2022
GitHub action to set up PHP with extensions, php.ini configuration, coverage drivers, and various tools.

GitHub action to set up PHP with extensions, php.ini configuration, coverage drivers, and various tools.

Shivam Mathur 2.4k Jan 6, 2023
A PHP library to support implementing representations for HATEOAS REST web services.

Hateoas A PHP library to support implementing representations for HATEOAS REST web services. Installation Working With Symfony Usage Introduction Conf

William Durand 998 Dec 5, 2022
Xenon\LaravelBDSms is a sms gateway package for sending text message to Bangladeshi mobile numbers using several gateways like sslcommerz, greenweb, dianahost,metronet in Laravel framework

Xenon\LaravelBDSms is a sms gateway package for sending text message to Bangladeshi mobile numbers using several gateways for Laravel. You should use

Ariful Islam 95 Jan 3, 2023
JSONFinder - a library that can find json values in a mixed text or html documents, can filter and search the json tree, and converts php objects to json without 'ext-json' extension.

JSONFinder - a library that can find json values in a mixed text or html documents, can filter and search the json tree, and converts php objects to json without 'ext-json' extension.

Eboubaker Eboubaker 2 Jul 31, 2022
This is a collection of tutorials for learning how to use Docker with various tools. Contributions welcome.

Docker Tutorials and Labs At this time we are not actively adding labs to this repository. Our focus is on training.play-with-docker.com where new lab

Docker 11.1k Jan 2, 2023
Helper to automatically load various Kirby extensions in a plugin

Autoloader for Kirby Helper to automatically load various Kirby extensions in a plugin Commerical Usage This package is free but if you use it in a co

Bruno Meilick 13 Nov 9, 2022
JSON schema models and generated code to validate and handle various data in PocketMine-MP

DataModels JSON schema models and generated code to validate and handle various data in PocketMine-MP This library uses php-json-schema-model-generato

PMMP 2 Nov 9, 2022
It's goal is to create my own platform where I can play various board games I like.

Card games The goal of this project is to create a social platform where players can communicate, create lobbies and play various board games. Current

Ondřej Mastík 2 Oct 29, 2021
Learning design patterns by implementing them in various programming languages.

design-patterns Learning design patterns by implementing them in various programming languages. Creational design patterns Creational design patterns

Paweł Tryfon 1 Dec 13, 2021