PHPackages                             ibroid/php-tts - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ibroid/php-tts

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ibroid/php-tts
==============

Convert text to speach using PHP

748PHP

Since May 16Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ibroid/php-tts)[ Packagist](https://packagist.org/packages/ibroid/php-tts)[ RSS](/packages/ibroid-php-tts/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Text To Speech
==================

[](#php-text-to-speech)

How it works ?
--------------

[](#how-it-works-)

---

This library leverages Google Translate's capabilities to provide text-to-speech functionality. Despite its unconventional approach, it has been reliable for years.

Google Translate can handle millions of requests, so you can use this library confidently.

1. The library sends a standard request to the Google Translate page, including query parameters with the text that needs to be converted.
2. The request headers are configured to instruct Google Translate to respond with the audio data in a base64-encoded format. This is necessary because PHP cannot natively handle audio formats.
3. The base64-encoded audio data is then handed over to JavaScript, which decodes it into an audio format that can be played.

Install
-------

[](#install)

#### Requirements

[](#requirements)

- PHP &gt;= 7.4

```
composer require ibroid/php-tts:dev-master
```

Example
-------

[](#example)

```

  Play Audio
  Status : Waiting for request

```

```
function sendText(event) {
  event.preventDefault();
  document.getElementById("indicator").innerText = "Status : Loading...";

  const body = new FormData();
  body.append("text", event.target.text.value);

  fetch("/index.php", {
    method: "POST",
    body: body,
  })
    .then(async (response) => {
      document.getElementById("indicator").innerText = "Status : Playing";

      const audio = new Audio(
        "data:audio/wav;base64," + (await response.text())
      );

      audio.addEventListener("ended", () => {
        document.getElementById("indicator").innerText = "Status : Ended";
      });

      const audioElement = document.createElement("audio");
      audioElement.src = audio.src;
      audioElement.controls = true;
      document.getElementById("output").append(audioElement);

      audio.play();
    })

    .catch((err) => {
      document.getElementById("indicator").innerText = "Status : Error. " + err;
    });
}
```

```
include "./vendor/autoload.php";

use Ibroid\PhpTts\Tts as Tts;

if (isset($_POST['text'])) {
  $audio = Tts::generateAudio($_POST['text'], [
    "lang" => "en",
    "timeout" => 5000
  ]);

  echo $audio;
}
```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/576cd7f26f63d68c8b93df6a06e0a05f252375f896326eb3b843ced35df55079?d=identicon)[ibroid](/maintainers/ibroid)

---

Top Contributors

[![ibroid](https://avatars.githubusercontent.com/u/56104889?v=4)](https://github.com/ibroid "ibroid (5 commits)")

### Embed Badge

![Health badge](/badges/ibroid-php-tts/health.svg)

```
[![Health](https://phpackages.com/badges/ibroid-php-tts/health.svg)](https://phpackages.com/packages/ibroid-php-tts)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
