421p/talker

PHP Text to speech

1.0.0 2018-09-23 00:16 UTC

This package is auto-updated.

Last update: 2024-10-23 15:02:05 UTC


README

Text to speech using Google TTS

Installing

composer require 421p/talker

Usage

use React\EventLoop\Factory;
use Talker\Talker\GoogleSpeechTalker;
use Talker\Talker\Response\Mp3File;

require __DIR__.'/vendor/autoload.php';

$loop = Factory::create();

$talker = new GoogleSpeechTalker($loop);

[$hours, $minutes] = explode(':', date('H:i'));

$time = sprintf(
    'Current time is %d hours %d minutes', $hours, $minutes
);

$talker->say($time, GoogleSpeechTalker::LOCALE_EN_US)->then(function (Mp3File $file) {
    file_put_contents(__DIR__.'/test.mp3', $file->getContent());
});

$loop->run();