PHPackages                             bestmomo/laravel-edge-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. bestmomo/laravel-edge-tts

ActiveLaravel-package[Utility &amp; Helpers](/categories/utility)

bestmomo/laravel-edge-tts
=========================

Edge-tts-php integration for Laravel

0.1.3(7mo ago)233[1 issues](https://github.com/bestmomo/laravel-edge-tts/issues)MITPHPPHP ^8.2

Since Oct 1Pushed 7mo agoCompare

[ Source](https://github.com/bestmomo/laravel-edge-tts)[ Packagist](https://packagist.org/packages/bestmomo/laravel-edge-tts)[ RSS](/packages/bestmomo-laravel-edge-tts/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (4)Versions (5)Used By (0)

Bestmomo/Laravel-Edge-TTS
=========================

[](#bestmomolaravel-edge-tts)

A simple yet powerful Laravel package for integrating **Microsoft Edge Text-to-Speech (TTS)** into your applications. It features **audio streaming**, **caching**, **abstraction**, and **security** controls.

This package relies on the excellent work of [andresayac/edge-tts-php](https://github.com/andresayac/edge-tts-php) to interface with the Microsoft Edge TTS API. All voice support and core synthesis features are inherited from this library.

Installation
------------

[](#installation)

### 1. Via Composer

[](#1-via-composer)

Add the package to your Laravel project:

```
composer require bestmomo/laravel-edge-tts

```

### 2. File Publication

[](#2-file-publication)

After installation, publish the configuration file:

```
php artisan vendor:publish --tag=edge-tts-config

```

This copies the `config/edge-tts.php` file, where you can define the default voice and security settings (middlewares).

Configuration
-------------

[](#configuration)

### The `config/edge-tts.php` File

[](#the-configedge-ttsphp-file)

The configuration file allows you to customize key aspects of the package:

```
return [
    // Default voice used if none is specified in the request
    'default_voice' => env('EDGE_TTS_DEFAULT_VOICE', 'fr-FR-DeniseNeural'),

    // Middlewares applied to the streaming route
    'middleware' => [
        'web',          // Required for session (and therefore 'auth') to work
        'auth',         // Require the user to be logged in
        'throttle:60,1',// Limit to 60 requests per minute
    ],

    // Audio caching parameters
    'cache' => [
        'enabled' => env('EDGE_TTS_CACHE_ENABLED', true),
        // Laravel storage disk to use for MP3 files (defaults to 'local')
        'disk' => env('EDGE_TTS_CACHE_DISK', 'local'),
        'lifetime' => env('EDGE_TTS_CACHE_LIFETIME', null), // Cache lifetime in minutes (null = indefinite)
    ],

    // Enable Call Logging
    'enable_call_logging' => env('EDGE_TTS_LOG_CALLS', false),
];

```

Usage
-----

[](#usage)

The package registers an abstraction contract (Interface) and a Facade, allowing you to use it easily anywhere in your application.

### 1. Using the Contract (Dependency Injection)

[](#1-using-the-contract-dependency-injection)

The recommended approach is to inject the `TtsSynthesizer` contract:

```
use Bestmomo\LaravelEdgeTts\Contracts\TtsSynthesizer;

class MyService
{
    protected $tts;

    public function __construct(TtsSynthesizer $tts)
    {
        $this->tts = $tts;
    }

    public function generateAudio()
    {
        // 1. Save the audio to a file:
        $filePath = $this->tts->toFile(
            'This is a file save test.',
            'en-US-JennyNeural',
            storage_path('app/audio/test_jenny')
        );

        // 2. Get the audio as a Base64 string:
        $base64 = $this->tts->toBase64('This is Base64 encoded audio.', 'en-US-JennyNeural');
    }
}

```

### 1.1 Using the Facade

[](#11-using-the-facade)

You can also use the `EdgeTts` facade to access the TTS synthesizer:

```
use Bestmomo\LaravelEdgeTts\Facades\EdgeTts;

class MyService
{
    public function generateAudio()
    {
        // 1. Save the audio to a file:
        $filePath = EdgeTts::toFile(
            'This is a file save test.',
            'en-US-JennyNeural',
            storage_path('app/audio/test_jenny')
        );

        // 2. Get the audio as a Base64 string:
        $base64 = EdgeTts::toBase64('This is Base64 encoded audio.', 'en-US-JennyNeural');
    }
}

```

### 2. Using the Streaming Route

[](#2-using-the-streaming-route)

The core of the package is the audio streaming route, which handles caching and security:

**Route URL:**

```
/edge-tts/stream

```

**Route Name:**

```
edge-tts.stream

```

You can use it directly in your JavaScript code for an `` element:

```
const text = "Hello world!";
const streamUrl = `/edge-tts/stream?text=${encodeURIComponent(text)}&voice=en-US-JennyNeural`;

document.getElementById('audioPlayer').src = streamUrl;
document.getElementById('audioPlayer').play();

```

**Query Parameters:**

- `text` the text to synthesize (can be SSML). (Required)
- `voice` the voice to use. (default defined in config)
- `rate` speech rate (e.g., `+10%`, `-5%`). Default `0%`
- `volume` voice volume (e.g., `+50%`, `-10%`). Default `0%`
- `pitch` voice pitch (e.g., `+5Hz`, `-2Hz`). Default `0Hz`

**SSML Note:** If the `text` parameter starts with ` 'Hello world!')
```

**Usage with Specific Voice and Parameters:**

The directive accepts the same parameters as the streaming route, passed as arguments: `text`, `voice`, `rate`, `volume`, and `pitch`.

```
{{-- Synthesize in French with specific options --}}
@edge_tts([
    'text' => 'Bonjour le monde !',
    'voice' => 'fr-FR-DeniseNeural',
    'rate' => '+10%'
])
```

This makes it incredibly easy to embed synthesized audio directly into your views.

Key Features
------------

[](#key-features)

### Caching

[](#caching)

The package uses the `edge-tts.cache` configuration to cache generated audio files. If the exact same combination of **(text, voice, options)** is requested multiple times, the MP3 file is served instantly from local storage, reducing latency and external API requests.

### Enable Call Logging

[](#enable-call-logging)

The `enable_call_logging` option in the `config/edge-tts.php` file allows you to log every TTS API call to the Laravel log. This can be useful for debugging purposes or to monitor the usage of the TTS service.

To enable it, set the `EDGE_TTS_LOG_CALLS` environment variable to `true` in your `.env` file:

```
EDGE_TTS_LOG_CALLS=true

```

### Cache Pruning

[](#cache-pruning)

The package includes an Artisan command to automatically delete old cache files:

```
php artisan edge-tts:cache-prune

```

By default, the command deletes files older than 90 days. You can customize this duration using the `--days` option:

```
// Delete files older than 30 days
php artisan edge-tts:cache-prune --days=30

```

To schedule it, add the following to your `routes/console.php` file:

```
use Illuminate\Support\Facades\Schedule;

Schedule::command('edge-tts:cache-prune --days=60')->daily();
```

### Abstraction

[](#abstraction)

The package utilizes a `TtsSynthesizer` contract. If you ever need to change the TTS provider (e.g., to Google Cloud TTS or Amazon Polly), you only need to create a new adapter implementing this contract and update the Service Provider binding, without changing your application's business logic.

### Demo (Development Environment)

[](#demo-development-environment)

You can access the demonstration interface (available only in `local`, `staging`, or `testing` environments):

```
/edge-tts/demo

```

[![img1](screenshots/img1.png)](screenshots/img1.png)

Contributing
------------

[](#contributing)

Contributions are welcome! Please open an issue or submit a pull request with your improvements.

License
-------

[](#license)

This package is open-source software licensed under the **MIT** license.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance54

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~1 days

Total

4

Last Release

220d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/db8c99e19bcb8c0855b62163521c90217dc197414d90802db0965cb422085645?d=identicon)[bestmomo](/maintainers/bestmomo)

---

Top Contributors

[![bestmomo](https://avatars.githubusercontent.com/u/2959682?v=4)](https://github.com/bestmomo "bestmomo (10 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bestmomo-laravel-edge-tts/health.svg)

```
[![Health](https://phpackages.com/badges/bestmomo-laravel-edge-tts/health.svg)](https://phpackages.com/packages/bestmomo-laravel-edge-tts)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

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